|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="utf-8"> |
| 5 | + <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
| 6 | + <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"> |
| 7 | + <meta name="description" content="Adjust hue, saturation, and brightness of the sky/atmosphere."> |
| 8 | + <meta name="cesium-sandcastle-labels" content="Showcases"> |
| 9 | + <title>Cesium Demo</title> |
| 10 | + <script type="text/javascript" src="../Sandcastle-header.js"></script> |
| 11 | + <script type="text/javascript" src="../../../ThirdParty/requirejs-2.1.20/require.js"></script> |
| 12 | + <script type="text/javascript"> |
| 13 | + require.config({ |
| 14 | + baseUrl : '../../../Source', |
| 15 | + waitSeconds : 60 |
| 16 | + }); |
| 17 | + </script> |
| 18 | +</head> |
| 19 | +<body class="sandcastle-loading" data-sandcastle-bucket="bucket-requirejs.html"> |
| 20 | +<style> |
| 21 | + @import url(../templates/bucket.css); |
| 22 | + #toolbar { |
| 23 | + background: rgba(42, 42, 42, 0.8); |
| 24 | + padding: 4px; |
| 25 | + border-radius: 4px; |
| 26 | + } |
| 27 | + #toolbar input { |
| 28 | + vertical-align: middle; |
| 29 | + padding-top: 2px; |
| 30 | + padding-bottom: 2px; |
| 31 | + } |
| 32 | +</style> |
| 33 | +<div id="cesiumContainer" class="fullSize"></div> |
| 34 | +<div id="loadingOverlay"><h1>Loading...</h1></div> |
| 35 | +<div id="toolbar"> |
| 36 | +<table><tbody> |
| 37 | +<tr> |
| 38 | + <td>Lighting Fade Out Distance</td> |
| 39 | + <td> |
| 40 | + <input type="range" min="1e6" max="1e8" step="1e6" data-bind="value: lightingFadeOutDistance, valueUpdate: 'input'"> |
| 41 | + <input type="text" size="10" data-bind="value: lightingFadeOutDistance"> |
| 42 | + </td> |
| 43 | +</tr> |
| 44 | +<tr> |
| 45 | + <td>Lighting Fade In Distance</td> |
| 46 | + <td> |
| 47 | + <input type="range" min="1e6" max="1e8" step="1e6" data-bind="value: lightingFadeInDistance, valueUpdate: 'input'"> |
| 48 | + <input type="text" size="10" data-bind="value: lightingFadeInDistance"> |
| 49 | + </td> |
| 50 | +</tr> |
| 51 | +<tr> |
| 52 | + <td>Night Fade Out Distance</td> |
| 53 | + <td> |
| 54 | + <input type="range" min="1e6" max="1e8" step="1e6" data-bind="value: nightFadeOutDistance, valueUpdate: 'input'"> |
| 55 | + <input type="text" size="10" data-bind="value: nightFadeOutDistance"> |
| 56 | + </td> |
| 57 | +</tr> |
| 58 | +<tr> |
| 59 | + <td>Night Fade In Distance</td> |
| 60 | + <td> |
| 61 | + <input type="range" min="1e6" max="1e8" step="1e6" data-bind="value: nightFadeInDistance, valueUpdate: 'input'"> |
| 62 | + <input type="text" size="10" data-bind="value: nightFadeInDistance"> |
| 63 | + </td> |
| 64 | +</tr> |
| 65 | +</tbody></table> |
| 66 | +</div> |
| 67 | +<script id="cesium_sandcastle_script"> |
| 68 | +function startup(Cesium) { |
| 69 | + 'use strict'; |
| 70 | +//Sandcastle_Begin |
| 71 | +var viewer = new Cesium.Viewer('cesiumContainer', { |
| 72 | + sceneModePicker:false |
| 73 | +}); |
| 74 | +var scene = viewer.scene; |
| 75 | +var globe = scene.globe; |
| 76 | + |
| 77 | +var defaultLightFadeOut = globe.lightingFadeOutDistance; |
| 78 | +var defaultLightFadeIn = globe.lightingFadeInDistance; |
| 79 | +var defaultNightFadeOut = globe.nightFadeOutDistance; |
| 80 | +var defaultNightFadeIn = globe.nightFadeInDistance; |
| 81 | + |
| 82 | +// The viewModel tracks the state of our mini application. |
| 83 | +var viewModel = { |
| 84 | + lightingFadeOutDistance : defaultLightFadeOut, |
| 85 | + lightingFadeInDistance : defaultLightFadeIn, |
| 86 | + nightFadeOutDistance : defaultNightFadeOut, |
| 87 | + nightFadeInDistance : defaultNightFadeIn |
| 88 | +}; |
| 89 | +// Convert the viewModel members into knockout observables. |
| 90 | +Cesium.knockout.track(viewModel); |
| 91 | + |
| 92 | +// Bind the viewModel to the DOM elements of the UI that call for it. |
| 93 | +var toolbar = document.getElementById('toolbar'); |
| 94 | +Cesium.knockout.applyBindings(viewModel, toolbar); |
| 95 | + |
| 96 | +// Make the skyAtmosphere's HSB parameters subscribers of the viewModel. |
| 97 | +function subscribeParameter(name) { |
| 98 | + Cesium.knockout.getObservable(viewModel, name).subscribe( |
| 99 | + function(newValue) { |
| 100 | + globe[name] = newValue; |
| 101 | + } |
| 102 | + ); |
| 103 | +} |
| 104 | + |
| 105 | +subscribeParameter('lightingFadeOutDistance'); |
| 106 | +subscribeParameter('lightingFadeInDistance'); |
| 107 | +subscribeParameter('nightFadeOutDistance'); |
| 108 | +subscribeParameter('nightFadeInDistance'); |
| 109 | + |
| 110 | +Sandcastle.addToggleButton('Ground atmosphere', globe.showGroundAtmosphere, function(checked) { |
| 111 | + globe.showGroundAtmosphere = checked; |
| 112 | +}); |
| 113 | + |
| 114 | +Sandcastle.addToggleButton('Lighting', globe.enableLighting, function(checked) { |
| 115 | + globe.enableLighting = checked; |
| 116 | +}); |
| 117 | + |
| 118 | +Sandcastle.addToolbarMenu([{ |
| 119 | + text : 'Cesium World Terrain - no effects', |
| 120 | + onselect : function() { |
| 121 | + viewer.terrainProvider = Cesium.createWorldTerrain(); |
| 122 | + } |
| 123 | +}, { |
| 124 | + text : 'Cesium World Terrain w/ Vertex Normals', |
| 125 | + onselect : function() { |
| 126 | + viewer.terrainProvider = Cesium.createWorldTerrain({ |
| 127 | + requestVertexNormals : true |
| 128 | + }); |
| 129 | + } |
| 130 | +}, { |
| 131 | + text : 'Cesium World Terrain w/ Water', |
| 132 | + onselect : function() { |
| 133 | + viewer.terrainProvider = Cesium.createWorldTerrain({ |
| 134 | + requestWaterMask : true |
| 135 | + }); |
| 136 | + } |
| 137 | +}, { |
| 138 | + text : 'Cesium World Terrain w/ Vertex Normals and Water', |
| 139 | + onselect : function() { |
| 140 | + viewer.terrainProvider = Cesium.createWorldTerrain({ |
| 141 | + requestVertexNormals : true, |
| 142 | + requestWaterMask : true |
| 143 | + }); |
| 144 | + } |
| 145 | +}, { |
| 146 | + text : 'EllipsoidTerrainProvider', |
| 147 | + onselect : function() { |
| 148 | + viewer.terrainProvider = new Cesium.EllipsoidTerrainProvider(); |
| 149 | + } |
| 150 | +}]); |
| 151 | + |
| 152 | +Sandcastle.addToolbarButton('Reset Fade Distances', function() { |
| 153 | + globe.lightingFadeOutDistance = defaultLightFadeOut; |
| 154 | + globe.lightingFadeInDistance = defaultLightFadeIn; |
| 155 | + globe.nightFadeOutDistance = defaultNightFadeOut; |
| 156 | + globe.nightFadeInDistance = defaultNightFadeIn; |
| 157 | + |
| 158 | + viewModel.lightingFadeOutDistance = defaultLightFadeOut; |
| 159 | + viewModel.lightingFadeInDistance = defaultLightFadeIn; |
| 160 | + viewModel.nightFadeOutDistance = defaultNightFadeOut; |
| 161 | + viewModel.nightFadeInDistance = defaultNightFadeIn; |
| 162 | +}); |
| 163 | + |
| 164 | +//Sandcastle_End |
| 165 | + Sandcastle.finishedLoading(); |
| 166 | +} |
| 167 | +if (typeof Cesium !== 'undefined') { |
| 168 | + startup(Cesium); |
| 169 | +} else if (typeof require === 'function') { |
| 170 | + require(['Cesium'], startup); |
| 171 | +} |
| 172 | +</script> |
| 173 | +</body> |
| 174 | +</html> |
0 commit comments