| 名称 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 标准弃用政策的情况下进行更改。 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
集合中三角形的数量。必须是 Number of triangles in collection. Must be <=
triangleCountMax.
集合中三角形的最大数量。必须 >= 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'
add(options, result) → BufferPolygon
使用指定选项将新多边形添加到集合中。一个 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 |
