<Canvas>. Same physics configuration as <MujocoCanvas>, but without the Canvas wrapper. Use this when you need control over gl settings, post-processing, or R3F context composition.
Usage
When to Use
Use<MujocoPhysics> instead of <MujocoCanvas> when you need:
- Custom gl settings (
antialias,toneMapping,outputColorSpace) - Post-processing pipelines (
EffectComposer, bloom, SSAO) - Multiple physics contexts in one Canvas
- Full control over the R3F
<Canvas>props - Components outside the physics context but inside the Canvas (e.g., background effects)
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.
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.
Ref
MujocoPhysics forwards its ref as a MujocoSimAPI handle (the same object passed to onReady):
Notes
- Must be a child of
<MujocoProvider>and inside an R3F<Canvas> - Children can use all mujoco-react hooks (
useMujoco,useBeforePhysicsStep, etc.) - Components placed outside
<MujocoPhysics>but inside<Canvas>won’t have access to physics hooks - Renders nothing while WASM is loading or if loading fails (call
onErrorto handle failures)