BufferPolygonCollection

存储在 ArrayBuffer 中以实现性能和内存优化的多边形集合。

默认缓冲区内存分配是任意的,集合无法调整大小,因此应在构造集合时尽可能提供每个缓冲区的具体容量。

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
positionNormalized boolean false optional
show boolean true optional
allowPicking boolean true optional 当值为 true 时,图元可通过 Scene#pick 进行拾取。当值为 false 时,内存和初始化开销更低。
boundingVolume BoundingSphere optional 集合在世界空间中的包围体。未指定时,将自动计算包围体并在图元位置变化时更新。指定后,用户负责按需更新包围体。手动预计算包围体并仅在需要时更新,将提升大型动态集合的性能。
debugShowBoundingVolume boolean false optional
blendOption BlendOption BlendOption.TRANSLUCENT 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 标准弃用策略的情况下发生变更。

See:

Extends

Members

此集合拥有的缓冲区总字节长度。包括由 primitiveCountMax 分配的任何未使用空间,即使该空间尚未添加多边形。
集合中的孔洞数量。必须 <= holeCountMax
集合中的最大孔洞数量。必须 >= holeCount
Default Value: BufferPrimitiveCollection.DEFAULT_CAPACITY

readonly triangleCount : number

集合中的三角形数量。必须 <= triangleCountMax

readonly triangleCountMax : number

集合中的最大三角形数量。必须 >= triangleCount
Default Value: BufferPrimitiveCollection.DEFAULT_CAPACITY

Methods

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

将此集合的内容复制到结果集合中。结果集合不会调整大小,且必须包含源集合中所有图元的足够空间。结果集合中现有多边形将被覆盖。

当为已达到容量上限的集合分配更多空间,并将多边形高效转移到新集合时非常有用。

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'
使用指定选项向集合中添加一个新多边形。一个 BufferPolygon 实例将链接到新多边形,如果提供了 result 参数则使用该参数,否则创建新实例。对于重复调用,建议复用单个 BufferPolygon 实例,而非每次调用都分配新实例。
Name Type Description
options BufferPolygonOptions
result BufferPolygon
Returns:
需要帮助?获取答案的最快方式是在 Cesium 论坛 上向社区和团队提问。