Refine stair slab opening placement
This commit is contained in:
@@ -437,16 +437,10 @@ function getStraightOpeningPolygonsForSurface(
|
|||||||
const segmentTopElevation = layout.topElevation
|
const segmentTopElevation = layout.topElevation
|
||||||
|
|
||||||
if (segment.segmentType === 'stair') {
|
if (segment.segmentType === 'stair') {
|
||||||
const minElevation = Math.min(segmentStartElevation, segmentTopElevation) - targetThreshold
|
if (Math.abs(targetElevation - segmentTopElevation) <= targetThreshold) {
|
||||||
const maxElevation = Math.max(segmentStartElevation, segmentTopElevation) + targetThreshold
|
|
||||||
|
|
||||||
if (targetElevation >= minElevation && targetElevation <= maxElevation) {
|
|
||||||
const openingDepth = getStraightFlightOpeningDepth(stair, segment)
|
const openingDepth = getStraightFlightOpeningDepth(stair, segment)
|
||||||
const climbRatio =
|
|
||||||
segment.height > 1e-6 ? clamp((targetElevation - segmentStartElevation) / segment.height, 0, 1) : 1
|
|
||||||
const intersectionAlong = climbRatio * segment.length
|
|
||||||
const flightRect = getAxisAlignedRectFromPolygon(
|
const flightRect = getAxisAlignedRectFromPolygon(
|
||||||
getStraightSegmentLocalSlicePolygon(layout, Math.max(0, intersectionAlong - openingDepth), segment.length),
|
getStraightSegmentLocalSlicePolygon(layout, Math.max(0, segment.length - openingDepth), segment.length),
|
||||||
)
|
)
|
||||||
if (flightRect) openingRects.push(expandRect(flightRect, openingOffset))
|
if (flightRect) openingRects.push(expandRect(flightRect, openingOffset))
|
||||||
}
|
}
|
||||||
@@ -462,24 +456,18 @@ function getStraightOpeningPolygonsForSurface(
|
|||||||
if (landingRect) landingRects.push(expandRect(landingRect, openingOffset))
|
if (landingRect) landingRects.push(expandRect(landingRect, openingOffset))
|
||||||
const previous = layouts[index - 1]
|
const previous = layouts[index - 1]
|
||||||
if (previous?.segment.segmentType === 'stair') {
|
if (previous?.segment.segmentType === 'stair') {
|
||||||
const previousDepth = getStraightFlightOpeningDepth(stair, previous.segment)
|
const previousTopElevation = previous.topElevation
|
||||||
const previousRect = getAxisAlignedRectFromPolygon(
|
if (Math.abs(targetElevation - previousTopElevation) <= targetThreshold) {
|
||||||
getStraightSegmentLocalSlicePolygon(
|
const previousDepth = getStraightFlightOpeningDepth(stair, previous.segment)
|
||||||
previous,
|
const previousRect = getAxisAlignedRectFromPolygon(
|
||||||
Math.max(0, previous.segment.length - previousDepth),
|
getStraightSegmentLocalSlicePolygon(
|
||||||
previous.segment.length,
|
previous,
|
||||||
),
|
Math.max(0, previous.segment.length - previousDepth),
|
||||||
)
|
previous.segment.length,
|
||||||
if (previousRect) landingRects.push(expandRect(previousRect, openingOffset))
|
),
|
||||||
}
|
)
|
||||||
|
if (previousRect) landingRects.push(expandRect(previousRect, openingOffset))
|
||||||
const next = layouts[index + 1]
|
}
|
||||||
if (next?.segment.segmentType === 'stair') {
|
|
||||||
const nextDepth = getStraightFlightOpeningDepth(stair, next.segment)
|
|
||||||
const nextRect = getAxisAlignedRectFromPolygon(
|
|
||||||
getStraightSegmentLocalSlicePolygon(next, 0, Math.min(next.segment.length, nextDepth)),
|
|
||||||
)
|
|
||||||
if (nextRect) landingRects.push(expandRect(nextRect, openingOffset))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
openingRects.push(...landingRects)
|
openingRects.push(...landingRects)
|
||||||
|
|||||||
Reference in New Issue
Block a user