Skip to content

roof: draw a roof by outline — shed/gable over any outline, canopies, overhangs, roof paint roles - #1028

Open
8Maverik8 wants to merge 1 commit into
pascalorg:mainfrom
8Maverik8:roof-by-outline
Open

8Maverik8 wants to merge 1 commit into
pascalorg:mainfrom
8Maverik8:roof-by-outline

Conversation

@8Maverik8

@8Maverik8 8Maverik8 commented Oct 12, 2026 •

Copy link
Copy Markdown

Continues #1018 ("viewer: nothing passes through a roof"). This branch contains that change as well (with follow-up fixes to the roof clip), so it can either land after #1018 or replace it.

What

  • Outline tool for roofs. Draw a roof segment as a polygon. Points snap to the building's outer contour: outer wall corners and faces of this storey and the one below, slab corners, posts. Partitions are ignored.
  • Shed and gable over any outline. The slope planes cover the drawn polygon, not just its bounding rectangle.
  • Per-side pitch and ridge step on gables. Each side can have its own pitch, and the ridge can step (split-level). Ridge height, ridge position and per-side attic walls are edited from a new "Ridge" section in the panel and from plan handles, measured against the house walls.
  • Canopies. Pull any edge of a segment's covering outwards. The covering continues in the slope's plane while the walls stay on the house. The sides narrow only the added part. Canopy edges snap to the building contour.
  • Overhang drawn on every edge of the outline (eaves and rakes), with fascia and soffit, set by the single Overhang value.
  • Separate roof paint roles: gables, fascia, inside, covering, soffit. Each has its own material slot (ROOF_SLOT_ROLES) and is paintable separately on roofs and segments, including the paint preview.
  • Walls and posts meet the roof. Walls under a roof are cut to its underside, and rise to it when the roof sits above the storey height. Posts end at the underside.
  • Roof clip fixes (on top of viewer: nothing passes through a roof #1018):
    • a storey above a lower roof stays intact;
    • removing a roof restores the clipped geometry;
    • clip planes are normalised before they are moved into mesh space;
    • clip planes face inwards whatever the outline winding.
  • Print solids follow the new shapes: per-side pitches, the gable back and the per-pitch deck overhang.
  • No mouse-wheel edits in panel fields. Metric and slider controls no longer change value on wheel, so scrolling the panel can't edit a value by accident.

Why

Real roofs rarely sit on a rectangle. L-shaped and irregular footprints, porches and terraces under an extended slope, and gables with unequal pitches or a stepped ridge were impossible or needed several hand-aligned segments. Walls poked through the roof or stopped short of it. Fascia and soffit could not be painted apart from the covering.

How tested

  • bun check: no new diagnostics (same warning count as main).
  • bun run check-types for core, nodes, viewer, editor; tsc --noEmit in each package.
  • bun run test in core (4017 pass), nodes (4775), viewer (604), editor (2070). All green; main is green as well.
  • New tests: outline snapping, outline tool, canopy snapping, gable ridge editing and handles, per-side pitches, ridge steps, canopies, abutments, footprint clipping, CSG robustness, paint slots and paint roles, wall fit to the roof, roof clip frame.
  • wall-progressive-budget.test.ts: its @react-three/fiber mock gains addAfterEffect/invalidate stubs, because the wall system now reaches lib/materials.ts through the roof underside.
  • The same changes run in our product's editor, where they were checked by hand on a real house plan. The full app build and e2e of this repository were not run here.

🤖 Generated with Claude Code


Note

High Risk
Large changes to core roof geometry, CSG/material slots, and wall/roof interaction; regressions could affect rendering, clipping, and saved scene compatibility despite broad test coverage.

Overview
Adds outline-based roof placement: click a closed polygon snapped to building contours, then build a gable segment with footprint / optional coverFootprint instead of a plain rectangle.

Gable modeling gains per-side pitch (backPitch), placed ridge (ridgeOffset), stepped ridge (ridgeStep), canopy edge pulls (pullRoofSegmentCoverEdge), and panel/plan/3D ridge edits with gableLocks. Shape math (getGableRidge, withRoofSegmentGableBack) propagates through wall faces, ridge vents, gutters, print solids, and floorplan linework.

Materials split into five paint roles (top, edge, soffit, fascia, wall) via roof-surface-roles and ROOF_SLOT_ROLES; paint patches freeze effective colors so repainting one role does not drag followers.

Editor/product: roof outline tool + floorplan preview, squareEaves / cutAtWallTop toggles, columns shortened to roof underside, metric/slider controls no longer change on mouse wheel.

Continues roof-clip / wall-under-roof behavior from the related branch (per PR description).

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

…nd overhangs PAR-1159

Roof by outline
- Outline tool: draw a roof segment as a polygon; points snap to the
  building's outer contour (outer wall corners and faces of this storey and
  the one below, slab corners, posts), partitions excluded.
- Shed and gable over an arbitrary outline: the slope planes cover the
  drawn polygon, not just its bounding rectangle.
- Gable with a different pitch per side and a ridge step (split-level
  ridge); ridge height, ridge position and per-side attic walls are edited
  from a "Ridge" section in the panel and from plan handles, read against
  the house walls.
- Canopies: pull any edge of a segment's covering outwards; the covering
  continues in the slope's plane while the walls stay on the house. Canopy
  edges snap to the building contour.
- Overhang is drawn on every edge of the outline (eaves and rakes), with
  fascia and soffit geometry.

Paint
- Separate surface roles for the roof: gables, fascia, inside, covering and
  soffit, each in its own material slot (ROOF_SLOT_ROLES) and paintable
  separately on roofs and segments.
- Print solids follow the new shapes: per-side pitches, the gable back and
  the per-pitch deck overhang.

Walls and posts under a roof
- Walls under a roof are cut to the roof's underside (and rise to it when
  the roof is higher than the storey); posts meet the underside.
- Nothing passes through a roof: levels above are clipped by the roof below
  them. Fixes: a storey above a lower roof stays intact, removing a roof
  restores the clipped geometry, and the clip planes use the right frame.

Panel fields
- Metric and slider fields no longer change their value on mouse wheel, so
  scrolling the panel cannot edit a value by accident.

Tests cover outline snapping, the outline tool, canopy snapping, gable ridge
editing and handles, per-side pitches, ridge steps, canopies, abutments,
fascia, footprint clipping, CSG robustness, paint slots, wall fit to the
roof and the roof clip frame.

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

@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 4 potential issues.

Fix All in Cursor

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

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 594fba1. Configure here.

slopes: slopeArrows(seg).map((arrow, index) => ({
tail: tp(arrow.tail[0], arrow.tail[1]),
head: tp(arrow.head[0], arrow.head[1]),
pitch,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Floorplan ignores drawn roof outline

High Severity

Outline-drawn roofs still plot as their bounding rectangle. buildSegPlan and buildRoofSegmentFloorplan use width/depth (and getRoofSegmentVisibleTopBounds) instead of footprint or coverFootprint, so an L-shaped roof shows a full rectangle for both the wall line and the drip edge.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 594fba1. Configure here.

// The covering follows what it covers: plumb here, or square to each slope
// (square eaves, cutSlabsSquare).
if (cover && slabs && !hasSquareEaves(segment)) {
clips.push(['shinSlab', cover, roofExtension], ['deckSlab', cover, roofExtension])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Clip uses only front-pitch overhang

Medium Severity

Footprint clipping and underside polygons offset the cover ring by overhang * cosTheta from the front slope only. On an uneven gable the back eave is built with a different horizontal reach, then cut (or fitted) to the front pitch’s offset.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 594fba1. Configure here.

<>
{/* drawn over an outline the outline sets the size: its edges pull out as
canopies, a rectangle of its own would only cut it */}
{!canPullCanopy(node) && (

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Outline sheds still resize the rectangle

Medium Severity

Width and depth stay editable for an outline shed. The panel hides those controls only when canPullCanopy is true (sloped gables), and non-gable handles still resize the bounding rectangle without updating footprint.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 594fba1. Configure here.

start: [minX, 0],
end: [maxX, 0],
start: [minX, ridgeZ],
end: [maxX, ridgeZ],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ridge vent spans the bounding box

Medium Severity

Auto ridge vents still run from minX to maxX of getRoofSegmentVisibleTopBounds, which is the unclipped rectangle. On an outline gable that line crosses the cut-away part of the polygon, so the vent hangs in open air.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 594fba1. Configure here.

Copy link
Copy Markdown
Member

Thanks @8Maverik8, we really like where this is going. Roofs by outline, canopies and per-side pitches would be a big step up.

This PR adds a lot of visible behavior, so could you add a few screenshots or a short screen recording? Please show:

  • drawing a roof with the outline tool on an L-shaped or irregular footprint
  • a gable with unequal pitches or a stepped ridge, and the new Ridge panel and plan handles
  • pulling out a canopy edge
  • the separate paint roles: covering, fascia, soffit and gables
  • walls and posts meeting the roof underside

The branch also has conflicts with main now. Could you rebase or merge main in when you update it? Since this builds on #1018, please also tell us whether it should replace that PR or land after it.

Copy link
Copy Markdown
Member

Friendly check-in @8Maverik8: we're still keen on outline roofs. The open ask is the screenshots or short recording from my last comment (outline roof on an L-shaped plan, a canopy, per-side overhangs). The branch has also fallen behind main, so a rebase would help. Let us know if you're still working on it.

@Aymericr Aymericr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[Maintainer] Thanks @8Maverik8, this is a lot of careful roof work and the description is clear. Triaged at 594fba1.

Where this stands:

  1. Conflicts. The branch conflicts with main (merge state dirty) and is a single commit of about +7.5k / -0.7k across 66 files. It also carries #1018 inside it. Please rebase on main; if #1018 has landed or is still open, say which of the two should go first so we do not review the same change twice.
  2. Size. This is too big to review safely as one change. I would like it split along your own list: (a) the roof clip fixes (if not already covered by #1018), (b) the outline drawing tool for shed/gable roofs, (c) canopies and per-side overhang, (d) the separate roof paint roles (ROOF_SLOT_ROLES), (e) walls and posts meeting the roof underside. Each can land separately and each can be tested separately.
  3. Bugbot. Four findings are open on this head. Please look at each one and reply with fixed / not-an-issue and why.
  4. Stored format. Per-side pitch, ridge step, canopy edges and the new roof paint roles change what is saved on roof nodes. Please state which fields are new, that they are optional with safe defaults so an older scene opens unchanged, and add a test that loads a legacy roof.
  5. Proof. There are no screenshots in the description. For this much visible behavior I need before/after screenshots or a recording of: drawing an outline roof, a gable with a stepped ridge, a canopy, and paint roles.

I am not blocking the direction. A rebase plus the first slice is the best way to move it forward.

Aymericr commented Dec 3, 2026

Copy link
Copy Markdown
Member

Review at 594fba1e, run with Codex (gpt-6.2-astra) over two rounds: a full review, then each finding re-checked against the diff. Only findings that survived are listed.

  • P1 CONFIRMED packages/viewer/src/systems/roof/roof-underside.ts:121 — The clip height uses level.baseY + roof.position[1] + seg.position[1] + point.y. The outline tool stores roof Y as 0, sets support: { kind: 'walls' }, and keeps the roof on the walls’ level when no level exists above. The clip therefore omits the lift that seats the visible roof on those walls. Fix: Use the same resolved support elevation for rendering and clipping; test a single-storey wall-supported roof.
  • P1 CONFIRMED packages/viewer/src/systems/roof/roof-system.tsx:1557 — growAxisRing stores one covered entry per X/Z grid cell. Every cell calls near, whose inside test scans every ring edge. With linearly many distinct coordinates on each axis, this takes cubic time and quadratic storage; the footprint schema has a minimum vertex count but no maximum. Fix: Enforce a complexity budget before grid generation, or replace the grid-based offset.
  • P1 CONFIRMED packages/editor/src/lib/print-roof-solids.ts:606 — buildRoofModuleGeometry receives four face sets derived from segment width and depth. None is clipped to footprint or coverFootprint, so an L-shaped gable exports across its missing corner and a pulled canopy uses the enlarged rectangle for its walls. Fix: Clip printable walls and covering to their respective outlines, or block export with a diagnostic until supported.
  • P2 CONFIRMED packages/viewer/src/systems/roof/roof-system.tsx:2466 — With cutAtWallTop, clipPlanarPolygon(face, (point) => point.y) removes the entire below-plate portion before the cover outline is applied. The visible deck subtracts only the wall-outline prism, so an exterior canopy can remain visible without an underside patch to cap its post. Fix: Remove below-plate patches only inside the wall outline.
  • P2 CONFIRMED packages/core/src/schema/nodes/roof-segment-canopy.ts:255 — A pull translates the segment origin but subtracts the translation only from the wall and cover rings. The floorplan commit at packages/nodes/src/roof-segment/floorplan-affordances.ts:271 updates only segmentId. A hosted child with unchanged segment-local coordinates consequently moves in world space. Fix: Keep the segment frame fixed or compensate hosted child coordinates in the same transaction.
  • P2 CONFIRMED packages/editor/src/lib/material-paint.ts:111 — On first edge paint, current(role) supplies no material or preset for an unpainted soffit or fascia. Both then resolve through ROLE_FALLBACK to the newly painted edge. On a segment, that local fallback also takes precedence over the parent’s role material. Fix: Represent theme or parent inheritance separately from legacy edge fallback; test first paint in both cases.
  • P2 CONFIRMED packages/core/src/schema/nodes/ridge-vent.ts:203 — The gable branch checks only whether ridgeZ lies between minZ and maxZ, then emits one vent from minX to maxX. A notch splitting the ridge into two covered intervals is bridged by that vent. Fix: Intersect the ridge line with the effective cover and emit one vent per covered interval.
  • P2 CONFIRMED packages/core/src/schema/nodes/roof-segment-canopy.ts:231 — Math.max(limit, distance) enforces only an inward limit. A positive pull into a U-shaped courtyard can pass the opposite arm; tidyRing removes adjacent repeats and backtracks, not nonadjacent crossings. Fix: Stop at the first outward collision or union the swept area and validate the resulting cover.
  • P2 CONFIRMED packages/viewer/src/systems/roof/roof-clip.ts:278 — Cleanup restores a tracked mesh only if !mesh.parent. Detaching its enclosing group leaves that parent intact, but removes the mesh from level traversal. While roofs remain, clippedMeshes retains the mesh and its cut geometry. Fix: Restore tracked meshes no longer beneath a registered level and drain the set on teardown.
  • P2 CONFIRMED packages/viewer/src/systems/roof/roof-clip.ts:200 — The loop processes each full group without intersecting it with source.drawRange. Once clipping changes a triangle, surviving triangles outside the original range are copied into a new geometry with no draw restriction. Fix: Intersect group ranges with the source draw range before clipping; test a partially drawn indexed mesh.
  • P2 CONFIRMED packages/nodes/src/roof/outline-tool.tsx:100 — The commit checks only outline.length < 3, and the footprint schema accepts any three or more coordinate pairs. A zero-area bow-tie is stored, but the viewer’s area check rejects it and skips footprint clipping, leaving the bounding rectangle. Fix: Require a simple, nonzero-area ring at commit and import, and leave an invalid draft editable.
  • P2 CONFIRMED packages/nodes/src/roof-segment/canopy-snap.ts:71 — Object.values(nodes) gathers slabs from every building and storey. Their raw polygon coordinates are passed to planToSegment as if they belonged to the active level, so an unrelated slab edge can win the snap. Fix: Scope candidates to the intended building and storeys, then compare them in a common frame.

This changes visible UI, so please attach before/after screenshots or a short clip.

P0/P1: 3. Those need fixing before this can land. CI hasn't run on this fork PR yet because it needs a maintainer to approve the workflow run; it merges once that's green.

This branch has not been deployed

No deployments
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