diff options
| author | gingerBill <bill@gingerbill.org> | 2022-06-01 10:32:24 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2022-06-01 10:32:24 +0100 |
| commit | 25dae06b6ab357847898ee5635f11e73d326ee4e (patch) | |
| tree | 5f07cfbd0f749bee56d049affbf646510f80109c | |
| parent | a1f15c2c69b557be5a95882d18137d1f74d980ee (diff) | |
Remove loader.mjs
| -rw-r--r-- | vendor/wasm/loader/loader.mjs | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/vendor/wasm/loader/loader.mjs b/vendor/wasm/loader/loader.mjs deleted file mode 100644 index be434cf36..000000000 --- a/vendor/wasm/loader/loader.mjs +++ /dev/null @@ -1,57 +0,0 @@ -import {WasmMemoryInterface, odinSetupDefaultImports, WebGLInterface} from "./runtime.mjs"; - -export async function runWasmCanvas(wasmPath, consoleElement, extraForeignImports) { - let wasmMemoryInterface = new WasmMemoryInterface(); - - let imports = odinSetupDefaultImports(wasmMemoryInterface, consoleElement); - let exports = {}; - - let gl_context = new WebGLInterface( - wasmMemoryInterface, - null, - {antialias: false}, - ); - imports["webgl"] = gl_context.getWebGL1Interface(); - imports["webgl2"] = gl_context.getWebGL2Interface(); - - if (extraForeignImports !== undefined) { - imports = { - ...imports, - ...extraForeignImports, - }; - } - - const response = await fetch(wasmPath); - const file = await response.arrayBuffer(); - const wasm = await WebAssembly.instantiate(file, imports); - exports = wasm.instance.exports; - wasmMemoryInterface.setExports(exports); - wasmMemoryInterface.setMemory(exports.memory); - - exports._start(); - - if (exports.step) { - const odin_ctx = exports.default_context_ptr(); - - let prevTimeStamp = undefined; - const step = (currTimeStamp) => { - if (prevTimeStamp == undefined) { - prevTimeStamp = currTimeStamp; - } - - const dt = (currTimeStamp - prevTimeStamp)*0.001; - prevTimeStamp = currTimeStamp; - exports.step(dt, odin_ctx); - window.requestAnimationFrame(step); - }; - - window.requestAnimationFrame(step); - } - - exports._end(); - - return; -}; - - -export {runWasmCanvas};
\ No newline at end of file |