From 8fd1870f42976e2e751541663a1c74db845a05c0 Mon Sep 17 00:00:00 2001 From: yuding <1023798085@qq.com> Date: Wed, 4 Feb 2026 15:29:27 +0800 Subject: [PATCH] refactor(engine): update Engine layer to accept models parameter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add getHighlightModels() to retrieve selected models - Rename hideSelectedModels → hideModels(models) - Rename translucentSelectedModels → translucentModels(models) - Rename isolateSelectedModels → isolateModels(models) - Update translucentOtherModels to accept models parameter - Update batch select methods to accept models parameter Tasks 1-6 completed from refactor-model-operations plan. --- src/components/engine/index.ts | 45 +++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/src/components/engine/index.ts b/src/components/engine/index.ts index c15e400..84e67be 100644 --- a/src/components/engine/index.ts +++ b/src/components/engine/index.ts @@ -834,28 +834,39 @@ export class Engine implements IBimComponent { // ==================== 构件操作 ==================== /** - * 隐藏选中构件 + * 获取当前高亮(选中)的模型 + * @returns 高亮模型对象,未选中时返回 null */ - public hideSelectedModels(): void { + public getHighlightModels(): any { + if (!this._isInitialized || !this.engine) { + return null; + } + return this.engine.engineStatus?.highlightModels ?? null; + } + + /** + * 隐藏指定模型 + * @param models 要隐藏的模型对象 + */ + public hideModels(models: any): void { if (!this._isInitialized || !this.engine?.modelToolModule) { console.warn('[Engine] Cannot hide models: engine not initialized.'); return; } - const models = this.engine.engineStatus?.highlightModels; if (models) { this.engine.modelToolModule.hideModel(models); } } /** - * 半透明选中构件 + * 半透明指定模型 + * @param models 要半透明的模型对象 */ - public translucentSelectedModels(): void { + public translucentModels(models: any): void { if (!this._isInitialized || !this.engine?.modelToolModule) { console.warn('[Engine] Cannot translucent models: engine not initialized.'); return; } - const models = this.engine.engineStatus?.highlightModels; if (models) { this.engine.modelToolModule.translucentModel(models); } @@ -873,14 +884,14 @@ export class Engine implements IBimComponent { } /** - * 隔离选中构件(隐藏其他) + * 隔离指定模型(隐藏其他) + * @param models 要隔离的模型对象 */ - public isolateSelectedModels(): void { + public isolateModels(models: any): void { if (!this._isInitialized || !this.engine?.modelToolModule) { console.warn('[Engine] Cannot isolate models: engine not initialized.'); return; } - const models = this.engine.engineStatus?.highlightModels; if (models) { this.engine.modelToolModule.isolateModel(models); } @@ -888,13 +899,13 @@ export class Engine implements IBimComponent { /** * 半透明其他构件 + * @param models 选中的模型对象(其他构件将被半透明) */ - public translucentOtherModels(): void { + public translucentOtherModels(models: any): void { if (!this._isInitialized || !this.engine?.modelToolModule) { console.warn('[Engine] Cannot translucent other models: engine not initialized.'); return; } - const models = this.engine.engineStatus?.highlightModels; if (models) { this.engine.modelToolModule.translucentOtherModel(models); } @@ -916,13 +927,13 @@ export class Engine implements IBimComponent { /** * 批量选择同类模型 + * @param models 参考模型对象 */ - public batchSelectSameTypeModel(): void { + public batchSelectSameTypeModel(models: any): void { if (!this._isInitialized || !this.engine?.modelToolModule) { console.warn('[Engine] Cannot batch select: engine not initialized.'); return; } - const models = this.engine.engineStatus?.highlightModels; if (models) { this.engine.modelToolModule.batchSelectSameTypeModel(models); } @@ -930,13 +941,13 @@ export class Engine implements IBimComponent { /** * 批量选择同层模型 + * @param models 参考模型对象 */ - public batchSelectSameLevelModel(): void { + public batchSelectSameLevelModel(models: any): void { if (!this._isInitialized || !this.engine?.modelToolModule) { console.warn('[Engine] Cannot batch select: engine not initialized.'); return; } - const models = this.engine.engineStatus?.highlightModels; if (models) { this.engine.modelToolModule.batchSelectSameLevelModel(models); } @@ -944,13 +955,13 @@ export class Engine implements IBimComponent { /** * 批量选择同层同类模型 + * @param models 参考模型对象 */ - public batchSelectSameLevelTypeModel(): void { + public batchSelectSameLevelTypeModel(models: any): void { if (!this._isInitialized || !this.engine?.modelToolModule) { console.warn('[Engine] Cannot batch select: engine not initialized.'); return; } - const models = this.engine.engineStatus?.highlightModels; if (models) { this.engine.modelToolModule.batchSelectSameLevelTypeModel(models); }