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
|
const viewer = new Cesium.Viewer("cesiumContainer", { geocoder: false, sceneModePicker: false, homeButton: false, navigationHelpButton: false, baseLayerPicker: false, navigationInstructionsInitiallyVisible: false, animation: false, timeline: false, fullscreenButton: false, selectionIndicator: false, skyBox: false, shouldAnimate: true, terrain: Cesium.Terrain.fromWorldTerrain(), });
viewer.cesiumWidget.creditContainer.style.display = "none"; viewer.scene.debugShowFramesPerSecond = true;
try {
const tileset = await Cesium.Cesium3DTileset.fromIonAssetId(16421); viewer.scene.primitives.add(tileset);
const classificationTileset = await Cesium.Cesium3DTileset.fromUrl( "../SampleData/Cesium3DTiles/Classification/PointCloud/tileset.json", { classificationType: Cesium.ClassificationType.CESIUM_3D_TILE, }, ); viewer.scene.primitives.add(classificationTileset);
classificationTileset.style = new Cesium.Cesium3DTileStyle({ color: { conditions: [ ["${id} === 'roof1'", "color('#004FFF', 0.5)"], ["${id} === 'towerBottom1'", "color('#33BB66', 0.5)"], ["${id} === 'towerTop1'", "color('#0099AA', 0.5)"], ["${id} === 'roof2'", "color('#004FFF', 0.5)"], ["${id} === 'tower3'", "color('#FF8833', 0.5)"], ["${id} === 'tower4'", "color('#FFAA22', 0.5)"], ["true", "color('#FFFF00', 0.5)"], ], }, }); } catch (error) { console.log(`Error loading tileset: ${error}`); }
viewer.scene.camera.setView({ destination: new Cesium.Cartesian3( 4401744.644145314, 225051.41078911052, 4595420.374784433, ), orientation: new Cesium.HeadingPitchRoll( 5.646733805039757, -0.276607153839886, 6.281110875400085, ), });
const highlighted = { feature: undefined, originalColor: new Cesium.Color(), };
viewer.screenSpaceEventHandler.setInputAction(function onMouseMove(movement) { if (Cesium.defined(highlighted.feature)) { highlighted.feature.color = highlighted.originalColor; highlighted.feature = undefined; }
const pickedFeature = viewer.scene.pick(movement.endPosition); if (!Cesium.defined(pickedFeature)) { return; }
highlighted.feature = pickedFeature; Cesium.Color.clone(pickedFeature.color, highlighted.originalColor); pickedFeature.color = Cesium.Color.YELLOW.withAlpha(0.5); }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
|