Performance:
为了获得最佳性能,最好选择几个集合,每个集合都有许多多段线 许多集合中每个集合只有几个多段线。组织集合以便多段线 具有相同更新频率的是在同一个集合中,即不在同一集合中的多段线 更改应在一个集合中;更改每个帧的多段线应位于另一个集合中 收集;等等。
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | optional
具有以下属性的对象:
|
Example:
// Create a polyline collection with two polylines
var polylines = new Cesium.PolylineCollection();
polylines.add({
positions : Cesium.Cartesian3.fromDegreesArray([
-75.10, 39.57,
-77.02, 38.53,
-80.50, 35.14,
-80.12, 25.46]),
width : 2
});
polylines.add({
positions : Cesium.Cartesian3.fromDegreesArray([
-73.10, 37.57,
-75.02, 36.53,
-78.50, 33.14,
-78.12, 23.46]),
width : 4
});
See:
Members
此属性仅用于调试;它不用于生产用途,也不进行优化。
Draws the bounding sphere for each draw command in the primitive.
-
Default Value:
false
返回此集合中的多段线数。通常用于
PolylineCollection#get
遍历所有多段线
收藏中。modelMatrix : Matrix4
4x4转换矩阵,用于将此集合中的每个多段线从模型转换为世界坐标。
当这是单位矩阵时,多段线以世界坐标系绘制,即地球的WGS84坐标系。
局部参考帧可以通过提供不同的转换矩阵来使用,就像返回的那样
通过
Transforms.eastNorthUpToFixedFrame
。-
Default Value:
Matrix4.IDENTITY
Methods
add(options) → Polyline
创建具有指定初始特性的多段线并将其添加到集合中。
将返回添加的多段线,以便以后可以在集合中修改或删除它。
Performance:
在调用add
后,调用PolylineCollection#update
并
集合的顶点缓冲区被重写-这是一个O(n)
操作,也会导致CPU到GPU的开销。
为了获得最佳性能,请在调用update
之前添加尽可能多的多段线。
Name | Type | Description |
---|---|---|
options |
Object | optional 描述多段线属性的模板,如示例1所示。 |
Returns:
添加到集合中的多段线。
Throws:
-
DeveloperError :此对象已销毁,即调用destroy()。
Example:
// Example 1: Add a polyline, specifying all the default values.
var p = polylines.add({
show : true,
positions : ellipsoid.cartographicArrayToCartesianArray([
Cesium.Cartographic.fromDegrees(-75.10, 39.57),
Cesium.Cartographic.fromDegrees(-77.02, 38.53)]),
width : 1
});
See:
确定此集合是否包含指定的多段线。
Name | Type | Description |
---|---|---|
polyline |
Polyline | 要检查的多段线。 |
Returns:
如果此集合包含多段线,则为true,否则为false。
销毁此对象持有的WebGL资源。销毁一个对象允许确定性 释放WebGL资源,而不是依赖垃圾回收器销毁此对象。 一旦一个对象被销毁,就不应该使用它;调用除
isDestroyed
将导致DeveloperError
异常。因此,
如示例所示,将返回值(undefined
)分配给对象。Throws:
-
DeveloperError :此对象已销毁,即调用destroy()。
Example:
polylines = polylines && polylines.destroy();
See:
get(index) → Polyline
返回集合中指定索引处的多段线。指数以零为基础
并随着多段线的添加而增加。删除多段线后,所有多段线都将随之移动
它在左边,改变他们的指数。此函数常用于
PolylineCollection#length
遍历所有多段线
收藏中。Performance:
如果从集合中删除了多段线,并且 不是6861166,是6866166 执行操作。
Name | Type | Description |
---|---|---|
index |
Number | 折线的从零开始的索引。 |
Returns:
指定索引处的多段线。
Throws:
-
DeveloperError :此对象已销毁,即调用destroy()。
Example:
// Toggle the show property of every polyline in the collection
var len = polylines.length;
for (var i = 0; i < len; ++i) {
var p = polylines.get(i);
p.show = !p.show;
}
See:
Returns:
如果此对象被销毁,则为
true
;否则为false
。从集合中删除多段线。
Performance:
在调用remove
后,调用PolylineCollection#update
并
集合的顶点缓冲区被重写-这是一个O(n)
操作,也会导致CPU到GPU的开销。
为了获得最佳性能,请在调用update
之前删除尽可能多的多段线。
如果要暂时隐藏多段线,通常调用
Polyline#show
,而不是删除并重新添加多段线。
Name | Type | Description |
---|---|---|
polyline |
Polyline | 要删除的多段线。 |
Returns:
如果多段线已删除,则为
true
;如果在集合中找不到该多段线,则为false
。Throws:
-
DeveloperError :此对象已销毁,即调用destroy()。
Example:
var p = polylines.add(...);
polylines.remove(p); // Returns true
See:
从集合中删除所有多段线。
Performance:
O(n)
删除所有多段线更有效
从一个集合中添加新的集合,而不是完全创建一个新集合。
Throws:
-
DeveloperError :此对象已销毁,即调用destroy()。
Example:
polylines.add(...);
polylines.add(...);
polylines.removeAll();
See:
当
Viewer
或CesiumWidget
将场景渲染到
获取渲染此基本体所需的draw命令。
Do not call this function directly. This is documented just to list the exceptions that may be propagated when the scene is rendered:
Throws:
-
RuntimeError :使用逐实例属性渲染基本体需要顶点纹理获取支持。顶点纹理图像单元的最大数目必须大于零。