Skip to content

Commit

Permalink
Added resolution scaling sandbox example
Browse files Browse the repository at this point in the history
  • Loading branch information
IanLilleyT committed Sep 11, 2019
1 parent 1305430 commit f66210f
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions Apps/Sandcastle/gallery/Resolution Scaling.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<!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 enable device pixel resolution.">
<meta name="cesium-sandcastle-labels" content="Post Processing">
<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 Device Pixel 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 params = {
useDevicePixelResolution : false,
customResolutionScale : 0.25
};

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

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

viewer.scene.camera.setView({
destination : new Cesium.Cartesian3(4382449.03239259, -33288005.26160439, 23632115.503561564),
orientation : new Cesium.HeadingPitchRoll(6.283185307179586, -1.5683666923070123, 0),
endTransform : Cesium.Matrix4.IDENTITY
});
//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.

0 comments on commit f66210f

Please sign in to comment.