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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
| const viewer = new Cesium.Viewer("cesiumContainer", { geocoder: false, homeButton: false, sceneModePicker: false, baseLayerPicker: false, navigationHelpButton: false, navigationInstructionsInitiallyVisible: false, animation: false, timeline: false, fullscreenButton: false, selectionIndicator: false, skyBox: false, shouldAnimate: true, infoBox: false, }); viewer.cesiumWidget.creditContainer.style.display = "none";
viewer.camera.flyTo({ destination: new Cesium.Rectangle.fromDegrees(-84, 43, -80, 47), });
const layers = viewer.imageryLayers; layers.removeAll();
const layerLinear = Cesium.ImageryLayer.fromProviderAsync( Cesium.TileMapServiceImageryProvider.fromUrl( Cesium.buildModuleUrl("Assets/Textures/NaturalEarthII"), ), ); layers.add(layerLinear);
const layerNearest = Cesium.ImageryLayer.fromProviderAsync( Cesium.TileMapServiceImageryProvider.fromUrl( Cesium.buildModuleUrl("Assets/Textures/NaturalEarthII"), ), ); layers.add(layerNearest);
layerNearest.minificationFilter = Cesium.TextureMinificationFilter.NEAREST;
layerNearest.magnificationFilter = Cesium.TextureMagnificationFilter.NEAREST;
layerNearest.splitDirection = Cesium.SplitDirection.RIGHT;
const slider = document.getElementById("slider"); viewer.scene.splitPosition = slider.offsetLeft / slider.parentElement.offsetWidth;
let dragStartX = 0;
document.getElementById("slider").addEventListener("mousedown", mouseDown, false); window.addEventListener("mouseup", mouseUp, false);
function mouseUp() { window.removeEventListener("mousemove", sliderMove, true); }
function mouseDown(e) { const slider = document.getElementById("slider"); dragStartX = e.clientX - slider.offsetLeft; window.addEventListener("mousemove", sliderMove, true); }
function sliderMove(e) { const slider = document.getElementById("slider"); const splitPosition = (e.clientX - dragStartX) / slider.parentElement.offsetWidth; slider.style.left = `${100.0 * splitPosition}%`; viewer.scene.splitPosition = splitPosition; }
|