<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
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.
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.
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)