-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.html
56 lines (45 loc) · 1.79 KB
/
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
</head>
<body>
<canvas id="amethyst-canvas" width="400" height="300" style="background: #ddddff;"></canvas><br />
<!-- Include the JS generated by `wasm-pack build` -->
<script src="spirv_cross/spirv_cross_wrapper_glsl.js"></script>
<script src='pkg/pong_wasm.js'></script>
<script src="js/cpal.js"></script>
<script src="js/amethyst_assets.js"></script>
<button>Launch Pong</button>
<script type=module>
// Like with the `--target web` output the exports are immediately
// available but they won't work until we initialize the module. Unlike
// `--target web`, however, the globals are all stored on a
// `wasm_bindgen` global. The global itself is the initialization
// function and then the properties of the global are all the exported
// functions.
//
// Note that the name `wasm_bindgen` can be configured with the
// `--no-modules-global` CLI flag
async function run() {
const module = window.sc_internal_wrapper().then(async module => {
window.sc_internal = module;
await wasm_bindgen('./pkg/pong_wasm_bg.wasm');
let canvas = document.getElementById("amethyst-canvas");
let input_bindings = await fetch('config/input.ron')
.then((response) => { return response.text(); });
console.log(input_bindings);
wasm_bindgen.PongAppBuilder
.new()
.with_canvas(canvas)
.with_input_bindings(input_bindings)
.run();
});
}
// run();
const launchBtn = document.querySelector('button:nth-of-type(1)');
launchBtn.onclick = function() {
run();
};
</script>
</body>
</html>