mujoco-react 0.2.0 → 1.0.0
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 +287 -48
- package/dist/index.d.ts +215 -135
- package/dist/index.js +1176 -795
- package/dist/index.js.map +1 -1
- package/package.json +6 -4
- package/src/components/ContactMarkers.tsx +19 -22
- package/src/components/Debug.tsx +173 -36
- package/src/components/DragInteraction.tsx +5 -3
- package/src/components/FlexRenderer.tsx +3 -2
- package/src/components/IkController.tsx +262 -0
- package/src/components/IkGizmo.tsx +17 -25
- package/src/components/SceneLights.tsx +2 -112
- package/src/components/SceneRenderer.tsx +13 -8
- package/src/components/SelectionHighlight.tsx +2 -49
- package/src/components/TendonRenderer.tsx +93 -28
- package/src/components/TrajectoryPlayer.tsx +14 -10
- package/src/core/IkContext.tsx +40 -0
- package/src/core/MujocoCanvas.tsx +1 -5
- package/src/core/MujocoPhysics.tsx +79 -0
- package/src/core/MujocoProvider.tsx +12 -4
- package/src/core/MujocoSimProvider.tsx +56 -340
- package/src/core/SceneLoader.ts +45 -18
- package/src/core/createController.tsx +91 -0
- package/src/hooks/useCameraAnimation.ts +102 -0
- package/src/hooks/useContacts.ts +52 -22
- package/src/hooks/useJointState.ts +18 -2
- package/src/hooks/useSceneLights.ts +117 -0
- package/src/hooks/useSelectionHighlight.ts +65 -0
- package/src/index.ts +18 -1
- package/src/types.ts +53 -26
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { CanvasProps } from '@react-three/fiber';
|
|
2
|
+
import { CanvasProps, ThreeElements } from '@react-three/fiber';
|
|
3
3
|
import * as THREE from 'three';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
|
|
@@ -8,6 +8,28 @@ import * as react from 'react';
|
|
|
8
8
|
* SPDX-License-Identifier: Apache-2.0
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* A single MuJoCo contact from the WASM module.
|
|
13
|
+
* Accessed via `data.contact.get(i)`.
|
|
14
|
+
*/
|
|
15
|
+
interface MujocoContact {
|
|
16
|
+
geom1: number;
|
|
17
|
+
geom2: number;
|
|
18
|
+
pos: Float64Array;
|
|
19
|
+
frame: Float64Array;
|
|
20
|
+
dist: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* WASM contact array — supports indexed access via `.get(i)`.
|
|
24
|
+
*/
|
|
25
|
+
interface MujocoContactArray {
|
|
26
|
+
get(i: number): MujocoContact | undefined;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Read a single contact from the WASM contact array.
|
|
30
|
+
* Returns undefined if the access fails (WASM heap issue, bad index, etc.).
|
|
31
|
+
*/
|
|
32
|
+
declare function getContact(data: MujocoData, i: number): MujocoContact | undefined;
|
|
11
33
|
/**
|
|
12
34
|
* Minimal interface for MuJoCo Model to avoid 'any'.
|
|
13
35
|
*/
|
|
@@ -45,11 +67,14 @@ interface MujocoModel {
|
|
|
45
67
|
body_geomnum: Int32Array;
|
|
46
68
|
body_geomadr: Int32Array;
|
|
47
69
|
body_inertia: Float64Array;
|
|
70
|
+
qpos0: Float64Array;
|
|
48
71
|
jnt_qposadr: Int32Array;
|
|
49
72
|
jnt_dofadr: Int32Array;
|
|
50
73
|
jnt_type: Int32Array;
|
|
51
74
|
jnt_range: Float64Array;
|
|
52
75
|
jnt_bodyid: Int32Array;
|
|
76
|
+
jnt_pos: Float64Array;
|
|
77
|
+
jnt_axis: Float64Array;
|
|
53
78
|
jnt_limited: Uint8Array;
|
|
54
79
|
geom_group: Int32Array;
|
|
55
80
|
geom_type: Int32Array;
|
|
@@ -135,7 +160,7 @@ interface MujocoData {
|
|
|
135
160
|
site_xmat: Float64Array;
|
|
136
161
|
sensordata: Float64Array;
|
|
137
162
|
ncon: number;
|
|
138
|
-
contact:
|
|
163
|
+
contact: MujocoContactArray;
|
|
139
164
|
cvel: Float64Array;
|
|
140
165
|
cfrc_ext: Float64Array;
|
|
141
166
|
ten_length: Float64Array;
|
|
@@ -212,13 +237,22 @@ interface SceneConfig {
|
|
|
212
237
|
sceneFile: string;
|
|
213
238
|
baseUrl?: string;
|
|
214
239
|
sceneObjects?: SceneObject[];
|
|
215
|
-
tcpSiteName?: string;
|
|
216
|
-
gripperActuatorName?: string;
|
|
217
|
-
numArmJoints?: number;
|
|
218
240
|
homeJoints?: number[];
|
|
219
241
|
xmlPatches?: XmlPatch[];
|
|
220
242
|
onReset?: (model: MujocoModel, data: MujocoData) => void;
|
|
221
243
|
}
|
|
244
|
+
interface IkConfig {
|
|
245
|
+
/** MuJoCo site name for IK target. */
|
|
246
|
+
siteName: string;
|
|
247
|
+
/** Number of joints to solve for. */
|
|
248
|
+
numJoints: number;
|
|
249
|
+
/** Custom IK solver. When omitted, uses built-in Damped Least-Squares solver. */
|
|
250
|
+
ikSolveFn?: IKSolveFn;
|
|
251
|
+
/** DLS damping. Default: 0.01. */
|
|
252
|
+
damping?: number;
|
|
253
|
+
/** Max solver iterations. Default: 50. */
|
|
254
|
+
maxIterations?: number;
|
|
255
|
+
}
|
|
222
256
|
interface SceneMarker {
|
|
223
257
|
id: number;
|
|
224
258
|
position: THREE.Vector3;
|
|
@@ -230,7 +264,6 @@ interface PhysicsConfig {
|
|
|
230
264
|
substeps?: number;
|
|
231
265
|
paused?: boolean;
|
|
232
266
|
speed?: number;
|
|
233
|
-
interpolate?: boolean;
|
|
234
267
|
}
|
|
235
268
|
type IKSolveFn = (pos: THREE.Vector3, quat: THREE.Quaternion, currentQ: number[]) => number[] | null;
|
|
236
269
|
type PhysicsStepCallback = (model: MujocoModel, data: MujocoData) => void;
|
|
@@ -407,14 +440,6 @@ interface MujocoSimAPI {
|
|
|
407
440
|
getKeyframeNames(): string[];
|
|
408
441
|
getKeyframeCount(): number;
|
|
409
442
|
loadScene(newConfig: SceneConfig): Promise<void>;
|
|
410
|
-
setIkEnabled(enabled: boolean): void;
|
|
411
|
-
moveTarget(pos: THREE.Vector3, duration?: number): void;
|
|
412
|
-
syncTargetToSite(): void;
|
|
413
|
-
solveIK(pos: THREE.Vector3, quat: THREE.Quaternion, currentQ: number[]): number[] | null;
|
|
414
|
-
getGizmoStats(): {
|
|
415
|
-
pos: THREE.Vector3;
|
|
416
|
-
rot: THREE.Euler;
|
|
417
|
-
} | null;
|
|
418
443
|
getCanvasSnapshot(width?: number, height?: number, mimeType?: string): string;
|
|
419
444
|
project2DTo3D(x: number, y: number, cameraPos: THREE.Vector3, lookAt: THREE.Vector3): {
|
|
420
445
|
point: THREE.Vector3;
|
|
@@ -424,11 +449,6 @@ interface MujocoSimAPI {
|
|
|
424
449
|
setBodyMass(name: string, mass: number): void;
|
|
425
450
|
setGeomFriction(name: string, friction: [number, number, number]): void;
|
|
426
451
|
setGeomSize(name: string, size: [number, number, number]): void;
|
|
427
|
-
getCameraState(): {
|
|
428
|
-
position: THREE.Vector3;
|
|
429
|
-
target: THREE.Vector3;
|
|
430
|
-
};
|
|
431
|
-
moveCameraTo(position: THREE.Vector3, target: THREE.Vector3, durationMs: number): Promise<void>;
|
|
432
452
|
readonly mjModelRef: React.RefObject<MujocoModel | null>;
|
|
433
453
|
readonly mjDataRef: React.RefObject<MujocoData | null>;
|
|
434
454
|
}
|
|
@@ -443,9 +463,6 @@ type MujocoCanvasProps = Omit<CanvasProps, 'onError'> & {
|
|
|
443
463
|
substeps?: number;
|
|
444
464
|
paused?: boolean;
|
|
445
465
|
speed?: number;
|
|
446
|
-
interpolate?: boolean;
|
|
447
|
-
gravityCompensation?: boolean;
|
|
448
|
-
mjcfLights?: boolean;
|
|
449
466
|
};
|
|
450
467
|
interface SitePositionResult {
|
|
451
468
|
position: React.RefObject<THREE.Vector3>;
|
|
@@ -477,6 +494,8 @@ interface JointStateResult {
|
|
|
477
494
|
declare function useMujoco(): MujocoContextValue;
|
|
478
495
|
interface MujocoProviderProps {
|
|
479
496
|
wasmUrl?: string;
|
|
497
|
+
/** Timeout in ms for WASM module load. Default: 30000. */
|
|
498
|
+
timeout?: number;
|
|
480
499
|
children: React.ReactNode;
|
|
481
500
|
onError?: (error: Error) => void;
|
|
482
501
|
}
|
|
@@ -484,7 +503,7 @@ interface MujocoProviderProps {
|
|
|
484
503
|
* MujocoProvider — WASM / module lifecycle.
|
|
485
504
|
* Loads the MuJoCo WASM module on mount and provides it to children via context.
|
|
486
505
|
*/
|
|
487
|
-
declare function MujocoProvider({ wasmUrl, children, onError }: MujocoProviderProps): react_jsx_runtime.JSX.Element;
|
|
506
|
+
declare function MujocoProvider({ wasmUrl, timeout, children, onError }: MujocoProviderProps): react_jsx_runtime.JSX.Element;
|
|
488
507
|
|
|
489
508
|
/**
|
|
490
509
|
* MujocoCanvas — thin R3F Canvas wrapper for MuJoCo scenes.
|
|
@@ -495,41 +514,49 @@ declare function MujocoProvider({ wasmUrl, children, onError }: MujocoProviderPr
|
|
|
495
514
|
*/
|
|
496
515
|
declare const MujocoCanvas: react.ForwardRefExoticComponent<Omit<MujocoCanvasProps, "ref"> & react.RefAttributes<MujocoSimAPI>>;
|
|
497
516
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
*/
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
517
|
+
interface MujocoPhysicsProps {
|
|
518
|
+
/** Scene/robot configuration. */
|
|
519
|
+
config: SceneConfig;
|
|
520
|
+
/** Fires when model is loaded and API is ready. */
|
|
521
|
+
onReady?: (api: MujocoSimAPI) => void;
|
|
522
|
+
/** Fires on scene load failure. */
|
|
523
|
+
onError?: (error: Error) => void;
|
|
524
|
+
/** Called each physics step. */
|
|
525
|
+
onStep?: (time: number) => void;
|
|
526
|
+
/** Called on body double-click selection. */
|
|
527
|
+
onSelection?: (bodyId: number, name: string) => void;
|
|
528
|
+
/** Override model gravity. */
|
|
529
|
+
gravity?: [number, number, number];
|
|
530
|
+
/** Override model.opt.timestep. */
|
|
531
|
+
timestep?: number;
|
|
532
|
+
/** mj_step calls per frame. */
|
|
533
|
+
substeps?: number;
|
|
534
|
+
/** Declarative pause. */
|
|
535
|
+
paused?: boolean;
|
|
536
|
+
/** Simulation speed multiplier. */
|
|
537
|
+
speed?: number;
|
|
538
|
+
children: React.ReactNode;
|
|
510
539
|
}
|
|
511
540
|
/**
|
|
512
|
-
*
|
|
513
|
-
*
|
|
514
|
-
*
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
solve(model: MujocoModel, data: MujocoData, siteId: number, numJoints: number, targetPos: THREE.Vector3, targetQuat: THREE.Quaternion, currentQ: number[], opts?: Partial<GenericIKOptions>): number[] | null;
|
|
532
|
-
}
|
|
541
|
+
* MujocoPhysics — physics provider for use inside a user-owned R3F Canvas.
|
|
542
|
+
*
|
|
543
|
+
* This is the R3F-idiomatic alternative to MujocoCanvas. Instead of wrapping
|
|
544
|
+
* the Canvas, place this inside your own <Canvas>:
|
|
545
|
+
*
|
|
546
|
+
* ```tsx
|
|
547
|
+
* <MujocoProvider>
|
|
548
|
+
* <Canvas shadows camera={...}>
|
|
549
|
+
* <MujocoPhysics config={config} paused={paused}>
|
|
550
|
+
* <SceneRenderer />
|
|
551
|
+
* <OrbitControls />
|
|
552
|
+
* </MujocoPhysics>
|
|
553
|
+
* </Canvas>
|
|
554
|
+
* </MujocoProvider>
|
|
555
|
+
* ```
|
|
556
|
+
*
|
|
557
|
+
* Forward ref exposes MujocoSimAPI.
|
|
558
|
+
*/
|
|
559
|
+
declare const MujocoPhysics: react.ForwardRefExoticComponent<MujocoPhysicsProps & react.RefAttributes<MujocoSimAPI>>;
|
|
533
560
|
|
|
534
561
|
interface MujocoSimContextValue {
|
|
535
562
|
api: MujocoSimAPI;
|
|
@@ -537,41 +564,13 @@ interface MujocoSimContextValue {
|
|
|
537
564
|
mjDataRef: React.RefObject<MujocoData | null>;
|
|
538
565
|
mujocoRef: React.RefObject<MujocoModule>;
|
|
539
566
|
configRef: React.RefObject<SceneConfig>;
|
|
540
|
-
siteIdRef: React.RefObject<number>;
|
|
541
|
-
gripperIdRef: React.RefObject<number>;
|
|
542
|
-
ikEnabledRef: React.RefObject<boolean>;
|
|
543
|
-
ikCalculatingRef: React.RefObject<boolean>;
|
|
544
567
|
pausedRef: React.RefObject<boolean>;
|
|
545
568
|
speedRef: React.RefObject<number>;
|
|
546
569
|
substepsRef: React.RefObject<number>;
|
|
547
|
-
ikTargetRef: React.RefObject<THREE.Group>;
|
|
548
|
-
genericIkRef: React.RefObject<GenericIK>;
|
|
549
|
-
ikSolveFnRef: React.RefObject<IKSolveFn>;
|
|
550
|
-
firstIkEnableRef: React.RefObject<boolean>;
|
|
551
|
-
gizmoAnimRef: React.RefObject<{
|
|
552
|
-
active: boolean;
|
|
553
|
-
startPos: THREE.Vector3;
|
|
554
|
-
endPos: THREE.Vector3;
|
|
555
|
-
startRot: THREE.Quaternion;
|
|
556
|
-
endRot: THREE.Quaternion;
|
|
557
|
-
startTime: number;
|
|
558
|
-
duration: number;
|
|
559
|
-
}>;
|
|
560
|
-
cameraAnimRef: React.RefObject<{
|
|
561
|
-
active: boolean;
|
|
562
|
-
startPos: THREE.Vector3;
|
|
563
|
-
endPos: THREE.Vector3;
|
|
564
|
-
startRot: THREE.Quaternion;
|
|
565
|
-
endRot: THREE.Quaternion;
|
|
566
|
-
startTarget: THREE.Vector3;
|
|
567
|
-
endTarget: THREE.Vector3;
|
|
568
|
-
startTime: number;
|
|
569
|
-
duration: number;
|
|
570
|
-
resolve: (() => void) | null;
|
|
571
|
-
}>;
|
|
572
570
|
onSelectionRef: React.RefObject<((bodyId: number, name: string) => void) | undefined>;
|
|
573
571
|
beforeStepCallbacks: React.RefObject<Set<PhysicsStepCallback>>;
|
|
574
572
|
afterStepCallbacks: React.RefObject<Set<PhysicsStepCallback>>;
|
|
573
|
+
resetCallbacks: React.RefObject<Set<() => void>>;
|
|
575
574
|
status: 'loading' | 'ready' | 'error';
|
|
576
575
|
}
|
|
577
576
|
declare function useMujocoSim(): MujocoSimContextValue;
|
|
@@ -590,10 +589,9 @@ interface MujocoSimProviderProps {
|
|
|
590
589
|
substeps?: number;
|
|
591
590
|
paused?: boolean;
|
|
592
591
|
speed?: number;
|
|
593
|
-
interpolate?: boolean;
|
|
594
592
|
children: React.ReactNode;
|
|
595
593
|
}
|
|
596
|
-
declare function MujocoSimProvider({ mujoco, config, apiRef: externalApiRef, onReady, onError, onStep, onSelection, gravity, timestep, substeps, paused, speed,
|
|
594
|
+
declare function MujocoSimProvider({ mujoco, config, apiRef: externalApiRef, onReady, onError, onStep, onSelection, gravity, timestep, substeps, paused, speed, children, }: MujocoSimProviderProps): react_jsx_runtime.JSX.Element;
|
|
597
595
|
|
|
598
596
|
/**
|
|
599
597
|
* @license
|
|
@@ -639,8 +637,6 @@ declare function findTendonByName(mjModel: MujocoModel, name: string): number;
|
|
|
639
637
|
interface LoadResult {
|
|
640
638
|
mjModel: MujocoModel;
|
|
641
639
|
mjData: MujocoData;
|
|
642
|
-
siteId: number;
|
|
643
|
-
gripperId: number;
|
|
644
640
|
}
|
|
645
641
|
/**
|
|
646
642
|
* Config-driven scene loader — replaces the old RobotLoader + patchSingleRobot approach.
|
|
@@ -650,52 +646,109 @@ declare function loadScene(mujoco: MujocoModule, config: SceneConfig, onProgress
|
|
|
650
646
|
/**
|
|
651
647
|
* @license
|
|
652
648
|
* SPDX-License-Identifier: Apache-2.0
|
|
649
|
+
*
|
|
650
|
+
* createController — typed factory for BYOC (Bring Your Own Controller) plugins.
|
|
653
651
|
*/
|
|
652
|
+
interface ControllerOptions<TConfig> {
|
|
653
|
+
/** Unique name for this controller (used as displayName). */
|
|
654
|
+
name: string;
|
|
655
|
+
/** Default values merged under user-supplied config. */
|
|
656
|
+
defaultConfig?: Partial<TConfig>;
|
|
657
|
+
}
|
|
658
|
+
type ControllerComponent<TConfig> = React.FC<{
|
|
659
|
+
config?: Partial<TConfig>;
|
|
660
|
+
children?: React.ReactNode;
|
|
661
|
+
}> & {
|
|
662
|
+
controllerName: string;
|
|
663
|
+
defaultConfig: Partial<TConfig>;
|
|
664
|
+
};
|
|
665
|
+
/**
|
|
666
|
+
* Factory that produces a typed controller component.
|
|
667
|
+
*
|
|
668
|
+
* Controllers are React components that plug into the MuJoCo simulation tree.
|
|
669
|
+
* Inside `Impl`, use any hooks (`useMujocoSim`, `useBeforePhysicsStep`, etc.)
|
|
670
|
+
* to interact with the physics engine.
|
|
671
|
+
*
|
|
672
|
+
* @example
|
|
673
|
+
* ```tsx
|
|
674
|
+
* const MyController = createController<{ speed: number }>(
|
|
675
|
+
* { name: 'my-controller', defaultConfig: { speed: 1.0 } },
|
|
676
|
+
* function MyControllerImpl({ config }) {
|
|
677
|
+
* useBeforePhysicsStep((_model, data) => {
|
|
678
|
+
* data.ctrl[0] = config.speed;
|
|
679
|
+
* });
|
|
680
|
+
* return null;
|
|
681
|
+
* },
|
|
682
|
+
* );
|
|
683
|
+
*
|
|
684
|
+
* // Usage:
|
|
685
|
+
* <MyController config={{ speed: 2.0 }} />
|
|
686
|
+
* ```
|
|
687
|
+
*/
|
|
688
|
+
declare function createController<TConfig>(options: ControllerOptions<TConfig>, Impl: React.FC<{
|
|
689
|
+
config: TConfig;
|
|
690
|
+
children?: React.ReactNode;
|
|
691
|
+
}>): ControllerComponent<TConfig>;
|
|
692
|
+
|
|
693
|
+
declare const IkController: ControllerComponent<IkConfig>;
|
|
694
|
+
|
|
695
|
+
interface IkContextValue {
|
|
696
|
+
ikEnabledRef: React.RefObject<boolean>;
|
|
697
|
+
ikCalculatingRef: React.RefObject<boolean>;
|
|
698
|
+
ikTargetRef: React.RefObject<THREE.Group>;
|
|
699
|
+
siteIdRef: React.RefObject<number>;
|
|
700
|
+
setIkEnabled(enabled: boolean): void;
|
|
701
|
+
moveTarget(pos: THREE.Vector3, duration?: number): void;
|
|
702
|
+
syncTargetToSite(): void;
|
|
703
|
+
solveIK(pos: THREE.Vector3, quat: THREE.Quaternion, currentQ: number[]): number[] | null;
|
|
704
|
+
getGizmoStats(): {
|
|
705
|
+
pos: THREE.Vector3;
|
|
706
|
+
rot: THREE.Euler;
|
|
707
|
+
} | null;
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* Access the IK controller context.
|
|
711
|
+
*
|
|
712
|
+
* - `useIk()` — throws if no `<IkController>` ancestor (use inside `<IkController>`)
|
|
713
|
+
* - `useIk({ optional: true })` — returns `null` if no ancestor (use in components
|
|
714
|
+
* that optionally interact with IK, e.g. keyboard controllers that disable IK)
|
|
715
|
+
*/
|
|
716
|
+
declare function useIk(): IkContextValue;
|
|
717
|
+
declare function useIk(options: {
|
|
718
|
+
optional: true;
|
|
719
|
+
}): IkContextValue | null;
|
|
720
|
+
|
|
654
721
|
/**
|
|
655
722
|
* SceneRenderer — creates and syncs MuJoCo body meshes every frame.
|
|
656
|
-
*
|
|
723
|
+
* Accepts standard R3F group props (position, rotation, scale, visible, etc.).
|
|
657
724
|
*/
|
|
658
|
-
declare function SceneRenderer(): react_jsx_runtime.JSX.Element;
|
|
725
|
+
declare function SceneRenderer(props: Omit<ThreeElements['group'], 'ref'>): react_jsx_runtime.JSX.Element;
|
|
659
726
|
|
|
660
727
|
/**
|
|
661
728
|
* IkGizmo — drei PivotControls that tracks a MuJoCo site.
|
|
662
729
|
*
|
|
730
|
+
* Must be rendered inside an `<IkController>`.
|
|
731
|
+
*
|
|
663
732
|
* Props:
|
|
664
|
-
* - `siteName` — MuJoCo site to track. Defaults to
|
|
733
|
+
* - `siteName` — MuJoCo site to track. Defaults to the IkController's configured site.
|
|
665
734
|
* - `scale` — Gizmo handle scale. Default: 0.18.
|
|
666
735
|
* - `onDrag` — Custom drag callback `(pos, quat) => void`.
|
|
667
|
-
* When omitted, dragging enables IK and writes to the
|
|
736
|
+
* When omitted, dragging enables IK and writes to the IK target.
|
|
668
737
|
* When provided, the consumer handles what happens during drag.
|
|
669
|
-
*
|
|
670
|
-
* Multiple gizmos can be rendered — each tracks its own site.
|
|
671
|
-
* Zero gizmos is fine — programmatic IK control works via the provider API.
|
|
672
|
-
*
|
|
673
|
-
* Uses a tiny invisible mesh as child instead of axesHelper — PivotControls
|
|
674
|
-
* computes an anchor offset from children's bounding box, and axesHelper's
|
|
675
|
-
* (0→0.15) bounds would shift the handles away from the TCP origin.
|
|
676
738
|
*/
|
|
677
739
|
declare function IkGizmo({ siteName, scale, onDrag }: IkGizmoProps): react_jsx_runtime.JSX.Element | null;
|
|
678
740
|
|
|
679
|
-
/**
|
|
680
|
-
* @license
|
|
681
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
682
|
-
*
|
|
683
|
-
* ContactMarkers — instanced sphere visualization of MuJoCo contacts (spec 6.2)
|
|
684
|
-
*
|
|
685
|
-
* Fixed from original: reads data.ncon first, accesses contact via .get(i),
|
|
686
|
-
* limits to maxContacts to avoid WASM heap OOM.
|
|
687
|
-
*/
|
|
688
741
|
interface ContactMarkersProps {
|
|
689
742
|
/** Maximum contacts to render. Default: 100. */
|
|
690
743
|
maxContacts?: number;
|
|
691
|
-
/** Sphere radius. Default: 0.
|
|
744
|
+
/** Sphere radius. Default: 0.008. */
|
|
692
745
|
radius?: number;
|
|
693
|
-
/** Color. Default: '#
|
|
746
|
+
/** Color. Default: '#22d3ee'. */
|
|
694
747
|
color?: string;
|
|
695
748
|
/** Show markers. Default: true. */
|
|
696
749
|
visible?: boolean;
|
|
697
750
|
}
|
|
698
|
-
declare function ContactMarkers({ maxContacts, radius, color, visible, }?: ContactMarkersProps): react_jsx_runtime.JSX.Element | null;
|
|
751
|
+
declare function ContactMarkers({ maxContacts, radius, color, visible, ...groupProps }?: ContactMarkersProps & Omit<ThreeElements['group'], 'ref' | 'visible'>): react_jsx_runtime.JSX.Element | null;
|
|
699
752
|
|
|
700
753
|
/**
|
|
701
754
|
* DragInteraction — Ctrl/Cmd+click-drag to apply spring forces to MuJoCo bodies.
|
|
@@ -710,7 +763,7 @@ declare function ContactMarkers({ maxContacts, radius, color, visible, }?: Conta
|
|
|
710
763
|
* Forces compose with useGravityCompensation — the provider zeros
|
|
711
764
|
* qfrc_applied each frame, then all consumers add to it.
|
|
712
765
|
*/
|
|
713
|
-
declare function DragInteraction({ stiffness, showArrow, }: DragInteractionProps): react_jsx_runtime.JSX.Element | null;
|
|
766
|
+
declare function DragInteraction({ stiffness, showArrow, ...groupProps }: DragInteractionProps & Omit<ThreeElements['group'], 'ref'>): react_jsx_runtime.JSX.Element | null;
|
|
714
767
|
|
|
715
768
|
/**
|
|
716
769
|
* @license
|
|
@@ -732,33 +785,15 @@ declare function SceneLights({ intensity }: SceneLightsProps): null;
|
|
|
732
785
|
* Declarative debug visualization component.
|
|
733
786
|
* Renders wireframe geoms, site markers, joint axes, contact forces, COM markers, etc.
|
|
734
787
|
*/
|
|
735
|
-
declare function Debug({ showGeoms, showSites, showJoints, showContacts, showCOM, showInertia, showTendons, }: DebugProps): react_jsx_runtime.JSX.Element | null;
|
|
788
|
+
declare function Debug({ showGeoms, showSites, showJoints, showContacts, showCOM, showInertia, showTendons, ...groupProps }: DebugProps & Omit<ThreeElements['group'], 'ref'>): react_jsx_runtime.JSX.Element | null;
|
|
736
789
|
|
|
737
|
-
|
|
738
|
-
* @license
|
|
739
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
740
|
-
*
|
|
741
|
-
* TendonRenderer — render tendons as tube geometries (spec 6.4)
|
|
742
|
-
*
|
|
743
|
-
* WASM fields used: model.ntendon, model.ten_wrapadr, model.ten_wrapnum
|
|
744
|
-
* data.wrap_xpos, data.ten_wrapadr (runtime)
|
|
745
|
-
*
|
|
746
|
-
* Note: ten_rgba and ten_width are NOT available in mujoco-js 0.0.7.
|
|
747
|
-
* Tendons use a default color and width.
|
|
748
|
-
*/
|
|
749
|
-
declare function TendonRenderer(): react_jsx_runtime.JSX.Element | null;
|
|
790
|
+
declare function TendonRenderer(props: Omit<ThreeElements['group'], 'ref'>): react_jsx_runtime.JSX.Element | null;
|
|
750
791
|
|
|
751
|
-
/**
|
|
752
|
-
* @license
|
|
753
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
754
|
-
*
|
|
755
|
-
* FlexRenderer — render deformable flex bodies (spec 6.4)
|
|
756
|
-
*/
|
|
757
792
|
/**
|
|
758
793
|
* Renders MuJoCo flex (deformable) bodies as dynamic meshes.
|
|
759
794
|
* Vertices are updated every frame from flexvert_xpos.
|
|
760
795
|
*/
|
|
761
|
-
declare function FlexRenderer(): react_jsx_runtime.JSX.Element | null;
|
|
796
|
+
declare function FlexRenderer(props: Omit<ThreeElements['group'], 'ref'>): react_jsx_runtime.JSX.Element | null;
|
|
762
797
|
|
|
763
798
|
/**
|
|
764
799
|
* @license
|
|
@@ -1080,4 +1115,49 @@ interface CtrlNoiseConfig {
|
|
|
1080
1115
|
*/
|
|
1081
1116
|
declare function useCtrlNoise(config?: CtrlNoiseConfig): void;
|
|
1082
1117
|
|
|
1083
|
-
|
|
1118
|
+
/**
|
|
1119
|
+
* @license
|
|
1120
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
1121
|
+
*
|
|
1122
|
+
* useSelectionHighlight — hook form of SelectionHighlight (spec 6.5)
|
|
1123
|
+
*
|
|
1124
|
+
* Applies emissive highlight to all meshes belonging to a body.
|
|
1125
|
+
* Restores original emissive when bodyId changes or hook unmounts.
|
|
1126
|
+
*/
|
|
1127
|
+
declare function useSelectionHighlight(bodyId: number | null, options?: {
|
|
1128
|
+
color?: string;
|
|
1129
|
+
emissiveIntensity?: number;
|
|
1130
|
+
}): void;
|
|
1131
|
+
|
|
1132
|
+
/**
|
|
1133
|
+
* @license
|
|
1134
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
1135
|
+
*
|
|
1136
|
+
* useSceneLights — hook form of SceneLights (spec 6.3)
|
|
1137
|
+
*
|
|
1138
|
+
* Auto-creates Three.js lights from MJCF <light> elements.
|
|
1139
|
+
*/
|
|
1140
|
+
declare function useSceneLights(intensity?: number): void;
|
|
1141
|
+
|
|
1142
|
+
/**
|
|
1143
|
+
* @license
|
|
1144
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
1145
|
+
*
|
|
1146
|
+
* useCameraAnimation — composable camera animation hook.
|
|
1147
|
+
*/
|
|
1148
|
+
|
|
1149
|
+
interface CameraAnimationAPI {
|
|
1150
|
+
getCameraState(): {
|
|
1151
|
+
position: THREE.Vector3;
|
|
1152
|
+
target: THREE.Vector3;
|
|
1153
|
+
};
|
|
1154
|
+
moveCameraTo(position: THREE.Vector3, target: THREE.Vector3, durationMs: number): Promise<void>;
|
|
1155
|
+
}
|
|
1156
|
+
/**
|
|
1157
|
+
* Standalone hook for animated camera transitions.
|
|
1158
|
+
*
|
|
1159
|
+
* Manages its own `useFrame` callback — drop it into any component inside `<Canvas>`.
|
|
1160
|
+
*/
|
|
1161
|
+
declare function useCameraAnimation(): CameraAnimationAPI;
|
|
1162
|
+
|
|
1163
|
+
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, IkController, 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, SceneRenderer, SelectionHighlight, type SelectionHighlightProps, 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, useBodyState, useCameraAnimation, useContactEvents, useContacts, useCtrl, useCtrlNoise, useGamepad, useGravityCompensation, useIk, useJointState, useKeyboardTeleop, useMujoco, useMujocoSim, usePolicy, useSceneLights, useSelectionHighlight, useSensor, useSensors, useSitePosition, useTrajectoryPlayer, useTrajectoryRecorder, useVideoRecorder };
|