Skip to content

editor: fix roof and placement previews - #718

Merged
wass08 merged 64 commits into
pascalorg:mainfrom
sudhir9297:t3code/understand-roof-improvement-system
Aug 28, 2026
Merged

editor: fix roof and placement previews#718
wass08 merged 64 commits into
pascalorg:mainfrom
sudhir9297:t3code/understand-roof-improvement-system

Conversation

@sudhir9297

@sudhir9297 sudhir9297 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Improves roof, dormer, lean-to, and window placement so cursor rays, ghosts, and committed items resolve to the exact pointer location, including centered freestanding lean-to placement. Transient placement previews now use live overrides during pointer movement, snapping follows the active mode, and shared helpers stay within the correct architecture boundaries.

How to test

  1. Run bun run check and bun run check-types.
  2. Run the focused tests with bun test packages/nodes/src/lean-to-extension packages/nodes/src/dormer packages/nodes/src/window packages/editor/src/components/tools/shared/pointer-support-cap.test.ts.
  3. Run bun dev, place and move a freestanding lean-to, dormer window, wall window, and roof-face window; confirm the ghost and final item stay centered under the cursor and follow the same raycast position.
  4. Confirm the lean-to footprint remains centered after rotation and movement, and that grid/line/off snapping modes behave consistently.

The package builds for core, nodes, and viewer pass. The full app production build is currently blocked by the unchanged react-scan dependency's webpack export mismatch; Turbopack also hits an environment process-permission error.

Screenshots / screen recording

Not included — visual verification should be performed with the interactive placement steps above.

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

Note

Medium Risk
Touches core roof schema (RoofSupport, conical fields), scene migration for dormers, overlap clipping, and shared placement/union math—well covered by tests but broad impact on structure editing.

Overview
Adds conical as a roof type with full geometry, surface height, and coverage (full cone vs clipped sector). Roofs can attach to a level or mount on another roof segment via new RoofSupport; resolveConicalRoofPlacement picks level vs surface support (with auto/ground/roof modes in the tool). Curved walls can spawn a conical sector (createConicalRoofSectorAboveWall), and overlap clipping treats host vs mounted conicals differently (roofPlanOverlapEntryOwns).

The Build tab roof panel now sets roof type and footprint source (room / draw / curved wall for conical), wired to toolDefaults.roof and shared build-tab-state helpers.

The roof tool implements room hover-and-click footprints, draw rectangles/circles, conical wall selection with ghosts, and invalid-preview coloring; floorplan drafting clears when footprint source is not draw.

Dormers promote legacy inline window params to hosted WindowNode children on wall faces (migration on scene load), with face frames, shed ceiling bounds, and exposed-face default placement. Windows gain dormerId / dormerFace hosting.

Lean-to schema grows (canopy form, host kind, slab edge refs, omitted post slots). Polygon union ring assembly picks the next boundary segment by clockwise turn to avoid point-touching self-rings. Resize handles add optional connectionSnap and portalTarget; orthographic pointer support rays use view direction so off-center cursors don’t drift.

Smaller fixes: item placement rotation updates live overrides and placement preview; direct move blocked in delete mode; root checks script runs biome + types.

Reviewed by Cursor Bugbot for commit 28ddc09. Bugbot is set up for automated code reviews on this repo. Configure here.

sudhir9297 and others added 30 commits May 19, 2026 02:59
Items (e.g. solar panels) can now be placed on sloped roof surfaces.
The placement system computes euler rotation from the roof surface
normal so items sit flush on the slope instead of going inside.

- Add roofStrategy to placement-strategies with enter/move/click/leave
- Wire roof:enter/move/click/leave events in the placement coordinator
- Add calculateRoofRotation in placement-math using surface normals
- Support full 3D cursor rotation for sloped surfaces
- Items on roofs are parented to the level with world-space rotation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment thread apps/editor/components/build-tab.tsx Outdated
Comment thread packages/editor/src/components/tools/roof/roof-tool.tsx
Comment thread packages/editor/src/components/tools/roof/roof-tool.tsx
Comment thread packages/core/src/lib/conical-roof-placement.ts
Comment thread packages/core/src/store/use-scene.ts
Comment thread packages/editor/src/components/tools/roof/roof-tool.tsx Outdated
Comment thread apps/editor/components/build-tab.tsx Outdated
Straight freestanding mono runs now only miter across a corner when the
joined chain is exactly two runs (an L). J-shapes, longer chains, and
closed loops render as plain overlapping runs — no shaped footprint,
no joint step closures, no corner extension — which avoids the dark
wedges and fascia slivers those multi-corner miters produced. Curved
and wall-attached canopies keep their multi-corner mitering.

The joint step closure that L runs still use is rebuilt on geometric
ownership (the lower run raises the closure wall to the sibling top),
so it no longer depends on node-id order or draw direction.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@Aymericr Aymericr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this, Sudhir — there is a lot of genuinely good work in here, and the test coverage (54 test files, ~6.7k lines) is exactly what I want to see on roof and placement code. But I can't take it as one PR, so let me be concrete about why and what I'd like instead.

Scope. The title says roof and placement previews, but the branch actually lands seven separable features: a new conical roof type, the new RoofSupport (roof-on-roof) concept, roof footprint sources + placement modes, the lean-to canopy overhaul (~4.9k lines on its own), dormer inline windows becoming hosted WindowNodes with a scene-load migration, core handle-registry extensions (portalTarget / visible / connectionSnap), and a set of unrelated riders (delete mode moving into selection-routing.ts, read-only gating in panel-manager.tsx, the root checks script). Any one of those is a reviewable PR. Together, 181 files, I can't give you a review that's worth your time, and I can't safely revert one piece if it regresses.

Please re-cut from main rather than resolve the conflicts. The branch is 8 commits behind and diverged, with 35 merge commits in the history. Most importantly it predates #721, which lifted the arbitrary maxes from every inspector dimension field and added the rule page wiki/architecture/inspector-field-limits.md. This branch still carries highEdgeHeight max: 10, wallSkirtHeight max: 6, roofHeight max: 2, column width/depth max: 2, and the new fields add fresh maxes — so a "keep mine" resolution would quietly revert that sweep. Same story on use-keyboard.ts, use-placement-coordinator.tsx and index.tsx against #691. A rebase here is more work than a clean series.

One architectural thing to change before the conical PR. Curved-wall conical roofs are created in a useEffect in apps/editor/components/build-tab.tsx, while roof-tool.tsx only selects the wall. The sidebar mounts one panel at a time, so leaving the Build tab stops wall placement working, and it never works for anyone consuming @pascal-app/editor outside our app. wiki/architecture/tools.md puts the input→useScene mutation in the tool — that creation belongs in roof-tool.tsx, with the Build tab only choosing roof type and footprint source. Bugbot flagged the same thing twice as High. Related: column/parametrics.ts importing leanToPostOmissionPatchesOnDelete from lean-to-extension/ couples two kinds — a shared helper in nodes/src/shared/ would keep each kind removable on its own.

Bugbot has 8 open findings (5 High) and they look real to me — worth working through in the split PRs rather than here: delete mode is unreachable behind the click-to-move early return in the new selection-routing.ts; the roof-tool placement effect deps on the whole scene nodes map, so any scene mutation resets a two-click draw mid-placement; room-footprint commit spreads defaults after wallHeight: 0, so the committed roof gets a curb the ghost never showed. The one I'd most like fixed is the dormer migration in use-scene.ts — it inserts a default window whenever no window child exists, so a user who deletes every dormer window and reloads gets one back.

Two housekeeping items: 15 PNGs under .artifacts/browser-canopy/ are committed (.artifacts isn't gitignored, so they'd be permanent in the public repo), and wiki/conical-turret-roof-research.md / wiki/conical-roof-implementation-plan.md are research/plan docs — wiki/ is for how the system works today, so send those to me and I'll archive them on our side.

Two extra heads-ups for the split, since these touch code that landed in the last fortnight: the pointer-support-cap.ts orthographic ray change sits in the resolver #686 fixed for node-top vs floor placement, and the use-placement-coordinator.tsx rotation rework is the exact path #643 fixed for wall-item preview drift. Both changes read plausible to me — I'd just like each in its own PR with a wall-hosted-item rotation check and a floor-vs-shelf placement check, so we can land them fast and independently.

Suggested order for the series: (1) the small independent fixes (ortho pointer ray, polygon-union, read-only gating); (2) core handle-registry extensions + the tools.md paragraph; (3) lean-to canopy forms; (4) dormer hosted windows + migration; (5) conical roofs + footprint sources with wall-mode creation moved into the roof tool. Happy to review the small ones the day you open them.

if (clonedNode.type === 'roof' && clonedNode.support?.kind === 'roof') {
clonedNode.support.roofSegmentId = (idMap.get(clonedNode.support.roofSegmentId) ??
clonedNode.support.roofSegmentId) as typeof clonedNode.support.roofSegmentId
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Clone omits new host IDs

Medium Severity

Scene and level cloning remaps roof.support.roofSegmentId but not the other new host references this PR adds, including metadata.conicalSourceWallId, lean-to hostSlabId, and window dormerId. Duplicated subgraphs keep pointing at the original nodes, so cloned lean-tos, dormer windows, and wall-created conical roofs attach to the wrong hosts or spawn duplicates.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 8307ad4. Configure here.

pitch: DEFAULT_CONICAL_ROOF_PITCH,
conicalStartAngle: arc.startAngle,
conicalSweepAngle: arc.delta,
conicalFullCircle: true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Wall conical roofs ignore stored sweep

High Severity

Curved-wall conical creation sets conicalFullCircle while also storing the wall conicalStartAngle and conicalSweepAngle. getConicalRoofCoverage then treats that flag as a full cone and drops the arc, so the hover ghost and committed roof become complete circles instead of matching the wall sweep.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f88754e. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

There are 3 total unresolved issues (including 2 from previous reviews).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 28ddc09. Configure here.

? resolveRoofFootprintWorldElevation(currentLevelId, footprintTarget, nodes)
: conicalPlacement?.valid === true
? conicalPlacement.position[1]
: levelY

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Conical draw ghost uses level-local Y

High Severity

The conical draw ghost and footprint outline use resolveConicalRoofPlacement's level-local position[1] while RoofTool renders in building space. Room and curved-wall previews add the active level base back, but the draw path does not, so on any storey above the ground the ghost and outline sit a full level-height too low and no longer match the committed roof.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 28ddc09. Configure here.

@wass08
wass08 merged commit 67ea40e into pascalorg:main Aug 28, 2026
4 checks passed
wass08 added a commit that referenced this pull request Sep 1, 2026
…ment regressions (#752)

* editor: camera follows the level across mode switches and new levels

Switching level presentation (stacked/exploded/solo) never moved the
camera — the level-frame effect only fired on selection change — and a
freshly created level framed at y=0 because the effect read the level
Object3D's position before LevelSystem had lerped it anywhere.

The effect now derives the destination analytically (stacked elevation +
exploded gap, shared with LevelSystem via getLevelPresentationY), watches
levelMode, and skips when already on target — which also swallows the
thumbnail generator's synchronous stacked/restore round-trip.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gQSsJ7nfdARkNH5PcKUjt

* editor: studio snapshot camera polish — capture pill, instant pointer lock, wheel lens + click shutter

- The Studio capbar's preselected crop no longer hides the
  standard/viewport/area pill: preselecting seeds the overlay, and only an
  explicit host lockCrop (the publish cover's exact-shape capture) hides
  the switcher.
- Switching the snapshot camera to walk/drone locks the pointer in the same
  click (flushSync mounts the controls first) instead of demanding a second
  canvas click.
- While walk/drone hold the lock: wheel drives the lens (accumulated
  sub-degree deltas, wheel-up zooms in) and left click fires the shutter
  alongside Enter. Walk's door-toggle click is silenced during capture, and
  the acquiring click can't shoot (shutter gates on the lock being held).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gQSsJ7nfdARkNH5PcKUjt

* editor: fix window on-wall placement preview and opening cursor facing

Two regressions in opening placement:

- #718 rewrote MoveWindowTool to publish drag state through
  useLiveNodeOverrides, including `parentId` — but reparenting is
  structural: the wall's CSG merge and the renderer's nesting walk the
  wall's `children` array, which an override never joins. Placing a window
  preset showed no on-wall preview at all (no cut, no mesh — only the
  override-independent guides), while doors, still on scene writes, worked.
  The wall branch and free-follow now write the scene exactly like
  MoveDoorTool (reparent on host change, direct mesh transform + live
  transforms on same-host slides), and stale overrides are dropped when
  entering the wall mode.

- The door/window PLACEMENT tools still fed `calculateCursorRotation` into
  the cursor and facing triangle — the helper #643 identified as π off and
  migrated every other caller away from. The triangle pointed at the far
  side of the wall on half the walls. Both tools now use the wall-child
  world yaw (`itemRotation - wallAngle`, the move tools' convention), and
  the helper is deleted so nothing can regress onto it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gQSsJ7nfdARkNH5PcKUjt

* editor: capture walk/drone — E opens, Esc pauses, click shoots, drone re-locks

Four snapshot-camera fixes:

- E/R open doors and windows again during capture walk (only the CLICK
  path is capture-gated now — a locked click is the shutter), and the
  walkthrough crosshair (dot → green ring over an interactable) renders in
  the capture overlay, which replaces the walkthrough HUD.
- Esc acts like P in walk/drone: the browser's pointer-lock exit pauses
  (cursor freed, camera and capture kept) instead of bailing to orbit and
  throwing away the framed pose; the overlay only dismisses on Esc from
  orbit. Covers both the keydown path and the no-keydown native unlock.
- The click shutter actually fires: FirstPersonControls' document-capture
  mousedown handler stops propagation while locked, so the overlay's
  listener moves to window-capture (and the door-toggle mousedown yields
  during capture).
- Switching cameras right after freeing the cursor hit the browser's
  ~1.25s re-lock cooldown — the reason drone (only reachable with a free
  cursor) never locked while walk-from-orbit did. The lock helper retries
  once after the cooldown while still framing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gQSsJ7nfdARkNH5PcKUjt

* editor: freeze walk/drone while the shutter renders

From the click/Enter until the saved toast clears, look, walk physics and
drone motion hold still — a late WASD tap or mouse twitch no longer shifts
the frame out from under the shot the user just took.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gQSsJ7nfdARkNH5PcKUjt

* editor: second Esc in capture walk/drone cancels the snapshot

First Esc frees the cursor (pause); with the cursor already free, Esc now
cancels capture — setCaptureMode(false) lands the camera back on orbit —
instead of doing nothing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gQSsJ7nfdARkNH5PcKUjt

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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.

3 participants