Cesium.Math.setRandomNumberSeed(1234);
var viewer = new Cesium.Viewer('cesiumContainer', { infoBox : false });
var entities = viewer.entities;
var i;
var height;
var positions;
var stripeMaterial = new Cesium.StripeMaterialProperty({
evenColor : Cesium.Color.WHITE.withAlpha(0.5),
oddColor : Cesium.Color.BLUE.withAlpha(0.5),
repeat : 5.0
});
entities.add({
position : Cesium.Cartesian3.fromDegrees(116.472305, 35.416434, -965),
cylinder : {
length: 200,
topRadius: 10,
bottomRadius: 10,
material : Cesium.Color.fromRandom({alpha : 1.0})
}
});
entities.add({
position : Cesium.Cartesian3.fromDegrees(116.472305, 35.416434, -600),
cylinder : {
length: 145,
topRadius: 10,
bottomRadius: 10,
material : Cesium.Color.fromRandom({alpha : 1.0})
}
});
entities.add({
position : Cesium.Cartesian3.fromDegrees(116.472305, 35.416434, -455),
cylinder : {
length: 155,
topRadius: 10,
bottomRadius: 10,
material : Cesium.Color.fromRandom({alpha : 1.0})
}
});
entities.add({
position : Cesium.Cartesian3.fromDegrees(116.472305, 35.416434, -300),
cylinder : {
length: 150,
topRadius: 10,
bottomRadius: 10,
material : Cesium.Color.fromRandom({alpha : 1.0})
}
});
entities.add({
position : Cesium.Cartesian3.fromDegrees(116.472305, 35.416434, -150),
cylinder : {
length: 185,
topRadius: 10,
bottomRadius: 10,
material : Cesium.Color.fromRandom({alpha : 1.0})
}
});
viewer.zoomTo(viewer.entities);
你是看到了有断开的部分,其实你应该发现上面几个圆柱已经重合了。
拿第一段来说:
entities.add({
position : Cesium.Cartesian3.fromDegrees(116.472305, 35.416434, -965),
cylinder : {
length: 200,
topRadius: 10,
bottomRadius: 10,
material : Cesium.Color.fromRandom({alpha : 1.0})
}
});
高程为 -965,高度为 200,那么这段圆柱的最低点高程为 -965-200/2 = -1065;最高点高程为 -965+200/2 = -865;也就是说它是以 -965 为中心向两头延伸。
因此该这么计算
https://sogrey.top/Cesium-start-Example/examples/other/cylinders.html