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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
| const clock = new Cesium.Clock({ startTime: Cesium.JulianDate.fromIso8601("2017-07-11T00:00:00Z"), stopTime: Cesium.JulianDate.fromIso8601("2017-07-11T24:00:00Z"), currentTime: Cesium.JulianDate.fromIso8601("2017-07-11T10:00:00Z"), clockRange: Cesium.ClockRange.LOOP_STOP, clockStep: Cesium.ClockStep.SYSTEM_CLOCK_MULTIPLIER, multiplier: 1000, shouldAnimate: true, });
const viewer = new Cesium.Viewer("cesiumContainer", { geocoder: false, homeButton: false, sceneModePicker: false, navigationHelpButton: false, navigationInstructionsInitiallyVisible: false, animation: false, timeline: false, fullscreenButton: false, skyBox: false, shouldAnimate: true, baseLayerPicker: false, shadows: true, selectionIndicator: false, clockViewModel: new Cesium.ClockViewModel(clock), terrain: Cesium.Terrain.fromWorldTerrain(), }); viewer.cesiumWidget.creditContainer.style.display = "none";
Sandcastle.addToggleButton("启用阴影", viewer.shadows, function (checked) { viewer.shadows = checked; });
viewer.scene.globe.enableLighting = true; viewer.scene.globe.depthTestAgainstTerrain = true; viewer.scene.atmosphere.dynamicLighting = Cesium.DynamicAtmosphereLightingType.SUNLIGHT;
const position = new Cesium.Cartesian3( -1371108.6511167218, -5508684.080096612, 2901825.449865087, );
const heading = Cesium.Math.toRadians(180); const pitch = Cesium.Math.toRadians(2); const roll = Cesium.Math.toRadians(-6); const hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
const orientation = Cesium.Transforms.headingPitchRollQuaternion(position, hpr);
const entity = viewer.entities.add({ name: "truck", position: position, orientation: orientation, model: { uri: "../SampleData/models/GroundVehicle/GroundVehicle.glb", heightReference: Cesium.HeightReference.CLAMP_TO_GROUND, minimumPixelSize: 128, maximumScale: 20, scale: 8.0, runAnimations: false, }, });
const threeQuartersView = { destination: new Cesium.Cartesian3( -1371203.1456494154, -5508700.033950869, 2901802.2749172337, ), orientation: { heading: Cesium.Math.toRadians(67.64973594265429), pitch: Cesium.Math.toRadians(-8.158676059409297), roll: Cesium.Math.toRadians(359.9999987450017), }, maximumHeight: 100, };
const frontView = { destination: new Cesium.Cartesian3( -1371214.9554156072, -5508700.8494476415, 2901826.794611029, ), orientation: { heading: Cesium.Math.toRadians(80.5354269423926), pitch: Cesium.Math.toRadians(-15.466062969558285), roll: Cesium.Math.toRadians(359.9999999526579), }, maximumHeight: 100, };
const topView = { destination: new Cesium.Cartesian3( -1371190.7755780201, -5508732.668834588, 2901827.2625979027, ), orientation: { heading: Cesium.Math.toRadians(68.29411482061157), pitch: Cesium.Math.toRadians(-33.97774554735345), roll: Cesium.Math.toRadians(359.9999999298912), }, maximumHeight: 100, };
const upwardsView = { destination: new Cesium.Cartesian3( -1371052.4616855076, -5508691.745389906, 2901861.440673151, ), orientation: { heading: Cesium.Math.toRadians(236.4536374528137), pitch: Cesium.Math.toRadians(-1.3382025460115552), roll: Cesium.Math.toRadians(359.9999985917282), }, maximumHeight: 100, };
viewer.scene.camera.flyTo({ destination: frontView.destination, orientation: frontView.orientation, duration: 5.0, pitchAdjustHeight: 20, }); Sandcastle.addToolbarMenu( [ { text: "前视图,20:00-傍晚光照", onselect: function () { viewer.scene.camera.flyTo(frontView); viewer.clockViewModel.clock.currentTime = Cesium.JulianDate.fromIso8601("2017-07-11T20:00:00Z"); }, }, { text: "三quarter晨光视角,11:00-接近中午", onselect: function () { viewer.scene.camera.flyTo(threeQuartersView); viewer.clockViewModel.clock.currentTime = Cesium.JulianDate.fromIso8601("2017-07-11T11:00:00Z"); }, }, { text: "俯视图,12:00-正午", onselect: function () { viewer.scene.camera.flyTo(topView); viewer.clockViewModel.clock.currentTime = Cesium.JulianDate.fromIso8601("2017-07-11T12:00:00Z"); }, }, { text: "仰视侧面视图,23:00-夜晚", onselect: function () { viewer.scene.camera.flyTo(upwardsView); viewer.clockViewModel.clock.currentTime = Cesium.JulianDate.fromIso8601("2017-07-11T23:00:00Z"); }, }, ], "toolbar", );
|