28 lines
514 B
JavaScript
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,
|
|
};
|
|
}
|