window.addEventListener("load", async () => { try { await Scheme.load_main("scene.wasm", { user_imports: { document: { getElementById(id) { return document.getElementById(id); }, body() { return document.body; }, createTextNode(text) { return document.createTextNode(text); }, createElement(tag) { return document.createElement(tag); } }, element: { innerText(elem) { return elem.innerText; }, setInnerText(elem, value) { elem.innerText = value; }, addEventListener(elem, event, listener) { elem.addEventListener(event, listener); }, appendChild(elem, child) { return elem.appendChild(child); }, parentElement(elem) { return elem.parentElement; }, replaceChild(elem, child, newChild) { // intentionally flipped as it's more intuitive than js elem.replaceChild(newChild, child); }, setAttribute(elem, name, value) { elem.setAttribute(name, value); } } } }); } catch (e) { if (e instanceof WebAssembly.CompileError) { document.getElementById("wasm-error").hidden = false; } throw e; } });