feat(editor): show placement grid for any armed grid-mode tool
The grid only appeared while a ghost was in flight (moving node / placing scope / armed GLB item), so a merely-armed draft tool (wall / slab / fence / ceiling / zone / column / MEP) showed no lattice. Gate visibility on isGridSnapActive() alone — it already derives the snap context from the interaction scope OR the armed build tool and is true only when that context resolves to grid (false for select / idle / paint / lines / off), so it is exactly the right condition. Draft tools publish no surface; the grid's horizontal branch already falls back to the active level floor, with the reveal patch following the cursor. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
81c5b2d22e
commit
dc468a084b
@@ -11,7 +11,7 @@ import { useCeilingEvents } from '../../hooks/use-ceiling-events'
|
|||||||
import { useGridEvents } from '../../hooks/use-grid-events'
|
import { useGridEvents } from '../../hooks/use-grid-events'
|
||||||
import { getPlacementSurface } from '../../lib/active-placement-surface'
|
import { getPlacementSurface } from '../../lib/active-placement-surface'
|
||||||
import useEditor, { isGridSnapActive } from '../../store/use-editor'
|
import useEditor, { isGridSnapActive } from '../../store/use-editor'
|
||||||
import useInteractionScope, { getMovingNode } from '../../store/use-interaction-scope'
|
import { getMovingNode } from '../../store/use-interaction-scope'
|
||||||
|
|
||||||
// Reveal radius (m) of the cursor-local grid patch shown while placing/moving in
|
// Reveal radius (m) of the cursor-local grid patch shown while placing/moving in
|
||||||
// grid-snap mode — much tighter than the idle reveal so only the area you're
|
// grid-snap mode — much tighter than the idle reveal so only the area you're
|
||||||
@@ -261,31 +261,19 @@ export const Grid = ({
|
|||||||
material.needsUpdate = true
|
material.needsUpdate = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// While placing/moving: in grid-snap mode shrink to a tight cursor patch
|
// The grid is a placement aid: a tight cursor patch (no always-on baseline)
|
||||||
// (drop the always-on baseline so only the snap area near the cursor shows);
|
// shown whenever the active context is in grid-snap mode — ANY armed
|
||||||
// when NOT grid-snapping, hide the grid entirely. Idle keeps the full grid.
|
// draft/build tool (wall / slab / fence / ceiling / zone / column / MEP / …),
|
||||||
// "Actively placing/moving" means a ghost is being positioned: a movingNode
|
// a node move, or a reshape — and hidden in select/idle, paint, and non-grid
|
||||||
// (preset/node move), an in-progress draft (wall/fence), or an armed GLB item
|
// (lines/off) modes. `isGridSnapActive()` already derives the snap context
|
||||||
// in build mode. A merely-armed build tool with no ghost is NOT placing —
|
// from the interaction scope OR the armed build tool and is true only when
|
||||||
// otherwise the patch would show while the user isn't positioning anything.
|
// that context resolves to grid, so it IS the gate. (Previously this also
|
||||||
const ed = useEditor.getState()
|
// required a ghost in flight, so a merely-armed draft tool showed nothing.)
|
||||||
const scopeKind = useInteractionScope.getState().scope.kind
|
const snapPatchVisible = isGridSnapActive()
|
||||||
const placingOrMoving =
|
|
||||||
getMovingNode() != null ||
|
|
||||||
scopeKind === 'drafting' ||
|
|
||||||
scopeKind === 'placing' ||
|
|
||||||
(ed.mode === 'build' && ed.selectedItem != null)
|
|
||||||
const gridSnap = isGridSnapActive()
|
|
||||||
// The grid is a placement aid, not always-on chrome: it shows ONLY while
|
|
||||||
// actively placing/moving in grid-snap mode, as a tight cursor patch. Idle,
|
|
||||||
// select, and non-grid placement all hide it entirely.
|
|
||||||
const snapPatchVisible = placingOrMoving && gridSnap
|
|
||||||
revealRadiusUniform.value = PLACEMENT_REVEAL_RADIUS
|
revealRadiusUniform.value = PLACEMENT_REVEAL_RADIUS
|
||||||
baseAlphaUniform.value = 0
|
baseAlphaUniform.value = 0
|
||||||
cellSizeUniform.value = useEditor.getState().gridSnapStep
|
cellSizeUniform.value = useEditor.getState().gridSnapStep
|
||||||
patchAlphaUniform.value = 1.5
|
patchAlphaUniform.value = 1.5
|
||||||
// The 3D grid is purely a placement aid now (no user-facing show/hide
|
|
||||||
// setting): visible only while actively placing/moving in grid-snap mode.
|
|
||||||
gridRef.current.visible = snapPatchVisible
|
gridRef.current.visible = snapPatchVisible
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user