new PointPrimitiveCollection(optionsopt)
A renderable collection of points.
Points are added and removed from the collection using
Points are added and removed from the collection using
PointPrimitiveCollection#add
and PointPrimitiveCollection#remove
.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Object with the following properties:
Properties
|
- Source:
- See:
Example
// Create a pointPrimitive collection with two points
var 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
});
Members
debugShowBoundingVolume :Boolean
This property is for debugging only; it is not for production use nor is it optimized.
Draws the bounding sphere for each draw command in the primitive.
Type:
- Boolean
- Default Value:
- false
- Source:
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.
Type:
- Number
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
.
Type:
- Default Value:
- Source:
- See:
-
- Transforms.eastNorthUpToFixedFrame
Example
var 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
});
Methods
add(pointPrimitiveopt) → {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.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
pointPrimitive |
Object |
<optional> |
A template describing the point's properties as shown in Example 1. |
- Source:
- See:
Throws:
-
This object was destroyed, i.e., destroy() was called.
- Type
- DeveloperError
Returns:
The point that was added to the collection.
- Type
- PointPrimitive
Examples
// Example 1: Add a point, specifying all the default values.
var 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
});
// Example 2: Specify only the point's cartographic position.
var p = pointPrimitives.add({
position : Cesium.Cartesian3.fromDegrees(longitude, latitude, height)
});
contains(pointPrimitiveopt) → {Boolean}
Check whether this collection contains a given point.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
pointPrimitive |
PointPrimitive |
<optional> |
The point to check for. |
Returns:
true if this collection contains the point, false otherwise.
- Type
- Boolean
destroy() → {undefined}
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.
Once an object is destroyed, it should not be used; calling any function other than
Once an object is destroyed, it should not be used; calling any function other than
isDestroyed
will result in a DeveloperError
exception. Therefore,
assign the return value (undefined
) to the object as done in the example.
Throws:
-
This object was destroyed, i.e., destroy() was called.
- Type
- DeveloperError
Returns:
- Type
- undefined
Example
pointPrimitives = pointPrimitives && pointPrimitives.destroy();
get(index) → {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.
Parameters:
Name | Type | Description |
---|---|---|
index |
Number | The zero-based index of the point. |
Throws:
-
This object was destroyed, i.e., destroy() was called.
- Type
- DeveloperError
Returns:
The point at the specified index.
- Type
- PointPrimitive
Example
// Toggle the show property of every point in the collection
var len = pointPrimitives.length;
for (var i = 0; i < len; ++i) {
var p = pointPrimitives.get(i);
p.show = !p.show;
}
isDestroyed() → {Boolean}
Returns true if this object was destroyed; otherwise, false.
If this object was destroyed, it should not be used; calling any function other than
If this object was destroyed, it should not be used; calling any function other than
isDestroyed
will result in a DeveloperError
exception.
Returns:
true
if this object was destroyed; otherwise, false
.
- Type
- Boolean
remove(pointPrimitive) → {Boolean}
Removes a point from the collection.
Parameters:
Name | Type | Description |
---|---|---|
pointPrimitive |
PointPrimitive | The point to remove. |
- Source:
- See:
Throws:
-
This object was destroyed, i.e., destroy() was called.
- Type
- DeveloperError
Returns:
true
if the point was removed; false
if the point was not found in the collection.
- Type
- Boolean
Example
var p = pointPrimitives.add(...);
pointPrimitives.remove(p); // Returns true
removeAll()
Removes all points from the collection.
- Source:
- See:
Throws:
-
This object was destroyed, i.e., destroy() was called.
- Type
- DeveloperError
Example
pointPrimitives.add(...);
pointPrimitives.add(...);
pointPrimitives.removeAll();