THREE.Mesh[] array for a given MuJoCo body ID. This is the low-level primitive for building custom selection visuals, outlines, postprocessing effects, or any logic that needs direct access to the meshes belonging to a body.
Signature
Usage
Custom Selection Visuals
BecauseuseBodyMeshes gives you raw mesh references, you can implement any visual effect:
Postprocessing
Pair with@react-three/postprocessing to apply per-body effects:
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
bodyId | number | null | — | ID of the MuJoCo body. Pass null to get an empty array. |
Returns
| Type | Description |
|---|---|
THREE.Mesh[] | Array of Three.js meshes belonging to the body. Empty array if bodyId is null or no meshes are found. |
How It Works
Traverses the R3F scene graph and collects all meshes whoseuserData.bodyID matches the given bodyId. The <SceneRenderer> component sets userData.bodyID on every mesh it creates, so this hook works with any standard mujoco-react scene.
Related
useSelectionHighlight— convenience hook built onuseBodyMeshesfor emissive highlights