原文链接及内容
注: 由于个人的Cesium Ion中没有官方示例中的数据,因此仅在官方提供的在线编辑器中进行了学习、修改。

main.js
代码如下:
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
|
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;
viewer.scene.camera.setView({ destination: new Cesium.Cartesian3( 4401744.644145314, 225051.41078911052, 4595420.374784433, ), orientation: new Cesium.HeadingPitchRoll( 5.646733805039757, -0.276607153839886, 6.281110875400085, ), });
try { const tileset = await Cesium.Cesium3DTileset.fromIonAssetId(16421); viewer.scene.primitives.add(tileset); } catch (error) { console.log(`Error loading tileset: ${error}`); }
|
界面布局文件index.html
代码如下:
1 2 3 4 5 6 7 8 9
| <style> @import url(../templates/bucket.css); .cesium-performanceDisplay-defaultContainer { top: 10px; } </style> <div id="cesiumContainer" class="fullSize"></div> <div id="loadingOverlay"><h1>Loading...</h1></div> <div id="toolbar"></div>
|