效果如下图,反选,设置地表透明,设置立体墙
let viewer = window.viewer;
//设置地表透明
let globe = window.viewer.scene.globe;
let scene = window.viewer.scene;
globe.depthTestAgainstTerrain = false;
viewer.scene.skyAtmosphere.show = false; //关闭大气层阴影
// screenSpaceCameraController获取用于摄像机输入处理的控制器;
// enableCollisionDetectio启用或禁用摄影机与地形的碰撞检测,
// 为true不会进入地下;
// scene.screenSpaceCameraController.enableCollisionDetection = false;
globe.translucency.frontFaceAlphaByDistance = new Cesium.NearFarScalar(
400.0,
0.0,
800.0,
1.0
);
globe.translucency.enabled = true;
globe.translucency.frontFaceAlphaByDistance.nearValue = Cesium.Math.clamp(
0.3,
0.0,
0.1
);
globe.translucency.frontFaceAlphaByDistance.farValue = 1.0;
viewer.scene.screenSpaceCameraController.minimumZoomDistance = 10000;
viewer.scene.screenSpaceCameraController.maximumZoomDistance = 50000;
let bounds = [];
// viewer.scene.globe.depthTestAgainstTerrain = true;
let response = pinggubianjieJson;
const maskpointArray = [];
for (
let i = 0;
i < response.features[0].geometry.coordinates[0].length;
i++
) {
bounds.push([
response.features[0].geometry.coordinates[0][i][0],
response.features[0].geometry.coordinates[0][i][1],
]);
maskpointArray.push(response.features[0].geometry.coordinates[0][i][0]);
maskpointArray.push(response.features[0].geometry.coordinates[0][i][1]);
}
boundspolygon = turf.polygon([bounds]);
var maskspoint = Cesium.Cartesian3.fromDegreesArray(maskpointArray);
const entity1 = new Cesium.Entity({
id: 1,
polygon: {
hierarchy: {
// 绘制的区域太大容易卡顿
positions: Cesium.Cartesian3.fromDegreesArray([
// 100, 0, 100, 89, 150, 89, 150, 0,
113.37890625, 37.50972584293751, 121.28906250000001,
37.50972584293751, 121.28906250000001, 42.35854391749705,
113.37890625, 42.35854391749705, 113.37890625, 37.50972584293751,
]),
// holes是图形内需要挖空的区域
holes: [
{
positions: maskspoint,
},
],
},
material: Cesium.Color.fromCssColorString("#0C1F34"),
// material: Cesium.Color.WHITE.withAlpha(1),
},
});
const entity3 = new Cesium.Entity({
name: "动态立体墙",
wall: {
positions: maskspoint,
maximumHeights: maskspoint.map((res) => {
return 600;
}),
minimumHeights: maskspoint.map((res) => {
return -600;
}),
material: Cesium.Color.fromCssColorString("#6dcdeb"),
},
});
viewer.entities.add(entity1);
viewer.entities.add(entity3);
viewer.flyTo(entity3, {
duration: 3,
});
cesium 可以关注微信公众号 Da6668Lei 有很多的ceisum特效展示案例,数据格式讲解,代码详细讲解等