BufferPointCollection
Collection of points held in ArrayBuffer storage for performance and memory optimization.
Default buffer memory allocation is arbitrary, and collections cannot be resized, so specific per-buffer capacities should be provided in the collection constructor when available.
const collection = new BufferPointCollection({primitiveCountMax: 1024});
const point = new BufferPoint();
const material = new BufferPointMaterial({color: Color.WHITE});
// Create a new point, temporarily bound to 'point' local variable.
collection.add({
position: new Cartesian3(0.0, 0.0, 0.0),
material
}, point);
// Iterate over all points in collection, temporarily binding 'point'
// local variable to each, and updating point material.
for (let i = 0; i < collection.primitiveCount; i++) {
collection.get(i, point);
point.setMaterial(material);
}See also
Types
Properties
Local bounding volume for all primitives in the collection, including both shown and hidden primitives.
World bounding volume for all primitives in the collection, including both shown and hidden primitives.
Total byte length of buffers owned by this collection. Includes any unused space allocated by primitiveCountMax, even if no primitives have yet been added in that space.
This property is for debugging only; it is not for production use nor is it optimized.
Default capacity of buffers on new collections. A quantity of elements: number of vertices in the vertex buffer, primitives in the primitive buffer, etc. This value is arbitrary, and collections cannot be resized, so specific per-buffer capacities should be provided in the collection constructor when available.
Transforms geometry from model to world coordinates.
Number of primitives in collection. Must be <= primitiveCountMax.
Maximum number of primitives this collection can contain. Must be >= primitiveCount.
Number of vertices in collection. Must be <= vertexCountMax.
Maximum number of vertices this collection can contain. Must be >= vertexCount.
Functions
Adds a new point to the collection, with the specified options. A BufferPoint instance is linked to the new point, using the 'result' argument if given, or a new instance if not. For repeated calls, prefer to reuse a single BufferPoint instance rather than allocating a new instance on each call.
Adds a new primitive to the collection, with the specified options. A BufferPrimitive instance is linked to the new primitive, using the 'result' argument if given, or a new instance if not. For repeated calls, prefer to reuse a single BufferPrimitive instance rather than allocating a new instance on each call.
Makes the given BufferPrimitive a view onto this collection's primitive at the given index, for use when reading/writing primitive properties. When iterating over a large collection, prefer to reuse the same BufferPrimitive instance throughout the loop — rebinding an existing instance to a different primitive is cheap, and avoids allocating in-memory objects for every object.
Returns true if this object was destroyed; otherwise, false.
Sorts primitives of the collection.
Returns a JSON-serializable array representing the collection. This encoding is not memory-efficient, and should generally be used for debugging and testing.