fix: учесть направление ступеней и защитить совместимость (#663)

Issue: #663
User-Visible: yes
This commit is contained in:
Sergey Matyunin
2026-09-27 01:14:46 +03:00
parent 3f8aae838f
commit d64338224d
5 changed files with 74 additions and 5 deletions
+4 -3
View File
@@ -148,17 +148,18 @@ export function stairRenderGeometry(
const outline = stairOutline(stair, scale);
const treadN = cmToNorm(STAIR_TREAD_CM, cellCm);
if (stair.kind === 'straight') {
const forward = stair.direction === 'forward';
const count = Math.max(0, Math.floor(stair.length / treadN));
const treads: StairLine[] = [];
for (let index = 1; index <= count; index++) {
const x = -stair.length / 2 + index * treadN;
if (x >= stair.length / 2 - 1e-10) break;
const x = (forward ? -1 : 1) * stair.length / 2
+ (forward ? 1 : -1) * index * treadN;
if (forward ? x >= stair.length / 2 - 1e-10 : x <= -stair.length / 2 + 1e-10) break;
treads.push({
a: worldPoint(stair, x, -stair.width / 2, scale),
b: worldPoint(stair, x, stair.width / 2, scale),
});
}
const forward = stair.direction === 'forward';
const fromX = (forward ? -0.3 : 0.3) * stair.length;
const toX = (forward ? 0.3 : -0.3) * stair.length;
const from = worldPoint(stair, fromX, 0, scale);