<Canvas> that sets up the physics simulation. Accepts all standard R3F Canvas props plus MuJoCo-specific configuration.
Usage
Props
MuJoCo Props
Scene configuration — robot ID, model file, joints, etc. See Loading Models.
Fires when the model is loaded and simulation is ready. Receives the full API object.
Called if model loading or simulation fails.
Called after each physics step with the current simulation time.
Fired when a body is double-clicked in the scene.
Physics Props
Pause/resume the simulation declaratively.
Simulation speed multiplier.
0.5 = half speed, 2.0 = double speed.Override gravity vector (m/s^2). Default: model’s gravity.
Override simulation timestep (seconds). Default: model’s timestep.
Number of physics substeps per frame for improved stability.
R3F Canvas Props
All standard@react-three/fiber Canvas props are passed through:
Ref
MujocoCanvas forwards its ref as a MujocoSimAPI handle — the same object passed to onReady:
Notes
- Must be a child of
<MujocoProvider> - Children can use all mujoco-react hooks (
useMujoco,useBeforePhysicsStep, etc.) - The
configprop is read on mount and whenapi.loadScene()is called — changing it after mount has no effect