fix: add null guards for cursorRef in fence and wall tool click handlers

This commit is contained in:
open-pascal
2026-05-20 00:57:15 +00:00
parent 3adae8acea
commit 251af2ce1d
2 changed files with 2 additions and 23 deletions
+1 -21
View File
@@ -509,27 +509,7 @@ export const FenceTool: React.FC = () => {
const nextStart = createdFence.end
startingPoint.current.set(nextStart[0], event.localPosition[1], nextStart[1])
endingPoint.current.copy(startingPoint.current)
cursorRef.current.position.copy(startingPoint.current)
previewRef.current.visible = false
buildingState.current = 1
setDraftMeasurement(null)
}
}
const onKeyDown = (e: KeyboardEvent) => {
if (e.key === 'Shift') shiftPressed.current = true
}
const onKeyUp = (e: KeyboardEvent) => {
if (e.key === 'Shift') shiftPressed.current = false
}
const onCancel = () => {
if (buildingState.current === 1) {
markToolCancelConsumed()
stopDrafting()
}
}
cursorRef.current?.position.copy(startingPoint.current)
emitter.on('grid:move', onGridMove)
emitter.on('grid:click', onGridClick)
+1 -2
View File
@@ -481,8 +481,7 @@ export const WallTool: React.FC = () => {
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
cursorRef.current?.position.copy(startingPoint.current)
buildingState.current = 1
setDraftMeasurement(null)
}