1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| const viewer = new Cesium.Viewer("cesiumContainer", { geocoder: false, sceneModePicker: false, homeButton: false, navigationHelpButton: false, baseLayerPicker: false, navigationInstructionsInitiallyVisible: false, fullscreenButton: false, selectionIndicator: false, skyBox: false, timeline: false, animation: false, shouldAnimate: true, baseLayer: new Cesium.ImageryLayer.fromProviderAsync( Cesium.IonImageryProvider.fromAssetId(3812) ), });
viewer.cesiumWidget.creditContainer.style.display = "none";
const dynamicLighting = false;
viewer.clock.multiplier = 4000;
const imageryLayers = viewer.imageryLayers; const nightLayer = imageryLayers.get(0); const dayLayer = Cesium.ImageryLayer.fromProviderAsync( Cesium.IonImageryProvider.fromAssetId(3845) ); imageryLayers.add(dayLayer); imageryLayers.lowerToBottom(dayLayer);
function updateLighting(dynamicLighting) { dayLayer.show = dynamicLighting; viewer.scene.globe.enableLighting = dynamicLighting; viewer.clock.shouldAnimate = dynamicLighting;
nightLayer.dayAlpha = dynamicLighting ? 0.0 : 1.0; }
updateLighting(dynamicLighting);
Sandcastle.addToggleButton( "启用动态照明", dynamicLighting, function (checked) { updateLighting(checked); } );
|