From fe4ca47193d6e7ccfa4bdc21e89a15e32bda32fe Mon Sep 17 00:00:00 2001 From: wass08 Date: Fri, 30 Jan 2026 10:13:14 +0900 Subject: [PATCH] fix furnish node --- apps/editor/components/tools/item/use-draft-node.ts | 5 +++-- .../components/tools/item/use-placement-coordinator.tsx | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/editor/components/tools/item/use-draft-node.ts b/apps/editor/components/tools/item/use-draft-node.ts index b8d93338..9286b37e 100644 --- a/apps/editor/components/tools/item/use-draft-node.ts +++ b/apps/editor/components/tools/item/use-draft-node.ts @@ -19,7 +19,7 @@ export interface DraftNodeHandle { /** Whether the current draft was adopted (move mode) vs created (create mode) */ readonly isAdopted: boolean /** Create a new draft item at the given position. Returns the created node or null. */ - create: (gridPosition: Vector3, asset: Asset) => ItemNode | null + create: (gridPosition: Vector3, asset: Asset, rotation?: [number, number, number]) => ItemNode | null /** Take ownership of an existing scene node as the draft (for move mode). */ adopt: (node: ItemNode) => void /** Commit the current draft. Create mode: delete+recreate. Move mode: update in place. */ @@ -41,12 +41,13 @@ export function useDraftNode(): DraftNodeHandle { const adoptedRef = useRef(false) const originalStateRef = useRef(null) - const create = useCallback((gridPosition: Vector3, asset: Asset): ItemNode | null => { + const create = useCallback((gridPosition: Vector3, asset: Asset, rotation?: [number, number, number]): ItemNode | null => { const currentLevelId = useViewer.getState().selection.levelId if (!currentLevelId) return null const node = ItemNode.parse({ position: [gridPosition.x, gridPosition.y, gridPosition.z], + rotation: rotation ?? [0, 0, 0], name: asset.name, asset, metadata: { isTransient: true }, diff --git a/apps/editor/components/tools/item/use-placement-coordinator.tsx b/apps/editor/components/tools/item/use-placement-coordinator.tsx index 7e163096..cea1c1b7 100644 --- a/apps/editor/components/tools/item/use-placement-coordinator.tsx +++ b/apps/editor/components/tools/item/use-placement-coordinator.tsx @@ -93,7 +93,7 @@ export function usePlacementCoordinator(config: PlacementCoordinatorConfig): Rea cursorRef.current.position.set(...result.cursorPosition) cursorRef.current.rotation.y = result.cursorRotationY - draftNode.create(gridPosition.current, asset) + draftNode.create(gridPosition.current, asset, [0, result.cursorRotationY, 0]) const draft = draftNode.current if (draft) { @@ -146,9 +146,12 @@ export function usePlacementCoordinator(config: PlacementCoordinatorConfig): Rea const result = floorStrategy.click(getContext(), event, validators) if (!result) return + // Preserve cursor rotation for the next draft + const currentRotation: [number, number, number] = [0, cursorRef.current.rotation.y, 0] + draftNode.commit(result.nodeUpdate) if (config.onCommitted()) { - draftNode.create(gridPosition.current, asset) + draftNode.create(gridPosition.current, asset, currentRotation) revalidate() } }