2024-10-11 23:36:52 +00:00
|
|
|
window.addEventListener("load", async () => {
|
|
|
|
try {
|
|
|
|
await Scheme.load_main("scene.wasm", {
|
|
|
|
user_imports: {
|
|
|
|
document: {
|
|
|
|
getElementById(id) {
|
|
|
|
return document.getElementById(id);
|
2024-10-12 01:34:43 +00:00
|
|
|
},
|
|
|
|
body() {
|
|
|
|
return document.body;
|
|
|
|
},
|
|
|
|
createTextNode(text) {
|
|
|
|
return document.createTextNode(text);
|
|
|
|
},
|
|
|
|
createElement(tag) {
|
|
|
|
return document.createElement(tag);
|
2024-10-11 23:36:52 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
element: {
|
|
|
|
innerText(elem) {
|
|
|
|
return elem.innerText;
|
|
|
|
},
|
|
|
|
setInnerText(elem, value) {
|
|
|
|
elem.innerText = value;
|
|
|
|
},
|
|
|
|
addEventListener(elem, event, listener) {
|
|
|
|
elem.addEventListener(event, listener);
|
2024-10-12 01:34:43 +00:00
|
|
|
},
|
|
|
|
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);
|
2024-10-11 23:36:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (e) {
|
|
|
|
if (e instanceof WebAssembly.CompileError) {
|
|
|
|
document.getElementById("wasm-error").hidden = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
});
|