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入门7 - Adding Terrain - 添加地形