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
+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.