Skip to content

Move handle + proximity / sill / equal-spacing guides for wall openings#408

Merged
Aymericr merged 7 commits into
mainfrom
feat/opening-proximity-guides
Jun 15, 2026
Merged

Move handle + proximity / sill / equal-spacing guides for wall openings#408
Aymericr merged 7 commits into
mainfrom
feat/opening-proximity-guides

Conversation

@Aymericr

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds a cross-arrow move handle to wall-hosted doors & windows (3D + 2D) and a full set of proximity / alignment guides for openings, in the spirit of Figma's smart guides — surfaced while placing, moving, and resizing.

Move handle

  • Doors/windows get a move-cross handle (previously movable only via the floating menu): slide along a wall or displace to another wall; windows also move in the wall's vertical plane.
  • Cmd/Ctrl + left-drag in select mode now moves the hovered item (door/window/node) instead of starting a box-select.

Opening guides (new pure computeOpeningGuides core service — no Three.js, unit-tested)

  • Sill / head dimensions: window bottom-edge → floor and top-edge → wall top.
  • Edge proximity gaps: clearance to the nearest neighbour opening (or wall end) on each side.
  • Vertical alignment (windows): sill / centre / top shared with a neighbour — snap + guide (sticky, competes with the 0.5 m grid; Shift bypasses).
  • Equal-spacing detection: a run of 3+ openings with near-equal gaps shows Figma-style "=" badges (detect-only; no auto-distribute in v1).
  • Rendered in both the 3D viewport (wall-plane line layer + pills) and the 2D floor plan, while placing, moving, and resizing (the resized edge shows its live dimension).

Performance hardening (perf is paramount for the 3D/2D editor)

  • The 3D guide layer reuses one THREE.Line + a preallocated position buffer per guide slot, mutating endpoints in place — no per-tick geometry/Line/Vector allocation or GPU buffer churn (mirrors the alignment-guide layer).
  • Guides keyed by stable semantic id so <Html> pills don't remount as the set churns; clear() is a no-op when already empty; cursor EdgesGeometry is memoized + disposed.

Reviewed by Codex (peer + adversarial) for correctness, hook usage, GPU leaks, and — after merging main (#407's placement restructure) into this branch — for merge-resolution regressions. No regressions found; all #407 behavior (always-visible ghosts, true-nearest snap, R-key flip, roof handling) preserved.

How to test

  1. bun dev, open the editor, draw a wall or two.
  2. Place a door/window: hover the wall — note the sill/head + edge-gap dimensions; place a second window near the first to see along-wall/vertical alignment snap and, with 3+, the "=" equal-spacing badges.
  3. Move: select a door/window and drag the cross-arrow handle (3D and 2D) — slide along the wall, hop to another wall; for a window, move it vertically and watch the sill snap. Also try Cmd/Ctrl + drag on a node in select mode (moves, not box-select).
  4. Resize: drag a width/height handle — the edge being resized shows its live dimension.
  5. Hold Shift to bypass snapping. Hover off the wall / over a roof — guides clear.

Screenshots / screen recording

Checklist

  • I've tested this locally with bun dev
  • My code follows the existing code style (run bun check to verify)
  • I've updated relevant documentation (if applicable)
  • This PR targets the main branch

Aymericr and others added 7 commits June 14, 2026 09:51
Doors and windows could only be moved via the floating action menu — their
3D handle rig declared width/height resize arrows but no move grip, and
Ctrl/Meta-drag was a no-op for them. Add a press-drag move cross and make
direct-drag work for every bespoke-mover kind.

- door/window: add a `tap-action` `move-cross` handle (plane node-normal,
  portal grandparent, `engageMoveDrag`) mirroring the item wall grip. It
  routes through the existing per-kind move tool (3D `affordanceTools.move`,
  2D `floorplanMoveTarget`) — wall-bound slide + re-host onto another wall —
  so the grip, the floating Move button, and the 2D plan's move dot share one
  pipeline. Grab-drag-release commits without a second click.

- canDirectMoveNode: gate Ctrl/Meta-drag on `movable || affordanceTools.move`
  (the 3D-mountable move paths) instead of `movable` only, so doors/windows/
  walls/slabs/stairs/… are draggable in 3D as they already are in 2D.
  Floorplan-only movers (zone) stay excluded — no 3D tool mounts. The
  floating helper auto-syncs (it reads canDirectMoveNode).

- TapActionArrow: honor `plane: 'node-normal'` by tilting the move cross
  [π/2,0,0] into the wall face — previously ignored, so the item wall grip
  rendered flat too. Now door/window/wall-item crosses lie in the wall.

- use-node-events: split the drag-suppression gate. `inputDragging` still
  suppresses SELECTION events (the synthesized release-click would re-select),
  but no longer suppresses SPATIAL events (enter/move/leave) — a
  surface-following move tool runs with `inputDragging` set and needs
  wall:move to track the cursor. General consumers that must ignore drags
  (viewer hover, box-select) already self-gate on `inputDragging`; the
  editor's select-hover and paint-preview enter handlers now gate on it too.

- handle-arrow: make handle hit areas inert while `placementDragMode` is set,
  so a move grip riding the dragged node can't intercept the ray and starve
  the move tool's surface raycast.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… openings

Pure, Three.js-free wall-local geometry that will power directly-visible
proximity guides for doors and windows (rendered in the follow-up phases):

  - sill / head height (floor → bottom edge, top edge → wall top)
  - edge-to-edge proximity clearance to the nearest neighbour on each side
    (or the wall end), with overlap suppression
  - along-wall alignment (edge/centre coincidence with a neighbour)
  - vertical alignment (shared sill / centre / top — "same sill height")
  - Figma-style equal-spacing run detection across a series of 3+ openings

Single `computeOpeningGuides` entry plus exported detectors; 23 unit tests.
Codex-reviewed — equal-spacing uses a longest-equal-window scan (a greedy
first-gap anchor dropped valid runs), edge gaps suppress straddling overlaps,
and the alignment detectors guard against the moving opening appearing in its
own sibling list.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Route the door/window floor-plan placement dimensions through the new
opening-guides service:
  - edge-to-edge clearance to the nearest neighbour (or wall end) on each
    side, now with overlap suppression (previously nearest-only, ad-hoc).
  - Figma-style equal-spacing — a "=" badge per gap on the wall centreline
    whenever the moving opening is part of a run of 3+ (near-)equally-spaced
    openings.

Adds the `equal-spacing-badge` FloorplanGeometry primitive, its 2D renderer
(distinct pink accent), and overlay registration. Shown while placing/moving.
Sill height + vertical alignment are 3D-only (a top-down plan has no vertical
axis) and land in the next phase.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… openings

Wire the opening-guides service into the 3D door/window move tools and render the
wall-plane guides as the spatial twin of the 2D plan guides:

  - sill / head height (floor → bottom edge, top edge → wall top) — windows only
  - edge-to-edge proximity dimensions to the nearest neighbour each side
  - a sill-alignment line + SNAP when a window shares a neighbour's sill / centre
    / top (competes with the 0.5m grid, Shift bypasses) — the chosen
    "snap + guide" behaviour
  - Figma-style equal-spacing "=" badges across a run of openings

Adds `useOpeningGuides` (editor store) + `OpeningGuides3DLayer` (raw THREE.Line
overlays + Html pills, mounted beside Alignment3DGuideLayer) and a thin
`opening-guides-runtime` helper (collect siblings / sill snap / publish / clear)
called from the door + window move-tools at their per-tick `applyPreview` hook;
guides clear on commit / cancel / leave / roof-hover / unmount.

Guides render in the move cursor's building-local frame (reuses `wallLocalToWorld`)
so they track the dragged opening exactly. Codex-reviewed (roof-hover stale-guide
clear, collapsed-dimension suppression). Placement-time guides reuse the same
helper and are the next step.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Extend the opening proximity guides to two more interactions:

  - PLACEMENT: the door/window placement tools publish the same 3D guides
    (sill/head, edge proximity, sill alignment, equal-spacing) while a NEW
    opening is being dropped; window placement also snaps its sill to a
    neighbour's sill/centre/top (Shift bypass) — so "two windows aligned" reads
    during placement, not just move.
  - RESIZE: a new `onDrag` hook on the linear-resize handle descriptor lets the
    door/window width/height arrows publish live guides for the edge being
    resized — proximity to neighbours as the width grows, and the live sill/head
    as a window's height changes. The generic LinearArrow stays kind-agnostic;
    only door/window declare the hook.

Refactor (Codex review follow-up): one `publishOpeningGuidesForWallEvent`
wrapper now backs all four wall-event publish sites (door/window move +
placement) over a shared `makeWallToWorld`; window placement's repeated
sill-snap is a single `resolvePlacementY` helper. Opening guides clear on
commit / leave / cancel / roof-hover / unmount (mirroring the alignment-guide
lifecycle) and on resize end.

Codex-reviewed — no blockers; lifecycle/leaks, coordinate frame, sill-snap
precedence, and resize disposal confirmed. Typecheck + biome + 23 core + 170
nodes tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…PU churn

Reuse one THREE.Line + preallocated position buffer per guide slot, mutating
endpoints in place each drag tick instead of rebuilding the geometry, line, and
two Vector3s and re-uploading the GPU buffer every frame. Key guides by a stable
semantic id (sill / head / gap:side / vertical / spacing:i) so a slot that
persists keeps its React element and drei <Html> pill mounted as the guide set
churns, rather than remounting under shifting index keys.

Also: make useOpeningGuides.clear() a no-op when already empty so the common
no-guide hover frame doesn't push a fresh [] and re-render to the same nothing;
dispose the move-tool cursor EdgesGeometry on unmount; and memoize the
placement-tool cursor EdgesGeometry (static fallback dims) so it isn't
reallocated and orphaned on every render during placement.

Reviewed by Codex (peer + adversarial): no correctness, hook-order, or GPU-leak
regressions.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…-guides

#407 ("Always-visible placement ghosts + true-nearest 2D opening snap")
restructured the door/window placement tools: it split the old
create-in-resolve into a pure resolveWallPlacement() + side-effecting
applyWallTarget(), added an off-host floating ghost (fallbackPose / showGhostAt),
unified wall hover into onWallHover, and extracted commit{Door,Window}AtWall.

Conflict resolution (door/tool.tsx, window/tool.tsx):
- Re-homed the single publishOpeningGuidesForWallEvent() call into applyWallTarget
  (after the draft update + updateCursor), using that scope (wall,
  getSlabElevationForWall(wall)); door includeVertical:false, window true.
- Routed clearOpeningGuides3D() through showGhostAt so every off-host fallback
  path clears; kept clears in hideCursor, commit helpers, onRoofHover, teardown.
- Made the window sill snap (resolvePlacementY) event-free and call it from the
  pure resolveWallPlacement, so hover + click both get sill/centre/top snapping;
  Shift bypasses, the moving draft is excluded via ignoreId.
- Dropped the branch's inline onWallClick in favour of #407's onWallClick +
  commitWindowAtWall (no behavior lost).
- Reconstructed both files' import blocks, which the auto-merge had truncated to
  stubs (only tsc caught it).

All other conflicts auto-merged (registry types, floorplan-registry-layer,
both move-tools). Verified: typecheck 9/9, biome clean, nodes 169 + core 594
tests pass, editor `bun run build` 7/7. Merge resolution reviewed by Codex
(adversarial): no semantic regressions; all #407 behavior preserved.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Aymericr
Aymericr merged commit 2d053c4 into main Jun 15, 2026
2 checks passed
@Aymericr
Aymericr deleted the feat/opening-proximity-guides branch June 15, 2026 17:01
@mintlify

mintlify Bot commented Jun 15, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
pascal 🔴 Failed Jun 15, 2026, 5:12 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

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.

1 participant