Skip to Content
HooksuseViewerSelection

useViewerSelection

Manages selection state for the viewer. Pass handleObjectSelect to onObjectSelect and consume selectedObjectBinding wherever you need to react to the user’s selection.

Usage

import { useViewerSelection } from "@liveroom/react-immersive"; const { selectedObjectBinding, setSelectedObjectBinding, handleObjectSelect, clearSelection, } = useViewerSelection(); <ModelViewer onObjectSelect={handleObjectSelect} selectedObject={selectedObjectBinding} ... />

Returns

NameTypeDescription
selectedObjectBindingObjectBinding | nullThe currently selected binding, or null
setSelectedObjectBinding(binding: ObjectBinding | null) => voidSet selection imperatively
handleObjectSelect(binding: ObjectBinding | null) => voidCallback to pass to onObjectSelect
clearSelection() => voidClears the current selection