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:
committed by
Copybara-Service
parent
b0c48ba846
commit
f1715e67bd
@@ -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_));
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user