Cesium 控制地形TerrainProvider 显示与移除

头像
码农笔录
2018-12-13阅读 2178

function toggleTerrain(){
var scene = viewer.scene;
var terrainProvider;
if (scene.terrainProvider._url){
//add a simple terain so no terrain shall be preseneted
terrainProvider = new Cesium.EllipsoidTerrainProvider({});
}
else {
//enable the terain
terrainProvider = new Cesium.CesiumTerrainProvider({
url : '//cesiumjs.org/stk-terrain/tilesets/world/tiles',
requestWaterMask: true
});
}
scene.terrainProvider = terrainProvider;
}