BufferPolygonCollection

Collection of polygons 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.

new Cesium.BufferPolygonCollection(options)

Name Type Description
options object
Name Type Default Description
primitiveCountMax number BufferPrimitiveCollection.DEFAULT_CAPACITY optional
vertexCountMax number BufferPrimitiveCollection.DEFAULT_CAPACITY optional
holeCountMax number BufferPrimitiveCollection.DEFAULT_CAPACITY optional
triangleCountMax number BufferPrimitiveCollection.DEFAULT_CAPACITY optional
positionDatatype ComponentDatatype ComponentDatatype.DOUBLE optional
show boolean true optional
debugShowBoundingVolume boolean false optional
Example:
import earcut from "earcut";

const collection = new BufferPolygonCollection({
  primitiveCountMax: 1024,
  vertexCountMax: 4096,
  holeCountMax: 1024,
  triangleCountMax: 2048,
});

const polygon = new BufferPolygon();
const positions = [ ... ];
const holes = [ ... ];

// Create a new polygon, temporarily bound to 'polygon' local variable.
collection.add({
  positions: new Float64Array(positions),
  holes: new Uint32Array(holes),
  triangles: new Uint32Array(earcut(positions, holes, 3)),
  color: Color.WHITE,
}, polygon);

// Iterate over all polygons in collection, temporarily binding 'polygon'
// local variable to each, and updating polygon color.
for (let i = 0; i < collection.primitiveCount; i++) {
  collection.get(i, polygon);
  polygon.setColor(Color.RED);
}
Experimental

This feature is not final and is subject to change without Cesium's standard deprecation policy.

See:

Extends

Members

Total byte length of buffers owned by this collection. Includes any unused space allocated by primitiveCountMax, even if no polygons have yet been added in that space.
Number of holes in collection. Must be <= holeCountMax.
Maximum number of holes in collection. Must be >= holeCount.
Default Value: BufferPrimitiveCollection.DEFAULT_CAPACITY

readonly triangleCount : number

Number of triangles in collection. Must be <= triangleCountMax.

readonly triangleCountMax : number

Maximum number of triangles in collection. Must be >= triangleCount.
Default Value: BufferPrimitiveCollection.DEFAULT_CAPACITY

Methods

static Cesium.BufferPolygonCollection.clone(collection, result)BufferPolygonCollection

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 polygons in the result collection will be overwritten.

Useful when allocating more space for a collection that has reached its capacity, and efficiently transferring polygons to the new collection.

Name Type Description
collection BufferPolygonCollection
result BufferPolygonCollection
Returns:
Example:
const result = new BufferPolygonCollection({ ... }); // allocate larger 'result' collection
BufferPolygonCollection.clone(collection, result);   // copy polygons from 'collection' into 'result'
Adds a new polygon to the collection, with the specified options. A BufferPolygon instance is linked to the new polygon, using the 'result' argument if given, or a new instance if not. For repeated calls, prefer to reuse a single BufferPolygon instance rather than allocating a new instance on each call.
Name Type Description
options BufferPolygonOptions
result BufferPolygon
Returns:
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.