fix placement

This commit is contained in:
wass08
2026-02-02 11:39:38 +09:00
parent 5392d66bd6
commit 73dfac795a
2 changed files with 12 additions and 4 deletions
@@ -503,12 +503,14 @@ export function usePlacementCoordinator(config: PlacementCoordinatorConfig): Rea
if (!asset.attachTo) { if (!asset.attachTo) {
const levelId = useViewer.getState().selection.levelId const levelId = useViewer.getState().selection.levelId
if (levelId) { if (levelId) {
mesh.position.y = spatialGridManager.getSlabElevationForItem( const slabElevation = spatialGridManager.getSlabElevationForItem(
levelId, levelId,
[gridPosition.current.x, gridPosition.current.y, gridPosition.current.z], [gridPosition.current.x, gridPosition.current.y, gridPosition.current.z],
asset.dimensions ?? DEFAULT_DIMENSIONS, asset.dimensions ?? DEFAULT_DIMENSIONS,
draftNode.current.rotation, draftNode.current.rotation,
) )
mesh.position.y = slabElevation
cursorRef.current.position.y = slabElevation
} }
} }
} }
@@ -97,9 +97,15 @@ export const updateNodesAction = (
return { nodes: nextNodes } return { nodes: nextNodes }
}) })
// Mark dirty // Mark dirty after the next frame to ensure React renders complete
updates.forEach((u) => get().markDirty(u.id)) requestAnimationFrame(() => {
parentsToUpdate.forEach((pId) => get().markDirty(pId)) updates.forEach((u) => {
get().markDirty(u.id)
})
parentsToUpdate.forEach((pId) => {
get().markDirty(pId)
})
})
} }
export const deleteNodesAction = ( export const deleteNodesAction = (