English中文

BufferPolygonCollection

ArrayBuffer 存储中保存的多边形集合,用于性能和内存优化。 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
allowPicking boolean true 可选 optional When true,基元可以选择 , primitives are pickable with Scene#pick。当 . When false,内存和初始化成本较低。 , memory and initialization cost are lower.
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 = [ ... ];
const material = new BufferPolygonMaterial({color: Color.WHITE});

// 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)),
  material
}, polygon);

// Iterate over all polygons in collection, temporarily binding 'polygon'
// local variable to each, and updating polygon material.
for (let i = 0; i < collection.primitiveCount; i++) {
  collection.get(i, polygon);
  polygon.setMaterial(material);
}
实验性 Experimental

此功能不是最终版本,可能会在没有 Cesium 标准弃用政策的情况下进行更改。 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 实例链接到新的多边形,如果给定则使用“结果”参数,如果没有则使用新实例。对于重复调用,最好重用单个 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.