Skip to content

slab: add planar slope support (direction and pitch) - #1318

Open
kruschdev wants to merge 5 commits into
pascalorg:mainfrom
kruschdev:feat/sloped-slabs
Open

kruschdev wants to merge 5 commits into
pascalorg:mainfrom
kruschdev:feat/sloped-slabs

Conversation

@kruschdev

@kruschdev kruschdev commented Nov 25, 2026 •

Copy link
Copy Markdown

What does this PR do?

Adds planar sloped slab support for manual solid slabs (ramps, driveways, sloped terraces, and flat-roof drainage falls), following the design suggested in #260 (Relates to #260; leaves roof-driven wall tops open in #260).

  • Schema and pure plane math (@pascal-app/core): Adds optional slope: { direction, pitch } (pitch in 0..45 degrees, direction uphill azimuth in degrees where 0 = +X and 90 = +Z) to SlabNode, keeping legacy flat scenes unchanged (E-003). packages/core/src/systems/slab/slab-slope.ts anchors slab.elevation at the low-edge projection (minProj) of the stored polygon so adding slope or extending the high edge never sinks a ramp below the floor plane, and keeps recessed slabs and reconciler-owned floor plates flat.
  • Position-dependent support, raycasting, and dirtying (@pascal-app/core): Updates selectSlabSupportForItem, SpatialGridManager (getSlabElevationAt, getSlabSupportForItem, getPointedSupportSurface exact analytical ray-plane intersection, getSupportCandidatesForFootprint, getHostSlabElevationForFootprint), floor-placed-elevation, usage-field (floorUnder and approx region tagging), layout-clearance, procedural-items/query, clampSlabElevationForWalls, and spatial-grid-sync dirty triggers so floor-placed items and cursor picks follow the inclined surface live.
  • 3D solid and terrain-fill geometry (@pascal-app/viewer, @pascal-app/nodes): Extrudes coplanar sloped top/bottom caps, sloped outer/hole side walls, and per-vertex sloped fillToTerrain skirts (buildTerrainPerimeterFillGeometry). Keeps top vs. side face splitting clean up to 45 degrees (cos(45°) > 0.5).
  • 2D floor plan, 3D handles, and Inspector UI (@pascal-app/nodes, i18n): Draws an uphill direction arrow on sloped slabs in 2D floor plans, places 3D thickness/base handles on the sloped surface, clears slope when toggling a slab to recessed, and adds a Slope section to SlabPanel (Pitch, Direction, Rotate 90°, Flip 180°, live Grade % and total rise readout, and Flat / Drainage 2% / Ramp 1:12 / Driveway 12% presets) with extracted and compiled Lingui catalogs.
  • IFC export, MCP, and agent authoring (@pascal-app/ifc-converter, @pascal-app/mcp, skills/pascal-3d): Exports sloped slabs as inclined IFCSLAB mesh geometry rather than flat SweptSolid, evaluates node-world-point on the sloped surface centroid, accepts optional slope in author_scene using shared measurement('angle', 'deg') notation, and documents the field in skills/pascal-3d/SKILL.md.

How to test

  1. Select a manual solid slab (or create one via the Slab tool) and open its inspector panel.
  2. In the Slope section, pick a preset (such as Ramp 1:12 or Driveway (12%)) or drag Pitch and Direction: the slab top and underside tilt from the low edge at elevation, Grade updates with the percentage and rise, and Rotate 90° / Flip 180° reorient the uphill direction.
  3. Enable Follows terrain on a sloped ramp: the perimeter fill skirt meets the sloped underside cleanly.
  4. Place floor items or columns at the low, middle, and high ends of the ramp: each lifts to the exact sloped surface height at its plan position and updates immediately when slope changes.
  5. Switch to 2D or Split view: sloped slabs display an uphill direction arrow that flips immediately when Flip 180° is clicked.
  6. Run the automated verification suite I executed:
    • bun run check
    • bun run check-types
    • bun run i18n:check
    • bun run skills:validate
    • bun run check:render-bundle
    • bun run --cwd packages/core test (7,692 pass, 3 skip, 0 fail)
    • bun run --cwd packages/viewer test (1,769 pass, 0 fail)
    • bun run --cwd packages/editor test (2,792 pass, 0 fail)
    • bun run --cwd packages/mcp test (1,576 pass, 0 fail)
    • bun test packages/nodes/src/slab packages/nodes/src/index.test.ts packages/ifc-converter/tests scripts/i18n.test.ts scripts/i18n-provider.test.ts scripts/i18n-literals.test.ts apps/editor/proxy.test.ts
    • bun run --cwd apps/editor build && bun run --cwd apps/editor smoke (8/8 pass)

Screenshots / screen recording

Verified live in Chrome (WebGPU) against the Next.js 16 production build (node next start) with zero console or page errors across 3D, 2D, and Split views:

3D view showing a 12° entry ramp with fillToTerrain skirt meeting a flat upper landing, three columns stepping up the sloped surface, a hosted balustrade railing climbing the ramp, and a 15° sloped terrace with a rectangular cutout:

3D view of sloped ramp with fillToTerrain skirt, stepped columns, hosted railing, and sloped terrace with cutout

2D floor plan and Slab inspector Slope controls (Pitch, Direction, Rotate 90°, Flip 180°, live Grade and rise readout, and presets), with uphill arrows anchored cleanly inside the solid slab regions (avoiding the terrace cutout):

2D floor plan with uphill slope arrows and Slab inspector Slope section

Split 2D + 3D view immediately after clicking Flip 180° (both the 2D uphill arrow and 3D ramp/railing/columns reorient live to 180°):

Split 2D and 3D view after clicking Flip 180°

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
Large cross-cutting change to slab support, wall bases, and spatial grid election; regressions could mis-place items or walls on ramps, though extensive automated tests cover the main paths.

Overview
Introduces optional slope: { direction, pitch } (up to 45°) on manual solid slabs, with elevation anchored at the low edge of the polygon. A new slab-slope module supplies point elevation, ray–plane hits, and max height so the rest of the stack can treat ramps as inclined planes instead of flat tops.

Support and authoring now sample height at each item’s XZ position: spatial grid election, floor-placed elevation, layout clearance, stairs (base and deck rise), fences/railings, wall slab support (including sloped baseSegments / endElevation), elevation clamping against storey-bound walls, sync dirtying when slope changes, and author_scene persistence plus slab_over_wall checks using getSlabMaxElevation.

Product surface: Slab inspector Slope controls (pitch, direction, presets, grade/rise readout), 2D uphill arrows, sloped 3D geometry and terrain fill, fence lift along ramps, IFC export as inclined mesh, MCP centroid on the sloped surface, and i18n strings.

Reviewed by Cursor Bugbot for commit 7ead760. Bugbot is set up for automated code reviews on this repo. 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.

Stale Bugbot comment from a previous run.

- Sample sloped slab surfaces along wall polylines in computeWallSlabSupport
  and emit sloped baseSegments/faceDatum (endElevation) honored by wall CSG cutouts.
- Treat sloped slabs as non-grounded in isFloatingSlab so drawn polygons stay
  verbatim and never expand into adjacent walls or sibling floor seams.
- Guard all reconciler plateRole values (base, platform, sunken) in hasSlabSlope.
- Sample point elevation in stairBaseElevation, resolveStairTotalRise,
  resolveFenceConstructionSupport, fence lift/geometry, and inline slab.railing.
- Harden clampSlabElevationForWalls for steep rise > storeyHeight and add
  clampSlabSlope for inspector pitch/direction edits; remove static [0,360] clamp
  on Direction slider so scrubbing wraps modulo 360.
- Anchor 2D floorplan slope arrows on the widest solid interior chord to avoid
  interior cutouts and concave exteriors.
- Account for slope rise in author-scene slab_over_wall validation.

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

Stale Bugbot comment from a previous run.

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

Stale Bugbot comment from a previous run.

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

There are 4 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 3b6fb67. Configure here.

- Compare pointer-cap maxElevation against the lowest sloped slab point across
  the item/fence footprint (planFootprintCorners) so downhill grabs on a ramp
  do not drop to ground while overhead decks/ramps are still rejected.
- Subtract only the overlapping plane-bound wall local rise in
  clampSlabElevationForWalls, getSlabElevationUpperBound, and clampSlabSlope
  so a wall touching only the low end of a long ramp does not over-clamp.

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.

1 participant