码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2019-12-07 15:58:45      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:scene   art   cross   地形   view   ping   cli   cart   nec   

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地形开挖(仅限凸多边形)

标签:scene   art   cross   地形   view   ping   cli   cart   nec   

原文地址:https://www.cnblogs.com/pumpkin-123/p/12001716.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!