-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
42 lines (39 loc) · 949 Bytes
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<html>
<head>
<title>go webassembly - words</title>
<script src="wasm_exec.js"></script>
<script>
if (!WebAssembly.instantiateStreaming) {
// polyfill
WebAssembly.instantiateStreaming = async (resp, importObject) => {
const source = await (await resp).arrayBuffer();
return await WebAssembly.instantiate(source, importObject);
};
}
const go = new Go();
let mod, inst;
WebAssembly.instantiateStreaming(fetch("main.wasm"), go.importObject).then(
async result => {
mod = result.module;
inst = result.instance;
await go.run(inst);
}
);
function render() {
replay(null);
}
</script>
<style>
*{
margin: 0;
}
canvas{
position: fixed;
}
</style>
</head>
<body>
<canvas onclick="render()" id="sCanvas"></canvas>
<canvas onclick="render()" id="wCanvas"></canvas>
</body>
</html>