ClippingPlaneCollection

new Cesium.ClippingPlaneCollection(options)

指定一组裁剪平面。裁剪平面选择性地禁用对单个gltf模型、3D Tileset或地球的外部区域的渲染。

通常情况下,裁剪平面的坐标是相对于它们所附加的对象的,因此距离设置为0的平面将裁剪穿过对象的中心。

对于3D Tiles,使用根瓦片的变换来定位裁剪平面。如果未定义变换,则使用根瓦片的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:
  • DeveloperError : 此对象已被销毁,即destroy()已被调用。
Example:
clippingPlanes = clippingPlanes && clippingPlanes.destroy();
See:
返回集合中指定索引处的平面。索引从零开始,随着平面的添加而增加。移除平面会将该平面之后的所有平面向左移动,改变它们的索引。此函数通常与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渲染场景时调用,以构建裁剪平面的资源。

不要直接调用此函数。

需要帮助?获得答案的最快方法是来自社区和团队 Cesium Forum.