mujoco-react 6.0.1 → 7.0.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 +80 -45
- package/dist/index.d.ts +88 -57
- package/dist/index.js +372 -243
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Body.tsx +102 -0
- package/src/components/ContactMarkers.tsx +2 -2
- package/src/components/Debug.tsx +2 -2
- package/src/components/DragInteraction.tsx +2 -2
- package/src/components/FlexRenderer.tsx +2 -2
- package/src/components/IkGizmo.tsx +7 -11
- package/src/components/SceneRenderer.tsx +9 -6
- package/src/components/TendonRenderer.tsx +2 -2
- package/src/core/MujocoSimProvider.tsx +87 -6
- package/src/core/createController.tsx +54 -2
- package/src/hooks/useActuators.ts +2 -2
- package/src/hooks/useBodyState.ts +2 -2
- package/src/hooks/useContacts.ts +2 -2
- package/src/hooks/useCtrl.ts +2 -2
- package/src/hooks/useCtrlNoise.ts +2 -2
- package/src/hooks/useGamepad.ts +2 -2
- package/src/hooks/useIkController.ts +242 -0
- package/src/hooks/useJointState.ts +2 -2
- package/src/hooks/useKeyboardTeleop.ts +2 -2
- package/src/hooks/usePolicy.ts +2 -2
- package/src/hooks/useSceneLights.ts +2 -2
- package/src/hooks/useSensor.ts +3 -3
- package/src/hooks/useSitePosition.ts +2 -2
- package/src/hooks/useTrajectoryPlayer.ts +2 -2
- package/src/hooks/useTrajectoryRecorder.ts +2 -2
- package/src/index.ts +5 -4
- package/src/types.ts +30 -0
- package/src/components/IkController.tsx +0 -262
- package/src/core/IkContext.tsx +0 -40
package/README.md
CHANGED
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
# mujoco-react
|
|
6
6
|
|
|
7
|
+
> **Beta** — This library is under active development. The API may change between minor versions until 1.0.
|
|
8
|
+
|
|
7
9
|
Composable [React Three Fiber](https://docs.pmnd.rs/react-three-fiber) wrapper around [mujoco-js](https://www.npmjs.com/package/mujoco-js). Load any MuJoCo model, step physics, render bodies, and write controllers as React components.
|
|
8
10
|
|
|
9
|
-
**[
|
|
11
|
+
**[Demo](https://mujoco-react-example.pages.dev)** | **[Docs](https://dadd.mintlify.app)** | **[Example Source](https://github.com/noah-wardlow/mujoco-react-example)** | **[llms.txt](https://dadd.mintlify.app/llms.txt)**
|
|
10
12
|
|
|
11
13
|
## Install
|
|
12
14
|
|
|
@@ -20,7 +22,7 @@ npm install mujoco-react three @react-three/fiber @react-three/drei
|
|
|
20
22
|
import {
|
|
21
23
|
MujocoProvider,
|
|
22
24
|
MujocoCanvas,
|
|
23
|
-
|
|
25
|
+
useIkController,
|
|
24
26
|
IkGizmo,
|
|
25
27
|
} from 'mujoco-react';
|
|
26
28
|
import type { SceneConfig } from 'mujoco-react';
|
|
@@ -32,6 +34,18 @@ const config: SceneConfig = {
|
|
|
32
34
|
homeJoints: [1.707, -1.754, 0.003, -2.702, 0.003, 0.951, 2.490],
|
|
33
35
|
};
|
|
34
36
|
|
|
37
|
+
function Scene() {
|
|
38
|
+
const ik = useIkController({ siteName: 'tcp', numJoints: 7 });
|
|
39
|
+
return (
|
|
40
|
+
<>
|
|
41
|
+
<OrbitControls enableDamping makeDefault />
|
|
42
|
+
{ik && <IkGizmo controller={ik} />}
|
|
43
|
+
<ambientLight intensity={0.7} />
|
|
44
|
+
<directionalLight position={[1, 2, 5]} intensity={1.2} castShadow />
|
|
45
|
+
</>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
35
49
|
function App() {
|
|
36
50
|
return (
|
|
37
51
|
<MujocoProvider>
|
|
@@ -41,12 +55,7 @@ function App() {
|
|
|
41
55
|
shadows
|
|
42
56
|
style={{ width: '100%', height: '100vh' }}
|
|
43
57
|
>
|
|
44
|
-
<
|
|
45
|
-
<IkController config={{ siteName: 'tcp', numJoints: 7 }}>
|
|
46
|
-
<IkGizmo />
|
|
47
|
-
</IkController>
|
|
48
|
-
<ambientLight intensity={0.7} />
|
|
49
|
-
<directionalLight position={[1, 2, 5]} intensity={1.2} castShadow />
|
|
58
|
+
<Scene />
|
|
50
59
|
</MujocoCanvas>
|
|
51
60
|
</MujocoProvider>
|
|
52
61
|
);
|
|
@@ -60,13 +69,14 @@ Inside `<MujocoCanvas>` or `<MujocoPhysics>`, `useMujoco()` gives you the simula
|
|
|
60
69
|
```tsx
|
|
61
70
|
import { useMujoco } from 'mujoco-react';
|
|
62
71
|
|
|
63
|
-
function
|
|
64
|
-
const {
|
|
72
|
+
function MyComponent() {
|
|
73
|
+
const { isPending, isError, error, api, mjModelRef } = useMujoco();
|
|
65
74
|
|
|
66
|
-
if (
|
|
75
|
+
if (isPending) return <span>Loading...</span>;
|
|
76
|
+
if (isError) return <span>Error: {error}</span>;
|
|
67
77
|
|
|
68
78
|
return (
|
|
69
|
-
<button onClick={() => api
|
|
79
|
+
<button onClick={() => api.reset()}>
|
|
70
80
|
Reset ({mjModelRef.current?.nq} joints)
|
|
71
81
|
</button>
|
|
72
82
|
);
|
|
@@ -122,17 +132,17 @@ export const MyController = createController<{ gain: number }>(
|
|
|
122
132
|
```
|
|
123
133
|
<MujocoProvider> <MujocoProvider>
|
|
124
134
|
<MujocoCanvas config={...}> <Canvas shadows gl={...}>
|
|
125
|
-
<
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
</MujocoProvider>
|
|
135
|
+
<Scene /> <MujocoPhysics config={...}>
|
|
136
|
+
<MyController /> <MyController />
|
|
137
|
+
</MujocoCanvas> </MujocoPhysics>
|
|
138
|
+
</MujocoProvider> <EffectComposer>...</EffectComposer>
|
|
139
|
+
</Canvas>
|
|
140
|
+
</MujocoProvider>
|
|
131
141
|
```
|
|
132
142
|
|
|
133
143
|
### Custom IK Solvers
|
|
134
144
|
|
|
135
|
-
The built-in
|
|
145
|
+
The built-in `useIkController()` uses Damped Least-Squares. Pass `ikSolveFn` to swap in your own solver (analytical, learned, etc.):
|
|
136
146
|
|
|
137
147
|
```tsx
|
|
138
148
|
import type { IKSolveFn } from 'mujoco-react';
|
|
@@ -141,19 +151,16 @@ const myIK: IKSolveFn = (pos, quat, currentQ) => {
|
|
|
141
151
|
return myAnalyticalSolver(pos, currentQ); // return joint angles or null
|
|
142
152
|
};
|
|
143
153
|
|
|
144
|
-
|
|
145
|
-
<IkGizmo />
|
|
146
|
-
</IkController>
|
|
154
|
+
const ik = useIkController({ siteName: 'tcp', numJoints: 7, ikSolveFn: myIK });
|
|
147
155
|
```
|
|
148
156
|
|
|
149
|
-
###
|
|
157
|
+
### `useIkController(config | null)`
|
|
150
158
|
|
|
151
|
-
|
|
159
|
+
Hook for interactive end-effector control. Pass `null` to disable IK (safe to call unconditionally):
|
|
152
160
|
|
|
153
161
|
```tsx
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
</IkController>
|
|
162
|
+
const ik = useIkController({ siteName: 'tcp', numJoints: 7 });
|
|
163
|
+
return ik ? <IkGizmo controller={ik} /> : null;
|
|
157
164
|
```
|
|
158
165
|
|
|
159
166
|
| Config | Type | Default | Description |
|
|
@@ -164,17 +171,9 @@ The library includes one controller for interactive end-effector control:
|
|
|
164
171
|
| `damping` | `number` | `0.01` | DLS damping |
|
|
165
172
|
| `maxIterations` | `number` | `50` | Max solver iterations |
|
|
166
173
|
|
|
167
|
-
|
|
174
|
+
Returns `IkContextValue | null` with methods like `setIkEnabled`, `moveTarget`, `syncTargetToSite`, `solveIK`, and `getGizmoStats`.
|
|
168
175
|
|
|
169
|
-
|
|
170
|
-
const { setIkEnabled, moveTarget, solveIK } = useIk();
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
Pass `{ optional: true }` for components that may or may not be inside an `<IkController>`:
|
|
174
|
-
|
|
175
|
-
```tsx
|
|
176
|
-
const ikCtx = useIk({ optional: true });
|
|
177
|
-
```
|
|
176
|
+
Pass the returned value to `<IkGizmo controller={ik} />` or to your own controller as a prop.
|
|
178
177
|
|
|
179
178
|
## Loading Models
|
|
180
179
|
|
|
@@ -289,13 +288,46 @@ Physics provider for use inside your own R3F `<Canvas>`. Same physics props as `
|
|
|
289
288
|
| `paused` | `boolean` | Declarative pause |
|
|
290
289
|
| `speed` | `number` | Simulation speed multiplier |
|
|
291
290
|
|
|
291
|
+
### `<Body />`
|
|
292
|
+
|
|
293
|
+
Declaratively add physics bodies to the simulation as JSX. Bodies are injected into the MJCF XML before model compilation.
|
|
294
|
+
|
|
295
|
+
```tsx
|
|
296
|
+
<Body name="cube" type="box" size={[0.05, 0.05, 0.05]}
|
|
297
|
+
position={[0.5, 0, 0.05]} rgba={[1, 0, 0, 1]}
|
|
298
|
+
mass={0.1} freejoint />
|
|
299
|
+
|
|
300
|
+
// With custom Three.js visuals
|
|
301
|
+
<Body name="ball" type="sphere" size={[0.03, 0, 0]}
|
|
302
|
+
position={[0, 0.3, 0.1]} mass={0.5} freejoint>
|
|
303
|
+
<mesh>
|
|
304
|
+
<sphereGeometry args={[0.03]} />
|
|
305
|
+
<meshPhysicalMaterial color="gold" metalness={0.8} />
|
|
306
|
+
</mesh>
|
|
307
|
+
</Body>
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
| Prop | Type | Default | Description |
|
|
311
|
+
|------|------|---------|-------------|
|
|
312
|
+
| `name` | `string` | **required** | Unique body name |
|
|
313
|
+
| `type` | `'box' \| 'sphere' \| 'cylinder'` | **required** | Geom type |
|
|
314
|
+
| `size` | `[number, number, number]` | **required** | Geom size |
|
|
315
|
+
| `position` | `[number, number, number]` | `[0,0,0]` | Initial position |
|
|
316
|
+
| `rgba` | `[number, number, number, number]` | `[0.5,0.5,0.5,1]` | Color (ignored with children) |
|
|
317
|
+
| `mass` | `number?` | -- | Body mass in kg |
|
|
318
|
+
| `freejoint` | `boolean?` | -- | Add freejoint for free movement |
|
|
319
|
+
| `friction` | `string?` | -- | MuJoCo friction params |
|
|
320
|
+
| `condim` | `number?` | -- | Contact dimensionality (4-6 for grasping) |
|
|
321
|
+
| `children` | `ReactNode?` | -- | Custom Three.js visuals |
|
|
322
|
+
|
|
292
323
|
### `<IkGizmo />`
|
|
293
324
|
|
|
294
|
-
drei PivotControls gizmo that tracks a MuJoCo site and drives IK on drag.
|
|
325
|
+
drei PivotControls gizmo that tracks a MuJoCo site and drives IK on drag. Requires a `controller` from `useIkController()`.
|
|
295
326
|
|
|
296
327
|
| Prop | Type | Default | Description |
|
|
297
328
|
|------|------|---------|-------------|
|
|
298
|
-
| `
|
|
329
|
+
| `controller` | `IkContextValue` | **required** | Controller from `useIkController()` |
|
|
330
|
+
| `siteName` | `string?` | controller's site | MuJoCo site to track |
|
|
299
331
|
| `scale` | `number?` | `0.18` | Gizmo handle scale |
|
|
300
332
|
| `onDrag` | `(pos, quat) => void` | -- | Custom drag handler (disables auto-IK) |
|
|
301
333
|
|
|
@@ -373,10 +405,13 @@ Plays back recorded qpos trajectories with scrubbing.
|
|
|
373
405
|
|
|
374
406
|
### `useMujoco()`
|
|
375
407
|
|
|
376
|
-
Access the simulation API
|
|
408
|
+
Access the simulation API (must be inside `<MujocoCanvas>` or `<MujocoPhysics>`). Narrow on `isReady`, `isPending`, or `isError`:
|
|
377
409
|
|
|
378
410
|
```tsx
|
|
379
|
-
const
|
|
411
|
+
const sim = useMujoco();
|
|
412
|
+
if (sim.isReady) {
|
|
413
|
+
sim.api.reset(); // fully typed
|
|
414
|
+
}
|
|
380
415
|
```
|
|
381
416
|
|
|
382
417
|
### `useMujocoWasm()`
|
|
@@ -410,9 +445,9 @@ useBeforePhysicsStep((model, data) => {
|
|
|
410
445
|
|
|
411
446
|
Run logic **after** `mj_step` each frame. Read results, compute rewards, log telemetry.
|
|
412
447
|
|
|
413
|
-
### `
|
|
448
|
+
### `useIkController(config | null)`
|
|
414
449
|
|
|
415
|
-
|
|
450
|
+
Set up IK control for a MuJoCo site. Pass `null` to disable. Returns `IkContextValue | null`.
|
|
416
451
|
|
|
417
452
|
### `useCameraAnimation()`
|
|
418
453
|
|
|
@@ -579,7 +614,7 @@ useSceneLights(1.5);
|
|
|
579
614
|
|
|
580
615
|
## MujocoSimAPI
|
|
581
616
|
|
|
582
|
-
The full API object available via `ref` or `useMujoco()
|
|
617
|
+
The full API object available via `ref` or `useMujoco()` (when `isReady`):
|
|
583
618
|
|
|
584
619
|
### Simulation Control
|
|
585
620
|
|
|
@@ -682,7 +717,7 @@ See [Click-to-Select](https://dadd.mintlify.app/guides/click-to-select) for the
|
|
|
682
717
|
| Priority | Owner | Purpose |
|
|
683
718
|
|----------|-------|---------|
|
|
684
719
|
| -1 | MujocoSimProvider | beforeStep, mj_step, afterStep |
|
|
685
|
-
| 0 (default) | SceneRenderer (internal),
|
|
720
|
+
| 0 (default) | SceneRenderer (internal), useIkController, your code | Body mesh sync, IK, rendering |
|
|
686
721
|
|
|
687
722
|
## Roadmap
|
|
688
723
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as React$1 from 'react';
|
|
3
|
+
import React__default, { ReactNode } from 'react';
|
|
2
4
|
import { CanvasProps, ThreeElements } from '@react-three/fiber';
|
|
3
5
|
import * as THREE from 'three';
|
|
4
|
-
import * as react from 'react';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @license
|
|
@@ -254,6 +255,20 @@ interface IkConfig {
|
|
|
254
255
|
/** Max solver iterations. Default: 50. */
|
|
255
256
|
maxIterations?: number;
|
|
256
257
|
}
|
|
258
|
+
interface IkContextValue {
|
|
259
|
+
ikEnabledRef: React__default.RefObject<boolean>;
|
|
260
|
+
ikCalculatingRef: React__default.RefObject<boolean>;
|
|
261
|
+
ikTargetRef: React__default.RefObject<THREE.Group>;
|
|
262
|
+
siteIdRef: React__default.RefObject<number>;
|
|
263
|
+
setIkEnabled: (enabled: boolean) => void;
|
|
264
|
+
moveTarget: (pos: THREE.Vector3, duration?: number) => void;
|
|
265
|
+
syncTargetToSite: () => void;
|
|
266
|
+
solveIK: (pos: THREE.Vector3, quat: THREE.Quaternion, currentQ: number[]) => number[] | null;
|
|
267
|
+
getGizmoStats: () => {
|
|
268
|
+
pos: THREE.Vector3;
|
|
269
|
+
rot: THREE.Euler;
|
|
270
|
+
} | null;
|
|
271
|
+
}
|
|
257
272
|
interface SceneMarker {
|
|
258
273
|
id: number;
|
|
259
274
|
position: THREE.Vector3;
|
|
@@ -374,6 +389,7 @@ interface DebugProps {
|
|
|
374
389
|
showTendons?: boolean;
|
|
375
390
|
}
|
|
376
391
|
interface IkGizmoProps {
|
|
392
|
+
controller: IkContextValue;
|
|
377
393
|
siteName?: string;
|
|
378
394
|
scale?: number;
|
|
379
395
|
onDrag?: (position: THREE.Vector3, quaternion: THREE.Quaternion) => void;
|
|
@@ -398,6 +414,20 @@ interface ContactListenerProps {
|
|
|
398
414
|
onContactEnter?: (info: ContactInfo) => void;
|
|
399
415
|
onContactExit?: (info: ContactInfo) => void;
|
|
400
416
|
}
|
|
417
|
+
interface BodyProps {
|
|
418
|
+
name: string;
|
|
419
|
+
type: 'box' | 'sphere' | 'cylinder';
|
|
420
|
+
size: [number, number, number];
|
|
421
|
+
position?: [number, number, number];
|
|
422
|
+
rgba?: [number, number, number, number];
|
|
423
|
+
mass?: number;
|
|
424
|
+
freejoint?: boolean;
|
|
425
|
+
friction?: string;
|
|
426
|
+
solref?: string;
|
|
427
|
+
solimp?: string;
|
|
428
|
+
condim?: number;
|
|
429
|
+
children?: ReactNode;
|
|
430
|
+
}
|
|
401
431
|
interface MujocoSimAPI {
|
|
402
432
|
readonly status: 'loading' | 'ready' | 'error';
|
|
403
433
|
readonly config: SceneConfig;
|
|
@@ -445,8 +475,8 @@ interface MujocoSimAPI {
|
|
|
445
475
|
setBodyMass(name: string, mass: number): void;
|
|
446
476
|
setGeomFriction(name: string, friction: [number, number, number]): void;
|
|
447
477
|
setGeomSize(name: string, size: [number, number, number]): void;
|
|
448
|
-
readonly mjModelRef:
|
|
449
|
-
readonly mjDataRef:
|
|
478
|
+
readonly mjModelRef: React__default.RefObject<MujocoModel | null>;
|
|
479
|
+
readonly mjDataRef: React__default.RefObject<MujocoData | null>;
|
|
450
480
|
}
|
|
451
481
|
type MujocoCanvasProps = Omit<CanvasProps, 'onError'> & {
|
|
452
482
|
config: SceneConfig;
|
|
@@ -461,8 +491,8 @@ type MujocoCanvasProps = Omit<CanvasProps, 'onError'> & {
|
|
|
461
491
|
speed?: number;
|
|
462
492
|
};
|
|
463
493
|
interface SitePositionResult {
|
|
464
|
-
position:
|
|
465
|
-
quaternion:
|
|
494
|
+
position: React__default.RefObject<THREE.Vector3>;
|
|
495
|
+
quaternion: React__default.RefObject<THREE.Quaternion>;
|
|
466
496
|
}
|
|
467
497
|
interface MujocoContextValue {
|
|
468
498
|
mujoco: MujocoModule | null;
|
|
@@ -470,18 +500,18 @@ interface MujocoContextValue {
|
|
|
470
500
|
error: string | null;
|
|
471
501
|
}
|
|
472
502
|
interface SensorResult {
|
|
473
|
-
value:
|
|
503
|
+
value: React__default.RefObject<Float64Array>;
|
|
474
504
|
size: number;
|
|
475
505
|
}
|
|
476
506
|
interface BodyStateResult {
|
|
477
|
-
position:
|
|
478
|
-
quaternion:
|
|
479
|
-
linearVelocity:
|
|
480
|
-
angularVelocity:
|
|
507
|
+
position: React__default.RefObject<THREE.Vector3>;
|
|
508
|
+
quaternion: React__default.RefObject<THREE.Quaternion>;
|
|
509
|
+
linearVelocity: React__default.RefObject<THREE.Vector3>;
|
|
510
|
+
angularVelocity: React__default.RefObject<THREE.Vector3>;
|
|
481
511
|
}
|
|
482
512
|
interface JointStateResult {
|
|
483
|
-
position:
|
|
484
|
-
velocity:
|
|
513
|
+
position: React__default.RefObject<number | Float64Array>;
|
|
514
|
+
velocity: React__default.RefObject<number | Float64Array>;
|
|
485
515
|
}
|
|
486
516
|
|
|
487
517
|
/**
|
|
@@ -508,7 +538,7 @@ declare function MujocoProvider({ wasmUrl, timeout, children, onError }: MujocoP
|
|
|
508
538
|
*
|
|
509
539
|
* Forward ref exposes MujocoSimAPI (not the canvas element).
|
|
510
540
|
*/
|
|
511
|
-
declare const MujocoCanvas:
|
|
541
|
+
declare const MujocoCanvas: React$1.ForwardRefExoticComponent<Omit<MujocoCanvasProps, "ref"> & React$1.RefAttributes<MujocoSimAPI>>;
|
|
512
542
|
|
|
513
543
|
interface MujocoPhysicsProps {
|
|
514
544
|
/** Scene/robot configuration. */
|
|
@@ -552,24 +582,37 @@ interface MujocoPhysicsProps {
|
|
|
552
582
|
*
|
|
553
583
|
* Forward ref exposes MujocoSimAPI.
|
|
554
584
|
*/
|
|
555
|
-
declare const MujocoPhysics:
|
|
585
|
+
declare const MujocoPhysics: React$1.ForwardRefExoticComponent<MujocoPhysicsProps & React$1.RefAttributes<MujocoSimAPI>>;
|
|
556
586
|
|
|
557
|
-
|
|
587
|
+
type UseMujocoResult = {
|
|
588
|
+
status: 'loading';
|
|
589
|
+
isPending: true;
|
|
590
|
+
isReady: false;
|
|
591
|
+
isError: false;
|
|
592
|
+
error: null;
|
|
593
|
+
api: null;
|
|
594
|
+
mjModelRef: null;
|
|
595
|
+
mjDataRef: null;
|
|
596
|
+
} | {
|
|
597
|
+
status: 'error';
|
|
598
|
+
isPending: false;
|
|
599
|
+
isReady: false;
|
|
600
|
+
isError: true;
|
|
601
|
+
error: string;
|
|
602
|
+
api: null;
|
|
603
|
+
mjModelRef: null;
|
|
604
|
+
mjDataRef: null;
|
|
605
|
+
} | {
|
|
606
|
+
status: 'ready';
|
|
607
|
+
isPending: false;
|
|
608
|
+
isReady: true;
|
|
609
|
+
isError: false;
|
|
610
|
+
error: null;
|
|
558
611
|
api: MujocoSimAPI;
|
|
559
612
|
mjModelRef: React.RefObject<MujocoModel | null>;
|
|
560
613
|
mjDataRef: React.RefObject<MujocoData | null>;
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
pausedRef: React.RefObject<boolean>;
|
|
564
|
-
speedRef: React.RefObject<number>;
|
|
565
|
-
substepsRef: React.RefObject<number>;
|
|
566
|
-
onSelectionRef: React.RefObject<((bodyId: number, name: string) => void) | undefined>;
|
|
567
|
-
beforeStepCallbacks: React.RefObject<Set<PhysicsStepCallback>>;
|
|
568
|
-
afterStepCallbacks: React.RefObject<Set<PhysicsStepCallback>>;
|
|
569
|
-
resetCallbacks: React.RefObject<Set<() => void>>;
|
|
570
|
-
status: 'loading' | 'ready' | 'error';
|
|
571
|
-
}
|
|
572
|
-
declare function useMujoco(): MujocoSimContextValue;
|
|
614
|
+
};
|
|
615
|
+
declare function useMujoco(): UseMujocoResult;
|
|
573
616
|
declare function useBeforePhysicsStep(callback: PhysicsStepCallback): void;
|
|
574
617
|
declare function useAfterPhysicsStep(callback: PhysicsStepCallback): void;
|
|
575
618
|
interface MujocoSimProviderProps {
|
|
@@ -642,8 +685,6 @@ declare function loadScene(mujoco: MujocoModule, config: SceneConfig, onProgress
|
|
|
642
685
|
/**
|
|
643
686
|
* @license
|
|
644
687
|
* SPDX-License-Identifier: Apache-2.0
|
|
645
|
-
*
|
|
646
|
-
* createController — typed factory for BYOC (Bring Your Own Controller) plugins.
|
|
647
688
|
*/
|
|
648
689
|
interface ControllerOptions<TConfig> {
|
|
649
690
|
/** Unique name for this controller (used as displayName). */
|
|
@@ -686,47 +727,37 @@ declare function createController<TConfig>(options: ControllerOptions<TConfig>,
|
|
|
686
727
|
children?: React.ReactNode;
|
|
687
728
|
}>): ControllerComponent<TConfig>;
|
|
688
729
|
|
|
689
|
-
|
|
730
|
+
/**
|
|
731
|
+
* @license
|
|
732
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
733
|
+
*/
|
|
734
|
+
|
|
735
|
+
declare const useIkController: (config: IkConfig | null) => IkContextValue | null;
|
|
690
736
|
|
|
691
|
-
interface IkContextValue {
|
|
692
|
-
ikEnabledRef: React.RefObject<boolean>;
|
|
693
|
-
ikCalculatingRef: React.RefObject<boolean>;
|
|
694
|
-
ikTargetRef: React.RefObject<THREE.Group>;
|
|
695
|
-
siteIdRef: React.RefObject<number>;
|
|
696
|
-
setIkEnabled(enabled: boolean): void;
|
|
697
|
-
moveTarget(pos: THREE.Vector3, duration?: number): void;
|
|
698
|
-
syncTargetToSite(): void;
|
|
699
|
-
solveIK(pos: THREE.Vector3, quat: THREE.Quaternion, currentQ: number[]): number[] | null;
|
|
700
|
-
getGizmoStats(): {
|
|
701
|
-
pos: THREE.Vector3;
|
|
702
|
-
rot: THREE.Euler;
|
|
703
|
-
} | null;
|
|
704
|
-
}
|
|
705
737
|
/**
|
|
706
|
-
*
|
|
738
|
+
* Declarative physics body component. Registers a body definition in the
|
|
739
|
+
* provider-level registry so it gets injected into the MJCF XML at load time.
|
|
707
740
|
*
|
|
708
|
-
*
|
|
709
|
-
*
|
|
710
|
-
*
|
|
711
|
-
*/
|
|
712
|
-
declare function
|
|
713
|
-
declare function useIk(options: {
|
|
714
|
-
optional: true;
|
|
715
|
-
}): IkContextValue | null;
|
|
741
|
+
* Bodies present at initial mount cause zero extra reloads (useLayoutEffect
|
|
742
|
+
* runs before the provider's loadScene useEffect). Bodies added/removed after
|
|
743
|
+
* the initial load trigger a debounced scene reload.
|
|
744
|
+
*/
|
|
745
|
+
declare function Body({ name, type, size, position, rgba, mass, freejoint, friction, solref, solimp, condim, children, }: BodyProps): react_jsx_runtime.JSX.Element | null;
|
|
716
746
|
|
|
717
747
|
/**
|
|
718
748
|
* IkGizmo — drei PivotControls that tracks a MuJoCo site.
|
|
719
749
|
*
|
|
720
|
-
*
|
|
750
|
+
* Requires a `controller` from `useIkController()`.
|
|
721
751
|
*
|
|
722
752
|
* Props:
|
|
723
|
-
* - `
|
|
753
|
+
* - `controller` — IkContextValue from `useIkController()`.
|
|
754
|
+
* - `siteName` — MuJoCo site to track. Defaults to the controller's configured site.
|
|
724
755
|
* - `scale` — Gizmo handle scale. Default: 0.18.
|
|
725
756
|
* - `onDrag` — Custom drag callback `(pos, quat) => void`.
|
|
726
757
|
* When omitted, dragging enables IK and writes to the IK target.
|
|
727
758
|
* When provided, the consumer handles what happens during drag.
|
|
728
759
|
*/
|
|
729
|
-
declare function IkGizmo({ siteName, scale, onDrag }: IkGizmoProps): react_jsx_runtime.JSX.Element | null;
|
|
760
|
+
declare function IkGizmo({ controller, siteName, scale, onDrag }: IkGizmoProps): react_jsx_runtime.JSX.Element | null;
|
|
730
761
|
|
|
731
762
|
interface ContactMarkersProps {
|
|
732
763
|
/** Maximum contacts to render. Default: 100. */
|
|
@@ -1164,4 +1195,4 @@ interface CameraAnimationAPI {
|
|
|
1164
1195
|
*/
|
|
1165
1196
|
declare function useCameraAnimation(): CameraAnimationAPI;
|
|
1166
1197
|
|
|
1167
|
-
export { type ActuatorInfo, type BodyInfo, type BodyStateResult, type CameraAnimationAPI, type ContactInfo, ContactListener, type ContactListenerProps, ContactMarkers, type ControllerComponent, type ControllerOptions, Debug, type DebugProps, DragInteraction, type DragInteractionProps, FlexRenderer, type GeomInfo, type IKSolveFn, type IkConfig, type IkContextValue,
|
|
1198
|
+
export { type ActuatorInfo, Body, type BodyInfo, type BodyProps, type BodyStateResult, type CameraAnimationAPI, type ContactInfo, ContactListener, type ContactListenerProps, ContactMarkers, type ControllerComponent, type ControllerOptions, Debug, type DebugProps, DragInteraction, type DragInteractionProps, FlexRenderer, type GeomInfo, type IKSolveFn, type IkConfig, type IkContextValue, IkGizmo, type IkGizmoProps, type JointInfo, type JointStateResult, type KeyBinding, type KeyboardTeleopConfig, 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 PolicyConfig, type RayHit, type SceneConfig, SceneLights, type SceneLightsProps, type SceneMarker, type SceneObject, type SensorInfo, type SensorResult, type SiteInfo, type SitePositionResult, type StateSnapshot, TendonRenderer, type TrajectoryData, type TrajectoryFrame, TrajectoryPlayer, type TrajectoryPlayerProps, type XmlPatch, createController, 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 };
|