new Cesium.PolylineCollection(options)

一种可转换的多线集.


Example polylines


Polylines are added and removed from the collection using PolylineCollection#addPolylineCollection#remove .
Performance:

For best performance, prefer a few collections, each with many polylines, to 许多收藏,每个只有几条多线. 组织收藏以便多线 同一更新频率的集合中为 i.e .,不包含的多线 更改应该在一个集合中;改变每个框架的多线应该在另一个集合中 收藏; 等.

Name Type Description
options object optional 下列属性的对象 :
Name Type Default Description
modelMatrix Matrix4 Matrix4.IDENTITY optional The 4x4 transformation matrix that transforms each polyline from model to world coordinates.
debugShowBoundingVolume boolean false optional For debugging only. Determines if this primitive's commands' bounding spheres are shown.
show boolean true optional Determines if the polylines in the collection will be shown.
Example:
// Create a polyline collection with two polylines
const 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

debugShowBoundingVolume : boolean

此属性仅用于调试;不用于生产,也不优化.

绘制原始中每个绘图命令的边框.

Default Value: false

length : number

返回此收藏中的多行数。 这通常用于 PolylineCollection#get to iterate over all the polylines 在收藏中.

modelMatrix : Matrix4

4x4变换矩阵,将本集合中的每个聚线从模型变为世界坐标. 当这是身份矩阵时, 聚线被绘制在世界坐标中, . i.e−., 地球的 WGS84−坐标. 本地参考框架可以通过提供不同的变换矩阵来使用, 如返回的变换矩阵 by Transforms.eastNorthUpToFixedFrame.
Default Value: Matrix4.IDENTITY

show : boolean

确定是否显示此收藏中的多线 .
Default Value: true

Methods

add(options)Polyline

在收藏中创建和添加带有指定初始属性的多线. 添加的多线被返回,以便日后可以修改或从收藏中移除.
Performance:

After calling add, PolylineCollection#update is called and 收藏的顶点缓冲器被重写 - 一个 O(n) 操作,它也导致 CPU 到 GPU % 管理. 对于最佳性能,在拨打 NT 0 update NT 1 前,请加入尽可能多的多线.

Name Type Description
options object optional A template describing the polyline's properties as shown in Example 1.
Returns:
收藏中加入的多线.
Throws:
  • DeveloperError : This object was destroyed, i.e., destroy() was called.
Example:
// Example 1:  Add a polyline, specifying all the default values.
const 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:

contains(polyline)boolean

确定此收藏是否包含指定的多线 .
Name Type Description
polyline Polyline 要检查的多线.
Returns:
如果此收藏包含多线, 则不正确 .
See:

destroy()

Destroys the WebGL resources held by this object. Destroying an object allows for deterministic 释放 WebGL 资源,而不是依赖垃圾收集器来摧毁此对象.

Once an object is destroyed, it should not be used; calling any function other than isDestroyed will result in a DeveloperError exception. Therefore, assign the return value (undefined) to the object as done in the example.
Throws:
  • DeveloperError : This object was destroyed, i.e., destroy() was called.
Example:
polylines = polylines && polylines.destroy();
See:

get(index)Polyline

在指定的索引中返回收藏中的多线。 指数为零 并随着多线的增加而增加。 删除多线在之后所有多线 在左边,改变他们的指数。 此函数通常用于 PolylineCollection#length to iterate over all the polylines 在收藏中.
Performance:

If polylines were removed from the collection and PolylineCollection#update was not called, an implicit O(n) 操作完成.

Name Type Description
index number 多线的零基指数.
Returns:
指定指数下的多线 .
Throws:
  • DeveloperError : This object was destroyed, i.e., destroy() was called.
Example:
// Toggle the show property of every polyline in the collection
const len = polylines.length;
for (let i = 0; i < len; ++i) {
  const p = polylines.get(i);
  p.show = !p.show;
}
See:

isDestroyed()boolean

如果此对象被销毁, 返回真实; 否则, 错误 .

If this object was destroyed, it should not be used; calling any function other than isDestroyed will result in a DeveloperError exception.
Returns:
true if this object was destroyed; otherwise, false.
See:

remove(polyline)boolean

从收藏中删除多线.
Performance:

After calling remove, PolylineCollection#update is called and 收藏的顶点缓冲器被重写 - 一个 O(n) 操作,它也导致 CPU 到 GPU % 管理. 为了达到最佳性能,请在拨打 NT 0 update NT 1 前,尽可能删除多条多线. 如果你打算暂时隐藏一条多线,通常更高效的呼叫 Polyline#show 而不是去除和重新添加多线.

Name Type Description
polyline Polyline 要删除的多线.
Returns:
true if the polyline was removed; false if the polyline was not found in the collection.
Throws:
  • DeveloperError : This object was destroyed, i.e., destroy() was called.
Example:
const p = polylines.add(...);
polylines.remove(p);  // Returns true
See:

removeAll()

从收藏中删除所有多行.
Performance:

O(n). It is more efficient to remove all the polylines 从收藏开始,然后添加新收藏,而不是完全创建新收藏.

Throws:
  • DeveloperError : This object was destroyed, i.e., destroy() was called.
Example:
polylines.add(...);
polylines.add(...);
polylines.removeAll();
See:

update()

Called when Viewer or CesiumWidget render the scene to 获得使这个原始化所需的绘图命令.

不要直接调用此函数 。 记录下来的只是 列出场景拍摄时可能宣传的例外情况:

Throws:
  • RuntimeError : Vertex texture fetch support is required to render primitives with per-instance attributes. The maximum number of vertex texture image units must be greater than zero.
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.