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:
199
.sisyphus/notepads/path-roaming/learnings.md
Normal file
199
.sisyphus/notepads/path-roaming/learnings.md
Normal 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
|
||||
|
||||
Reference in New Issue
Block a user