Appearance
KBE3D / KBCore / Cesium / PolylineCollection
类: PolylineCollection
A renderable collection of polylines. <br /><br /> <div align="center"> <img src="/Images/Polyline.png" width="400" height="300" /><br /> Example polylines </div> <br /><br /> Polylines are added and removed from the collection using PolylineCollection#add and PolylineCollection#remove.
示例
ts
// 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
});参数
Object with the following properties:
参数
The 4x4 transformation matrix that transforms each polyline from model to world coordinates.
参数
For debugging only. Determines if this primitive's commands' bounding spheres are shown.
参数
Determines if the polylines in the collection will be shown.
属性
show
show:
boolean
Determines if polylines in this collection will be shown.
modelMatrix
modelMatrix:
Matrix4
The 4x4 transformation matrix that transforms each polyline in this collection from model to world coordinates. When this is the identity matrix, the polylines are drawn in world coordinates, i.e., Earth's WGS84 coordinates. Local reference frames can be used by providing a different transformation matrix, like that returned by Transforms.eastNorthUpToFixedFrame.
debugShowBoundingVolume
debugShowBoundingVolume:
boolean
This property is for debugging only; it is not for production use nor is it optimized. <p> Draws the bounding sphere for each draw command in the primitive. </p>
length
length:
number
Returns the number of polylines in this collection. This is commonly used with PolylineCollection#get to iterate over all the polylines in the collection.
方法
add()
add(
options?:any):Polyline
Creates and adds a polyline with the specified initial properties to the collection. The added polyline is returned so it can be modified or removed from the collection later.
参数
options?
any
A template describing the polyline's properties as shown in Example 1.
返回
The polyline that was added to the collection.
示例
ts
// 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
});remove()
remove(
polyline:Polyline):boolean
Removes a polyline from the collection.
参数
polyline
The polyline to remove.
返回
boolean
true if the polyline was removed; false if the polyline was not found in the collection.
示例
ts
const p = polylines.add(...);
polylines.remove(p); // Returns trueremoveAll()
removeAll():
void
Removes all polylines from the collection.
返回
void
示例
ts
polylines.add(...);
polylines.add(...);
polylines.removeAll();contains()
contains(
polyline:Polyline):boolean
Determines if this collection contains the specified polyline.
参数
polyline
The polyline to check for.
返回
boolean
true if this collection contains the polyline, false otherwise.
get()
get(
index:number):Polyline
Returns the polyline in the collection at the specified index. Indices are zero-based and increase as polylines are added. Removing a polyline shifts all polylines after it to the left, changing their indices. This function is commonly used with PolylineCollection#length to iterate over all the polylines in the collection.
参数
index
number
The zero-based index of the polyline.
返回
The polyline at the specified index.
示例
ts
// 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;
}update()
update():
void
Called when Viewer or CesiumWidget render the scene to get the draw commands needed to render this primitive. <p> Do not call this function directly. This is documented just to list the exceptions that may be propagated when the scene is rendered: </p>
返回
void
isDestroyed()
isDestroyed():
boolean
Returns true if this object was destroyed; otherwise, false. <br /><br /> If this object was destroyed, it should not be used; calling any function other than <code>isDestroyed</code> will result in a DeveloperError exception.
返回
boolean
true if this object was destroyed; otherwise, false.
destroy()
destroy():
void
Destroys the WebGL resources held by this object. Destroying an object allows for deterministic release of WebGL resources, instead of relying on the garbage collector to destroy this object. <br /><br /> Once an object is destroyed, it should not be used; calling any function other than <code>isDestroyed</code> will result in a DeveloperError exception. Therefore, assign the return value (<code>undefined</code>) to the object as done in the example.
返回
void
示例
ts
polylines = polylines && polylines.destroy();构造函数
构造函数
new PolylineCollection(
options?: {modelMatrix?:Matrix4;debugShowBoundingVolume?:boolean;show?:boolean; }):PolylineCollection
参数
options?
modelMatrix?
debugShowBoundingVolume?
boolean
show?
boolean
返回
PolylineCollection
