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 viewer = new Cesium.Viewer("cesiumContainer", { geocoder: false, sceneModePicker: false, navigationHelpButton: false, baseLayerPicker: false, navigationInstructionsInitiallyVisible: false, fullscreenButton: false, selectionIndicator: false, skyBox: false, timeline: false, animation: false, shouldAnimate: true, infoBox: false, shadows: true, terrain: Cesium.Terrain.fromWorldTerrain(), }); viewer.cesiumWidget.creditContainer.style.display = "none";
if (!viewer.scene.highDynamicRangeSupported) { window.alert("该浏览器不支持高动态范围(HDR,即high dynamic range)。"); }
viewer.scene.highDynamicRange = true;
Sandcastle.addToggleButton( "HDR", true, function (checked) { viewer.scene.highDynamicRange = checked; }, "hdr-toggle" );
const toneMapOptions = [ { text: "PBR Neutral算法", onselect: function () { viewer.scene.postProcessStages.tonemapper = Cesium.Tonemapper.PBR_NEUTRAL; }, }, { text: "Aces算法", onselect: function () { viewer.scene.postProcessStages.tonemapper = Cesium.Tonemapper.ACES; }, }, { text: "Reinhard算法", onselect: function () { viewer.scene.postProcessStages.tonemapper = Cesium.Tonemapper.REINHARD; }, }, { text: "Modified_Reinhard算法", onselect: function () { viewer.scene.postProcessStages.tonemapper = Cesium.Tonemapper.MODIFIED_REINHARD; }, }, { text: "Filmic算法", onselect: function () { viewer.scene.postProcessStages.tonemapper = Cesium.Tonemapper.FILMIC; }, }, ]; Sandcastle.addDefaultToolbarMenu(toneMapOptions, "tonemap-select");
const viewModel = { exposure: 1, };
Cesium.knockout.track(viewModel);
const toolbar = document.getElementById("toolbar"); Cesium.knockout.applyBindings(viewModel, toolbar);
Cesium.knockout .getObservable(viewModel, "exposure") .subscribe(function (newValue) { viewer.scene.postProcessStages.exposure = Number.parseFloat(newValue); });
const url = "../SampleData/models/DracoCompressed/CesiumMilkTruck.gltf"; const position = Cesium.Cartesian3.fromRadians( -1.9516424279517286, 0.6322397098422969, 1239.0006814631095 ); const heading = Cesium.Math.toRadians(-15.0); const pitch = 0; const roll = 0; const hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll); const orientation = Cesium.Transforms.headingPitchRollQuaternion(position, hpr); const scale = 10.0;
const entity = viewer.entities.add({ name: url, position: position, orientation: orientation, model: { uri: url, scale: scale, }, });
viewer.scene.camera.setView({ destination: new Cesium.Cartesian3( -1915097.7863741855, -4783356.851539908, 3748887.43462683 ), orientation: new Cesium.HeadingPitchRoll( 6.166004548388564, -0.043242401760068994, 0.002179961955988574 ), endTransform: Cesium.Matrix4.IDENTITY, });
viewer.clock.currentTime = new Cesium.JulianDate(2460550, 21637);
viewer.scene.debugShowFramesPerSecond = true;
viewer.homeButton.viewModel.command.beforeExecute.addEventListener((e) => { e.cancel = true; viewer.scene.camera.setView({ destination: new Cesium.Cartesian3( -1915097.7863741855, -4783356.851539908, 3748887.43462683 ), orientation: new Cesium.HeadingPitchRoll( 6.166004548388564, -0.043242401760068994, 0.002179961955988574 ), endTransform: Cesium.Matrix4.IDENTITY, }); });
|