Clamp spiral stair openings at full sweep

This commit is contained in:
sudhir
2026-05-20 00:45:28 +00:00
committed by open-pascal
parent 3800bd7fc8
commit cdde88f9c0
3 changed files with 62 additions and 55 deletions
@@ -83,6 +83,14 @@ function getNormalizedFloorplanStairSweepAngle(stair: StairNode) {
return baseSweepAngle
}
function clampFloorplanCircularSweepAngle(sweepAngle: number) {
if (Math.abs(sweepAngle) >= Math.PI * 2) {
return Math.sign(sweepAngle || 1) * (Math.PI * 2 - 0.001)
}
return sweepAngle
}
function getFloorplanStairStepCount(stair: StairNode, minimum: number) {
return Math.max(minimum, Math.round(stair.stepCount ?? 10))
}
@@ -139,7 +147,10 @@ export const FloorplanStairLayer = memo(function FloorplanStairLayer({
const sectorStartAngle = -stair.rotation - normalizedSweepAngle / 2
const sectorEndAngle = sectorStartAngle + normalizedSweepAngle
const spiralLandingSweep = getFloorplanSpiralLandingSweep(stair, normalizedSweepAngle)
const visualSectorEndAngle = sectorEndAngle + spiralLandingSweep
const visualSweepAngle = clampFloorplanCircularSweepAngle(
normalizedSweepAngle + spiralLandingSweep,
)
const visualSectorEndAngle = sectorStartAngle + visualSweepAngle
const stairCenter = {
x: stair.position[0],
y: stair.position[2],
+12 -1
View File
@@ -209,6 +209,14 @@ function getNormalizedFloorplanStairSweepAngle(stair: StairNode) {
return baseSweepAngle
}
function clampFloorplanCircularSweepAngle(sweepAngle: number) {
if (Math.abs(sweepAngle) >= Math.PI * 2) {
return Math.sign(sweepAngle || 1) * (Math.PI * 2 - 0.001)
}
return sweepAngle
}
function getFloorplanSpiralLandingSweep(stair: StairNode, sweepAngle: number) {
if (
(stair.stairType ?? 'straight') !== 'spiral' ||
@@ -230,8 +238,11 @@ function getFloorplanSpiralLandingSweep(stair: StairNode, sweepAngle: number) {
function getFloorplanCurvedStairHitPolygon(stair: StairNode): Point2D[] {
const stairType = stair.stairType ?? 'straight'
const sweepAngle = getNormalizedFloorplanStairSweepAngle(stair)
const visualSweepAngle = clampFloorplanCircularSweepAngle(
sweepAngle + getFloorplanSpiralLandingSweep(stair, sweepAngle),
)
const startAngle = -stair.rotation - sweepAngle / 2
const endAngle = startAngle + sweepAngle + getFloorplanSpiralLandingSweep(stair, sweepAngle)
const endAngle = startAngle + visualSweepAngle
const center = {
x: stair.position[0],
y: stair.position[2],