Appearance
KBE3D / KBCore / Cesium / PointPrimitiveCollection
类: PointPrimitiveCollection
A renderable collection of points. <br /><br /> Points are added and removed from the collection using PointPrimitiveCollection#add and PointPrimitiveCollection#remove.
示例
ts
// Create a pointPrimitive collection with two points
const points = scene.primitives.add(new Cesium.PointPrimitiveCollection());
points.add({
position : new Cesium.Cartesian3(1.0, 2.0, 3.0),
color : Cesium.Color.YELLOW
});
points.add({
position : new Cesium.Cartesian3(4.0, 5.0, 6.0),
color : Cesium.Color.CYAN
});参数
Object with the following properties:
参数
The 4x4 transformation matrix that transforms each point from model to world coordinates.
参数
For debugging only. Determines if this primitive's commands' bounding spheres are shown.
参数
The point blending option. The default is used for rendering both opaque and translucent points. However, if either all of the points are completely opaque or all are completely translucent, setting the technique to BlendOption.OPAQUE or BlendOption.TRANSLUCENT can improve performance by up to 2x.
参数
Determines if the primitives in the collection will be shown.
属性
show
show:
boolean
Determines if primitives in this collection will be shown.
modelMatrix
modelMatrix:
Matrix4
The 4x4 transformation matrix that transforms each point in this collection from model to world coordinates. When this is the identity matrix, the pointPrimitives are drawn in world coordinates, i.e., Earth's WGS84 coordinates. Local reference frames can be used by providing a different transformation matrix, like that returned by Transforms.eastNorthUpToFixedFrame.
示例
ts
const center = Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883);
pointPrimitives.modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(center);
pointPrimitives.add({
color : Cesium.Color.ORANGE,
position : new Cesium.Cartesian3(0.0, 0.0, 0.0) // center
});
pointPrimitives.add({
color : Cesium.Color.YELLOW,
position : new Cesium.Cartesian3(1000000.0, 0.0, 0.0) // east
});
pointPrimitives.add({
color : Cesium.Color.GREEN,
position : new Cesium.Cartesian3(0.0, 1000000.0, 0.0) // north
});
pointPrimitives.add({
color : Cesium.Color.CYAN,
position : new Cesium.Cartesian3(0.0, 0.0, 1000000.0) // up
});debugShowBoundingVolume
debugShowBoundingVolume:
boolean
This property is for debugging only; it is not for production use nor is it optimized. <p> Draws the bounding sphere for each draw command in the primitive. </p>
blendOption
blendOption:
BlendOption
The point blending option. The default is used for rendering both opaque and translucent points. However, if either all of the points are completely opaque or all are completely translucent, setting the technique to BlendOption.OPAQUE or BlendOption.TRANSLUCENT can improve performance by up to 2x.
length
length:
number
Returns the number of points in this collection. This is commonly used with PointPrimitiveCollection#get to iterate over all the points in the collection.
方法
add()
add(
options?:any):PointPrimitive
Creates and adds a point with the specified initial properties to the collection. The added point is returned so it can be modified or removed from the collection later.
参数
options?
any
A template describing the point's properties as shown in Example 1.
返回
The point that was added to the collection.
Examples
ts
// Example 1: Add a point, specifying all the default values.
const p = pointPrimitives.add({
show : true,
position : Cesium.Cartesian3.ZERO,
pixelSize : 10.0,
color : Cesium.Color.WHITE,
outlineColor : Cesium.Color.TRANSPARENT,
outlineWidth : 0.0,
id : undefined
});ts
// Example 2: Specify only the point's cartographic position.
const p = pointPrimitives.add({
position : Cesium.Cartesian3.fromDegrees(longitude, latitude, height)
});remove()
remove(
pointPrimitive:PointPrimitive):boolean
Removes a point from the collection.
参数
pointPrimitive
The point to remove.
返回
boolean
true if the point was removed; false if the point was not found in the collection.
示例
ts
const p = pointPrimitives.add(...);
pointPrimitives.remove(p); // Returns trueremoveAll()
removeAll():
void
Removes all points from the collection.
返回
void
示例
ts
pointPrimitives.add(...);
pointPrimitives.add(...);
pointPrimitives.removeAll();contains()
contains(
pointPrimitive?:PointPrimitive):boolean
Check whether this collection contains a given point.
参数
pointPrimitive?
The point to check for.
返回
boolean
true if this collection contains the point, false otherwise.
get()
get(
index:number):PointPrimitive
Returns the point in the collection at the specified index. Indices are zero-based and increase as points are added. Removing a point shifts all points after it to the left, changing their indices. This function is commonly used with PointPrimitiveCollection#length to iterate over all the points in the collection.
参数
index
number
The zero-based index of the point.
返回
The point at the specified index.
示例
ts
// Toggle the show property of every point in the collection
const len = pointPrimitives.length;
for (let i = 0; i < len; ++i) {
const p = pointPrimitives.get(i);
p.show = !p.show;
}isDestroyed()
isDestroyed():
boolean
Returns true if this object was destroyed; otherwise, false. <br /><br /> If this object was destroyed, it should not be used; calling any function other than <code>isDestroyed</code> will result in a DeveloperError exception.
返回
boolean
true if this object was destroyed; otherwise, false.
destroy()
destroy():
void
Destroys the WebGL resources held by this object. Destroying an object allows for deterministic release of WebGL resources, instead of relying on the garbage collector to destroy this object. <br /><br /> Once an object is destroyed, it should not be used; calling any function other than <code>isDestroyed</code> will result in a DeveloperError exception. Therefore, assign the return value (<code>undefined</code>) to the object as done in the example.
返回
void
示例
ts
pointPrimitives = pointPrimitives && pointPrimitives.destroy();构造函数
构造函数
new PointPrimitiveCollection(
options?: {modelMatrix?:Matrix4;debugShowBoundingVolume?:boolean;blendOption?:BlendOption;show?:boolean; }):PointPrimitiveCollection
参数
options?
modelMatrix?
debugShowBoundingVolume?
boolean
blendOption?
show?
boolean
返回
PointPrimitiveCollection
