Cesium地形开挖(仅限凸多边形)

Posted pumpkin-123

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Cesium地形开挖(仅限凸多边形)相关的知识,希望对你有一定的参考价值。

var points = [
      Cesium.Cartesian3.fromDegrees(116.5,40.8),
      Cesium.Cartesian3.fromDegrees(116.9,40.8),
      Cesium.Cartesian3.fromDegrees(116.9,41.5)
];
      
var pointsLength = points.length;
var clippingPlanes = []; // 存储ClippingPlane集合
for (var i = 0; i < pointsLength; ++i) {
      var nextIndex = (i + 1) % pointsLength;
      var midpoint = Cesium.Cartesian3.add(points[i], points[nextIndex], new Cesium.Cartesian3());
      midpoint = Cesium.Cartesian3.multiplyByScalar(midpoint, 0.5, midpoint);
 
      var up = Cesium.Cartesian3.normalize(midpoint, new Cesium.Cartesian3());
      var right = Cesium.Cartesian3.subtract(points[nextIndex], midpoint, new Cesium.Cartesian3());
      right = Cesium.Cartesian3.normalize(right, right);
 
      var normal = Cesium.Cartesian3.cross(right, up, new Cesium.Cartesian3());
      normal = Cesium.Cartesian3.normalize(normal, normal);
 
      var originCenteredPlane = new Cesium.Plane(normal, 0.0);
      var distance = Cesium.Plane.getPointDistance(originCenteredPlane, midpoint);
 
      clippingPlanes.push(new Cesium.ClippingPlane(normal, distance));
      }
viewer.scene.globe.clippingPlanes = new Cesium.ClippingPlaneCollection({
      planes:clippingPlanes,
      edgeWidth: 1.0,
      edgeColor: Cesium.Color.YELLOW
      });

待解决

以上是关于Cesium地形开挖(仅限凸多边形)的主要内容,如果未能解决你的问题,请参考以下文章

从片段着色器中的地形高程数据计算法线

cesium 3d地形和平面地形动态转换,取消3d地形

Cesium入门7 - Adding Terrain - 添加地形

cesium测量距离,测量地形上两点的距离(工具篇)

cesium 加载地图、地形、模型不显示提示CORS policy错误

Cesium官方教程5--地形图层