diff --git a/src/components/engine/index.ts b/src/components/engine/index.ts index 6bdbb49..ec7dda7 100644 --- a/src/components/engine/index.ts +++ b/src/components/engine/index.ts @@ -521,6 +521,51 @@ export class Engine implements IBimComponent { this.currentSectionMode = null; } + /** + * 隐藏剖切面(临时隐藏,可恢复) + * @remarks + * - 隐藏当前剖切面,但不停用剖切功能 + * - 配合 recoverSection() 使用 + * - 底层调用 engine.clipping.disabled() + * @example + * ```typescript + * // 临时隐藏剖切面 + * engine.hideSection(); + * // 稍后恢复 + * engine.recoverSection(); + * ``` + */ + public hideSection(): void { + if (!this._isInitialized || !this.engine?.clipping) { + console.error('[Engine] Cannot hide section: engine not initialized.'); + return; + } + console.log('[Engine] Hiding section'); + this.engine.clipping.disabled(); + } + + /** + * 恢复剖切面(从隐藏状态恢复) + * @remarks + * - 恢复被 hideSection() 隐藏的剖切面 + * - 底层调用 engine.clipping.recover() + * @example + * ```typescript + * // 隐藏后恢复剖切面 + * engine.hideSection(); + * // ... 一段时间后 + * engine.recoverSection(); + * ``` + */ + public recoverSection(): void { + if (!this._isInitialized || !this.engine?.clipping) { + console.error('[Engine] Cannot recover section: engine not initialized.'); + return; + } + console.log('[Engine] Recovering section'); + this.engine.clipping.recover(); + } + // ==================== 结束:剖切功能 ==================== // ==================== 漫游功能 ==================== diff --git a/src/managers/engine-manager.ts b/src/managers/engine-manager.ts index 365bb80..c3a1744 100644 --- a/src/managers/engine-manager.ts +++ b/src/managers/engine-manager.ts @@ -302,6 +302,28 @@ export class EngineManager extends BaseManager { this.engineInstance.setSectionBoxRange(range); } + /** + * 隐藏剖切面(临时隐藏,可恢复) + * @remarks 配合 recoverSection() 使用 + */ + public hideSection(): void { + if (!this.engineInstance) { + return; + } + this.engineInstance.hideSection(); + } + + /** + * 恢复剖切面(从隐藏状态恢复) + * @remarks 恢复被 hideSection() 隐藏的剖切面 + */ + public recoverSection(): void { + if (!this.engineInstance) { + return; + } + this.engineInstance.recoverSection(); + } + /** 激活框选放大功能 */ public activateZoomBox(): void { if (!this.engineInstance) { diff --git a/src/managers/section-plane-dialog-manager.ts b/src/managers/section-plane-dialog-manager.ts index 50e85ee..115ee0f 100644 --- a/src/managers/section-plane-dialog-manager.ts +++ b/src/managers/section-plane-dialog-manager.ts @@ -48,10 +48,8 @@ export class SectionPlaneDialogManager extends BaseDialogManager { protected createContent(): HTMLElement { this.panel = new SectionPlanePanel({ onHide: () => { - console.log('[SectionPlaneDialogManager] 隐藏'); - if (this.registry.engine3d) { - (this.registry.engine3d as any).engine?.clipping?.disabled(); - } + console.log('[SectionPlaneDialogManager] 隐藏剖切面'); + this.registry.engine3d?.hideSection(); }, onReverse: () => { console.log('[SectionPlaneDialogManager] 反向 (not supported in new API)');