Clamp spiral stair openings at full sweep
This commit is contained in:
@@ -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],
|
||||
|
||||
@@ -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],
|
||||
|
||||
Reference in New Issue
Block a user