mach: wasm: Implement setShouldClose for wasm
This commit is contained in:
parent
2d53b8bdfd
commit
772a821ce1
3 changed files with 17 additions and 3 deletions
|
|
@ -24,12 +24,19 @@
|
|||
mach.init(instance);
|
||||
instance.exports.wasmInit();
|
||||
|
||||
let frame = true;
|
||||
let update = function() {{
|
||||
if (!frame) return;
|
||||
instance.exports.wasmUpdate();
|
||||
requestAnimationFrame(update);
|
||||
window.requestAnimationFrame(update);
|
||||
}};
|
||||
|
||||
requestAnimationFrame(update);
|
||||
window.requestAnimationFrame(update);
|
||||
|
||||
window.addEventListener("mach-close", () => {{
|
||||
instance.exports.wasmDeinit();
|
||||
frame = false;
|
||||
}});
|
||||
}})
|
||||
.catch(err => console.error(err));
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue