Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added resolution scaling sandcasle example #8151

Merged
merged 4 commits into from
Sep 11, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions Apps/Sandcastle/gallery/Resolution Scaling.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta name="description" content="Set a custom resolution scale or use browser recommended resolution.">
<meta name="cesium-sandcastle-labels" content="Showcases">
<title>Cesium Demo</title>
<script type="text/javascript" src="../Sandcastle-header.js"></script>
<script type="text/javascript" src="../../../ThirdParty/requirejs-2.1.20/require.js"></script>
<script type="text/javascript">
if(typeof require === 'function') {
require.config({
baseUrl : '../../../Source',
waitSeconds : 120
});
}
</script>
</head>
<body class="sandcastle-loading" data-sandcastle-bucket="bucket-requirejs.html">
<style>
@import url(../templates/bucket.css);
</style>
<div id="cesiumContainer" class="fullSize"></div>
<div id="loadingOverlay"><h1>Loading...</h1></div>
<div id="toolbar">
<table><tbody>
<tr>
<td>Use Browser Recommended Resolution</td>
<td><input type="checkbox" data-bind="checked: useDevicePixelResolution"></td>
</tr>
<tr>
<td data-bind="style: { color: useDevicePixelResolution ? 'gray' : ''}">Custom Resolution Scale</td>
<td>
<input type="range" min="0.1" max="2.0" step="0.1" data-bind="value: customResolutionScale, enable: !useDevicePixelResolution, valueUpdate: 'input'">
<input type="text" size="5" data-bind="value: customResolutionScale, enable: !useDevicePixelResolution">
</td>
</tr>
</tbody></table>
</div>
<script id="cesium_sandcastle_script">
function startup(Cesium) {
'use strict';
//Sandcastle_Begin
var viewer = new Cesium.Viewer('cesiumContainer');

var viewModel = {
useDevicePixelResolution : false,
customResolutionScale : 0.25
};

Cesium.knockout.track(viewModel);
var toolbar = document.getElementById('toolbar');
Cesium.knockout.applyBindings(viewModel, toolbar);
for (var name in viewModel) {
if (viewModel.hasOwnProperty(name)) {
Cesium.knockout.getObservable(viewModel, name).subscribe(update);
}
}

function update() {
if (viewModel.useDevicePixelResolution) {
viewer.resolutionScale = 1.0 / window.devicePixelRatio;
} else {
var resolutionScale = Number(viewModel.customResolutionScale);
resolutionScale = !isNaN(resolutionScale) ? resolutionScale : 1.0;
resolutionScale = Cesium.Math.clamp(resolutionScale, 0.1, 2.0);
viewer.resolutionScale = resolutionScale;
}
}
update();

//Sandcastle_End
Sandcastle.finishedLoading();
}
if (typeof Cesium !== 'undefined') {
startup(Cesium);
} else if (typeof require === 'function') {
require(['Cesium'], startup);
}
</script>
</body>
</html>
Binary file added Apps/Sandcastle/gallery/Resolution Scaling.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.