fix duplicate door
This commit is contained in:
@@ -204,27 +204,15 @@ export const MoveDoorTool: React.FC<{ node: DoorNode }> = ({ node: movingDoorNod
|
|||||||
useScene.getState().deleteNode(movingDoorNode.id)
|
useScene.getState().deleteNode(movingDoorNode.id)
|
||||||
useScene.temporal.getState().resume()
|
useScene.temporal.getState().resume()
|
||||||
|
|
||||||
|
const cloned = structuredClone(movingDoorNode) as any
|
||||||
|
delete cloned.id
|
||||||
const node = DoorNode.parse({
|
const node = DoorNode.parse({
|
||||||
|
...cloned,
|
||||||
position: [clampedX, clampedY, 0],
|
position: [clampedX, clampedY, 0],
|
||||||
rotation: [0, itemRotation, 0],
|
rotation: [0, itemRotation, 0],
|
||||||
side,
|
side,
|
||||||
wallId: event.node.id,
|
wallId: event.node.id,
|
||||||
parentId: event.node.id,
|
parentId: event.node.id,
|
||||||
width: movingDoorNode.width,
|
|
||||||
height: movingDoorNode.height,
|
|
||||||
frameThickness: movingDoorNode.frameThickness,
|
|
||||||
frameDepth: movingDoorNode.frameDepth,
|
|
||||||
threshold: movingDoorNode.threshold,
|
|
||||||
thresholdHeight: movingDoorNode.thresholdHeight,
|
|
||||||
hingesSide: movingDoorNode.hingesSide,
|
|
||||||
swingDirection: movingDoorNode.swingDirection,
|
|
||||||
segments: movingDoorNode.segments,
|
|
||||||
handle: movingDoorNode.handle,
|
|
||||||
handleHeight: movingDoorNode.handleHeight,
|
|
||||||
handleSide: movingDoorNode.handleSide,
|
|
||||||
doorCloser: movingDoorNode.doorCloser,
|
|
||||||
panicBar: movingDoorNode.panicBar,
|
|
||||||
panicBarHeight: movingDoorNode.panicBarHeight,
|
|
||||||
})
|
})
|
||||||
useScene.getState().createNode(node, event.node.id as AnyNodeId)
|
useScene.getState().createNode(node, event.node.id as AnyNodeId)
|
||||||
placedId = node.id
|
placedId = node.id
|
||||||
|
|||||||
@@ -68,29 +68,10 @@ export function DoorPanel() {
|
|||||||
if (!node || !node.parentId) return
|
if (!node || !node.parentId) return
|
||||||
sfxEmitter.emit('sfx:item-pick')
|
sfxEmitter.emit('sfx:item-pick')
|
||||||
useScene.temporal.getState().pause()
|
useScene.temporal.getState().pause()
|
||||||
const duplicate = DoorNode.parse({
|
const cloned = structuredClone(node) as any
|
||||||
position: [...node.position] as [number, number, number],
|
delete cloned.id
|
||||||
rotation: [...node.rotation] as [number, number, number],
|
cloned.metadata = { ...cloned.metadata, isNew: true }
|
||||||
side: node.side,
|
const duplicate = DoorNode.parse(cloned)
|
||||||
wallId: node.wallId,
|
|
||||||
parentId: node.parentId,
|
|
||||||
width: node.width,
|
|
||||||
height: node.height,
|
|
||||||
frameThickness: node.frameThickness,
|
|
||||||
frameDepth: node.frameDepth,
|
|
||||||
threshold: node.threshold,
|
|
||||||
thresholdHeight: node.thresholdHeight,
|
|
||||||
hingesSide: node.hingesSide,
|
|
||||||
swingDirection: node.swingDirection,
|
|
||||||
segments: node.segments.map(s => ({ ...s, columnRatios: [...s.columnRatios] })),
|
|
||||||
handle: node.handle,
|
|
||||||
handleHeight: node.handleHeight,
|
|
||||||
handleSide: node.handleSide,
|
|
||||||
doorCloser: node.doorCloser,
|
|
||||||
panicBar: node.panicBar,
|
|
||||||
panicBarHeight: node.panicBarHeight,
|
|
||||||
metadata: { isNew: true },
|
|
||||||
})
|
|
||||||
useScene.getState().createNode(duplicate, node.parentId as AnyNodeId)
|
useScene.getState().createNode(duplicate, node.parentId as AnyNodeId)
|
||||||
setMovingNode(duplicate)
|
setMovingNode(duplicate)
|
||||||
setSelection({ selectedIds: [] })
|
setSelection({ selectedIds: [] })
|
||||||
|
|||||||
Reference in New Issue
Block a user