指定一組剪切平面。剪切平面有選擇地禁用單個(gè)GLTF模型、3D Tileset或球體的指定
new ClippingPlaneCollection(options)
ClippingPlane
對(duì)象列表外部區(qū)域的渲染。通常,裁剪平面的坐標(biāo)是相對(duì)于它們所附著的對(duì)象的,因此距離設(shè)置為0的平面將裁剪通過(guò)對(duì)象的中心。
對(duì)于3D瓦片,根瓦片的變換用于定位剪切平面。如果未定義轉(zhuǎn)換,則使用根瓦片的BM3DTile#boundingSphere
。
Parameters:
options
(Object)
Name | Description |
---|---|
options.planes
Array.<ClippingPlane>
default []
|
ClippingPlane 對(duì)象數(shù)組,用于選擇性地禁用每個(gè)平面外部的渲染。
|
options.enabled
Boolean
default true
|
確定剪切平面是否處于活動(dòng)狀態(tài)。 |
options.modelMatrix
Matrix4
default Matrix4.IDENTITY
|
4x4變換矩陣,指定相對(duì)于裁剪平面原始坐標(biāo)系的附加變換。 |
options.unionClippingRegions
Boolean
default false
|
如果為true,則如果區(qū)域位于集合中任何平面的外部,則該區(qū)域?qū)⒈患舨谩7駝t,僅當(dāng)區(qū)域位于每個(gè)平面的外部時(shí),區(qū)域才會(huì)被剪裁。 |
options.edgeColor
Color
default Color.WHITE
|
用于突出顯示對(duì)象沿其裁剪的邊的顏色。 |
options.edgeWidth
Number
default 0.0
|
應(yīng)用于對(duì)象剪切邊緣的高光的寬度(以像素為單位)。 |
Example
// This clipping plane's distance is positive, which means its normal
// is facing the origin. This will clip everything that is behind
// the plane, which is anything with y coordinate < -5.
var clippingPlanes = new bmgl.ClippingPlaneCollection({
planes : [
new bmgl.ClippingPlane(new bmgl.Cartesian3(0.0, 1.0, 0.0), 5.0)
],
});
// Create an entity and attach the ClippingPlaneCollection to the model.
var entity = viewer.entities.add({
position : bmgl.Cartesian3.fromDegrees(-123.0744619, 44.0503706, 10000),
model : {
uri : 'model.gltf',
minimumPixelSize : 128,
maximumScale : 20000,
clippingPlanes : clippingPlanes
}
});
viewer.zoomTo(entity);
Members
edgeColor : Color
用于突出顯示對(duì)象沿其裁剪的邊的顏色。
-
Default Value:
Color.WHITE
edgeWidth : Number
應(yīng)用于對(duì)象剪切邊緣的高光的寬度(以像素為單位)。
-
Default Value:
0.0
enabled : Boolean
如果為真,將啟用剪輯。
-
Default Value:
true
(readonly) length : Number
返回此集合中的平面數(shù)。這通常與
ClippingPlaneCollection#get
一起用于迭代集合中的所有平面。
modelMatrix : Matrix4
4x4變換矩陣,指定相對(duì)于裁剪平面原始坐標(biāo)系的附加變換。
-
Default Value:
Matrix4.IDENTITY
planeAdded : Event
將新剪切平面添加到集合時(shí)觸發(fā)的事件。事件處理程序?qū)鬟f新平面及其添加索引。
-
Default Value:
Event()
planeRemoved : Event
從集合中刪除新剪切平面時(shí)觸發(fā)的事件。事件處理程序?qū)鬟f新平面及其從中移除的索引。
-
Default Value:
Event()
unionClippingRegions : Boolean
如果為true,則如果區(qū)域位于集合中任何平面的外部,則該區(qū)域?qū)⒈患舨谩7駝t,僅當(dāng)區(qū)域位于每個(gè)平面的外部時(shí),區(qū)域才會(huì)被剪裁。
-
Default Value:
false
Methods
add(plane)
將指定的
ClippingPlane
添加到集合中,用于選擇性地禁用每個(gè)平面外部的渲染。使用ClippingPlaneCollection#unionClippingRegions
修改如何修改多個(gè)平面的剪切行為。
Parameters:
See:
檢查此集合是否包含與給定clippingplane相等的clippingplane。
Parameters:
銷毀此對(duì)象持有的WebGL資源。銷毀對(duì)象允許確定地釋放WebGL資源,而不是依賴?yán)占鱽?lái)銷毀此對(duì)象。
一旦對(duì)象被破壞,就不應(yīng)使用它;調(diào)用除
一旦對(duì)象被破壞,就不應(yīng)使用它;調(diào)用除
isDestroyed
以外的任何函數(shù)都將導(dǎo)致DeveloperError
異常。因此,將返回值(undefined
)賦給對(duì)象,如示例中所述。
Throws
-
DeveloperError : 此對(duì)象已被銷毀,即調(diào)用destroy()。
返回集合中指定索引處的平面。索引以零為基礎(chǔ),并隨著平面的添加而增加。刪除一個(gè)平面后,所有平面都會(huì)向左移動(dòng),從而更改其索引。此函數(shù)通常與
ClippingPlaneCollection#length
一起用于迭代集合中的所有平面。
Parameters:
index
(Number)
平面的零基索引。
如果此對(duì)象被破壞,則返回true;否則返回false。
如果此對(duì)象被破壞,則不應(yīng)使用它;調(diào)用除
remove(clippingPlane) → {Boolean}
如果此對(duì)象被破壞,則不應(yīng)使用它;調(diào)用除
isDestroyed
以外的任何函數(shù)將導(dǎo)致DeveloperError
異常。
從集合中移除給定clippingplane的第一個(gè)匹配項(xiàng)。
Parameters:
clippingPlane
(ClippingPlane)
從集合中刪除所有平面。
update()
當(dāng)渲染場(chǎng)景以生成裁剪平面的資源時(shí)調(diào)用。
不要直接調(diào)用此函數(shù)。