-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added resolution scaling sandbox example
- Loading branch information
1 parent
1305430
commit f66210f
Showing
2 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.