BufferPrimitiveCollection

Collection of primitives held in ArrayBuffer storage for performance and memory optimization.

To get the full performance benefit of using a BufferPrimitiveCollection containing "N" primitives, be careful to avoid allocating "N" instances of any related JavaScript object. BufferPrimitive, Color, Cartesian3, and other objects can all be reused when working with large collections, using the flyweight pattern.

See also

Inheritors

Constructors

Link copied to clipboard

Types

Link copied to clipboard
object Companion
Link copied to clipboard

Properties

Link copied to clipboard

Local bounding volume for all primitives in the collection, including both shown and hidden primitives.

Link copied to clipboard

World bounding volume for all primitives in the collection, including both shown and hidden primitives.

Link copied to clipboard

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.

Link copied to clipboard

This property is for debugging only; it is not for production use nor is it optimized.

Link copied to clipboard

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.

Link copied to clipboard

Transforms geometry from model to world coordinates.

Link copied to clipboard

Number of primitives in collection. Must be <= primitiveCountMax.

Link copied to clipboard

Maximum number of primitives this collection can contain. Must be >= primitiveCount.

Link copied to clipboard

Determines if primitives in this collection will be shown.

Link copied to clipboard

Number of vertices in collection. Must be <= vertexCountMax.

Link copied to clipboard

Maximum number of vertices this collection can contain. Must be >= vertexCount.

Functions

Link copied to clipboard
fun add(options: BufferPrimitiveOptions, result: JsAny)

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.

Link copied to clipboard
fun destroy()

Destroys collection and its GPU resources.

Link copied to clipboard
fun get(index: Int, result: BufferPrimitive): BufferPrimitive

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.

Link copied to clipboard

Returns true if this object was destroyed; otherwise, false.

Link copied to clipboard
fun sort(sortFn: Function<*>, result: Uint32Array<*>): Uint32Array<*>

Sorts primitives of the collection.

Link copied to clipboard

Returns a JSON-serializable array representing the collection. This encoding is not memory-efficient, and should generally be used for debugging and testing.