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 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
| 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, }); viewer.cesiumWidget.creditContainer.style.display = "none";
const scene = viewer.scene;
viewer.clock.currentTime = Cesium.JulianDate.fromIso8601( "2022-08-01T00:00:00Z" );
scene.camera.setView({ destination: new Cesium.Cartesian3( 1234151.4883992162, -5086036.79436967, 3633328.4278331124 ), orientation: { heading: 5.593695742186853, pitch: -1.0786797635545216, roll: 6.27892466154778, }, });
let powerPlant; let powerPlantShow = true; try { powerPlant = await Cesium.Cesium3DTileset.fromIonAssetId(2464651); powerPlant.show = powerPlantShow; scene.primitives.add(powerPlant); powerPlant.tileLoad.addEventListener(function (tile) { processTileFeatures(tile, hideDuplicateFloor); }); } catch (error) { console.log(`Error loading tileset: ${error}`); }
const duplicateFloor = 114082; function getElement(feature) { return parseInt(feature.getProperty("element"), 10); }
function hideDuplicateFloor(feature) { const element = parseInt(feature.getProperty("element"), 10);
if (element === duplicateFloor) { feature.show = false; } }
function processContentFeatures(content, callback) { const featuresLength = content.featuresLength; for (let i = 0; i < featuresLength; ++i) { const feature = content.getFeature(i); callback(feature); } }
function processTileFeatures(tile, callback) { const content = tile.content; const innerContents = content.innerContents; if (Cesium.defined(innerContents)) { const length = innerContents.length; for (let i = 0; i < length; ++i) { processContentFeatures(innerContents[i], callback); } } else { processContentFeatures(content, callback); } }
const pipes = viewer.entities.add({ polyline: { positions: Cesium.Cartesian3.fromDegreesArray([ -76.36053390920833, 34.949935893493596, -76.36055481641581, 34.94993589886988, -76.36055477047704, 34.94992280693651, ]), width: 6, material: new Cesium.PolylineDashMaterialProperty({ color: Cesium.Color.YELLOW, dashLength: 20.0, }), show: true, clampToGround: true, classificationType: Cesium.ClassificationType.CESIUM_3D_TILE, }, });
let building; try { building = await Cesium.Cesium3DTileset.fromIonAssetId(40866); building.show = !powerPlantShow; scene.primitives.add(building); } catch (error) { console.log(`瓦片集加载出错: ${error}`); }
const route = viewer.entities.add({ polyline: { positions: Cesium.Cartesian3.fromDegreesArray([ -75.59604807301078, 40.03948512841901, -75.59644577413066, 40.039316280505446, -75.59584544997564, 40.03846271524258, -75.59661425371488, 40.03814087821916, -75.59664726332451, 40.03818297772907, ]), width: 6, material: new Cesium.PolylineDashMaterialProperty({ color: Cesium.Color.YELLOW, }), show: false, clampToGround: true, classificationType: Cesium.ClassificationType.CESIUM_3D_TILE, }, });
Sandcastle.addDefaultToolbarMenu([ { text: "BIM(发电厂模型)", onselect: function () { powerPlantShow = true;
pipes.polyline.show = powerPlantShow; route.polyline.show = !powerPlantShow; if (Cesium.defined(powerPlant)) { powerPlant.show = powerPlantShow; } if (Cesium.defined(building)) { building.show = !powerPlantShow; }
scene.camera.setView({ destination: new Cesium.Cartesian3( 1234151.4883992162, -5086036.79436967, 3633328.4278331124 ), orientation: { heading: 5.593695742186853, pitch: -1.0786797635545216, roll: 6.27892466154778, }, }); }, }, { text: "摄影测量模型", onselect: function () { powerPlantShow = false;
pipes.polyline.show = powerPlantShow; route.polyline.show = !powerPlantShow; if (Cesium.defined(powerPlant)) { powerPlant.show = powerPlantShow; } if (Cesium.defined(building)) { building.show = !powerPlantShow; }
scene.camera.setView({ destination: new Cesium.Cartesian3( 1216596.5376729995, -4736445.416889214, 4081406.990364228 ), orientation: { heading: 5.153176564030707, pitch: -0.9701972964526693, roll: 6.277883257569513, }, }); }, }, ]);
|