为性能和内存优化在ArrayBuffer存储中保存的多边形集合.

Default buffer memory allocation is arbitrary, and collections cannot be resized, 因此,收集中应提供具体的每缓冲能力 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
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

readonly byteLength : number

此收藏所拥有的缓冲总字节长度 。 包括未使用 space allocated by primitiveCountMax, even if no polygons have 却被添加在这个空间.

readonly holeCount : number

Number of holes in collection. Must be <= holeCountMax.

readonly holeCountMax : number

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

将本集的内容复制到结果集中. 结果收藏没有调整大小,必须包含足够的空间供所有人使用 源集中的原始语. 结果中的现有多边形 收藏将被覆盖. NT 0 当为收藏分配更多空间时有用 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'

add(options, result)BufferPolygon

在收藏中添加新的多边形,并附带指定的选项。 A级 BufferPolygon instance is linked to the new polygon, using 如果给出了“ 结果” 参数, 或者没有给出新实例 。 对重复 调用,宁可重复使用单个缓冲Polygon实例,而不是 每次通话都分配一个新实例.
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.