Skip to Content
HooksuseObjectBinding

useObjectBinding

Resolves a single binding from the objectBindings map by any of its identifiers.

Usage

import { useObjectBinding } from "@liveroom/react-immersive"; const binding = useObjectBinding(objectBindings, "some-object-id");

Resolution Order

useObjectBinding checks, in order:

  1. The object binding map key (e.g. "CarBody")
  2. binding.id (e.g. "some-object-id")
  3. binding.modelObjectId (e.g. "CarBody")

This lets you pass any of the three identifiers and get back the same binding.

Parameters

NameTypeDescription
objectBindingsRecord<string, ObjectBinding>The current bindings map
idstringAny binding identifier: map key, binding.id, or binding.modelObjectId

Returns

ObjectBinding | undefined — the resolved binding, or undefined if not found.

Example

const focusedBinding = useObjectBinding(objectBindings, "some-object-id"); if (focusedBinding) { console.log(focusedBinding.label); }