<Canvas> that sets up the physics simulation. Accepts all standard R3F Canvas props plus MuJoCo-specific configuration.
Usage
Props
MuJoCo Props
SceneConfig
required
Scene configuration — robot ID, model file, joints, etc. See Loading Models.
({ api }) => void
Fires when the model is loaded and simulation is ready. Receives the full API object.
(error: Error) => void
Called if model loading or simulation fails.
({ time, model, data }) => void
Called after each physics step with the current simulation time.
({ bodyId, name }) => void
Fired when a body is double-clicked in the scene.
Physics Props
boolean
default:"false"
Pause/resume the simulation declaratively.
number
default:"1.0"
Simulation speed multiplier.
0.5 = half speed, 2.0 = double speed.[number, number, number]
Override gravity vector (m/s^2). Default: model’s gravity.
number
Override simulation timestep (seconds). Default: model’s timestep.
number
Number of physics substeps per frame for improved stability.
boolean
default:"false"
Smooth rendered body poses between fixed physics steps. Useful for high-refresh displays.
MujocoRenderOptions
Optional render-time settings for generated MuJoCo geometry. Set
renderOptions={{ meshNormalSmoothing: true }} to weld duplicate mesh
vertices before recomputing normals, which smooths faceted STL visuals. Leave
it unset when you need exact policy-render parity.Names of model bodies whose geometry should not be rendered. The bodies stay
in the compiled model and keep simulating — only their meshes are skipped at
scene-build time, so body, joint, and actuator indices are unchanged. The set
is reapplied on every render rebuild, so toggling names can never be lost to a
scene rebuild. Use it to show one arm of a bimanual model, hide fixtures, etc.
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