创建一个带边框的线柱体几何体。
var geometry = new Cesium.PolylineVolumeOutlineGeometry({
vertexFormat : Cesium.VertexFormat.POSITION_ONLY,
polylinePositions : Cesium.Cartesian3[],
shapePositions : Cesium.Cartesian2[],
cornerType : Cesium.CornerType.ROUNDED,
granularity : Number
});
VertexFormat
。默认值为VertexFormat.POSITION_ONLY
。Cartesian3[]
。这里的数组长度必须是shapePositions
数组长度+1。Cartesian2[]
。这里的数组长度必须是奇数,它的中间点作为轴心线上一端中点的位置。轴心线另一端中点的位置是由polylinePositions
数组决定的。CornerType
。默认值为CornerType.ROUNDED
。Number
。默认值为Math.PI / ( shapePositions.length - 1 )
。PolylineVolumeOutlineGeometry
由一组线段和一个横截面组成,该横截面沿着指定的轴心线旋转形成线柱体。使用PolylineVolumeOutlineGeometry
创建的几何实例可以使用GeometryInstance
传递给Primitive
进行渲染。
var polylinePositions = [
new Cesium.Cartesian3(-200000.0, -200000.0, -500000.0),
new Cesium.Cartesian3(200000.0, 200000.0, -500000.0)
];
var shapePositions = [
new Cesium.Cartesian2(0.0, -50000.0),
new Cesium.Cartesian2(0.0, 50000.0),
new Cesium.Cartesian2(100000.0, 50000.0),
new Cesium.Cartesian2(100000.0, -50000.0)
];
var geometry = new Cesium.PolylineVolumeOutlineGeometry({
vertexFormat: Cesium.VertexFormat.POSITION_ONLY,
polylinePositions: polylinePositions,
shapePositions: shapePositions,
cornerType: Cesium.CornerType.ROUNDED,
granularity: Math.PI / (shapePositions.length - 1)
});
var instance = new Cesium.GeometryInstance({
geometry: geometry,
attributes: {
color: Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.WHITE)
}
});
var primitive = new Cesium.Primitive({
geometryInstances: instance,
appearance: new Cesium.PerInstanceColorAppearance()
});
scene.primitives.add(primitive);