The dist/ folder contains:
WasmGPU.js / WasmGPU.min.js — ESM bundleWasmGPU.iife.min.js — IIFE bundle (global WasmGPU)math.js — AssemblyScript ESM bindings (loads wasm)math.wasm — WebAssembly moduleImportant:
math.jsandmath.wasmmust be hosted next to the WasmGPU bundle (samedist/directory).
<canvas></canvas>
<script type="module">
import { WasmGPU } from "@zushah/wasmgpu";
const canvas = document.querySelector("canvas");
const wgpu = await WasmGPU.create(canvas);
wgpu.setClearColor(255, 255, 255);
function frame(t) {
wgpu.renderFrame(t * 0.001);
requestAnimationFrame(frame);
}
requestAnimationFrame(frame);
</script>
<canvas></canvas>
<script src="https://cdn.jsdelivr.net/gh/Zushah/WasmGPU@0.1.0/dist/WasmGPU.iife.min.js"></script>
<script>
const canvas = document.querySelector("canvas");
WasmGPU.create(canvas).then(wgpu => {
wgpu.setClearColor(255, 255, 255);
function frame(t) {
wgpu.renderFrame(t * 0.001);
requestAnimationFrame(frame);
}
requestAnimationFrame(frame);
});
</script>
npm installnpm run buildnpm run start or use the live server extensionQuick examples: examples/esm.html and examples/iife.html.
WasmGPU is available under the Mozilla Public License 2.0 (MPL-2.0).