BufferPolygonCollection
Cesium v1.147 · 中文

以 ArrayBuffer 存储的多边形集合,用于优化性能与内存使用。

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

constructor when available.

new Cesium.BufferPolygonCollection(options)

Name Type Description
options BufferPolygonCollectionOptions 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),
三角形:新的 Uint32Array(earcut(positions, holes, 3)),
材质
}, polygon);

// 遍历集合中的所有多边形,临时绑定 'polygon'
// 为每个多边形创建本地变量,并更新多边形材质。
for (let i = 0; i < collection.primitiveCount; i++) {
collection.get(i, polygon);
polygon.setMaterial(material);
}
Experimental

This 该特征并非最终确定,可能会根据 Cesium 的标准弃用政策发生变化。

See:

Extends

Members

集合中三角形的数量。必须 <= triangleCountMax。 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

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

Methods

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

将此集合的内容复制到结果集合中。 结果集合不会调整大小,必须为源集合中的所有 原语提供足够空间。结果集合中现有的多边形 将被覆盖。

当集合达到其容量并需要分配更多空间时非常有用,可以高效地将多边形转移到新集合中。

const result = new BufferPolygonCollection({ ... }); // 分配更大的 'result' 集合
Name Type Description
collection BufferPolygonCollection
result BufferPolygonCollection
predicate function optional 返回给定集合的副本,覆盖任何提供的构造函数选项。未提供的选项则继承自源集合。任何
Returns:
Example:
BufferPolygonCollection.clone(collection, result);   // 将 'collection' 中的多边形复制到 'result'
当提供时,仅复制返回值为 <code>true</code> 的多边形。存活的多边形会被压缩到连续索引中。

static Cesium.BufferPolygonCollection.fromCollection(collection, options, predicate) → BufferPolygonCollection

调整大小的缓冲区必须足够大以容纳所有多边形。 要复制的源集合。 要覆盖的构造函数选项。未提供的选项则继承自源集合。
Name Type Description
collection BufferPolygonCollection 当提供时,仅复制返回值为 true 的多边形。存活的多边形会被压缩到连续索引中。
options BufferPolygonCollectionOptions optional 向集合中添加新多边形,并指定选项。一个
predicate function optional BufferPolygon 实例与新多边形关联,使用
Returns:
提供的 'result' 参数,否则使用新实例。对于重复调用, BufferPolygon instance is linked to the new polygon, using 此集合拥有的缓冲区总字节长度。包括由 primitiveCountMax 分配的任何未使用空间,即使该空间中尚未添加任何多边形。 集合中洞的数量。必须 <= holeCountMax。 集合中洞的最大数量。必须 >= holeCount。
Name Type Description
options BufferPolygonOptions
result BufferPolygon
Returns:

setPositions(positions, primitiveOffset, primitiveCount)

在指定的基础体对象范围内更新顶点位置。对于 许多基础体对象的仅位置更新,使用 `setPositions()` 更为 高效,无需单独更新每个基础体对象。 参数 `positions` 必须包含与 目标基础体对象范围相同的顶点总数;该方法无法添加或移除顶点。
Name Type Description
positions TypedArray
primitiveOffset number
primitiveCount number
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.