Feat/2d editor#277
Conversation
wass08
left a comment
There was a problem hiding this comment.
PR #277 review — blocker fix
Blocker — move the entire packages/core/src/plan/* module to the editor
The new plan/ folder in core is 100% consumed by the floorplan panel and its selection tool — verified by grep, no other system, renderer, or core module imports any of it. That makes it straightforwardly editor-scope code living in the wrong package: any downstream consumer of @pascal-app/core (embeds, read-only viewers, future packages) now ships floorplan types and helpers for a view they don't render.
What to do:
Move the whole packages/core/src/plan/ directory to packages/editor/src/lib/floorplan/ as-is. Delete the corresponding exports from packages/core/src/index.ts. Fold packages/editor/src/components/tools/floorplan/selection-tool.ts into the same packages/editor/src/lib/floorplan/ folder while you're there — it's another editor-only pure-logic file that was in the wrong place and gets fixed by the same reshuffle.
Update imports in packages/editor/src/components/editor/floorplan-panel.tsx and the new editor-2d/* files to point at the editor lib path instead of @pascal-app/core.
One side check during the move: the one import from core's scene store is useLiveTransforms in plan/items.ts. That's fine — it stays, and plan/items.ts (now in the editor) keeps importing useLiveTransforms from @pascal-app/core like any other editor file does.
Suggestions
S1. Fence live-transform subscriber fires on unrelated transform changes — packages/editor/src/components/editor/floorplan-panel.tsx:9264-9272
const unsubscribe = useLiveTransforms.subscribe((state, previousState) => {
if (state.transforms !== previousState.transforms) {
refreshFencePreview()
}
})The door/opening/roof effects next to this one compare by specific node id. The fence version re-renders the whole floorplan on any transform change — during a multi-fence drag the tool writes once per linked fence per mouse move, firing this subscriber N times.
Fix: track the moving fence's id and linked ids in refs; compare only those entries. Or coalesce the render tick with queueMicrotask so N writes in one task produce one render.
S2. floorplan-panel.tsx is now 13,331 lines (+3,794 in this PR)
The new editor-2d/ extraction direction is the right one. But the panel itself still absorbed ~3.8k lines of measurement rendering, roof/stair drag state, and SVG path construction. Continue the pattern — editor-2d/renderers/floorplan-measurements-layer.tsx, …/floorplan-roof-layer.tsx, …/floorplan-stair-layer.tsx, plus an editor-2d/svg-paths.ts for the SVG arc/annular/arrow helpers. Not required to merge; just don't let this keep growing unbounded.
Summary
- Blockers: 1 (the
packages/core/src/plan/*floorplan leak) - Suggestions: 2
- Nits: 0
Verdict: needs changes. The rest of the PR is clean — no viewer-isolation violations, no core→Three.js leaks, 2D↔3D decoupling goes through useLiveTransforms correctly, and the tool live-drag pattern now matches the updated .claude/rules/tools.md. The single fix is relocating the plan/ module end-to-end.
Files to open first:
packages/core/src/plan/*andpackages/core/src/index.ts— move out, delete exportspackages/editor/src/lib/floorplan/(new destination) — drop the moved files inpackages/editor/src/components/tools/floorplan/selection-tool.ts— move into the same folder- All import sites in
packages/editor/src/components/editor/floorplan-panel.tsxandpackages/editor/src/components/editor-2d/**
What does this PR do?
This PR significantly upgrades the 2D floorplan editor by aligning it with the shared 3D scene model, improving visual fidelity, interaction accuracy, and feature parity across walls, stairs, roofs, fences, slabs, and ceilings.
It delivers:
Architecture & Core
floorplan-panel.tsxfor better maintainability.Walls (2D)
Doors & Windows (2D)
Slabs (2D)
Stairs (2D)
Fences (2D)
Roofs (2D)
Ceilings (2D)
Measurements & Feedback
Stability & Fixes
getServerSnapshotwarning.BufferGeometry.toNonIndexed()warning for stairs.Folder Structure
Main floorplan logic is kept in:
packages/editor/src/components/editor/floorplan-panel.tsxFloorplan-specific UI layers are kept in:
packages/editor/src/components/editor-2d/Floorplan render helpers (draft, marquee, action menu, cursor overlays) are kept in:
packages/editor/src/components/editor-2d/renderers/and nearbyeditor-2dfilesFloorplan selection and hit-testing logic is kept in:
packages/editor/src/components/tools/floorplan/Shared floorplan geometry and math utilities are kept in:
packages/core/src/plan/Structure overview:
floorplan-panel.tsx→ main 2D floorplan orchestratoreditor-2d/→ floorplan UI and render layerstools/floorplan/→ floorplan interaction logiccore/plan/→ reusable geometry and math