Add StairRun component#85
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the StairRun component type to support blocky vertical circulation in multi-level builds, updating the design guides, schemas, validation logic, and tests accordingly. The review feedback identifies a critical bug in the step placement calculations where non-integer step divisions can result in gaps at the top or bottom of the staircase, and provides an elegant fix using interval partitioning to distribute step depths evenly.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| const treadDepth = Math.max(1, Math.floor(runLength / size.height)); | ||
| const placements: Array<{ part: string; anchor: { x: number; y: number; z: number }; size: ComponentSize; materialRole: string; materialFallback: string }> = []; | ||
|
|
||
| for (let step = 0; step < size.height; step += 1) { | ||
| const start = direction === "positive" | ||
| ? step * treadDepth | ||
| : runLength - (step + 1) * treadDepth; | ||
| const clampedStart = Math.max(0, Math.min(runLength - treadDepth, start)); | ||
| placements.push({ | ||
| part: `step_${step}`, | ||
| anchor: stairPlacementAnchor(anchor, axis, clampedStart, 0, step), | ||
| size: stairPlacementSize(axis, treadDepth, 1, crossWidth), | ||
| materialRole: "main", | ||
| materialFallback: "floor", | ||
| }); | ||
| } |
There was a problem hiding this comment.
When the runLength of a StairRun is not a perfect multiple of its height, the integer division Math.floor(runLength / size.height) leaves a remainder. This results in a gap at the top (or bottom) of the staircase where no steps are generated, which can cause players to fall through or prevent the stairs from connecting to the upper landing.\n\nWe can elegantly solve this by dynamically distributing the step depths across the entire runLength using standard interval partitioning. This guarantees that the staircase perfectly spans the entire run length with zero gaps, regardless of the dimensions.
const placements: Array<{ part: string; anchor: { x: number; y: number; z: number }; size: ComponentSize; materialRole: string; materialFallback: string }> = [];\n\n for (let step = 0; step < size.height; step += 1) {\n const stepStart = Math.floor((step * runLength) / size.height);\n const stepEnd = Math.floor(((step + 1) * runLength) / size.height);\n const currentTreadDepth = stepEnd - stepStart;\n const start = direction === "positive" ? stepStart : runLength - stepEnd;\n placements.push({\n part: `step_${step}`,\n anchor: stairPlacementAnchor(anchor, axis, start, 0, step),\n size: stairPlacementSize(axis, currentTreadDepth, 1, crossWidth),\n materialRole: "main",\n materialFallback: "floor",\n });\n }2f52892 to
91ecbcf
Compare
Summary
Closes #82
Tests