cesium地下模式(地表透明)


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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM