使用polylineVolume : PolylineVolumeGraphics 设置折线体积,通过设置折线体为圆形,实现管道实体模型,polylineVolume提供的属性如下:
实现代码如下:
function computedCircle(radius) {
var positions = [];
for (var i = 0; i < 36; i++) {
var radian = Cesium.Math.toRadians(i * 10);
var x = radius * Math.cos(radian);
var y = radius * Math.sin(radian);
positions.push(new Cesium.Cartesian2(x, y));
}
return positions;
}
const greenTube = viewer.entities.add({
name: "Green Line",
polylineVolume: {
positions: Cesium.Cartesian3.fromDegreesArray([
116.39, 39.9, 116.38, 39.85, 116.41, 39.86, 116.41, 39.88,
]),
material: Cesium.Color.GREEN.withAlpha(0.5),
shape: computedCircle(100),
},
});
实现效果: