--- outline: [2, 3] --- # ClippingManager - 源文件:`packages/sdk/src/manager/ClippingManager.ts` - 文档位置:`packages/docs/api/manager/ClippingManager.md` ## 类:`ClippingManager` - 作用:剖切管理器 管理剖切组和任意数量的剖切面(通过 addPlane 手动创建) ### 构造函数 #### `new ClippingManager(viewer: Viewer)` - 作用:创建 ClippingManager 实例。 - 入参: | 参数名 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | `viewer` | `Viewer` | 是 | 关联的 Viewer 实例。 | - 出参:`ClippingManager` - 返回说明:返回当前类实例。 ### 属性 | 属性名 | 可见性 | 类型 | 作用 | | --- | --- | --- | --- | | `panelCounter` | `public static` | `number` | 用于保存 `panelCounter` 对应的数据。 | | `emitter` | `public` | `Emittery<{ clippingStart: undefined; clippingEnd: undefined; }, { clippingStart: undefined; clippingEnd: undefined; } & OmnipresentEventData, DatalessEventNames<{ clippingStart: undefined; clippingEnd: undefined; }>>` | 用于保存 `emitter` 对应的数据。 | | `isClipping` | `public` | `boolean` | 剖切是否已开始 | | `clippingPlanes` | `public` | `THREE.Plane[]` | 所有注册的剖切平面(THREE.Plane),同步到 clippingGroup | | `clippingPlaneHelpers` | `public` | `THREE.PlaneHelper[]` | 已废弃的辅助对象数组(保留以防外部引用) | | `clippingGroup` | `public` | `THREE.ClippingGroup` | 用于保存 `clippingGroup` 对应的数据。 | | `scene` | `public` | `THREE.Scene` | 用于保存 `scene` 对应的数据。 | | `viewer` | `public` | `Viewer` | 用于保存 `viewer` 对应的数据。 | | `planeHelperGroup` | `public` | `THREE.Group` | 平面辅助对象组 | ### 方法 #### `addDefaultPlanes(): [ClippingPlane, ClippingPlane, ClippingPlane]` - 作用:创建默认的 X / Y / Z 三个剖切面 - 入参:无 - 出参:`[ClippingPlane, ClippingPlane, ClippingPlane]` - 返回说明:[planeX, planeY, planeZ] #### `addPlane(id: string, options: IClippingPlaneOptions): ClippingPlane` - 作用:创建并注册一个剖切面 - 入参: | 参数名 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | `id` | `string` | 是 | 唯一标识 | | `options` | `IClippingPlaneOptions` | 是 | 剖切面配置 | - 出参:`ClippingPlane` - 返回说明:返回 `ClippingPlane`。 #### `removePlane(id: string): void` - 作用:移除剖切面 - 入参: | 参数名 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | `id` | `string` | 是 | 参数 `id`,类型为 `string`。 | - 出参:`void` - 返回说明:无返回值。 #### `getPlane(id: string): ClippingPlane | undefined` - 作用:获取剖切面 - 入参: | 参数名 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | `id` | `string` | 是 | 参数 `id`,类型为 `string`。 | - 出参:`ClippingPlane \| undefined` - 返回说明:返回 `ClippingPlane | undefined`。 #### `autoPlanePosition(offset: number = 2): void` - 作用:根据剖切组包围盒自动定位 X/Y/Z 三个剖切面 必须先调用 addDefaultPlanes() 注册剖切面 - 入参: | 参数名 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | `offset` | `number` | 否 | 从包围盒 min 边的偏移量 | - 出参:`void` - 返回说明:无返回值。 #### `addClippingObjectsByUuid(uuids: Array): void` - 作用:─── 剖切组对象管理(保持不变)──────────────────────────────────────── - 入参: | 参数名 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | `uuids` | `Array` | 是 | 参数 `uuids`,类型为 `Array`。 | - 出参:`void` - 返回说明:无返回值。 #### `addClippingObjects(objects: Array): void` - 作用:添加 Clipping Objects。 - 入参: | 参数名 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | `objects` | `Array` | 是 | 目标对象集合。 | - 出参:`void` - 返回说明:无返回值。 #### `addClippingToObject(object: THREE.Object3D): void` - 作用:添加 Clipping To Object。 - 入参: | 参数名 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | `object` | `THREE.Object3D` | 是 | 目标对象。 | - 出参:`void` - 返回说明:无返回值。 #### `removeClippingObjectsByUuid(uuids: Array): void` - 作用:移除 Clipping Objects By Uuid。 - 入参: | 参数名 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | `uuids` | `Array` | 是 | 参数 `uuids`,类型为 `Array`。 | - 出参:`void` - 返回说明:无返回值。 #### `clearClippingGroups(): void` - 作用:清理 Clipping Groups。 - 入参:无 - 出参:`void` - 返回说明:无返回值。 #### `clearClippingPlanes(): void` - 作用:清理 Clipping Planes。 - 入参:无 - 出参:`void` - 返回说明:无返回值。 #### `hideClippingPlanes(): void` - 作用:执行 hide Clipping Planes 相关逻辑。 - 入参:无 - 出参:`void` - 返回说明:无返回值。 #### `computeBoundingBox(): THREE.Box3` - 作用:执行 compute Bounding Box 相关逻辑。 - 入参:无 - 出参:`THREE.Box3` - 返回说明:返回 `THREE.Box3`。 #### `createDebugPanel(clippingObjects: THREE.Object3D[] = []): void` - 作用:创建调试面板 - 入参: | 参数名 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | `clippingObjects` | `THREE.Object3D[]` | 否 | 参数 `clippingObjects`,类型为 `THREE.Object3D[]`。 | - 出参:`void` - 返回说明:无返回值。 #### `startClipping(): void` - 作用:执行 start Clipping 相关逻辑。 - 入参:无 - 出参:`void` - 返回说明:无返回值。 #### `stopClipping(): void` - 作用:执行 stop Clipping 相关逻辑。 - 入参:无 - 出参:`void` - 返回说明:无返回值。 #### `dispose(): void` - 作用:释放资源并销毁当前实例。 - 入参:无 - 出参:`void` - 返回说明:无返回值。 ## 构造示例 - 当前 Demo 中没有直接展示 `ClippingManager` 的构造调用。 ## 函数示例 - 当前 Demo 中没有直接展示 `ClippingManager` 的公开方法调用。