Files
havox/projects/tsp/wasm.js
2026-03-31 22:19:53 +01:00

28 lines
514 B
JavaScript

export async function initWasm() {
let wasmMemory = new WebAssembly.Memory({
initial: 256,
maximum: 256,
});
let importObject = {
env: {
memory: wasmMemory,
},
};
const response = await fetch('./main.wasm');
const wasmModule = await WebAssembly.instantiateStreaming(
response,
importObject
);
const { initialisePoints, getPointOrder, memory } =
wasmModule.instance.exports;
return {
initialisePoints,
getPointOrder,
memory,
wasmMemory,
};
}