mujoco-react 3.0.0 → 5.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 +9 -20
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/core/SceneLoader.ts +1 -3
- package/src/types.ts +3 -2
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ import type { SceneConfig } from 'mujoco-react';
|
|
|
27
27
|
import { OrbitControls } from '@react-three/drei';
|
|
28
28
|
|
|
29
29
|
const config: SceneConfig = {
|
|
30
|
-
|
|
30
|
+
src: 'https://raw.githubusercontent.com/google-deepmind/mujoco_menagerie/main/franka_emika_panda/',
|
|
31
31
|
sceneFile: 'scene.xml',
|
|
32
32
|
homeJoints: [1.707, -1.754, 0.003, -2.702, 0.003, 0.951, 2.490],
|
|
33
33
|
};
|
|
@@ -178,39 +178,28 @@ const ikCtx = useIk({ optional: true });
|
|
|
178
178
|
|
|
179
179
|
## Loading Models
|
|
180
180
|
|
|
181
|
-
|
|
181
|
+
The loader fetches `src + sceneFile`, parses the XML for dependencies (meshes, textures, includes), recursively fetches those too, and writes everything to MuJoCo's in-memory WASM filesystem.
|
|
182
182
|
|
|
183
183
|
```tsx
|
|
184
|
-
// Menagerie
|
|
184
|
+
// MuJoCo Menagerie
|
|
185
185
|
const franka: SceneConfig = {
|
|
186
|
-
|
|
186
|
+
src: 'https://raw.githubusercontent.com/google-deepmind/mujoco_menagerie/main/franka_emika_panda/',
|
|
187
187
|
sceneFile: 'scene.xml',
|
|
188
188
|
};
|
|
189
189
|
|
|
190
|
-
// Any
|
|
191
|
-
const so101: SceneConfig = {
|
|
192
|
-
robotId: 'so101',
|
|
193
|
-
sceneFile: 'SO101.xml',
|
|
194
|
-
baseUrl: 'https://raw.githubusercontent.com/your-org/your-repo/main/models/',
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
// Self-hosted
|
|
190
|
+
// Any URL
|
|
198
191
|
const custom: SceneConfig = {
|
|
199
|
-
|
|
200
|
-
sceneFile: '
|
|
201
|
-
baseUrl: 'http://localhost:3000/models/my_robot/',
|
|
192
|
+
src: 'http://localhost:3000/models/my_model/',
|
|
193
|
+
sceneFile: 'model.xml',
|
|
202
194
|
};
|
|
203
195
|
```
|
|
204
196
|
|
|
205
|
-
The loader fetches the scene XML, parses it for dependencies (meshes, textures, includes), recursively fetches those too, applies any XML patches, and writes everything to MuJoCo's in-memory WASM filesystem.
|
|
206
|
-
|
|
207
197
|
## SceneConfig
|
|
208
198
|
|
|
209
199
|
```ts
|
|
210
200
|
interface SceneConfig {
|
|
211
|
-
|
|
201
|
+
src: string; // Base URL for model files
|
|
212
202
|
sceneFile: string; // Entry XML file, e.g. 'scene.xml'
|
|
213
|
-
baseUrl?: string; // Base URL for fetching model files
|
|
214
203
|
sceneObjects?: SceneObject[]; // Objects injected into scene XML at load time
|
|
215
204
|
homeJoints?: number[]; // Initial joint positions
|
|
216
205
|
xmlPatches?: XmlPatch[]; // Patches applied to XML files during loading
|
|
@@ -222,7 +211,7 @@ interface SceneConfig {
|
|
|
222
211
|
|
|
223
212
|
```tsx
|
|
224
213
|
const config: SceneConfig = {
|
|
225
|
-
|
|
214
|
+
src: 'https://raw.githubusercontent.com/google-deepmind/mujoco_menagerie/main/franka_emika_panda/',
|
|
226
215
|
sceneFile: 'scene.xml',
|
|
227
216
|
sceneObjects: [
|
|
228
217
|
{ name: 'ball', type: 'sphere', size: [0.03, 0.03, 0.03],
|
package/dist/index.d.ts
CHANGED
|
@@ -233,9 +233,10 @@ interface XmlPatch {
|
|
|
233
233
|
replace?: [string, string];
|
|
234
234
|
}
|
|
235
235
|
interface SceneConfig {
|
|
236
|
-
|
|
236
|
+
/** Base URL for fetching model files. The loader fetches `src + sceneFile` and follows dependencies. */
|
|
237
|
+
src: string;
|
|
238
|
+
/** Entry MJCF XML file name, e.g. 'scene.xml'. */
|
|
237
239
|
sceneFile: string;
|
|
238
|
-
baseUrl?: string;
|
|
239
240
|
sceneObjects?: SceneObject[];
|
|
240
241
|
homeJoints?: number[];
|
|
241
242
|
xmlPatches?: XmlPatch[];
|
package/dist/index.js
CHANGED
|
@@ -400,7 +400,7 @@ async function loadScene(mujoco, config, onProgress) {
|
|
|
400
400
|
mujoco.FS.mkdir("/working");
|
|
401
401
|
} catch {
|
|
402
402
|
}
|
|
403
|
-
const baseUrl = config.
|
|
403
|
+
const baseUrl = config.src.endsWith("/") ? config.src : config.src + "/";
|
|
404
404
|
const downloaded = /* @__PURE__ */ new Set();
|
|
405
405
|
const queue = [config.sceneFile];
|
|
406
406
|
const parser = new DOMParser();
|