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
show boolean true optional
allowPicking boolean true optionaltrue 时,图元可使用 Scene#pick 进行拾取。当 false 时,内存和初始化成本更低。
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});

// 创建新多边形,临时绑定到 'polygon' 局部变量。
collection.add({
  positions: new Float64Array(positions),
  holes: new Uint32Array(holes),
  triangles: new Uint32Array(earcut(positions, holes, 3)),
  material
}, polygon);

// 遍历集合中的所有多边形,将 'polygon' 局部变量临时绑定到每个多边形,
// 并更新多边形材质。
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({ ... }); // 分配更大的 'result' 集合
BufferPolygonCollection.clone(collection, result);   // 将 'collection' 中的多边形复制到 'result'
向集合添加新多边形,并指定选项。 BufferPolygon 实例链接到新多边形,使用 'result' 参数(如果提供), 否则使用新实例。对于重复调用,建议重用单个 BufferPolygon 实例, 而不是在每次调用时分配新实例。
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.