fix: add null guards for cursorRef in fence and wall tool click handlers
This commit is contained in:
@@ -509,27 +509,7 @@ export const FenceTool: React.FC = () => {
|
|||||||
const nextStart = createdFence.end
|
const nextStart = createdFence.end
|
||||||
startingPoint.current.set(nextStart[0], event.localPosition[1], nextStart[1])
|
startingPoint.current.set(nextStart[0], event.localPosition[1], nextStart[1])
|
||||||
endingPoint.current.copy(startingPoint.current)
|
endingPoint.current.copy(startingPoint.current)
|
||||||
cursorRef.current.position.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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
emitter.on('grid:move', onGridMove)
|
emitter.on('grid:move', onGridMove)
|
||||||
emitter.on('grid:click', onGridClick)
|
emitter.on('grid:click', onGridClick)
|
||||||
|
|||||||
@@ -481,8 +481,7 @@ export const WallTool: React.FC = () => {
|
|||||||
const nextStart = createdWall.end
|
const nextStart = createdWall.end
|
||||||
startingPoint.current.set(nextStart[0], event.localPosition[1], nextStart[1])
|
startingPoint.current.set(nextStart[0], event.localPosition[1], nextStart[1])
|
||||||
endingPoint.current.copy(startingPoint.current)
|
endingPoint.current.copy(startingPoint.current)
|
||||||
cursorRef.current.position.copy(startingPoint.current)
|
cursorRef.current?.position.copy(startingPoint.current)
|
||||||
wallPreviewRef.current.visible = false
|
|
||||||
buildingState.current = 1
|
buildingState.current = 1
|
||||||
setDraftMeasurement(null)
|
setDraftMeasurement(null)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user