Phase 5 Stage D moves: align useLiveTransforms with the direct mesh.position delta
User reported the slab/fence mesh jittered/teleported continuously
while dragging (not on commit — during the drag). Root cause: the
move tool wrote TWO conflicting values per grid:move tick:
1. `mesh.position.set(deltaX, 0, deltaZ)` — relative offset, direct
Three.js mutation.
2. `useLiveTransforms.set(id, { position: [originalCenter + deltaX,
0, originalCenter + deltaZ], rotation: 0 })` — absolute world
position of the translated polygon center.
`ParametricNodeRenderer` reads `useLiveTransforms` and binds it via
React: `<group position={liveTransform.position}>`. So every Zustand
notification re-rendered the renderer and reconciled the group's
position back to "originalCenter + delta" (the absolute), overriding
the "delta" the direct mutation had just written. The two systems
fought every frame → visible jitter.
Fix: `useLiveTransforms.position` now holds the SAME delta the direct
mutation uses (`[deltaX, 0, deltaZ]`). React reconciles to the same
value the direct mutation already set — no conflict.
The cursor sphere position stays as the translated polygon center
(it's tracked separately via React state, not `useLiveTransforms`).
Ceiling aligned for consistency, though CeilingRenderer doesn't read
`useLiveTransforms` so the value there has no rendering effect.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
f4ea07e05b
commit
82c9b5e1df
@@ -109,11 +109,17 @@ export const MoveSlabTool: React.FC<{ node: SlabNode }> = ({ node }) => {
|
||||
// Visual: translate the slab MESH only. No scene mutation, no
|
||||
// polygon rebuild, no React re-render of geometry.
|
||||
setMeshOffset(slabId as AnyNodeId, deltaX, deltaZ)
|
||||
// useLiveTransforms holds the same delta the direct mesh.position
|
||||
// mutation uses — ParametricNodeRenderer reads it and reconciles
|
||||
// `<group position={liveTransform.position}>` via React. Mismatched
|
||||
// values here cause the two systems to fight per frame (jitter
|
||||
// during drag).
|
||||
useLiveTransforms.getState().set(slabId, {
|
||||
position: [originalCenter[0] + deltaX, 0, originalCenter[1] + deltaZ],
|
||||
position: [deltaX, 0, deltaZ],
|
||||
rotation: 0,
|
||||
})
|
||||
// Cursor sphere follows the new polygon center.
|
||||
// Cursor sphere follows the new polygon center (independent of
|
||||
// group position).
|
||||
setCursorLocalPos([originalCenter[0] + deltaX, 0, originalCenter[1] + deltaZ])
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user