ClippingPlaneCollection

new Cesium.ClippingPlaneCollection(options)

指定一组剪切平面。剪切平面选择性地禁用 超出单个 gltf 模型、3D 瓦片集或地球的指定 ClippingPlane 对象列表。

通常,裁剪平面的坐标是相对于它们所附加到的对象而言的,因此距离设置为 0 的平面将进行裁剪 通过对象的中心。

对于 3D 瓦片,根瓦片的变换用于定位剪切平面。如果未定义变换,则改用根图块的 Cesium3DTile#boundingSphere

Name Type Description
options object optional 对象,具有以下属性:
Name Type Default Description
planes Array.<ClippingPlane> [] optional 一个 ClippingPlane 对象的数组,用于选择性地禁用每个平面外部的渲染。
enabled boolean true optional 确定剪切平面是否处于活动状态。
modelMatrix Matrix4 Matrix4.IDENTITY optional 4x4 变换矩阵,指定相对于剪切平面原始坐标系的附加变换。
unionClippingRegions boolean false optional 如果为 true,则如果某个区域位于集合中任何平面的外部,则该区域将被剪切。否则,只有当一个区域位于每个平面的外部时,它才会被剪切。
edgeColor Color Color.WHITE optional 用于高亮显示对象剪切沿的边缘的颜色。
edgeWidth number 0.0 optional 应用于剪切对象所沿的边缘的高光的宽度(以像素为单位)。
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.
const clippingPlanes = new Cesium.ClippingPlaneCollection({
    planes : [
        new Cesium.ClippingPlane(new Cesium.Cartesian3(0.0, 1.0, 0.0), 5.0)
    ],
});
// Create an entity and attach the ClippingPlaneCollection to the model.
const entity = viewer.entities.add({
    position : Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706, 10000),
    model : {
        uri : 'model.gltf',
        minimumPixelSize : 128,
        maximumScale : 20000,
        clippingPlanes : clippingPlanes
    }
});
viewer.zoomTo(entity);
Demo:

Members

用于高亮显示剪切对象时所沿的边缘的颜色。
Default Value: Color.WHITE
应用于剪切对象所沿的边缘的高光的宽度(以像素为单位)。
Default Value: 0.0
如果为 true,则将启用剪辑。
Default Value: true
返回此集合中的平面数。 这通常与 ClippingPlaneCollection#get 遍历所有平面 在集合中。
指定相对于剪切平面的其他转换的 4x4 转换矩阵 原始坐标系。
Default Value: Matrix4.IDENTITY
将新的剪切平面添加到集合时触发的事件。 事件处理程序 将传递新平面和添加它的索引。
Default Value: Event()
从集合中删除新的剪切平面时触发的事件。 事件处理程序 将传递新平面和从中删除它的索引。
Default Value: Event()
如果为 true,则如果区域位于 收集。否则,只有当区域位于 在每个平面之外。
Default Value: false

Methods

将指定的 ClippingPlane 添加到集合中,以用于选择性地禁用渲染 在每个平面的外侧。使用 ClippingPlaneCollection#unionClippingRegions 修改 如何修改多个基准面的裁剪行为。
Name Type Description
plane ClippingPlane 要添加到集合的 ClippingPlane。
See:

contains(clippingPlane)boolean

检查此集合是否包含等于给定 ClippingPlane 的 ClippingPlane。
Name Type Description
clippingPlane ClippingPlane optional 要检查的 ClippingPlane。
Returns:
如果此集合包含 ClippingPlane,则 true, 否则为 false。
See:
销毁此对象持有的 WebGL 资源。 销毁对象允许确定性 释放 WebGL 资源,而不是依赖垃圾回收器来销毁这个对象。

一旦对象被销毁,就不应该使用它;调用 isDestroyed 将导致 DeveloperError 异常。 因此 将返回值 (undefined) 分配给对象,如示例中所示。
Throws:
Example:
clippingPlanes = clippingPlanes && clippingPlanes.destroy();
See:
返回集合中指定索引处的平面。 索引从 0 开始 并随着平面的添加而增加。 移除基准面时,所有基准面都会移动 它向左移动,更改其索引。 此功能通常用于 ClippingPlaneCollection#length 迭代所有平面 在集合中。
Name Type Description
index number 平面的从零开始的索引。
Returns:
指定索引处的 ClippingPlane。
See:
如果此对象已销毁,则返回 true;否则为 false。

如果此对象已销毁,则不应使用;调用 * isDestroyed 将导致 DeveloperError 异常。
Returns:
true,如果此对象被销毁;否则为 false
See:

remove(clippingPlane)boolean

从集合中删除给定 ClippingPlane 的第一个匹配项。
Name Type Description
clippingPlane ClippingPlane
Returns:
如果飞机被移除,则为 true;如果在集合中找不到该平面,则为 false
See:
从集合中删除所有平面。
See:
ViewerCesiumWidget 将场景渲染到 构建用于剪切平面的资源。

请勿直接调用此函数。

Need help? The fastest way to get answers is from the community and team on the Cesium Forum.