Skip to content

Feat/2d editor#277

Merged
wass08 merged 13 commits intopascalorg:mainfrom
sudhir9297:feat/2d-editor
Apr 28, 2026
Merged

Feat/2d editor#277
wass08 merged 13 commits intopascalorg:mainfrom
sudhir9297:feat/2d-editor

Conversation

@sudhir9297
Copy link
Copy Markdown
Contributor

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:

  • A synchronized 2D–3D architecture with shared geometry and projection logic
  • Improved visual consistency
  • Enhanced interaction handling for selection, dragging, and drawing
  • Full support for structural elements (walls, stairs, roofs, fences, ceilings) in floorplan
  • Better measurement systems and real-time feedback during edits
  • Multiple stability and performance fixes

Architecture & Core

  • Synced 2D editor with shared 3D scene model.
  • Added shared core helpers for geometry projection and 2D calculations.
  • Began modularizing floorplan-panel.tsx for better maintainability.

Walls (2D)

  • Updated wall visuals for improved clarity and consistency.
  • Added:
    • Wall hatch patterns
    • Darker outlines
    • Improved curved wall line rendering
  • Fixed selected wall dimension display.
  • Added inner and outer wall dimension measurements.
  • Fixed connected wall movement when dragging endpoints.

Doors & Windows (2D)

  • Updated visuals for consistency.
  • Fixed real-time movement updates during drag.
  • Added live opening distance measurement lines while dragging.

Slabs (2D)

  • Improved slab visuals.
  • Added thin border rendering for better clarity.

Stairs (2D)

  • Added distinct symbols for:
    • Straight stairs
    • Curved stairs
    • Spiral stairs
  • Fixed stair color consistency and straight stair borders.
  • Removed incorrect stair bounding box visuals.
  • Fixed stair selection and dragging behavior.
  • Fixed hit areas for curved and spiral stairs.
  • Fixed stair preview to follow cursor correctly during drawing.

Fences (2D)

  • Added fence rendering to floorplan.
  • Improved fence visuals and endpoint markers.
  • Included fences in fit-to-view bounds.
  • Fixed fence selection and dragging behavior.
  • Added endpoint handles for fences.
  • Added live preview during fence drawing.
  • Reduced lag during fence drag interactions.

Roofs (2D)

  • Added roof rendering in floorplan.
  • Included roofs in fit-to-view bounds.
  • Fixed roof selection and movement interactions.
  • Added 2D roof drawing support.
  • Fixed 2D-to-3D sync during roof creation.
  • Fixed placement drift and rotation issues for buildings.

Ceilings (2D)

  • Added ceiling drawing support in 2D.
  • Added ceiling rendering in floorplan.
  • Added ceiling selection and action menu integration.
  • Included ceilings in hit testing and viewport fitting.
  • Fixed ceiling placement drift issues.

Measurements & Feedback

  • Added nearby wall measurements for selected elements.
  • Matched item clearance measurements with wall-style measurement visuals.

Stability & Fixes

  • Fixed multiple interaction conflicts across:
    • Walls
    • Stairs
    • Roofs
    • Fences
  • Fixed getServerSnapshot warning.
  • Fixed BufferGeometry.toNonIndexed() warning for stairs.

Folder Structure

  • Main floorplan logic is kept in:

    • packages/editor/src/components/editor/floorplan-panel.tsx
  • Floorplan-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 nearby editor-2d files
  • Floorplan 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 orchestrator
  • editor-2d/ → floorplan UI and render layers
  • tools/floorplan/ → floorplan interaction logic
  • core/plan/ → reusable geometry and math

Copy link
Copy Markdown
Collaborator

@wass08 wass08 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 changespackages/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:

  1. packages/core/src/plan/* and packages/core/src/index.ts — move out, delete exports
  2. packages/editor/src/lib/floorplan/ (new destination) — drop the moved files in
  3. packages/editor/src/components/tools/floorplan/selection-tool.ts — move into the same folder
  4. All import sites in packages/editor/src/components/editor/floorplan-panel.tsx and packages/editor/src/components/editor-2d/**

@wass08 wass08 merged commit 010c874 into pascalorg:main Apr 28, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants