From c938b3ccddb3e6a481db72841e26744a53947f04 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Tue, 31 Mar 2026 04:24:18 +0200 Subject: [PATCH] Add focusRequestId and focusSelection to ViewportCanvas props and update useEffect --- src/viewport-three/ViewportCanvas.tsx | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/viewport-three/ViewportCanvas.tsx b/src/viewport-three/ViewportCanvas.tsx index 8f7fba2f..edad2655 100644 --- a/src/viewport-three/ViewportCanvas.tsx +++ b/src/viewport-three/ViewportCanvas.tsx @@ -14,6 +14,8 @@ interface ViewportCanvasProps { sceneDocument: SceneDocument; selection: EditorSelection; toolMode: ToolMode; + focusRequestId: number; + focusSelection: EditorSelection; onSelectionChange(selection: EditorSelection): void; onCreateBoxBrush(center: Vec3): void; } @@ -26,7 +28,16 @@ function formatVec3(vector: Vec3 | null): string { return `${vector.x}, ${vector.y}, ${vector.z}`; } -export function ViewportCanvas({ world, sceneDocument, selection, toolMode, onSelectionChange, onCreateBoxBrush }: ViewportCanvasProps) { +export function ViewportCanvas({ + world, + sceneDocument, + selection, + toolMode, + focusRequestId, + focusSelection, + onSelectionChange, + onCreateBoxBrush +}: ViewportCanvasProps) { const containerRef = useRef(null); const hostRef = useRef(null); const [viewportMessage, setViewportMessage] = useState(null); @@ -95,6 +106,14 @@ export function ViewportCanvas({ world, sceneDocument, selection, toolMode, onSe } }, [toolMode]); + useEffect(() => { + if (focusRequestId === 0) { + return; + } + + hostRef.current?.focusSelection(sceneDocument, focusSelection); + }, [focusRequestId, focusSelection, sceneDocument]); + return (
{toolMode === "box-create" ? `Click to place a ${DEFAULT_BOX_BRUSH_SIZE.x} x ${DEFAULT_BOX_BRUSH_SIZE.y} x ${DEFAULT_BOX_BRUSH_SIZE.z} box on the ${DEFAULT_GRID_SIZE}m grid.` - : "Click a brush, face, or Player Start marker to update the authored selection."} + : "Click to select. Middle-drag orbits, Shift + middle-drag pans, wheel zooms, and Numpad Comma frames the selection."}
{toolMode !== "box-create" ? null : (