Repository navigation
Conversation
Aymericr
left a comment
There was a problem hiding this comment.
[Maintainer] Thanks @kruschdev. A planar ground slope, a slope brush and a two-point grade picker is a useful, self-contained terrain tool, and the screenshots are in the description. Status at 96f3115:
- Merge conflicts. The branch is
dirtyagainstmain; please rebase. - Overlap, needs a decision. #1288 (AxiomeCG, a draft for discussion) proposes a different stored representation of ground (
terrain-tileheight samples plusterrain-breakandrampkinds) and a draped slab. A planar slope stored on the site would sit next to, and possibly conflict with, that. Before this goes further, we need the team to decide which representation of non-flat ground we are committing to, because both end up in saved scenes. I will raise it with the team; in the meantime please do not invest in more rework here. - This PR does not link an issue; if it is meant to address one, add
Fixes #<n>orPart of #<n>.
CI: GitHub Actions have not run on this head (fork workflows are waiting for maintainer approval).
|
Thanks @Aymericr! That makes sense while the team decides on the terrain direction with #1288. Quick note for context: #1321 didn't add any new saved fields on |
What does this PR do?
Adds deterministic ground slope and elevation controls to the existing terrain heightfield (
site.terrain) with zero schema changes, complementing the existingraise,lower,flatten, andsmoothsculpting verbs.@pascal-app/core): Addspackages/core/src/lib/terrain-slope.tswithclampTerrainSlopePitch(0..45°),normalizeTerrainSlopeDirection(0° = +X,90° = +Z),terrainSlopeGradePercent,compileTerrainSlopePlane(hoisting trig out of per-sample loops),resolveLotSlopePlane(centerdatum anchor matching USGS DEM imports orlow-edgeanchor),terrainSlopeBaseElevationForPlane,terrainSlopeElevationRange,deriveTerrainSlopeFromPoints, andbuildSlopedTerrainField.slopebrush verb (@pascal-app/core): ExtendsTerrainVerbinpackages/core/src/lib/terrain-brush.tswith'slope'using the same saturating snapshot-and-falloff kernel (re-crossing strokes never compound). ExportsBaseTerrainVerbsouseEditor.terrainVerbstays narrowed to the four original verbs for full type and runtime compatibility with@webxr/plugin, while editor consumers readselectActiveTerrainVerbandsetActiveTerrainVerb.@pascal-app/editor,i18n):slopeSite(grades the full padded heightfield in a single undo step and drops in-flight live strokes) andresolveSlopeStrokePlaneinpackages/editor/src/lib/terrain-sculpt.ts.#14b8a6) brush ring color, a draped uphill direction arrow inside the brush ring (hidden when pitch is0°), an amber A -> B guide line, and a live grade%readout in the cursor pill during two-point picking (TerrainBrushCursor).TerrainSculptPanel(Flat,2%,5%,1:12, and12%presets,Pitch, wrappingDirectionwithRotate 90°andFlip 180°,Elevation,Anchor: Center/Low edge, liveGrade %and lot elevation range readout, two-pointPick A -> Beyedropper with locked anchor indicator, andSlope lot), updatesuseTerrainPanelRows, and extracts/compiles Lingui catalogs across all 5 locales.How to test
5%or12%) or adjust Pitch, Direction (Rotate 90°/Flip 180°), Elevation, and Anchor (CentervsLow edge), then click Slope lot. Verify the terrain grades smoothly across the lot, the readout shows the exact grade%and min-to-max elevation range, andCtrl+Z/Cmd+Zundoes it in a single step.0°is selected). Drag across the lot to locally grade along the inclined plane.%pill), and click to lock the derived pitch, direction, lot base elevation, and plane anchor.bun run check(0 errors across 4,595 files)bun run check-types(14/14 packages pass, includingapps/editorand@webxr/plugin)bun run i18n:check(5/5 catalogs in sync, literal guard pass)bun run skills:validate(75/75 pass)bun test packages/core/src/lib/terrain*.test.ts packages/core/src/store/use-live-terrain.test.ts(147/147 pass)bun run --cwd packages/core test(7,688 pass, 3 skip, 0 fail)bun run --cwd packages/editor test(2,797 pass, 0 fail)bun test scripts/i18n.test.ts scripts/i18n-provider.test.ts scripts/i18n-literals.test.ts apps/editor/proxy.test.ts(81/81 pass)bun run --cwd apps/editor build && bun run --cwd apps/editor smoke(8/8 pass)bun run check:render-bundle(pass)Screenshots / screen recording
Verified live in Chrome against the Next.js 16 production build with 0 console or page errors:
1. Whole-lot planar grading (
Slope lot) on a 12% hillside lot: shows the Slope panel controls (Flat / 2% / 5% / 1:12 / 12%presets,Pitch,DirectionwithRotate 90°/Flip 180°,Elevation,Anchor: Center/Low edge, liveGrade 11.9%and0'0" -> 9'5"range readout, andSlope lot), 3D topographic contours, a hillside pavilion withfillToTerraindeck foundation, and the teal brush ring with draped uphill direction arrow and elevation pill.2. Two-point
A -> Bgrade picker on a terraced hillside ramp: clicking near the foot of the carved ramp and moving uphill drapes the amberA -> Bguide line and brush ring across the terrain, displays the live elevation and grade readout pill (H 3'7" · 8.6%), and shows the contextualPick end point to match slopeHUD prompt.3. Locked
A -> Banchor and rotatedSlopebrush: completing point B locks the derivedPitch(4.9°),Direction(302°),Elevation(3.87ft), andAnchored at 0'0" [x Clear]plane reference in the sidebar, rotating the teal brush ring's draped uphill arrow to match the picked slope for local touch-up strokes.Checklist
bun devbun checkto verify)mainbranchNote
Medium Risk
Touches core terrain heightfield mutation and editor pointer/state flows; scope is additive with tests, but incorrect slope math or stroke plane resolution could visibly corrupt site terrain.
Overview
Adds a slope terrain sculpt verb on top of the existing heightfield brush pipeline, plus pure planar slope math in
@pascal-app/core.The core layer introduces
terrain-slope.ts(pitch/direction clamping, lot plane resolution with center vs low-edge anchors, two-pointderiveTerrainSlopeFromPoints, andbuildSlopedTerrainFieldfor whole-field grading).terrain-brushextends strokes with aslopeverb that lerps brushed samples toward a compiled inclined plane using the same non-compounding mask as flatten.The editor wires slope through sculpt state (
terrainSlope, A→B pick anchor,selectActiveTerrainVerb/setActiveTerrainVerbsoterrainVerbstays narrowed for WebXR),slopeSiteandresolveSlopeStrokePlane, panel controls (presets, pitch/direction/elevation, Slope lot), cursor feedback (uphill arrow, pick guide line, live grade %), HUD/i18n, and teal ring color for the new verb.Reviewed by Cursor Bugbot for commit 96f3115. Bugbot is set up for automated code reviews on this repo. Configure here.