| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
|
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
集合中的三角形数量。必须 <=
triangleCountMax。
集合中的最大三角形数量。必须 >=
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'
add(options, result) → BufferPolygon
使用指定选项向集合中添加一个新多边形。一个
BufferPolygon 实例将链接到新多边形,如果提供了 result 参数则使用该参数,否则创建新实例。对于重复调用,建议复用单个 BufferPolygon 实例,而非每次调用都分配新实例。
| Name | Type | Description |
|---|---|---|
options |
BufferPolygonOptions | |
result |
BufferPolygon |
