mujoco-react 8.3.3 → 8.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +107 -81
- package/dist/index.d.ts +87 -5
- package/dist/index.js +399 -28
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/core/GenericIK.ts +13 -10
- package/src/core/MujocoProvider.tsx +91 -7
- package/src/core/MujocoSimProvider.tsx +48 -5
- package/src/core/SceneLoader.ts +343 -1
- package/src/hooks/useIkController.ts +30 -11
- package/src/index.ts +10 -0
- package/src/types.ts +72 -3
package/README.md
CHANGED
|
@@ -18,149 +18,138 @@ Composable [React Three Fiber](https://docs.pmnd.rs/react-three-fiber) wrapper a
|
|
|
18
18
|
npm install mujoco-react three @react-three/fiber @react-three/drei
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
##
|
|
21
|
+
## Load a Model
|
|
22
22
|
|
|
23
23
|
```tsx
|
|
24
|
-
import {
|
|
25
|
-
MujocoProvider,
|
|
26
|
-
MujocoCanvas,
|
|
27
|
-
useIkController,
|
|
28
|
-
IkGizmo,
|
|
29
|
-
} from "mujoco-react";
|
|
24
|
+
import { MujocoProvider, MujocoCanvas } from "mujoco-react";
|
|
30
25
|
import type { SceneConfig } from "mujoco-react";
|
|
31
|
-
import { OrbitControls } from "@react-three/drei";
|
|
32
26
|
|
|
33
|
-
const
|
|
27
|
+
const panda: SceneConfig = {
|
|
34
28
|
src: "https://raw.githubusercontent.com/google-deepmind/mujoco_menagerie/main/franka_emika_panda/",
|
|
35
29
|
sceneFile: "scene.xml",
|
|
36
30
|
homeJoints: [1.707, -1.754, 0.003, -2.702, 0.003, 0.951, 2.490],
|
|
37
31
|
};
|
|
38
32
|
|
|
39
|
-
function
|
|
40
|
-
const ik = useIkController({ siteName: "tcp", numJoints: 7 });
|
|
41
|
-
return (
|
|
42
|
-
<>
|
|
43
|
-
<OrbitControls enableDamping makeDefault />
|
|
44
|
-
{ik && <IkGizmo controller={ik} />}
|
|
45
|
-
<ambientLight intensity={0.7} />
|
|
46
|
-
<directionalLight position={[1, 2, 5]} intensity={1.2} castShadow />
|
|
47
|
-
</>
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function App() {
|
|
33
|
+
export function App() {
|
|
52
34
|
return (
|
|
53
35
|
<MujocoProvider>
|
|
54
36
|
<MujocoCanvas
|
|
55
|
-
config={
|
|
37
|
+
config={panda}
|
|
56
38
|
camera={{ position: [2, -1.5, 2.5], up: [0, 0, 1], fov: 45 }}
|
|
57
|
-
shadows
|
|
58
39
|
style={{ width: "100%", height: "100vh" }}
|
|
59
|
-
|
|
60
|
-
<Scene />
|
|
61
|
-
</MujocoCanvas>
|
|
40
|
+
/>
|
|
62
41
|
</MujocoProvider>
|
|
63
42
|
);
|
|
64
43
|
}
|
|
65
44
|
```
|
|
66
45
|
|
|
67
|
-
##
|
|
68
|
-
|
|
69
|
-
Inside `<MujocoCanvas>` or `<MujocoPhysics>`, `useMujoco()` gives you the simulation API, refs to the live model/data, and status:
|
|
46
|
+
## Add Scene Tools
|
|
70
47
|
|
|
71
48
|
```tsx
|
|
72
|
-
import {
|
|
73
|
-
|
|
74
|
-
function MyComponent() {
|
|
75
|
-
const { isPending, isError, error, api, mjModelRef } = useMujoco();
|
|
49
|
+
import { OrbitControls } from "@react-three/drei";
|
|
50
|
+
import { IkGizmo, useIkController } from "mujoco-react";
|
|
76
51
|
|
|
77
|
-
|
|
78
|
-
|
|
52
|
+
function PandaTools() {
|
|
53
|
+
const ik = useIkController({ siteName: "tcp" });
|
|
79
54
|
|
|
80
55
|
return (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
56
|
+
<>
|
|
57
|
+
<OrbitControls makeDefault />
|
|
58
|
+
{ik && <IkGizmo controller={ik} />}
|
|
59
|
+
<ambientLight intensity={0.7} />
|
|
60
|
+
<directionalLight position={[1, 2, 5]} intensity={1.2} />
|
|
61
|
+
</>
|
|
84
62
|
);
|
|
85
63
|
}
|
|
86
64
|
```
|
|
87
65
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
A controller is a hook that reads sensors and writes actuators each physics step:
|
|
66
|
+
Use it as a child of `<MujocoCanvas>`:
|
|
91
67
|
|
|
92
68
|
```tsx
|
|
93
|
-
|
|
69
|
+
<MujocoCanvas config={panda}>
|
|
70
|
+
<PandaTools />
|
|
71
|
+
</MujocoCanvas>
|
|
72
|
+
```
|
|
94
73
|
|
|
95
|
-
|
|
96
|
-
const shoulder = useCtrl("shoulder");
|
|
97
|
-
const elbow = useCtrl("elbow");
|
|
98
|
-
const force = useSensor("force_sensor");
|
|
74
|
+
## Write Controllers
|
|
99
75
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
76
|
+
```tsx
|
|
77
|
+
import { useBeforePhysicsStep } from "mujoco-react";
|
|
78
|
+
|
|
79
|
+
function MyController() {
|
|
80
|
+
useBeforePhysicsStep((_model, data) => {
|
|
81
|
+
data.ctrl[0] = Math.sin(data.time);
|
|
103
82
|
});
|
|
83
|
+
|
|
84
|
+
return null;
|
|
104
85
|
}
|
|
105
86
|
```
|
|
106
87
|
|
|
107
|
-
|
|
88
|
+
Controllers are just React children that read sensors, write `data.ctrl`, apply forces, or call the `MujocoSimAPI` at physics-step time.
|
|
108
89
|
|
|
109
|
-
|
|
90
|
+
## Use the Sim API
|
|
110
91
|
|
|
111
92
|
```tsx
|
|
112
|
-
import {
|
|
93
|
+
import { useMujoco } from "mujoco-react";
|
|
113
94
|
|
|
114
|
-
function
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
data.xfrc_applied[i6 + 4] = (target[1] - data.xpos[i3 + 1]) * stiffness;
|
|
120
|
-
data.xfrc_applied[i6 + 5] = (target[2] - data.xpos[i3 + 2]) * stiffness;
|
|
121
|
-
});
|
|
95
|
+
function ResetButton() {
|
|
96
|
+
const sim = useMujoco();
|
|
97
|
+
if (!sim.isReady) return null;
|
|
98
|
+
|
|
99
|
+
return <button onClick={() => sim.api.reset()}>Reset</button>;
|
|
122
100
|
}
|
|
123
101
|
```
|
|
124
102
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
### WebSocket Joint Control
|
|
103
|
+
## WebSocket Control
|
|
128
104
|
|
|
129
|
-
Stream
|
|
105
|
+
Stream actuator commands over a WebSocket and send simulation state back. Use a schema validator such as Zod at this boundary because socket messages are untrusted app input (`npm install zod` for this example):
|
|
130
106
|
|
|
131
107
|
```tsx
|
|
132
108
|
import { useEffect, useRef } from "react";
|
|
109
|
+
import { z } from "zod";
|
|
133
110
|
import { useMujoco, useBeforePhysicsStep, useAfterPhysicsStep } from "mujoco-react";
|
|
134
111
|
|
|
135
|
-
|
|
136
|
-
|
|
112
|
+
const CtrlCommand = z.object({
|
|
113
|
+
type: z.literal("ctrl_command"),
|
|
114
|
+
ctrl: z.array(z.number()),
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
type CtrlCommand = z.infer<typeof CtrlCommand>;
|
|
118
|
+
|
|
119
|
+
function parseSocketMessage(data: string): CtrlCommand | null {
|
|
120
|
+
try {
|
|
121
|
+
const parsed = CtrlCommand.safeParse(JSON.parse(data));
|
|
122
|
+
return parsed.success ? parsed.data : null;
|
|
123
|
+
} catch {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function useWebSocketControls(url: string) {
|
|
137
129
|
const wsRef = useRef<WebSocket | null>(null);
|
|
138
|
-
const
|
|
130
|
+
const latestCommandRef = useRef<CtrlCommand | null>(null);
|
|
139
131
|
|
|
140
132
|
useEffect(() => {
|
|
141
133
|
const ws = new WebSocket(url);
|
|
142
134
|
wsRef.current = ws;
|
|
143
135
|
|
|
144
136
|
ws.onmessage = (evt) => {
|
|
145
|
-
|
|
146
|
-
if (msg.type === "joint_command") {
|
|
147
|
-
latestJointsRef.current = msg.qpos;
|
|
148
|
-
}
|
|
137
|
+
latestCommandRef.current = parseSocketMessage(evt.data);
|
|
149
138
|
};
|
|
150
139
|
|
|
151
140
|
return () => ws.close();
|
|
152
141
|
}, [url]);
|
|
153
142
|
|
|
154
|
-
// Apply incoming
|
|
143
|
+
// Apply incoming actuator controls each physics step.
|
|
155
144
|
useBeforePhysicsStep((model, data) => {
|
|
156
|
-
const
|
|
157
|
-
if (!
|
|
158
|
-
for (let i = 0; i < Math.min(
|
|
159
|
-
data.ctrl[i] =
|
|
145
|
+
const command = latestCommandRef.current;
|
|
146
|
+
if (!command) return;
|
|
147
|
+
for (let i = 0; i < Math.min(command.ctrl.length, model.nu); i++) {
|
|
148
|
+
data.ctrl[i] = command.ctrl[i];
|
|
160
149
|
}
|
|
161
150
|
});
|
|
162
151
|
|
|
163
|
-
// Send
|
|
152
|
+
// Send simulation feedback back after physics.
|
|
164
153
|
useAfterPhysicsStep((model, data) => {
|
|
165
154
|
const ws = wsRef.current;
|
|
166
155
|
if (!ws || ws.readyState !== WebSocket.OPEN) return;
|
|
@@ -227,7 +216,7 @@ const myIK: IKSolveFn = (pos, quat, currentQ) => {
|
|
|
227
216
|
return myAnalyticalSolver(pos, currentQ); // return joint angles or null
|
|
228
217
|
};
|
|
229
218
|
|
|
230
|
-
const ik = useIkController({ siteName: "tcp",
|
|
219
|
+
const ik = useIkController({ siteName: "tcp", ikSolveFn: myIK });
|
|
231
220
|
```
|
|
232
221
|
|
|
233
222
|
### `useIkController(config | null)`
|
|
@@ -235,14 +224,16 @@ const ik = useIkController({ siteName: "tcp", numJoints: 7, ikSolveFn: myIK });
|
|
|
235
224
|
Hook for interactive end-effector control. Pass `null` to disable IK (safe to call unconditionally):
|
|
236
225
|
|
|
237
226
|
```tsx
|
|
238
|
-
const ik = useIkController({ siteName: "tcp"
|
|
227
|
+
const ik = useIkController({ siteName: "tcp" });
|
|
239
228
|
return ik ? <IkGizmo controller={ik} /> : null;
|
|
240
229
|
```
|
|
241
230
|
|
|
242
231
|
| Config | Type | Default | Description |
|
|
243
232
|
|--------|------|---------|-------------|
|
|
244
233
|
| `siteName` | `string` | **required** | MuJoCo site to track |
|
|
245
|
-
| `
|
|
234
|
+
| `joints` | `string \| string[] \| RegExp \| (joint) => boolean` | inferred | Explicit hinge/slide joints for IK |
|
|
235
|
+
| `actuators` | `string \| string[] \| RegExp \| (actuator) => boolean` | inferred | Explicit actuators for IK output |
|
|
236
|
+
| `numJoints` | `number` | legacy only | Contiguous qpos/ctrl count from older examples |
|
|
246
237
|
| `ikSolveFn` | `IKSolveFn` | built-in DLS | Custom solver function |
|
|
247
238
|
| `damping` | `number` | `0.01` | DLS damping |
|
|
248
239
|
| `maxIterations` | `number` | `50` | Max solver iterations |
|
|
@@ -251,6 +242,20 @@ Returns `IkContextValue | null` with methods like `setIkEnabled`, `moveTarget`,
|
|
|
251
242
|
|
|
252
243
|
Pass the returned value to `<IkGizmo controller={ik} />` or to your own controller as a prop.
|
|
253
244
|
|
|
245
|
+
By default the controller infers scalar hinge/slide joints by walking from the site body toward the model root. For robots where the MJCF control layout is not a simple chain, pass explicit names:
|
|
246
|
+
|
|
247
|
+
```tsx
|
|
248
|
+
const leftArmIk = useIkController({
|
|
249
|
+
siteName: "left_tcp",
|
|
250
|
+
joints: ["left_shoulder", "left_elbow", "left_wrist"],
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
const gripperIk = useIkController({
|
|
254
|
+
siteName: "tcp",
|
|
255
|
+
actuators: /^actuator/,
|
|
256
|
+
});
|
|
257
|
+
```
|
|
258
|
+
|
|
254
259
|
## Type-Safe Resource Names
|
|
255
260
|
|
|
256
261
|
Use TypeScript module augmentation to get autocomplete and type checking for actuator, sensor, body, joint, site, geom, and keyframe names:
|
|
@@ -334,8 +339,29 @@ Loads the MuJoCo WASM module. Wrap your entire app in this.
|
|
|
334
339
|
| Prop | Type | Description |
|
|
335
340
|
|------|------|-------------|
|
|
336
341
|
| `wasmUrl` | `string?` | Custom WASM URL override |
|
|
342
|
+
| `mtWasmUrl` | `string?` | Custom multi-threaded WASM URL override |
|
|
343
|
+
| `threadedLoader` | `(options?) => Promise<unknown>` | Optional loader imported from `@mujoco/mujoco/mt` |
|
|
344
|
+
| `wasmVariant` | `"single" \| "threaded" \| "auto"` | MuJoCo WASM build. Defaults to `"single"` |
|
|
345
|
+
| `timeout` | `number` | WASM load timeout in ms |
|
|
337
346
|
| `onError` | `(error: Error) => void` | Called if WASM fails to load |
|
|
338
347
|
|
|
348
|
+
The official `@mujoco/mujoco` package also ships a multi-threaded WASM build. Import it only in apps that opt into it:
|
|
349
|
+
|
|
350
|
+
```tsx
|
|
351
|
+
import loadMujocoMt from "@mujoco/mujoco/mt";
|
|
352
|
+
import mtWasmUrl from "@mujoco/mujoco/mt/mujoco.wasm?url";
|
|
353
|
+
|
|
354
|
+
<MujocoProvider
|
|
355
|
+
wasmVariant="auto"
|
|
356
|
+
threadedLoader={loadMujocoMt}
|
|
357
|
+
mtWasmUrl={mtWasmUrl}
|
|
358
|
+
>
|
|
359
|
+
<App />
|
|
360
|
+
</MujocoProvider>
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
`"auto"` uses the threaded build only when `threadedLoader` and `mtWasmUrl` are provided and `globalThis.crossOriginIsolated` is true. Forced `"threaded"` mode requires `threadedLoader`, `mtWasmUrl`, `Cross-Origin-Opener-Policy: same-origin` and `Cross-Origin-Embedder-Policy: require-corp`.
|
|
364
|
+
|
|
339
365
|
### `<MujocoCanvas>`
|
|
340
366
|
|
|
341
367
|
Thin wrapper around R3F `<Canvas>`. Accepts all R3F Canvas props plus:
|
package/dist/index.d.ts
CHANGED
|
@@ -285,11 +285,22 @@ interface SceneConfig {
|
|
|
285
285
|
xmlPatches?: XmlPatch[];
|
|
286
286
|
onReset?: (model: MujocoModel, data: MujocoData) => void;
|
|
287
287
|
}
|
|
288
|
+
type ResourceSelector<TInfo, TName extends string = string> = TName | readonly TName[] | RegExp | ((info: TInfo) => boolean);
|
|
288
289
|
interface IkConfig {
|
|
289
290
|
/** MuJoCo site name for IK target. */
|
|
290
291
|
siteName: Sites;
|
|
291
|
-
/**
|
|
292
|
-
|
|
292
|
+
/**
|
|
293
|
+
* Explicit joints for IK. When omitted, the controller infers scalar hinge/slide
|
|
294
|
+
* joints by walking from the site body to the model root.
|
|
295
|
+
*/
|
|
296
|
+
joints?: ResourceSelector<JointInfo, Joints>;
|
|
297
|
+
/** Explicit actuators for IK control output. */
|
|
298
|
+
actuators?: ResourceSelector<ActuatorInfo, Actuators>;
|
|
299
|
+
/**
|
|
300
|
+
* Number of joints to solve for, assuming legacy contiguous qpos/ctrl layout
|
|
301
|
+
* starting at index 0. Prefer inferred IK or `joints`/`actuators`.
|
|
302
|
+
*/
|
|
303
|
+
numJoints?: number;
|
|
293
304
|
/** Custom IK solver. When omitted, uses built-in Damped Least-Squares solver. */
|
|
294
305
|
ikSolveFn?: IKSolveFn;
|
|
295
306
|
/** DLS damping. Default: 0.01. */
|
|
@@ -323,7 +334,13 @@ interface PhysicsConfig {
|
|
|
323
334
|
paused?: boolean;
|
|
324
335
|
speed?: number;
|
|
325
336
|
}
|
|
326
|
-
type IKSolveFn = (pos: THREE.Vector3, quat: THREE.Quaternion, currentQ: number[]) => number[] | null;
|
|
337
|
+
type IKSolveFn = (pos: THREE.Vector3, quat: THREE.Quaternion, currentQ: number[], context?: IKSolveContext) => number[] | null;
|
|
338
|
+
interface IKSolveContext {
|
|
339
|
+
model: MujocoModel;
|
|
340
|
+
data: MujocoData;
|
|
341
|
+
siteId: number;
|
|
342
|
+
controlGroup: ControlGroupInfo;
|
|
343
|
+
}
|
|
327
344
|
type PhysicsStepCallback = (model: MujocoModel, data: MujocoData) => void;
|
|
328
345
|
interface StateSnapshot {
|
|
329
346
|
time: number;
|
|
@@ -368,6 +385,44 @@ interface ActuatorInfo {
|
|
|
368
385
|
name: string;
|
|
369
386
|
range: [number, number];
|
|
370
387
|
}
|
|
388
|
+
interface ActuatedJointInfo extends JointInfo {
|
|
389
|
+
actuatorId: number;
|
|
390
|
+
actuatorName: string;
|
|
391
|
+
ctrlAdr: number;
|
|
392
|
+
ctrlRange: [number, number];
|
|
393
|
+
}
|
|
394
|
+
interface ControlJointInfo extends JointInfo {
|
|
395
|
+
actuatorId: number | null;
|
|
396
|
+
actuatorName: string | null;
|
|
397
|
+
ctrlAdr: number | null;
|
|
398
|
+
ctrlRange: [number, number] | null;
|
|
399
|
+
}
|
|
400
|
+
interface ControlGroupSelector {
|
|
401
|
+
/** Infer a kinematic chain from a MuJoCo site. */
|
|
402
|
+
siteName?: Sites;
|
|
403
|
+
/** Infer a kinematic chain from a body. */
|
|
404
|
+
bodyName?: Bodies;
|
|
405
|
+
/** Select joints by name, names, regex, or predicate. */
|
|
406
|
+
joints?: ResourceSelector<JointInfo, Joints>;
|
|
407
|
+
/** Select actuators by name, names, regex, or predicate. */
|
|
408
|
+
actuators?: ResourceSelector<ActuatorInfo, Actuators>;
|
|
409
|
+
}
|
|
410
|
+
interface ControlGroupInfo {
|
|
411
|
+
/** Joints in solve/control order. */
|
|
412
|
+
joints: ControlJointInfo[];
|
|
413
|
+
/** Actuators in control output order. */
|
|
414
|
+
actuators: ActuatorInfo[];
|
|
415
|
+
/** qpos addresses for scalar hinge/slide joints. */
|
|
416
|
+
qposAdr: number[];
|
|
417
|
+
/** dof addresses for scalar hinge/slide joints. */
|
|
418
|
+
dofAdr: number[];
|
|
419
|
+
/** ctrl addresses matching writable actuators. */
|
|
420
|
+
ctrlAdr: number[];
|
|
421
|
+
readQpos(data: MujocoData): Float64Array;
|
|
422
|
+
readCtrl(data: MujocoData): Float64Array;
|
|
423
|
+
writeQpos(data: MujocoData, values: ArrayLike<number>): void;
|
|
424
|
+
writeCtrl(data: MujocoData, values: ArrayLike<number>): void;
|
|
425
|
+
}
|
|
371
426
|
interface SensorInfo {
|
|
372
427
|
id: number;
|
|
373
428
|
name: string;
|
|
@@ -495,6 +550,9 @@ interface MujocoSimAPI {
|
|
|
495
550
|
getQvel(): Float64Array;
|
|
496
551
|
setCtrl(nameOrValues: Actuators | Record<Actuators, number>, value?: number): void;
|
|
497
552
|
getCtrl(): Float64Array;
|
|
553
|
+
getControlMap(): ControlGroupInfo;
|
|
554
|
+
getActuatedJoints(): ActuatedJointInfo[];
|
|
555
|
+
resolveControlGroup(selector: ControlGroupSelector): ControlGroupInfo | null;
|
|
498
556
|
applyForce(bodyName: Bodies, force: THREE.Vector3, point?: THREE.Vector3): void;
|
|
499
557
|
applyTorque(bodyName: Bodies, torque: THREE.Vector3): void;
|
|
500
558
|
setExternalForce(bodyName: Bodies, force: THREE.Vector3, torque: THREE.Vector3): void;
|
|
@@ -585,8 +643,28 @@ interface JointStateResult {
|
|
|
585
643
|
* Hook to access the MuJoCo WASM module.
|
|
586
644
|
*/
|
|
587
645
|
declare function useMujocoWasm(): MujocoContextValue;
|
|
646
|
+
type MujocoWasmVariant = 'single' | 'threaded' | 'auto';
|
|
647
|
+
interface MujocoLoaderOptions {
|
|
648
|
+
locateFile?: (path: string) => string;
|
|
649
|
+
printErr?: (text: string) => void;
|
|
650
|
+
}
|
|
651
|
+
type MujocoLoader = (options?: MujocoLoaderOptions) => Promise<unknown>;
|
|
588
652
|
interface MujocoProviderProps {
|
|
589
653
|
wasmUrl?: string;
|
|
654
|
+
/** Optional URL for the multi-threaded WASM asset. */
|
|
655
|
+
mtWasmUrl?: string;
|
|
656
|
+
/**
|
|
657
|
+
* Optional official multi-threaded loader, usually imported from
|
|
658
|
+
* `@mujoco/mujoco/mt`. It is supplied by the app so the default package path
|
|
659
|
+
* does not force every bundler to process the threaded Emscripten build.
|
|
660
|
+
*/
|
|
661
|
+
threadedLoader?: MujocoLoader;
|
|
662
|
+
/**
|
|
663
|
+
* MuJoCo WASM build to load. `single` is the default and works everywhere.
|
|
664
|
+
* `threaded` requires `threadedLoader` and cross-origin isolation. `auto`
|
|
665
|
+
* uses threaded only when both conditions are satisfied.
|
|
666
|
+
*/
|
|
667
|
+
wasmVariant?: MujocoWasmVariant;
|
|
590
668
|
/** Timeout in ms for WASM module load. Default: 30000. */
|
|
591
669
|
timeout?: number;
|
|
592
670
|
children: React.ReactNode;
|
|
@@ -596,7 +674,7 @@ interface MujocoProviderProps {
|
|
|
596
674
|
* MujocoProvider — WASM / module lifecycle.
|
|
597
675
|
* Loads the MuJoCo WASM module on mount and provides it to children via context.
|
|
598
676
|
*/
|
|
599
|
-
declare function MujocoProvider({ wasmUrl, timeout, children, onError }: MujocoProviderProps): react_jsx_runtime.JSX.Element;
|
|
677
|
+
declare function MujocoProvider({ wasmUrl, mtWasmUrl, threadedLoader, wasmVariant, timeout, children, onError, }: MujocoProviderProps): react_jsx_runtime.JSX.Element;
|
|
600
678
|
|
|
601
679
|
/**
|
|
602
680
|
* MujocoCanvas — thin R3F Canvas wrapper for MuJoCo scenes.
|
|
@@ -740,6 +818,10 @@ declare function findSensorByName(mjModel: MujocoModel, name: string): number;
|
|
|
740
818
|
* Find a tendon by name in the MuJoCo model. Returns -1 if not found.
|
|
741
819
|
*/
|
|
742
820
|
declare function findTendonByName(mjModel: MujocoModel, name: string): number;
|
|
821
|
+
declare function getActuatedJoints(mjModel: MujocoModel): ActuatedJointInfo[];
|
|
822
|
+
declare function getControlMap(mjModel: MujocoModel): ControlGroupInfo;
|
|
823
|
+
declare function resolveControlGroup(mjModel: MujocoModel, selector: ControlGroupSelector): ControlGroupInfo | null;
|
|
824
|
+
declare function createContiguousControlGroup(mjModel: MujocoModel, count: number): ControlGroupInfo;
|
|
743
825
|
interface LoadResult {
|
|
744
826
|
mjModel: MujocoModel;
|
|
745
827
|
mjData: MujocoData;
|
|
@@ -1304,4 +1386,4 @@ interface CameraAnimationAPI {
|
|
|
1304
1386
|
*/
|
|
1305
1387
|
declare function useCameraAnimation(): CameraAnimationAPI;
|
|
1306
1388
|
|
|
1307
|
-
export { type ActuatorInfo, type Actuators, type Bodies, Body, type BodyInfo, type BodyProps, type BodyStateResult, type CameraAnimationAPI, type ContactInfo, ContactListener, type ContactListenerProps, ContactMarkers, type ControllerComponent, type ControllerOptions, type CtrlHandle, Debug, type DebugProps, DragInteraction, type DragInteractionProps, FlexRenderer, type GeomInfo, type Geoms, type IKSolveFn, type IkConfig, type IkContextValue, IkGizmo, type IkGizmoProps, type JointInfo, type JointStateResult, type Joints, type KeyBinding, type KeyboardTeleopConfig, type Keyframes, type ModelOptions, MujocoCanvas, type MujocoCanvasProps, type MujocoContact, type MujocoContactArray, type MujocoContextValue, type MujocoData, type MujocoModel, type MujocoModule, MujocoPhysics, type MujocoPhysicsProps, MujocoProvider, type MujocoSimAPI, MujocoSimProvider, type PhysicsConfig, type PhysicsStepCallback, type PlaybackState, type PolicyConfig, type RayHit, type Register, type SceneConfig, SceneLights, type SceneLightsProps, type SceneMarker, type SceneObject, type SensorHandle, type SensorInfo, type SensorResult, type Sensors, type SiteInfo, type SitePositionResult, type Sites, type StateSnapshot, TendonRenderer, type TrajectoryData, type TrajectoryFrame, type TrajectoryInput, TrajectoryPlayer, type TrajectoryPlayerProps, type XmlPatch, createController, createControllerHook, findActuatorByName, findBodyByName, findGeomByName, findJointByName, findKeyframeByName, findSensorByName, findSiteByName, findTendonByName, getContact, getName, loadScene, useActuators, useAfterPhysicsStep, useBeforePhysicsStep, useBodyMeshes, useBodyState, useCameraAnimation, useContactEvents, useContacts, useCtrl, useCtrlNoise, useGamepad, useGravityCompensation, useIkController, useJointState, useKeyboardTeleop, useMujoco, useMujocoWasm, usePolicy, useSceneLights, useSelectionHighlight, useSensor, useSensors, useSitePosition, useTrajectoryPlayer, useTrajectoryRecorder, useVideoRecorder };
|
|
1389
|
+
export { type ActuatedJointInfo, type ActuatorInfo, type Actuators, type Bodies, Body, type BodyInfo, type BodyProps, type BodyStateResult, type CameraAnimationAPI, type ContactInfo, ContactListener, type ContactListenerProps, ContactMarkers, type ControlGroupInfo, type ControlGroupSelector, type ControlJointInfo, type ControllerComponent, type ControllerOptions, type CtrlHandle, Debug, type DebugProps, DragInteraction, type DragInteractionProps, FlexRenderer, type GeomInfo, type Geoms, type IKSolveFn, type IkConfig, type IkContextValue, IkGizmo, type IkGizmoProps, type JointInfo, type JointStateResult, type Joints, type KeyBinding, type KeyboardTeleopConfig, type Keyframes, type ModelOptions, MujocoCanvas, type MujocoCanvasProps, type MujocoContact, type MujocoContactArray, type MujocoContextValue, type MujocoData, type MujocoLoader, type MujocoLoaderOptions, type MujocoModel, type MujocoModule, MujocoPhysics, type MujocoPhysicsProps, MujocoProvider, type MujocoProviderProps, type MujocoSimAPI, MujocoSimProvider, type MujocoWasmVariant, type PhysicsConfig, type PhysicsStepCallback, type PlaybackState, type PolicyConfig, type RayHit, type Register, type ResourceSelector, type SceneConfig, SceneLights, type SceneLightsProps, type SceneMarker, type SceneObject, type SensorHandle, type SensorInfo, type SensorResult, type Sensors, type SiteInfo, type SitePositionResult, type Sites, type StateSnapshot, TendonRenderer, type TrajectoryData, type TrajectoryFrame, type TrajectoryInput, TrajectoryPlayer, type TrajectoryPlayerProps, type XmlPatch, createContiguousControlGroup, createController, createControllerHook, findActuatorByName, findBodyByName, findGeomByName, findJointByName, findKeyframeByName, findSensorByName, findSiteByName, findTendonByName, getActuatedJoints, getContact, getControlMap, getName, loadScene, resolveControlGroup, useActuators, useAfterPhysicsStep, useBeforePhysicsStep, useBodyMeshes, useBodyState, useCameraAnimation, useContactEvents, useContacts, useCtrl, useCtrlNoise, useGamepad, useGravityCompensation, useIkController, useJointState, useKeyboardTeleop, useMujoco, useMujocoWasm, usePolicy, useSceneLights, useSelectionHighlight, useSensor, useSensors, useSitePosition, useTrajectoryPlayer, useTrajectoryRecorder, useVideoRecorder };
|