GroundPolyLinePrimitive表示覆蓋在地形上的多段線或
new GroundPolylinePrimitive(options)
Scene
中的三維瓦片。僅用于包含GroundPolylineGeometry
的幾何狀態(tài)。
Parameters:
options
(Object)
Name | Description |
---|---|
options.geometryInstances
(Array | GeometryInstance)
|
包含GroundPolyLineGeometry的幾何條件 |
options.appearance
Appearance
|
用于渲染多段線的外觀。默認(rèn)為APolylineMaterialAppearance 上的白色Material 。
|
options.show
Boolean
default true
|
確定是否顯示此基元。 |
options.interleave
Boolean
default false
|
當(dāng)true 時(shí),幾何頂點(diǎn)屬性交錯(cuò),這可以稍微提高渲染性能,但增加加載時(shí)間。
|
options.releaseGeometryInstances
Boolean
default true
|
當(dāng)true 時(shí),原語不保留對(duì)輸入geometryInstances 的引用以保存內(nèi)存。
|
options.allowPicking
Boolean
default true
|
當(dāng)true 時(shí),每個(gè)幾何體實(shí)例只能使用Scene#pick 進(jìn)行選擇。當(dāng)false 時(shí),保存GPU內(nèi)存。
|
options.asynchronous
Boolean
default true
|
確定在準(zhǔn)備就緒之前是異步創(chuàng)建基元還是阻止創(chuàng)建基元。如果為false,則必須首先調(diào)用initiaterrainheights()。 |
options.classificationType
ClassificationType
default ClassificationType.BOTH
|
確定地形、三維瓦片還是兩者都要分類。 |
options.debugShowBoundingVolume
Boolean
default false
|
僅用于調(diào)試。確定是否顯示此基元的命令的邊界球。 |
options.debugShowShadowVolume
Boolean
default false
|
僅用于調(diào)試。確定是否繪制基本體中每個(gè)幾何體的陰影體積。必須在創(chuàng)建時(shí)為true 才能生效。
|
Example
// 1. Draw a polyline on terrain with a basic color material
var instance = new bmgl.GeometryInstance({
geometry : new bmgl.GroundPolylineGeometry({
positions : bmgl.Cartesian3.fromDegreesArray([
-112.1340164450331, 36.05494287836128,
-112.08821010582645, 36.097804071380715
]),
width : 4.0
}),
id : 'object returned when this instance is picked and to get/set per-instance attributes'
});
scene.groundPrimitives.add(new bmgl.GroundPolylinePrimitive({
geometryInstances : instance,
appearance : new bmgl.PolylineMaterialAppearance()
}));
// 2. Draw a looped polyline on terrain with per-instance color and a distance display condition.
// Distance display conditions for polylines on terrain are based on an approximate terrain height
// instead of true terrain height.
var instance = new bmgl.GeometryInstance({
geometry : new bmgl.GroundPolylineGeometry({
positions : bmgl.Cartesian3.fromDegreesArray([
-112.1340164450331, 36.05494287836128,
-112.08821010582645, 36.097804071380715,
-112.13296079730024, 36.168769146801104
]),
loop : true,
width : 4.0
}),
attributes : {
color : bmgl.ColorGeometryInstanceAttribute.fromColor(bmgl.Color.fromCssColorString('green').withAlpha(0.7)),
distanceDisplayCondition : new bmgl.DistanceDisplayConditionGeometryInstanceAttribute(1000, 30000)
},
id : 'object returned when this instance is picked and to get/set per-instance attributes'
});
scene.groundPrimitives.add(new bmgl.GroundPolylinePrimitive({
geometryInstances : instance,
appearance : new bmgl.PolylineColorAppearance()
}));
Members
(readonly) allowPicking : Boolean
-
Default Value:
true
appearance : Appearance
Appearance
用于對(duì)該原語進(jìn)行著色。每個(gè)幾何體實(shí)例都以相同的外觀著色。一些外觀,如PolylineColorAppearance
允許為每個(gè)實(shí)例提供唯一的屬性。
-
Default Value:
undefined
(readonly) asynchronous : Boolean
確定是否將在Web工作者上創(chuàng)建和批處理幾何體實(shí)例。
-
Default Value:
true
classificationType : ClassificationType
確定地形、三維瓦片還是兩者都要分類。
-
Default Value:
ClassificationType.BOTH
debugShowBoundingVolume : Boolean
此屬性僅用于調(diào)試;它既不用于生產(chǎn),也不進(jìn)行優(yōu)化。
為基本體中的每個(gè)draw命令繪制邊界球體。
-
Default Value:
false
(readonly) debugShowShadowVolume : Boolean
此屬性僅用于調(diào)試;它既不用于生產(chǎn),也不進(jìn)行優(yōu)化。
如果為真,則為基本體中的每個(gè)幾何體繪制陰影體積。
-
Default Value:
false
(readonly) geometryInstances : (Array|GeometryInstance)
使用此基元渲染的幾何體實(shí)例。在構(gòu)造基元時(shí),如果
options.releaseGeometryInstances
是true
,則可能是undefined
。在呈現(xiàn)基元后更改此屬性沒有效果。
-
Default Value:
undefined
(readonly) interleave : Boolean
確定幾何體頂點(diǎn)屬性是否交錯(cuò),這可以稍微提高渲染性能。
-
Default Value:
false
(readonly) ready : Boolean
確定基元是否已完成并準(zhǔn)備好呈現(xiàn)。如果此屬性為真,則下次調(diào)用
GroundPolylinePrimitive#update
時(shí)將呈現(xiàn)原語。
(readonly) readyPromise : Promise.<GroundPolylinePrimitive>
獲取解決基元何時(shí)準(zhǔn)備呈現(xiàn)的承諾。
(readonly) releaseGeometryInstances : Boolean
當(dāng)
true
時(shí),原語不保留對(duì)輸入geometryInstances
的引用以保存內(nèi)存。
-
Default Value:
true
show : Boolean
確定是否顯示基元。這會(huì)影響基本體中的所有幾何體實(shí)例。
-
Default Value:
true
Methods
(static) initializeTerrainHeights() → {Promise}
初始化最小和最大地形高度。只有在同步創(chuàng)建groundPolyLinePrimitive時(shí)才需要調(diào)用此函數(shù)。
檢查給定的場景是否支持groundPolyLinePrimitive。GroundPolyLinePrimitives需要支持WebGL“深度”紋理擴(kuò)展。
Parameters:
銷毀此對(duì)象持有的WebGL資源。銷毀對(duì)象允許確定地釋放WebGL資源,而不是依賴?yán)占鱽礓N毀此對(duì)象。
一旦對(duì)象被破壞,就不應(yīng)使用它;調(diào)用除isDestroyed
以外的任何函數(shù)都將導(dǎo)致DeveloperError
異常。因此,將返回值(undefined
)賦給對(duì)象,如示例中所述。
Throws
-
DeveloperError : 此對(duì)象已被銷毀,即調(diào)用destroy()。
返回
GeometryInstance
的每個(gè)實(shí)例可修改屬性。
Parameters:
Example
var attributes = primitive.getGeometryInstanceAttributes('an id');
attributes.color = bmgl.ColorGeometryInstanceAttribute.toValue(bmgl.Color.AQUA);
attributes.show = bmgl.ShowGeometryInstanceAttribute.toValue(true);
Throws
-
DeveloperError : 必須在調(diào)用GetGeometryInstanceAttributes之前調(diào)用Update。
如果此對(duì)象被破壞,則返回true;否則返回false。
update()
如果此對(duì)象被破壞,則不應(yīng)使用它;調(diào)用除isDestroyed
以外的任何函數(shù)都將導(dǎo)致DeveloperError
異常。
當(dāng)
Viewer
或BMWidget
渲染場景以獲取渲染此原語所需的繪制命令時(shí)調(diào)用。不要直接調(diào)用此函數(shù)。這只是為了列出渲染場景時(shí)可能傳播的異常:
Throws
-
DeveloperError : 對(duì)于同步groundPolyLinePrimitives,必須調(diào)用groundPolyLinePrimitives.InitializerRainHeights(),然后等待返回的Promise解析。
-
DeveloperError : 所有幾何實(shí)例都必須具有顏色屬性才能將PolyLineColorAppearance與GroundPolyLinePrimitive一起使用。