English中文

ClippingPlaneCollection

new Cesium.ClippingPlaneCollection(options)

指定一组剪切平面。剪切平面有选择地禁用指定列表外部区域的渲染 Specifies a set of clipping planes. Clipping planes selectively disable rendering in a region on the outside of the specified list of ClippingPlane 单个 gltf 模型、3D Tileset 或地球的对象。 objects for a single gltf model, 3D Tileset, or the globe.

一般来说,剪裁平面的坐标是相对于它们所附着的对象的,因此距离设置为 0 的平面将剪裁穿过对象的中心。 In general the clipping planes' coordinates are relative to the object they're attached to, so a plane with distance set to 0 will clip through the center of the object.

对于 3D 图块,根图块的变换用于定位剪切平面。如果未定义变换,则根图块的 For 3D Tiles, the root tile's transform is used to position the clipping planes. If a transform is not defined, the root tile's Cesium3DTile#boundingSphere 被用来代替。 is used instead.

名称 Name 类型 Type 说明 Description
options object 可选 optional 具有以下属性的对象: Object with the following properties:
名称 Name 类型 Type 默认值 Default 说明 Description
planes Array.<ClippingPlane> [] 可选 optional 一个数组 An array of ClippingPlane 用于有选择地禁用每个平面外部渲染的对象。 objects used to selectively disable rendering on the outside of each plane.
enabled boolean true 可选 optional 确定剪裁平面是否处于活动状态。 Determines whether the clipping planes are active.
modelMatrix Matrix4 Matrix4.IDENTITY 可选 optional 4x4 变换矩阵指定相对于裁剪平面原始坐标系的附加变换。 The 4x4 transformation matrix specifying an additional transform relative to the clipping planes original coordinate system.
unionClippingRegions boolean false 可选 optional 如果为 true,则如果某个区域位于集合中任何平面的外部,则该区域将被剪裁。否则,只有位于每个平面外部的区域才会被剪裁。 If true, a region will be clipped if it is on the outside of any plane in the collection. Otherwise, a region will only be clipped if it is on the outside of every plane.
edgeColor Color Color.WHITE 可选 optional 用于突出显示对象被剪切的边缘的颜色。 The color applied to highlight the edge along which an object is clipped.
edgeWidth number 0.0 可选 optional 应用于剪切对象的边缘的突出显示的宽度(以像素为单位)。 The width, in pixels, of the highlight applied to the edge along which an object is clipped.
示例: 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

用于突出显示对象被剪切的边缘的颜色。 The color applied to highlight the edge along which an object is clipped.
默认值: Default Value: Color.WHITE
应用于剪切对象的边缘的突出显示的宽度(以像素为单位)。 The width, in pixels, of the highlight applied to the edge along which an object is clipped.
默认值: Default Value: 0.0
如果为 true,将启用剪辑。 If true, clipping will be enabled.
默认值: Default Value: true
返回此集合中的平面数。这通常与 Returns the number of planes in this collection. This is commonly used with ClippingPlaneCollection#get 迭代集合中的所有飞机。 to iterate over all the planes in the collection.
4x4 变换矩阵指定相对于裁剪平面原始坐标系的附加变换。 The 4x4 transformation matrix specifying an additional transform relative to the clipping planes original coordinate system.
默认值: Default Value: Matrix4.IDENTITY
将新的剪切平面添加到集合时触发的事件。事件处理程序将传递新平面和添加它的索引。 An event triggered when a new clipping plane is added to the collection. Event handlers are passed the new plane and the index at which it was added.
从集合中删除新的剪切平面时触发的事件。事件处理程序将传递新平面和从中删除它的索引。 An event triggered when a new clipping plane is removed from the collection. Event handlers are passed the new plane and the index from which it was removed.
如果为 true,则如果某个区域位于集合中任何平面的外部,则该区域将被剪裁。否则,只有位于每个平面外部的区域才会被剪裁。 If true, a region will be clipped if it is on the outside of any plane in the collection. Otherwise, a region will only be clipped if it is on the outside of every plane.
默认值: Default Value: false

方法 Methods

添加指定的 Adds the specified ClippingPlane 到用于有选择地禁用每个平面外部渲染的集合。使用 to the collection to be used to selectively disable rendering on the outside of each plane. Use ClippingPlaneCollection#unionClippingRegions 修改如何修改多个平面的裁剪行为。 to modify how modify the clipping behavior of multiple planes.
名称 Name 类型 Type 说明 Description
plane ClippingPlane 要添加到集合中的 ClippingPlane。 The ClippingPlane to add to the collection.
另见: See:

contains(clippingPlane)boolean

检查此集合是否包含等于给定 ClippingPlane 的 ClippingPlane。 Checks whether this collection contains a ClippingPlane equal to the given ClippingPlane.
名称 Name 类型 Type 说明 Description
clippingPlane ClippingPlane 可选 optional 要检查的 ClippingPlane。 The ClippingPlane to check for.
返回: Returns:
如果此集合包含 ClippingPlane,则为 true,否则为 false。 true if this collection contains the ClippingPlane, false otherwise.
另见: See:
销毁该对象持有的 WebGL 资源。销毁对象可以确定性地释放 WebGL 资源,而不是依赖垃圾收集器来销毁该对象。 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.

一旦对象被销毁,就不应再使用;调用除 Once an object is destroyed, it should not be used; calling any function other than isDestroyed 将导致 will result in a DeveloperError 例外。因此,分配返回值( exception. Therefore, assign the return value (undefined) 到对象,如示例中所做的那样。 ) to the object as done in the example.
抛出: Throws:
  • DeveloperError : This object was destroyed, i.e., destroy() was called.
示例: Example:
clippingPlanes = clippingPlanes && clippingPlanes.destroy();
另见: See:
返回集合中指定索引处的平面。索引从零开始,并随着飞机的添加而增加。删除一个平面会将其后面的所有平面向左移动,从而改变它们的索引。此功能通常与 Returns the plane in the collection at the specified index. Indices are zero-based and increase as planes are added. Removing a plane shifts all planes after it to the left, changing their indices. This function is commonly used with ClippingPlaneCollection#length 迭代集合中的所有飞机。 to iterate over all the planes in the collection.
名称 Name 类型 Type 说明 Description
index number 平面的从零开始的索引。 The zero-based index of the plane.
返回: Returns:
指定索引处的 ClippingPlane。 The ClippingPlane at the specified index.
另见: See:
如果该对象被销毁则返回 true;否则为假。 Returns true if this object was destroyed; otherwise, false.

如果该对象被破坏,则不应使用它;调用除 If this object was destroyed, it should not be used; calling any function other than isDestroyed 将导致 will result in a DeveloperError exception.
返回: Returns:
true 如果该物体被摧毁;否则, if this object was destroyed; otherwise, false.
另见: See:

remove(clippingPlane)boolean

从集合中删除第一次出现的给定 ClippingPlane。 Removes the first occurrence of the given ClippingPlane from the collection.
名称 Name 类型 Type 说明 Description
clippingPlane ClippingPlane
返回: Returns:
true 如果飞机被移除; if the plane was removed; false 如果在集合中没有找到飞机。 if the plane was not found in the collection.
另见: See:
从集合中删除所有飞机。 Removes all planes from the collection.
另见: See:
调用时间 Called when Viewer or CesiumWidget 渲染场景以构建裁剪平面的资源。 render the scene to build the resources for clipping planes.

不要直接调用该函数。 Do not call this function directly.

需要帮助吗?获得答案的最快方法是从社区和团队那里获得答案 Need help? The fastest way to get answers is from the community and team on the Cesium Forum.