Skip to content

feat(wall): add endHeightOffset for sloped top edge - #640

Closed
vducasse wants to merge 4 commits into
pascalorg:mainfrom
vducasse:feat/wall-end-height
Closed

vducasse wants to merge 4 commits into
pascalorg:mainfrom
vducasse:feat/wall-end-height

Conversation

@vducasse

@vducasse vducasse commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds an endHeightOffset property to the WallNode schema to allow wall extremities to have different heights (e.g., for creating a knee wall following a single-pitch roof slope). This adds an "End height offset" slider to the wall properties panel and updates the geometry generation to apply the slope along the top edge of the wall.

Relates to #260 (sloped elements).

How to test

  1. Open a scene in the editor and draw a standard wall.
  2. Select the wall to open the properties panel.
  3. Under the dimensions/properties, look for the new End height offset slider.
  4. Adjust the slider and verify that the top edge of the wall tilts smoothly between the start and end points.

Screenshots / screen recording

image image image image

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
Broad changes to wall height resolution, viewer extrusion/CSG, and opening placement across core, editor, and nodes; behavior is heavily tested but regressions in plane-bound walls or wall-hosted items are plausible.

Overview
Adds endHeightOffset on walls so the top edge can slope linearly from start to end (knee walls / single-pitch roofs), with an End height offset slider on the wall panel and clamping so the low end never collapses below 0.01 m.

Core & rendering: resolveWallTop / resolveWallEffectiveHeight and getWallEffectiveHeightForNodes now take parametric t along the wall; the viewer tilts extruded tops via applyWallEndHeightSlope, caps door/window CSG to the sloped cap, and extends face bands, crown trim, and room/level height logic to use start/end or per-sample heights. Spatial-grid wall placement uses the minimum effective height across the item’s along-wall span; sync invalidates when slope-related wall fields change.

Openings & editor: Doors and windows clamp and resize against sloped ceilings (readHostWallCeiling at multiple S positions, readHostWallCeilingMaxWidth, fits on clampToWall); measurement overlays, snap highlights, and elevation guides follow the tilted top. Print rejects sloped walls with unsupported_wall_print_slope.

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

Comment thread packages/nodes/src/wall/panel.tsx Resolved
@vducasse
vducasse force-pushed the feat/wall-end-height branch from cf8f12c to 7200ea6 Compare August 17, 2026 10:33
@vducasse
vducasse force-pushed the feat/wall-end-height branch from 7200ea6 to 8910206 Compare August 17, 2026 11:07
@vducasse
vducasse force-pushed the feat/wall-end-height branch from 8910206 to 6a53abd Compare August 17, 2026 11:29
Comment thread packages/nodes/src/wall/paint.ts Resolved
@vducasse
vducasse force-pushed the feat/wall-end-height branch from 6a53abd to f250e10 Compare August 17, 2026 11:43
Comment thread packages/nodes/src/door/door-math.ts Resolved
@vducasse
vducasse force-pushed the feat/wall-end-height branch from f250e10 to d2b2045 Compare August 17, 2026 12:15
@vducasse
vducasse force-pushed the feat/wall-end-height branch from d2b2045 to a51d552 Compare August 17, 2026 12:48
@vducasse
vducasse force-pushed the feat/wall-end-height branch 3 times, most recently from 8cedc3a to bda880e Compare August 18, 2026 08:31
Comment thread packages/nodes/src/wall/panel.tsx Resolved
@vducasse
vducasse force-pushed the feat/wall-end-height branch from bda880e to 4eb816b Compare August 18, 2026 08:46
Comment thread packages/nodes/src/wall/treatments.tsx Resolved
Comment thread packages/nodes/src/wall/treatments.tsx Resolved
@vducasse
vducasse force-pushed the feat/wall-end-height branch from d19ca3c to 73902b5 Compare August 29, 2026 14:08
Comment thread packages/nodes/src/wall/panel.tsx Resolved
@vducasse
vducasse force-pushed the feat/wall-end-height branch from 73902b5 to 1195d3f Compare August 29, 2026 15:00
@vducasse
vducasse force-pushed the feat/wall-end-height branch from 1195d3f to 31ab927 Compare August 29, 2026 18:33
Comment thread packages/nodes/src/wall/panel.tsx Resolved
@vducasse
vducasse force-pushed the feat/wall-end-height branch from 31ab927 to 763d38a Compare August 30, 2026 07:35
@vducasse
vducasse requested a review from Aymericr August 30, 2026 07:36
@vducasse
vducasse force-pushed the feat/wall-end-height branch from 763d38a to 4b7e5b0 Compare August 30, 2026 08:29
@vducasse

vducasse commented Aug 30, 2026 via email

Copy link
Copy Markdown
Contributor Author

@Aymericr

Copy link
Copy Markdown
Member

Answering the product question first: the slider stays. Knee walls under stairs, stepped parapets, landscaping walls — you're right that there's no roof plane to derive from in those cases, and that's exactly the argument I asked for. Roof-driven automation stays a follow-up that sets endHeightOffset from getRoofOuterSurfaceFrameAtPoint; the schema you've built is the right substrate for it. For walls that are under a roof, the desync risk I flagged is real but acceptable as a manual-control tradeoff — we'll revisit when the follow-up lands.

I verified the branch against every item from my review. The good news: R2 (band split planes clamped to effectiveWallHeight + max(0, endHeightOffset), slope baked before splitting, groups re-sorted), R3 (#702's ground branch survived byte-for-byte), C2 (the new wall-top tests cover the clamp, t=0/0.5/1, and the plane-bound case), C3 (the analytic fit — I checked the interval algebra for both slope signs and the degenerate cases; it's correct, and the fits: false gating is wired at all call sites), C4, C5, C6: all genuinely done. The trapezoid t = 0.5 for zone quantities is exactly right.

What's still red, all fixable in one push:

  1. The branch doesn't compile. use-editor.tsx:1490 passes movingNodeType into snapContextOf, but snapping-mode.ts never gained that property — TS2353, which is your cli-smoke failure. It looks like half of a snapping change fell out in the rebase (the test grew door/window profiles; the implementation didn't). Finish it or drop both halves.
  2. quality is red on formatting — 7 biome errors, zero-indent lines in door/floorplan-move.ts, door/tool.tsx, window/definition.ts and an uncollapsed call in wall-system.tsx:1338. Patch-application artifacts; bun run check --write.
  3. A rebase casualty deleted a main feature: both door and window move-tool.tsx lost the dragAnchor/grabWallId grab-offset preservation from the snapping overhaul — moved openings now always center under the cursor. Restore it, or tell me why it had to go.
  4. The offset slider swapped max: 3 for max: metersToLinearUnit(1000, unit) — per wiki/architecture/inspector-field-limits.md, offsets get no static max at all (the 1000 sentinel is for dimension fields). Keep the dynamic min, drop the max.
  5. C1 is done at the API layer but the hazard moved up one floor: getWallEffectiveHeightForNodes (spatial-grid-manager.ts:1311) gained a defaulted t = 0, and resolveWallOpeningCeiling has optional t — a dozen wrapper callers silently evaluate at the start end, which is the exact silent-flat-wall pattern making t required was meant to kill. Make them required too; the compile errors will point at every caller that needs a decision.

The core geometry work here is solid and the review items were taken seriously — this is close. One push covering the five above and I'll do the final pass.

@vducasse

vducasse commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the clear feedback and guidance @Aymericr! All 5 items have been addressed in this push:

  1. Compilation (TS2353): Removed movingNodeType and the unused import from use-editor.tsx (useInteractionScope already passes nodeType via scope).
  2. Quality / Biome: Formatted all 7 files; Biome checks pass with 0 errors.
  3. Grab-Offset Preservation: Restored dragAnchor and grabWallId in door/move-tool.tsx and window/move-tool.tsx while preserving the new sloped-wall fits check.
  4. Inspector Slider Limits: Dropped the static max: 1000 clamp from the endHeightOffset slider per inspector-field-limits.md, keeping only the dynamic min.
  5. Strict t Parametric Typing: Made t: number strictly required in getWallEffectiveHeightForNodes, getWallHeight, and resolveWallOpeningCeiling, and updated all call sites across core, editor, and nodes with explicit domain evaluations (t = 0, t = 0.5, or Math.max(t = 0, t = 1)).

Full quality check (bun run checks), production build (bun run build), and test suite (bun test) are green. Ready for the final pass!

Ducasse, Vincent (external) and others added 3 commits September 1, 2026 13:58
- **Schema & Core Systems**:
  - Add endHeightOffset property to WallNode schema with default 0.
  - Update resolveWallTop and resolveWallOpeningCeiling to support
    parametric height sampling along sloped top edges.
  - Update getWallFaceBandConfig and getWallFaceBandForHeight to
    scale with maximum sloped wall height.
  - Update spatial grid synchronization, space detection, and level
    height calculations for sloped walls.

- **3D Geometry & Viewer Systems**:
  - Add applyWallEndHeightSlope in wall-system to evaluate planar slope
    continuously across miter extensions without creases.
  - Update getWallBandSplitPlanes to split horizontal face bands across
    the full sloped wall envelope.
  - Update treatments to clamp slope offsets against minimum height,
    omit trims on low walls, and make cutouts slope-aware.

- **Openings & Floorplan Tools**:
  - Update door and window ceiling clearance math, floorplan move
    handlers, and 3D move tools to respect sloped wall height.
  - Fix resolveWallRole in paint to resolve face bands by elevation Y,
    ensuring 1:1 parity with 3D mesh horizontal band splits.
  - Update 3D opening head clearance guides to sample minimum ceiling
    across the opening width.
  - Update elevation guides, measurement features with chord-projected
    t for curved walls, side move handles, and snap beacons.
@vducasse
vducasse force-pushed the feat/wall-end-height branch from 48dedb2 to 40a1800 Compare September 1, 2026 12:04

@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.

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 40a1800. Configure here.

@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.

One current blocker remains after the five requested fixes: printable wall export still flattens endHeightOffset. preparedWallHeight samples only t = 0, then buildPrintableWallSolids emits a flat prism; unlike stepped bases, sloped tops are not rejected. That means STL/print output can silently disagree with the editor mesh. Please either teach the print-solid path the two endpoint heights and cover it with a regression, or fail the print preflight explicitly for sloped walls until that geometry is supported. I’m adding ready-for-human as well because the accepted manual-slider behavior and its future roof-driven synchronization remain a product choice worth a final maintainer look.

@Aymericr Aymericr added the ready-for-human Needs human input during execution label Sep 12, 2026
@vducasse

Copy link
Copy Markdown
Contributor Author

Hi @Aymericr,

Commit f12f6c1b was pushed to address this: it explicitly rejects sloped walls during print preflight with an unsupported_wall_print_slope diagnostic (matching the behavior of stepped bases and non-planar curves), preventing any silent export discrepancies.

I don't currently have the time to build and validate the full 3D print solid generation in this PR, but I plan to work on it and submit it as a dedicated follow-up.

All quality checks, typechecks, and tests are green. Ready for your final pass!

@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.

Thanks @vducasse for sticking with this through a long review, and sorry the final pass took over a month.

I re-checked the branch against the open items:

  • The Sep 1 fixes are in: TS2353 cleanup, Biome formatting, dragAnchor/grabWallId restored in the door and window move tools alongside the new fits check, the static slider max dropped, and t required in getWallEffectiveHeightForNodes, getWallHeight and resolveWallOpeningCeiling.
  • f12f6c1b makes print preflight reject sloped walls with unsupported_wall_print_slope, in both print-shell-compiler and buildPrintableWallSolids, with a test. That's the right stopgap until there's a real sloped printable solid, and a follow-up PR for that would be very welcome.

From my side the code is good to go. Two things remain:

  1. The branch now conflicts with main (a lot has landed since September). Could you merge main in (please merge, not rebase/force-push)? Wall, opening and print code have all moved, so it's worth rerunning the wall-top and opening tests after.
  2. CI for fork PRs needs a maintainer to approve the workflow run.

Since this is a visual feature, @Aymericr makes the final merge call once it's up to date and green.

@Aymericr Aymericr added enhancement New feature or request bot:bugs labels Oct 23, 2026 — with Cursor

Copy link
Copy Markdown
Member

Thanks again @vducasse. Your sloped-wall work landed on main in #1248, which ports this PR onto current main with a few review fixes on top. Your commits kept their authorship and you're credited as co-author. Since this branch is now 880+ commits behind and fully covered by #1248, I'm closing it to keep the queue tidy.

The roof-driven follow-up you mentioned, setting endHeightOffset from the roof surface, would be very welcome as a fresh PR on top of main. Thanks for pushing this primitive through!

@Aymericr Aymericr closed this Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:bugs enhancement New feature or request ready-for-human Needs human input during execution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants