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)

参数名称 类型 描述信息
options object
参数名称 类型 默认值 描述信息
primitiveCountMax number BufferPrimitiveCollection.DEFAULT_CAPACITY 可选
vertexCountMax number BufferPrimitiveCollection.DEFAULT_CAPACITY 可选
holeCountMax number BufferPrimitiveCollection.DEFAULT_CAPACITY 可选
triangleCountMax number BufferPrimitiveCollection.DEFAULT_CAPACITY 可选
show boolean true 可选
debugShowBoundingVolume boolean false 可选
使用示例:
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.

参考:

继承

成员(属性)

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.
默认值: 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.
默认值: BufferPrimitiveCollection.DEFAULT_CAPACITY

方法

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.

参数名称 类型 描述信息
collection BufferPolygonCollection
result BufferPolygonCollection
返回值:
使用示例:
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.
参数名称 类型 描述信息
options BufferPolygonOptions
result BufferPolygon
返回值: