Fix studio web so that single file xml model can be loaded in a single-threaded wasm build

model_holder.cc modified to disable multi-threaded compilation for WASM builds. index.html `animate()` function modified so the animation rendering loop executes asynchronously with async/await calls. These changes are sufficient to make xml files without references work (e.g., humanoid.xml), more work is needed to make the vfs work so multi-file models can load.

PiperOrigin-RevId: 885537402
Change-Id: I3469cae48e7268073be334b99bf907c5ed8c27a7
This commit is contained in:
Matija Kecman
2026-03-18 05:30:48 -07:00
committed by Copybara-Service
parent b0c48ba846
commit f1715e67bd
2 changed files with 6 additions and 2 deletions
@@ -80,6 +80,10 @@ ModelHolder::~ModelHolder() {
void ModelHolder::PostInit() {
if (spec_ && !model_) {
#ifdef __EMSCRIPTEN__
// Disable threaded compilation on WASM since pthreads are not available.
spec_->compiler.usethread = 0;
#endif
model_ = mj_compile(spec_, &vfs_);
if (!model_) {
SetLoadError(mjs_getError(spec_));
+2 -2
View File
@@ -97,9 +97,9 @@
console.error('Failed to prefetch one or more assets.', error);
});
},
animate: () => {
animate: async () => {
try {
Module.renderFrame();
await Module.renderFrame();
} catch (error) {
console.error('Update error:', error);
}