Skip to content

Add StairRun component#85

Merged
madawei2699 merged 1 commit into
mainfrom
codex/stair-run
Jun 16, 2026
Merged

Add StairRun component#85
madawei2699 merged 1 commit into
mainfrom
codex/stair-run

Conversation

@madawei2699

Copy link
Copy Markdown
Contributor

Summary

  • add StairRun for blocky vertical circulation in multi-level builds
  • validate degenerate stair runs and side-rail width with repair hints
  • add a multilevel sample plus ComponentPlan, LLM, and component-design-guide docs

Closes #82

Tests

  • pnpm --filter @i365dev/craftdag-core test
  • pnpm --filter @i365dev/craftdag-core typecheck
  • pnpm lint

@gemini-code-assist gemini-code-assist 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.

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.

Comment thread packages/core/src/componentPlan.ts Outdated
Comment on lines +2533 to +2548
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",
});
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

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  }

@madawei2699 madawei2699 merged commit b2153a9 into main Jun 16, 2026
1 check passed
@madawei2699 madawei2699 deleted the codex/stair-run branch June 16, 2026 09:08
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.

Add StairRun for vertical circulation in multi-level builds

1 participant