refactor: slim down EngineManager from 861 to 290 lines by removing passthrough proxy pattern

- EngineManager now only exposes public SDK API (initialize, loadModel, pause/resumeRendering, getEngineComponent, destroy)
- Internal managers access Engine component directly via this.engineComponent getter on BaseManager
- Non-manager components use registry.engine3d.getEngineComponent() for direct Engine access
- Replaced getEngine() with onRawEvent()/offRawEvent() for raw engine event access
- Migrated 62 call sites across 13 files (9 managers, 1 panel, 3 toolbar buttons)
- Updated all architecture docs, API docs, and README to reflect new patterns
This commit is contained in:
yuding
2026-03-05 11:15:57 +08:00
parent c3bd82c03a
commit b96e5f3262
28 changed files with 3786 additions and 6261 deletions

View File

@@ -70,16 +70,18 @@ onMounted(() => {
bimEngine.initWalkControl(); // 漫游控制
bimEngine.initMap(); // 地图
// 加载模型
bimEngine.engine?.loadModel({
url: '/path/to/your/model.ifc',
onProgress: (progress) => {
console.log(`加载进度: ${progress}%`);
},
onComplete: () => {
console.log('模型加载完成');
// 加载模型EngineManager 对外公共 API
bimEngine.engine?.loadModel(
['/path/to/your/model.ifc'],
{
onProgress: (progress) => {
console.log(`加载进度: ${progress}%`);
},
onComplete: () => {
console.log('模型加载完成');
}
}
});
);
}
});
@@ -179,6 +181,13 @@ BIM Engine SDK 采用 **管理器模式 (Manager Pattern)** 作为核心架构,
- ✅ 简化集成复杂度
- ✅ 支持按需加载
> 架构更新2026-03
>
> - `EngineManager` 已从全量透传层收敛为“外部公共 API + 生命周期编排”
> - 内部 Manager 统一通过 `BaseManager.engineComponent` 直接访问 `Engine` 组件
> - 非 Manager 场景通过 `registry.engine3d?.getEngineComponent()?.xxx()` 访问引擎能力
> - `Engine.getEngine()` 已移除,事件订阅使用 `onRawEvent()/offRawEvent()`
### 架构分层
```
@@ -193,7 +202,7 @@ BIM Engine SDK 采用 **管理器模式 (Manager Pattern)** 作为核心架构,
│ Manager 层 (管理器) │
│ - ToolbarManager (工具栏) │
│ - DialogManager (对话框) │
│ - EngineManager (3D引擎)
│ - EngineManager (外部公共API/生命周期)
│ - MeasureDialogManager (测量) │
│ - SectionPlaneDialogManager (剖切) │
│ - WalkControlManager (漫游) │
@@ -333,12 +342,14 @@ class BimEngine {
每个管理器负责特定功能的生命周期管理:
```typescript
// 3D 引擎管理器
bimEngine.engine?.loadModel({
url: '/path/to/model.ifc',
onProgress: (progress) => console.log(progress),
onComplete: () => console.log('完成')
});
// 3D 引擎管理器(对外公共 API
bimEngine.engine?.loadModel(
['/path/to/model.ifc'],
{
onProgress: (progress) => console.log(progress),
onComplete: () => console.log('完成')
}
);
// 测量工具管理器
bimEngine.measure?.show();
@@ -509,6 +520,15 @@ npm run dev
## 📝 更新日志
### v1.3.2 (2026-03-05)
**架构优化**
- ✨ EngineManager 瘦身:移除大规模 1:1 透传方法
- ✨ 新增 `EngineManager.getEngineComponent()` 供内部访问
- ✨ BaseManager 新增 `engineComponent` 便捷访问器
- ✨ Manager 内部调用统一迁移为 `this.engineComponent?.xxx()`
- ✨ 原始事件访问改为 `onRawEvent()/offRawEvent()`,移除 `getEngine()`
### v1.0.0 (2024-12-26)
**核心功能**