The primary hook for accessing the MuJoCo simulation API from any component insideDocumentation Index
Fetch the complete documentation index at: https://dadd.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
<MujocoCanvas>.
Narrow on isReady, isPending, or isError to get type-safe access to the API and refs.
Usage
Return Value
useMujoco() returns a UseMujocoResult with three variants:
Loading
Error
Ready
The API Object
Theapi object (available when isReady is true) provides methods grouped into categories:
- Simulation Control —
reset(),setPaused(),setSpeed(),step(),getTime() - State Management —
saveState(),restoreState(),setQpos(),applyKeyframe() - Forces —
applyForce(),applyTorque(),setExternalForce() - Model Introspection —
getBodies(),getJoints(),getSensors() - Model Mutation —
setGravity(),setBodyMass(),setGeomFriction() - Spatial Queries —
raycast(),project2DTo3D(),getCanvasSnapshot() - Scene Management —
loadScene()
useIkController() hook — see useIkController and IK Control.
Camera animation is provided by the standalone useCameraAnimation() hook — see useCameraAnimation.
Direct Model/Data Access
For advanced use cases, access the raw MuJoCo model and data objects:Notes
- Must be called from a component inside
<MujocoCanvas>or<MujocoPhysics> - The
apiobject is stable (same reference across renders when status doesn’t change) - Use
isReady/isPending/isErrorfor type-safe narrowing instead of comparingstatusstrings