You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Replace "Bring Your Own" language with natural headings
- Add useMujoco() hook documentation to README
- Fix mujoco-js link to npm package page
- Add demo header video to README and docs overview
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use inside your own `<Canvas>` for control over gl settings, post-processing, etc:
85
-
86
-
```
87
-
<MujocoProvider>
88
-
<Canvas shadows camera={...} gl={...}> <- Your Canvas, your settings
89
-
<MujocoPhysics config={config}> <- Physics context only
90
-
<SceneRenderer />
91
-
<YourController />
92
-
</MujocoPhysics>
93
-
<OrbitControls />
94
-
<EffectComposer>...</EffectComposer> <- Post-processing, etc.
95
-
</Canvas>
96
-
</MujocoProvider>
97
-
```
98
-
99
-
The library handles WASM lifecycle, physics stepping, and body rendering. Controllers (IK, teleoperation, RL policies) are composable plugins you opt into or write yourself.
100
-
101
-
## Bring Your Own Controller
102
-
103
-
A controller is a React component that calls `useBeforePhysicsStep` to write `data.ctrl` each frame and returns `null`.
63
+
A controller is a React component that calls `useBeforePhysicsStep` to write `data.ctrl` each frame:
Or skip `<IkController>` entirely and solve IK yourself inside `useBeforePhysicsStep`:
104
+
## Architecture
142
105
143
-
```tsx
144
-
function MyIKController() {
145
-
useBeforePhysicsStep((model, data) => {
146
-
const joints =myCustomIKSolve(model, data);
147
-
if (joints) {
148
-
for (let i =0; i<joints.length; i++) data.ctrl[i] =joints[i];
149
-
}
150
-
});
151
-
returnnull;
152
-
}
106
+
`<MujocoCanvas>` wraps R3F `<Canvas>` and forwards all Canvas props (`camera`, `shadows`, `gl`, etc.). For full control over the Canvas, use `<MujocoPhysics>` inside your own:
Copy file name to clipboardExpand all lines: docs/architecture.mdx
+12-19Lines changed: 12 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,25 +8,18 @@ icon: "sitemap"
8
8
9
9
mujoco-react uses a layered provider pattern. Two setup options:
10
10
11
+
`MujocoCanvas` wraps R3F `<Canvas>` and forwards all Canvas props. `MujocoPhysics` provides just the physics context inside your own Canvas.
12
+
11
13
```
12
-
Option A: MujocoCanvas (quick start)
13
-
14
-
MujocoProvider <- WASM module lifecycle
15
-
└─ MujocoCanvas <- R3F Canvas + scene config
16
-
└─ MujocoSimProvider <- Physics loop + API
17
-
├─ SceneRenderer <- Body mesh sync
18
-
├─ IkController <- Opt-in IK plugin
19
-
│ └─ IkGizmo
14
+
MujocoCanvas MujocoPhysics
15
+
16
+
MujocoProvider MujocoProvider
17
+
└─ MujocoCanvas └─ Canvas
18
+
└─ MujocoSimProvider └─ MujocoPhysics
19
+
├─ SceneRenderer └─ MujocoSimProvider
20
+
├─ IkController ├─ SceneRenderer
21
+
│ └─ IkGizmo └─ YourComponents
20
22
└─ YourComponents
21
-
22
-
Option B: MujocoPhysics (bring your own Canvas)
23
-
24
-
MujocoProvider <- WASM module lifecycle
25
-
└─ Canvas <- Your R3F Canvas, your gl settings
26
-
└─ MujocoPhysics <- Physics context (no Canvas wrapper)
27
-
└─ MujocoSimProvider <- Physics loop + API
28
-
├─ SceneRenderer
29
-
└─ YourComponents
30
23
```
31
24
32
25
### MujocoProvider
@@ -61,9 +54,9 @@ You don't use this directly. `MujocoCanvas` and `MujocoPhysics` create it. It:
61
54
- Exposes the `MujocoSimAPI` via React context
62
55
- Provides callback registration for `useBeforePhysicsStep`, `useAfterPhysicsStep`, and `resetCallbacks`
63
56
64
-
### Controller Plugins (Bring Your Own)
57
+
### Controller Plugins
65
58
66
-
The core library has no built-in control logic. Controllers are React components that call `useBeforePhysicsStep` to write `data.ctrl`. The library ships `<IkController>` as one example, but the intended pattern is to write your own.
59
+
Controllers are React components that call `useBeforePhysicsStep` to write `data.ctrl`. The library ships `<IkController>` as one example; the same pattern works for any control logic.
Copy file name to clipboardExpand all lines: docs/introduction.mdx
+11-15Lines changed: 11 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,17 +6,17 @@ icon: "rocket"
6
6
7
7
# mujoco-react
8
8
9
-
**mujoco-react** is a composable [React Three Fiber](https://r3f.docs.pmnd.rs/) wrapper around [mujoco-js](https://github.com/nicepkg/mujoco-js). It provides components for loading models, stepping physics, and rendering bodies. Controllers like IK are opt-in plugins.
9
+
**mujoco-react** is a composable [React Three Fiber](https://r3f.docs.pmnd.rs/) wrapper around [mujoco-js](https://www.npmjs.com/package/mujoco-js). It provides components for loading models, stepping physics, and rendering bodies. Controllers like IK are opt-in plugins.
10
10
11
11
<CardGroupcols={2}>
12
12
<Cardtitle="Composable"icon="puzzle-piece">
13
13
`<SceneRenderer />`, `<IkGizmo />`, `<Debug />` etc. are R3F children you add to your scene.
14
14
</Card>
15
-
<Cardtitle="Bring Your Own Controller"icon="scale-balanced">
Controllers are React components that call `useBeforePhysicsStep`. Write your own or use the built-in ones.
17
17
</Card>
18
-
<Cardtitle="Bring Your Own IK"icon="plug">
19
-
Plug in any IK solver via `ikSolveFn`, or skip `IkController` entirely and solve IK yourself in `useBeforePhysicsStep`.
18
+
<Cardtitle="Pluggable IK"icon="plug">
19
+
Swap in any IK solver via `ikSolveFn`, or skip `IkController` entirely and solve IK yourself in `useBeforePhysicsStep`.
20
20
</Card>
21
21
<Cardtitle="Full MuJoCo"icon="atom">
22
22
Contacts, sensors, tendons, flex bodies, raycasting, domain randomization. The full MuJoCo API via React hooks.
@@ -63,7 +63,7 @@ function App() {
63
63
64
64
This loads the Franka Panda from [DeepMind Menagerie](https://github.com/google-deepmind/mujoco_menagerie), renders all bodies, and adds an interactive IK gizmo on the end-effector.
65
65
66
-
## Bring Your Own Controller
66
+
## Controllers
67
67
68
68
A controller is a React component that calls `useBeforePhysicsStep` to write `data.ctrl` each frame:
69
69
@@ -103,27 +103,23 @@ mujoco-react follows the same pattern as [react-three-rapier](https://github.com
103
103
-**Consumers compose everything else**: lights, grid, camera controls, UI, game logic
104
104
-**All scene elements are R3F children**: no config objects for visual-only things
105
105
106
-
Two ways to set up your scene:
106
+
`<MujocoCanvas>` wraps R3F `<Canvas>` and forwards all Canvas props. For full control over the Canvas (gl settings, post-processing, etc.), use `<MujocoPhysics>` inside your own:
0 commit comments