refactor: sync managers and section box actions

Wire section box scale/reverse/reset to clipping APIs and sync demo artifacts.
This commit is contained in:
yuding
2026-02-04 18:20:30 +08:00
parent b12940f49c
commit 191c571f40
64 changed files with 10569 additions and 7065 deletions

View File

@@ -0,0 +1,5 @@
# Decisions - Path Roaming Implementation
This notepad tracks architectural and design decisions made during implementation.
---

View File

@@ -0,0 +1,5 @@
# Issues - Path Roaming Implementation
This notepad tracks problems, gotchas, and issues encountered during implementation.
---

View File

@@ -0,0 +1,199 @@
# Learnings - Path Roaming Implementation
This notepad tracks conventions, patterns, and accumulated wisdom from the path-roaming feature implementation.
---
## [2026-02-03T07:48:40] Codebase Exploration - Locale and Component Patterns
### Locale Files Structure
- **Location**: `src/locales/{types.ts, zh-CN.ts, en-US.ts}`
- **Pattern**: Nested objects matching TypeScript interface
- **Existing `walkControl.path` field**: Already contains `dialogTitle` property
- **Line ranges**:
- types.ts: lines 158-176
- zh-CN.ts: lines 151-168
- en-US.ts: lines 151-168
### Engine/EngineManager Method Patterns
- **Engine class** (`src/components/engine/index.ts`):
- Use guard clauses: `if (!this._isInitialized || !this.engine?.xxx)`
- Console warnings for uninitialized state: `console.warn('[Engine] ...')`
- Return `null` explicitly (not `undefined`)
- JSDoc comments required
- Type assertions where needed
- **EngineManager class** (`src/managers/engine-manager.ts`):
- Proxy pattern: `this.engineInstance?.methodName() ?? null`
- Optional chaining with nullish coalescing
- Consistent return types with Engine class
- **getEngineInfo() locations**:
- Engine: line 691-697
- EngineManager: line 426-428
### Component Implementation Patterns
- **WalkPathPanel status**: Exists as stub (55 lines), missing CSS and types files
- **Reference implementations**: MeasurePanel (888 lines), WalkControlPanel (468 lines)
- **Core interface**: `IBimComponent` with init(), destroy(), setTheme(), setLocales()
- **Subscriptions**: localeManager and themeManager subscriptions in init()
- **CSS variables**: Prefix with `--bim-*` for theming
- **Class naming**: `bim-[panel-name]-[element]` convention
- **Import pattern**: CSS at top, services/types imports follow
## [2026-02-03T07:50:15] Task 1 Complete - I18n Text Added
### Changes Made
- **types.ts**: Expanded `walkControl.path` from 1 field to 9 fields (dialogTitle + 8 new fields)
- **zh-CN.ts**: Added Chinese translations for all 9 fields
- **en-US.ts**: Added English translations for all 9 fields
### Fields Added
1. duration - 漫游时间 / Duration
2. durationUnit - 秒 / s
3. loop - 循环播放 / Loop
4. addPoint - 添加漫游点 / Add Point
5. deleteAll - 删除全部 / Delete All
6. point - 漫游点 / Point
7. play - 播放漫游 / Play
8. noPoints - 暂无漫游点,请添加 / No points yet
### Verification
- ✅ Build succeeded: `npm run build` passed with no errors
- ✅ All three files modified with exact code from plan
- ✅ Type safety maintained (TypeScript interface matches implementation)
### Notes
- Chinese JSDoc comments in types.ts are intentional per plan specification
- Subagent failed with JSON parse error, completed directly as trivial edit
## [2026-02-03T07:51:30] Task 2 Complete - Types.ts Created
### File Created
- **Location**: `src/components/walk-path-panel/types.ts`
- **Size**: 24 lines
### Interfaces Defined
1. **RoamingPoint**: Represents a single roaming point with `index: number`
2. **PlayOptions**: Configuration for playback with 4 optional fields:
- duration?: number (milliseconds)
- loop?: boolean
- onComplete?: () => void
- onPointComplete?: (pointIndex: number) => void
### Documentation
- All interfaces have Chinese JSDoc comments (per plan requirement)
- All fields have inline comments explaining purpose
- Public API documentation complete
### Verification
- ✅ Build succeeded: `npm run build` passed
- ✅ File created with exact code from plan
- ✅ Type definitions ready for component implementation
## [2026-02-03T07:52:30] Task 3 Complete - Engine pathRoaming Methods Added
### Changes Made
- **File**: `src/components/engine/index.ts`
- **Location**: After `getEngineInfo()` method (line 697)
- **Lines added**: ~90 lines of code
### Methods Added
1. **pathRoamingAddPoint()** - void - Add current camera position as roaming point
2. **pathRoamingRemovePoint(index)** - void - Remove point by index
3. **pathRoamingClearPoints()** - void - Clear all points
4. **pathRoamingGetPoints()** - any[] - Get all points array
5. **pathRoamingJumpToPoint(index)** - void - Jump to specific point
6. **pathRoamingPlay(options)** - void - Play roaming with callbacks
### Pattern Compliance
- ✅ Guard clauses: `if (!this._isInitialized || !this.engine?.pathRoaming)`
- ✅ Console warnings: `console.warn('[Engine] pathRoaming not available')`
- ✅ JSDoc comments for all public methods
- ✅ Internal comments explaining logic flow
- ✅ Section markers for code organization
- ✅ Consistent with existing Engine class patterns
### Verification
- ✅ Build succeeded: `npm run build` passed
- ✅ All 6 methods added with exact signatures from plan
- ✅ Ready for EngineManager proxy methods
## [2026-02-03T07:53:15] Task 4 Complete - EngineManager Proxy Methods Added
### Changes Made
- **File**: `src/managers/engine-manager.ts`
- **Location**: After `getEngineInfo()` method (line 428)
- **Lines added**: ~60 lines of code
### Proxy Methods Added
All 6 methods delegate to `this.engineInstance`:
1. **pathRoamingAddPoint()** - Proxies to engineInstance
2. **pathRoamingRemovePoint(index)** - Proxies with parameter
3. **pathRoamingClearPoints()** - Proxies to engineInstance
4. **pathRoamingGetPoints()** - Returns array with nullish coalescing
5. **pathRoamingJumpToPoint(index)** - Proxies with parameter
6. **pathRoamingPlay(options)** - Proxies with options object
### Pattern Compliance
- ✅ Proxy pattern: `this.engineInstance?.methodName()`
- ✅ Optional chaining for safety
- ✅ Nullish coalescing for getPoints: `?? []`
- ✅ JSDoc comments matching Engine class
- ✅ Section markers for code organization
- ✅ Consistent with existing EngineManager patterns
### Verification
- ✅ Build succeeded: `npm run build` passed
- ✅ All 6 proxy methods match Engine class signatures
- ✅ Ready for WalkPathPanel component implementation
## [2026-02-03T07:55:00] Tasks 5-7 Complete - WalkPathPanel & CSS Implemented
### Task 5: WalkPathPanel Component
- **File**: `src/components/walk-path-panel/index.ts`
- **Lines**: 377 lines of TypeScript
- **Complexity**: Complex UI component with state management
#### Features Implemented
1. **Initialization**: Load existing points from engine on panel open
2. **Settings**: Duration input (seconds → milliseconds) and loop checkbox
3. **Point Management**: Add, delete, delete all operations
4. **Point List**: Dynamic rendering with empty state
5. **Playback**: Play with callbacks, highlight current point during playback
6. **Lifecycle**: init(), setLocales(), setTheme(), destroy()
#### Key Patterns
- Render-based updates: Full re-render on state changes
- Callback integration: onPointComplete for highlighting, onComplete for cleanup
- Theme application: CSS variables via setProperty
- I18n integration: Subscribe to localeManager, use t() function
### Task 6: CSS Styling
- **File**: `src/components/walk-path-panel/index.css`
- **Lines**: 233 lines of CSS
- **Sections**: Buttons, Forms, Points Section, Point Items
#### Style Features
1. **Theming**: All colors use CSS variables with fallbacks
2. **Highlight Effect**: `.walk-path-point-item-active` for playing point
3. **Hover Effects**: Button hover states, action button visibility on hover
4. **Responsive**: Flexbox layouts, overflow handling
5. **Transitions**: Smooth hover and state changes
### Task 7: Build Verification
-`npm run build` succeeded
- ✅ Bundle size: 2,078 KB (ES), 1,370 KB (UMD)
- ✅ No TypeScript errors
- ✅ All 7 tasks complete
### Total Implementation
- **Files created**: 2 (types.ts, index.css)
- **Files modified**: 5 (types.ts, zh-CN.ts, en-US.ts, Engine.ts, EngineManager.ts)
- **Files replaced**: 1 (walk-path-panel/index.ts)
- **Total lines added**: ~1,200 lines
- **Build status**: ✅ SUCCESSFUL

View File

@@ -0,0 +1,29 @@
# Problems - Path Roaming Implementation
This notepad tracks unresolved blockers and critical problems requiring attention.
---
## [2026-02-03T07:52:00] Delegation System Failure
### Issue
Subagent delegation consistently failing with JSON parse error:
```
SyntaxError: JSON Parse error: Unexpected EOF
```
### Impact
- Cannot use delegate_task() for any category
- All 3 delegation attempts failed (Tasks 1, 2, 3)
- Forced to complete tasks directly as orchestrator
### Workaround
Completing tasks directly while maintaining:
- Plan specification compliance
- Build verification
- Notepad documentation
### Action Required
- Investigate delegation system JSON serialization
- May need to report to framework maintainers

View File

@@ -0,0 +1,109 @@
## [2026-02-03T09:55] Task 1: I18n Files Update
### Pattern Observed
- All menu i18n keys use JSDoc comments with Chinese descriptions in types.ts
- Format: `/** 中文描述 */\n{key}: string;`
- This is a codebase convention for bilingual documentation
### Implementation
- Added 4 fields to menu object: quickSelect, selectSameType, selectSameLevel, selectSameLevelType
- Maintained alphabetical ordering after existing fields
- Chinese: 快速选择, 选择同类模型, 选择同层模型, 选择同层同类模型
- English: Quick Select, Select Same Type, Select Same Level, Select Same Level & Type
### Verification
- tsc --noEmit passed with no errors
- All three files updated consistently
## [2026-02-03T09:58] Task 2: Engine Layer Methods
### Implementation
- Added 8 public methods to Engine class between lines 792-903
- Pattern: check initialization → get highlightModels → call engine.modelToolModule API
- Section markers: `// ==================== 构件操作 ====================`
- Each method has JSDoc with Chinese description (SDK convention)
### API Mapping
```
hideSelectedModels() → modelToolModule.hideModel(models)
translucentSelectedModels() → modelToolModule.translucentModel(models)
isolateSelectedModels() → modelToolModule.isolateModel(models)
translucentOtherModels() → modelToolModule.translucentOtherModel(models)
showAllModels() → modelToolModule.showAllModels()
batchSelectSameTypeModel() → modelToolModule.batchSelectSameTypeModel(models)
batchSelectSameLevelModel() → modelToolModule.batchSelectSameLevelModel(models)
batchSelectSameLevelTypeModel() → modelToolModule.batchSelectSameLevelTypeModel(models)
```
### Verification
- TypeScript compilation: PASSED
- Methods follow existing patterns (fitSectionBoxToModel as reference)
- Positioned correctly before destroy() method
## [2026-02-03T10:00] Task 3: EngineManager Proxy Methods
### Implementation
- Added 8 proxy methods to EngineManager class (lines 494-555)
- Pattern: Simple delegation to engineInstance methods using optional chaining
- Format: `this.engineInstance?.{methodName}();`
- Each method has JSDoc with Chinese description
### Verification
- TypeScript compilation: PASSED
- All 8 methods correctly delegate to Engine layer
- Positioned between path roaming and destroy() method
## [2026-02-03T10:03] Task 4: Right-Click Menu Handler Updates
### Implementation
- Replaced all console.log placeholders with actual method calls
- Added "快速选择" submenu with 3 options (order: 5)
- Updated menu item ordering:
- isolateSelected: order 4 (unchanged)
- quickSelect: order 5 (NEW)
- fitSectionBox: order 5 → 6
- showAll: order 6 → 7
### Menu Structure
```
1. 构件详情 (componentDetail)
2. 隐藏选中构件 (hideSelected) → hideSelectedModels()
3. 半透明选中构件 (transparentSelected) → translucentSelectedModels()
4. 隔离选中构件 (isolateSelected) → SUBMENU
- 其他构件隐藏 (hideOthers) → isolateSelectedModels()
- 其他构件半透明 (transparentOthers) → translucentOtherModels()
5. 快速选择 (quickSelect) → SUBMENU [NEW]
- 选择同类模型 (selectSameType) → batchSelectSameTypeModel()
- 选择同层模型 (selectSameLevel) → batchSelectSameLevelModel()
- 选择同层同类模型 (selectSameLevelType) → batchSelectSameLevelTypeModel()
6. 剖切盒适应 (fitSectionBox) → fitSectionBoxToModel()
7. 显示全部 (showAll) → showAllModels() [always visible]
```
### Verification
- TypeScript compilation: PASSED
- All console.log placeholders replaced
- All i18n keys properly linked to translations
## [2026-02-03T10:05] Task 5: Build & Commit
### Build Verification
- Command: `npm run build`
- Result: SUCCESS
- Output size: 2,084.68 kB (ES), 1,374.53 kB (UMD)
- Build time: 4.06s
### Commit
- Hash: 89783d0
- Message: "feat(menu): implement right-click menu functions for model operations"
- Files staged: 5 (types.ts, zh-CN.ts, en-US.ts, engine/index.ts, engine-manager.ts)
- Stats: 551 insertions(+), 118 deletions(-)
### Summary
All 5 tasks completed successfully:
1. ✅ I18n files updated (4 new fields)
2. ✅ Engine layer: 8 methods added
3. ✅ EngineManager: 8 proxy methods added
4. ✅ Right-click menu handler: All functions connected + quick select submenu
5. ✅ Build verification: PASSED