var volume = new Cesium.PolylineVolumeGeometry({
polylinePositions: Cesium.Cartesian3.fromDegreesArrayHeights([
118.6052664564008, 31.896095367250844, 54.51094649588214
,118.60527265967644, 31.89600663109118, 55.521295395922415
,118.60602026340274, 31.896005195264078, 55.554240591949494
, 118.60604459487979, 31.896004133976497, 17.986539347126186
, 118.60633127622567, 31.896005795822646, 16.970510470055817
, 118.60633962942539, 31.89589418952046, 12.469632977799977
, 118.60644077343599, 31.89589221508266, 12.169390873433514
]),
shapePositions : computeCircleR(1, 10),
});
// 定义 Geometry
var geometry = Cesium.PolylineVolumeGeometry.createGeometry(volume);
// 定义 GeometryInstance
var instance = new Cesium.GeometryInstance({
geometry: geometry,
id: Math.random().toString(),
attributes: {
color: Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.AQUA)
}
});
// Primitive加载
var primitive = new Cesium.Primitive({
geometryInstances: instance, // 多个instance组成的集合
appearance: new Cesium.PerInstanceColorAppearance()
});
// viewer.scene.primitives.add(primitive);
scene.primitives.add(primitive); // Add regular primitive
/**
* polylineVolume 半径和边数
**/
function computeCircleR(radius, itemp) {
let result = [];
for (let i = 0; i < 360; i += itemp) {
let radians = Cesium.Math.toRadians(i);
result.push(new Cesium.Cartesian2(radius * Math.sin(radians),radius * Math.cos(radians) ));
}
console.log(result)
return result;
}
网友评论