Class: PolylineCollection

PolylineCollection

new PolylineCollection()

可渲染的多段线集合。


Example polylines


使用PolylineCollection#addPolylineCollection#remove从集合中添加和删除折线。
Performance:

为获得最佳性能,最好选择几个集合,每个集合都有许多折线,而不是多个集合,每个集合只有几条折线。组织集合,使更新频率相同的折线在同一个集合中,即不变的折线应该在一个集合中;改变每一帧的折线应该在另一个集合中;等等。

Name Type Default Description
options.modelMatrix Matrix4 Matrix4.IDENTITY 可选

将每条折线从模型坐标转换为地理坐标的 4x4 转换矩阵。

options.debugShowBoundingVolume Boolean false 可选

仅用于调试。确定是否显示此原语的命令的包围球。

See:
Example
// Create a polyline collection with two polylines
var polylines = new SuperMap3D.PolylineCollection();
polylines.add({
  positions : SuperMap3D.Cartesian3.fromDegreesArray([
    -75.10, 39.57,
    -77.02, 38.53,
    -80.50, 35.14,
    -80.12, 25.46]),
  width : 2
});

polylines.add({
  positions : SuperMap3D.Cartesian3.fromDegreesArray([
    -73.10, 37.57,
    -75.02, 36.53,
    -78.50, 33.14,
    -78.12, 23.46]),
  width : 4
});

Members

_polygonEntityId

矢量面内添矢量线

debugShowBoundingVolumeBoolean

此属性仅用于调试;它不是用于生产的,也没有经过优化。

为基元中的每个绘制命令绘制包围球。

Default Value:
false

lengthNumber

返回此集合中多段线的数量。通常与 PolylineCollection#get 一起使用,以遍历集合中的所有多段线。

modelMatrixMatrix4

将此集合中的每个折线从模型坐标转换为地理坐标的4x4变换矩阵。当这是单位矩阵时,折线以地理坐标绘制,即WGS84坐标。本地参考帧可以通过提供不同的转换矩阵来使用,就像Transforms.eastNorthUpToFixedFrame返回的那样。

Default Value:
Matrix4.IDENTITY

Methods

add(polyline){Polyline}

创建并向集合中添加具有指定初始属性的多段线。添加的多段线将被返回,以便以后修改或从集合中删除。

Performance:

调用add后,调用PolylineCollection#update和集合的顶点buffer被重写——一个 0 (n)操作,也会导致CPU到GPU的开销。为了获得最佳性能,在调用update之前添加尽可能多的折线。

Name Type Description
polyline Object 可选

描述多段线属性的模板,如例 1 所示。

See:
Throws:

该对象被销毁,即调用destroy()。

Type
DeveloperError
Returns:
Type Description
Polyline 添加到集合中的多段线。
Example
// Example 1:  Add a polyline, specifying all the default values.
var p = polylines.add({
  show : true,
  positions : ellipsoid.cartographicArrayToCartesianArray([
     SuperMap3D.Cartographic.fromDegrees(-75.10, 39.57),
    SuperMap3D.Cartographic.fromDegrees(-77.02, 38.53)]),
  width : 1
});

contains(polyline){Boolean}

确定此集合是否包含指定折线。

Name Type Description
polyline Polyline

要检查的折线。

See:
Returns:
Type Description
Boolean 如果此集合包含折线,则为True,否则为false。

destroy(){undefined}

销毁该对象持有的 WebGL 资源。 销毁对象可以确定性地释放 WebGL 资源,而不是依赖垃圾回收器来销毁该对象。

一旦对象被销毁,就不得再使用;调用 isDestroyed 以外的任何函数都将导致 DeveloperError 异常。 因此,请按照示例中的方法将返回值(undefined)赋值给对象。

See:
Throws:

该对象已被销毁,即 destroy() 被调用。

Type
DeveloperError
Returns:
Type Description
undefined
Example
polylines = polylines && polylines.destroy();

get(index){Polyline}

返回集合中位于指定索引处的折线。指数从零开始随着折线的增加而增加。 移除一条折线会移动之后的所有折线它移到左侧,改变它们的下标。此函数通常与PolylineCollection#length一起使用,用于迭代集合中的所有折线。

Performance:

如果从集合中删除了折线,并且没有调用PolylineCollection#update,则执行隐式O(n)操作。

Name Type Description
index Number

折线的从零开始的索引。

See:
Throws:

该对象被销毁,即调用destroy()。

Type
DeveloperError
Returns:
Type Description
Polyline 指定索引处的折线。
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;
}

isDestroyed(){Boolean}

如果此对象被销毁则返回true;否则,假的。

如果该对象已被破坏,则不应使用;调用任何函数,除了isDestroyed将导致DeveloperError异常。

See:
Returns:
Type Description
Boolean 如果该对象已被销毁,则为 true;否则为 false

remove(polyline){Boolean}

从集合中删除折线。

Performance:

调用remove后,调用PolylineCollection#update和集合的顶点buffer被重写——一个 0 (n)操作,也会导致CPU到GPU的开销。为了获得最佳性能,在调用update之前删除尽可能多的折线。如果你想暂时隐藏一条折线,调用#show通常比删除并重新添加折线更有效。

Name Type Description
polyline Polyline

要去除的折线。

See:
Throws:

该对象被销毁,即调用destroy()。

Type
DeveloperError
Returns:
Type Description
Boolean 如果折线被移除,则为True;如果在集合中未找到折线,则为False。
Example
var p = polylines.add(...);
polylines.remove(p);  // Returns true

removeAll()

从集合中移除所有折线。

Performance:

O(n)从集合中删除所有折线,然后添加新的折线比完全创建一个新集合更有效。

See:
Throws:

该对象被销毁,即调用destroy()。

Type
DeveloperError
Example
polylines.add(...);
polylines.add(...);
polylines.removeAll();

update()

ViewerWidget渲染场景时调用,以获取渲染此原语所需的绘制命令。

不要直接调用这个函数。这只是为了列出场景渲染时可能传播的异常:

Throws:

渲染具有实例属性的原语需要顶点纹理获取支持。顶点纹理影像单元的最大数量必须大于零。

Type
RuntimeError