wait event stuff for wasm backend

This commit is contained in:
David Vanderson 2022-06-09 10:00:00 -04:00 committed by Stephen Gutekanst
parent 0f7c34a5ad
commit 4eb872944a
3 changed files with 49 additions and 3 deletions

View file

@ -28,9 +28,19 @@
let update = function() {{
if (!frame) return;
instance.exports.wasmUpdate();
window.requestAnimationFrame(update);
if (mach.wait_event_timeout > 0) {{
mach.wait_event_timer = setTimeout(() => {{
window.requestAnimationFrame(update);
}},
mach.wait_event_timeout * 1000);
}}
else {{
window.requestAnimationFrame(update);
}}
}};
mach.update = update;
window.requestAnimationFrame(update);
window.addEventListener("mach-close", () => {{