1.3.Camera.js
將
if (cartographic.height < height) { cartographic.height = height; if (mode === SceneMode.SCENE3D) { ellipsoid.cartographicToCartesian(cartographic, this.position); } else { projection.project(cartographic, this.position); } heightUpdated = true; }
改為
if (cartographic.height < height) { if (M.underEarth.enable && cartographic.height > (height - M.underEarth.enableDepth)){ return; } cartographic.height = height; if (mode === SceneMode.SCENE3D) { ellipsoid.cartographicToCartesian(cartographic, this.position); } else { projection.project(cartographic, this.position); } heightUpdated = true; }
主要是監測到進入地下不自己彈出來的問題
參考:https://www.shuzhiduo.com/A/rV57QjWazP/
第一步:
1.修改cesium源碼,在GlobeSurfaceTileProvider.js文件里修改一行代碼
command.pass = Pass.GLOBE;
改為
command.pass = Pass.TRANSLUCENT;
2.重新打包
npm run minifyRelease
3.在沙盒里加入以下代碼
var viewer = new Cesium.Viewer('cesiumContainer'); viewer.scene.globe.baseColor = new Cesium.Color(, , , ); viewer.scene.globe.imageryLayers.get().alpha = 0.5; viewer.scene.globe.depthTestAgainstTerrain = !; viewer.scene.highDynamicRange = !; viewer.scene.skyAtmosphere.show = !; viewer.scene.skyBox.show = !; var blueBox = viewer.entities.add({ name: 'Blue box', position: Cesium.Cartesian3.fromDegrees(-114.0, 40.0, ), box: { dimensions: new Cesium.Cartesian3(100.0, 100.0, 5000.0), material: Cesium.Color.RED } }); viewer.zoomTo(blueBox);
還有以下問題沒有解決?
1.進入地下會自動彈上來問題
2.地下看地上長方體並沒有遮擋的感覺
3.白色網格
解決這個問題將會在下一篇博客。
https://www.cnblogs.com/SmilingEye/p/11473987.html
參考:
火星示例:http://cesium.marsgis.cn/cesium-example/editor.html#42_underground
問題解決最開始來源:https://stackoverflow.com/questions/41541223/how-to-display-data-underground-in-cesium-js