Experimental
This feature is not final and is subject to change without Cesium's standard deprecation policy.
See:
Members
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.
Matrix4.IDENTITY
World-space 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.
Draws the bounding sphere for each draw command in the primitive.
false
Determines which surfaces the collection is draped onto, in addition to
being drawn as standalone geometry. Draping requires that the collection
has been added to
Scene#primitives.
HeightReference.NONE
Transforms geometry from model to world coordinates.
Matrix4.IDENTITY
The component datatype used to store position values.
When true, integer position values are treated as normalized
values, where the full integer range maps to [-1, 1] (signed) or [0, 1]
(unsigned).
Number of primitives in collection. Must be <= primitiveCountMax.
Maximum number of primitives this collection can contain. Must be >=
primitiveCount.
BufferPrimitiveCollection.DEFAULT_CAPACITY
Determines if primitives in this collection will be shown.
true
Number of vertices in collection. Must be <= vertexCountMax.
Maximum number of vertices this collection can contain. Must be >=
vertexCount.
BufferPrimitiveCollection.DEFAULT_CAPACITY
Methods
Duplicates the contents of this collection into the result collection.
Result collection is not resized, and must contain enough space for all
primitives in the source collection. Existing primitives in the result
collection will be overwritten.
Useful when allocating more space for a collection that has reached its
capacity, and efficiently transferring features to the new collection.
| Name |
Type |
Description |
collection |
BufferPrimitiveCollection.<T>
|
|
result |
BufferPrimitiveCollection.<T>
|
|
predicate |
function
|
optional
When provided, only primitives for which this returns true are copied. Surviving primitives are compacted into contiguous indices. |
Example:
const result = new BufferPrimitiveCollection({ ... }); // allocate larger 'result' collection
BufferPrimitiveCollection.clone(collection, result); // copy primitives from 'collection' into 'result'
Returns a copy of the given collection, overriding any constructor options
provided. Omitted options are inherited from the source collection. Any
resized buffers must be large enough to hold every primitive.
Collection-level state (model matrix, blend option, picking, bounding-volume
mode, etc.) is carried over, but GPU resources are not: the source collection
retains ownership of its renderer resources, so the caller is responsible for
calling BufferPrimitiveCollection#destroy on the source once it is no
longer needed.
| Name |
Type |
Description |
collection |
BufferPrimitiveCollection.<T>
|
Source collection to copy. |
options |
BufferPrimitiveCollectionOptions
|
optional
Constructor options to override. Omitted options are inherited from the source collection. |
predicate |
function
|
optional
When provided, only primitives for which this returns true are copied. Surviving primitives are compacted into contiguous indices. |
Returns:
Examples:
const grown = BufferPrimitiveCollection.fromCollection(collection, {
primitiveCountMax: collection.primitiveCountMax * 2,
vertexCountMax: collection.vertexCountMax * 2,
});
collection.destroy(); // release the source collection's GPU resources
// Grow while dropping hidden primitives.
const compacted = BufferPrimitiveCollection.fromCollection(
collection,
{ primitiveCountMax: collection.primitiveCountMax * 2 },
(primitive) => primitive.show,
);
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.
Returns:
Destroys collection and its GPU resources.
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:
The BufferPrimitive instance passed as the
'result' argument, now bound to the specified primitive index.
Example:
const primitive = new BufferPrimitive();
for (let i = 0; i < collection.primitiveCount; i++) {
collection.get(i, primitive);
primitive.setColor(Color.RED);
}
Returns true if this object was destroyed; otherwise, false.
Returns:
True if this object was destroyed; otherwise, false.
Sorts primitives of the collection.
Because sorting changes the indices (but not the feature IDs) of primitives
in the collection, the function also returns an array mapping from previous
index to new index. When sorting repeatedly, the array can be reused and
passed as the 'result' argument for each call.
| Name |
Type |
Description |
sortFn |
function
|
|
result |
Uint32Array
|
|
Returns:
Mapping from previous index to new index.
Returns a JSON-serializable array representing the collection. This encoding
is not memory-efficient, and should generally be used for debugging and
testing.
Returns:
List of JSON-serializable objects, one for each
primitive in the collection.
Example:
console.table(collection.toJSON());
| Name |
Type |
Description |
frameState |
object
|
|