Add mj_loadBinary binding to WASM.

This change adds an Emscripten binding for loading binary MuJoCo models (`.mjb`) from the virtual filesystem. The new binding, `mj_loadBinary`, takes a filename and an `MjVFS` object, enabling the loading of models that reference assets within the VFS.

PiperOrigin-RevId: 859740455
Change-Id: I9f9d8bbba0b57422e2356867e4282a1b04566475
This commit is contained in:
Google DeepMind
2026-01-22 13:06:48 -08:00
committed by Copybara-Service
parent 61f13cd8f1
commit e1992e62d7
5 changed files with 110 additions and 3 deletions
+1 -1
View File
@@ -74,6 +74,7 @@ _SKIPPED_CLASS_METHODS: tuple[str, ...] = (
"mj_deleteModel",
"mj_deleteSpec",
"mj_deleteVFS",
"mj_loadModel",
"mj_loadXML",
"mj_makeData",
"mj_makeSpec",
@@ -139,7 +140,6 @@ _SKIPPED_MEMORY_FUNCTIONS: tuple[str, ...] = (
# go/keep-sorted start
"mj_freeLastXML",
"mj_freeStack",
"mj_loadModel",
"mj_loadModelBuffer",
"mj_markStack",
"mj_stackAllocByte",
+6 -2
View File
@@ -508,10 +508,14 @@ def _build_struct_bindings(
builder.line(".constructor<MjModel *>()")
builder.line(".constructor<const MjModel &, const MjData &>()")
elif w == "MjModel":
fn = common.wrapped_function_name(
f1 = common.wrapped_function_name(
introspect_functions.FUNCTIONS["mj_loadXML"]
)
builder.line(f'.class_function("mj_loadXML", &{fn}, take_ownership())')
builder.line(f'.class_function("mj_loadXML", &{f1}, take_ownership())')
f2 = common.wrapped_function_name(
introspect_functions.FUNCTIONS["mj_loadModel"]
)
builder.line(f'.class_function("mj_loadBinary", &{f2}, take_ownership())')
builder.line(".constructor<const MjModel &>()")
builder.line("""
// Binds the functions on MjModel that return accessors.