原文链接及内容

运行效果如下图:

示例代码如下:

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
const viewer = new Cesium.Viewer("cesiumContainer");

const greenCylinder = viewer.entities.add({
name: "带有黑色轮廓的绿色圆柱体(cylinder)",
position: Cesium.Cartesian3.fromDegrees(-100.0, 40.0, 200000.0),
cylinder: {
length: 400000.0,//圆柱体长度,即我们看到的高度
topRadius: 200000.0,//圆柱顶部半径
bottomRadius: 200000.0,//圆柱底部半径
material: Cesium.Color.GREEN.withAlpha(0.5),
outline: true,
outlineColor: Cesium.Color.BLACK,
},
});

const redCone = viewer.entities.add({
name: "红色圆锥(cone)",
position: Cesium.Cartesian3.fromDegrees(-105.0, 40.0, 200000.0),
cylinder: {
length: 400000.0,//同上
topRadius: 0.0,//顶部半径为0时,则变为圆锥
bottomRadius: 200000.0,
material: Cesium.Color.RED,
},
});

viewer.zoomTo(viewer.entities);