Add support for loading XML models with VFS in WASM bindings.

PiperOrigin-RevId: 874756898
Change-Id: If2c30aef4c690cf0852587261ca32a3b91448621
This commit is contained in:
Google DeepMind
2026-02-24 13:08:14 -08:00
committed by Copybara-Service
parent 09c7633a76
commit a83fa7299d
4 changed files with 79 additions and 10 deletions
+9 -4
View File
@@ -549,14 +549,19 @@ def _build_struct_bindings(
MJDATA_ACCESSORS
#undef X_ACCESSOR""".lstrip())
elif w == "MjModel":
f1 = common.wrapped_function_name(
introspect_functions.FUNCTIONS["mj_loadXML"]
builder.line(
'.class_function("mj_loadXML",'
" emscripten::select_overload<std::unique_ptr<MjModel>(std::string)>(&mj_loadXML_wrapper_1))"
)
builder.line(
'.class_function("mj_loadXML",'
" emscripten::select_overload<std::unique_ptr<MjModel>(std::string,"
" const MjVFS&)>(&mj_loadXML_wrapper_2))"
)
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(f'.class_function("mj_loadModel", &{f2})')
builder.line(".constructor<const MjModel &>()")
builder.line("""
// Binds the functions on MjModel that return accessors.