loadScene(newConfig)
Load a new model, replacing the current scene entirely.SceneConfig
required
New scene configuration. See Loading Models for all fields.
Promise<void> — resolves when the new model is loaded and ready.
This method:
- Fetches the new model files
- Applies XML patches and injects scene objects
- Compiles the model with
mj_loadXML - Creates new model/data objects
- Rebuilds the scene graph (SceneRenderer will re-render)
- Fires the
onReadycallback with the updated API
loadFromFiles(files, options?)
Load MJCF or URDF from browser-selected files. Folder uploads preserve paths fromwebkitRelativePath; flat uploads fall back to matching mesh/texture assets by basename.
FileList | File[]
required
Browser-selected MJCF/URDF files and referenced assets.
LoadFromFilesOptions
Optional
sceneFile, environmentFiles, homeJoints, xmlPatches, sceneObjects, and onReset settings.Composable Environments
UseenvironmentFiles when a robot should run inside a reusable MJCF environment. The loader merges the environment XML’s assets and physics sections into the entry model before MuJoCo compiles it.
.spz as a visual-only layer,
and add a paired scene.xml collision/physics layer only when the splat-backed
workflow needs contact geometry.
addBody(body), removeBody(name), recompile(patches?)
Edit the current scene configuration and recompile through MuJoCo. This is a model reload, not an in-place mutation of compiledmjModel memory.
Example: Model Switcher
Utility Functions
These standalone functions are exported for advanced use cases (e.g., building custom loaders).getName(model, address)
Read a null-terminated C string from the WASM model’s name buffer.find*ByName(model, name)
Look up element indices by name. All return-1 if not found.