Refine wall chaining and door arch clipping

This commit is contained in:
sudhir
2026-05-20 00:51:01 +00:00
committed by open-pascal
parent 023cd511e9
commit 5d53be26e5
2 changed files with 25 additions and 12 deletions
+24 -5
View File
@@ -396,6 +396,12 @@ export const WallTool: React.FC = () => {
let gridPosition: WallPlanPoint = [0, 0] let gridPosition: WallPlanPoint = [0, 0]
let previousWallEnd: [number, number] | null = null let previousWallEnd: [number, number] | null = null
const stopDrafting = () => {
buildingState.current = 0
wallPreviewRef.current.visible = false
setDraftMeasurement(null)
}
const onGridMove = (event: GridEvent) => { const onGridMove = (event: GridEvent) => {
if (!(cursorRef.current && wallPreviewRef.current)) return if (!(cursorRef.current && wallPreviewRef.current)) return
@@ -439,6 +445,11 @@ export const WallTool: React.FC = () => {
} }
const onGridClick = (event: GridEvent) => { const onGridClick = (event: GridEvent) => {
if (buildingState.current === 1 && event.nativeEvent.detail >= 2) {
stopDrafting()
return
}
const walls = getCurrentLevelWalls() const walls = getCurrentLevelWalls()
const localClick: WallPlanPoint = [event.localPosition[0], event.localPosition[2]] const localClick: WallPlanPoint = [event.localPosition[0], event.localPosition[2]]
@@ -460,9 +471,19 @@ export const WallTool: React.FC = () => {
const dx = snappedEnd[0] - startingPoint.current.x const dx = snappedEnd[0] - startingPoint.current.x
const dz = snappedEnd[1] - startingPoint.current.z const dz = snappedEnd[1] - startingPoint.current.z
if (dx * dx + dz * dz < 0.01 * 0.01) return if (dx * dx + dz * dz < 0.01 * 0.01) return
createWallOnCurrentLevel([startingPoint.current.x, startingPoint.current.z], snappedEnd) // Both start and end are building-local ✓
const createdWall = createWallOnCurrentLevel(
[startingPoint.current.x, startingPoint.current.z],
snappedEnd,
)
if (!createdWall) return
const nextStart = createdWall.end
startingPoint.current.set(nextStart[0], event.localPosition[1], nextStart[1])
endingPoint.current.copy(startingPoint.current)
cursorRef.current.position.copy(startingPoint.current)
wallPreviewRef.current.visible = false wallPreviewRef.current.visible = false
buildingState.current = 0 buildingState.current = 1
setDraftMeasurement(null) setDraftMeasurement(null)
} }
} }
@@ -478,9 +499,7 @@ export const WallTool: React.FC = () => {
const onCancel = () => { const onCancel = () => {
if (buildingState.current === 1) { if (buildingState.current === 1) {
markToolCancelConsumed() markToolCancelConsumed()
buildingState.current = 0 stopDrafting()
wallPreviewRef.current.visible = false
setDraftMeasurement(null)
} }
} }
@@ -438,8 +438,6 @@ function createRoundedClippedLeafFrameShape(
getRoundedBoundaryYAtX(x, fullLeft, fullRight, top, { getRoundedBoundaryYAtX(x, fullLeft, fullRight, top, {
topLeft: outerRadii.topLeft, topLeft: outerRadii.topLeft,
topRight: outerRadii.topRight, topRight: outerRadii.topRight,
bottomLeft: 0,
bottomRight: 0,
}), }),
) )
@@ -466,8 +464,6 @@ function createRoundedClippedLeafFrameShape(
getRoundedBoundaryYAtX(x, innerFullLeft, innerFullRight, innerTop, { getRoundedBoundaryYAtX(x, innerFullLeft, innerFullRight, innerTop, {
topLeft: innerRadii.topLeft, topLeft: innerRadii.topLeft,
topRight: innerRadii.topRight, topRight: innerRadii.topRight,
bottomLeft: 0,
bottomRight: 0,
}), }),
) )
@@ -730,8 +726,6 @@ function addLeafSegmentContent({
return getRoundedBoundaryYAtX(x, leafLeft, leafRight, leafTop, { return getRoundedBoundaryYAtX(x, leafLeft, leafRight, leafTop, {
topLeft: openingTopRadii.topLeft, topLeft: openingTopRadii.topLeft,
topRight: openingTopRadii.topRight, topRight: openingTopRadii.topRight,
bottomLeft: 0,
bottomRight: 0,
}) })
} }
@@ -742,7 +736,7 @@ function addLeafSegmentContent({
leafLeft, leafLeft,
leafRight, leafRight,
leafTop, leafTop,
archHeight, clampedLeafArchHeight,
archOuterSide, archOuterSide,
) )
} }