原文链接及内容

示例效果如下:

绘制平面的参数请看关于plane参数的plane属性的定义,具体请看官方文档:第一个参数表示平面的法线,第二个参数若为0,表示平面通过原点,为正或为负则原点分别位于平面法线的方向或其反方向的一半空间内。具体参考:https://cesium.com/learn/cesiumjs/ref-doc/Plane.html

示例代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const viewer = new Cesium.Viewer("cesiumContainer");

const bluePlane = viewer.entities.add({
name: "蓝色平面",
position: Cesium.Cartesian3.fromDegrees(-114.0, 40.0, 300000.0),
plane: {
plane: new Cesium.Plane(Cesium.Cartesian3.UNIT_X, 0.0),
dimensions: new Cesium.Cartesian2(400000.0, 300000.0),
material: Cesium.Color.BLUE,
},
});

const redPlane = viewer.entities.add({
name: "带有黑色轮廓红色平面",
position: Cesium.Cartesian3.fromDegrees(-107.0, 40.0, 300000.0),
plane: {
plane: new Cesium.Plane(Cesium.Cartesian3.UNIT_Y, 0.0),
dimensions: new Cesium.Cartesian2(400000.0, 300000.0),
material: Cesium.Color.RED.withAlpha(0.5),
outline: true,
outlineColor: Cesium.Color.BLACK,
},
});

const outlineOnly = viewer.entities.add({
name: "仅有轮廓但无填充的黄色平面",
position: Cesium.Cartesian3.fromDegrees(-100.0, 40.0, 300000.0),
plane: {
plane: new Cesium.Plane(Cesium.Cartesian3.UNIT_Z, 0.0),
dimensions: new Cesium.Cartesian2(400000.0, 300000.0),
fill: false,
outline: true,
outlineColor: Cesium.Color.YELLOW,
},
});

viewer.zoomTo(viewer.entities);