-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
74 lines (62 loc) · 2.8 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
</head>
<body style="margin: 0 auto;">
<canvas id="canvas_click" width="800" height="600" style="background: #112244; cursor: pointer;"></canvas>
<canvas id="amethyst-canvas" width="800" height="600" style="background: #112244; display: none;"></canvas>
<!-- Include the JS generated by `wasm-pack build` -->
<script src="spirv_cross/spirv_cross_wrapper_glsl.js"></script>
<script src='pkg/will.js'></script>
<script src="js/cpal.js"></script>
<script src="js/web_socket_send.js"></script>
<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/will_bg.wasm');
let canvas = document.getElementById("amethyst-canvas");
let will_config = await fetch('app/will/will_web.yaml')
.then((response) => { return response.text(); });
let player_input_configs = await fetch('resources/player_input_configs.yaml')
.then((response) => { return response.text(); });
let theme = await fetch('resources/font_config.ron')
.then((response) => { return response.text(); });
let logger_config = await fetch('app/will/logger.yaml')
.then((response) => { return response.text(); });
wasm_bindgen.WillAppBuilder
.new()
.with_canvas(canvas)
.with_will_config(will_config)
.with_player_input_configs(player_input_configs)
.with_theme(theme)
.with_logger_config(logger_config)
.run();
});
}
window.onload = function() {
let canvas_click = document.getElementById("canvas_click");
let ctx = canvas_click.getContext("2d");
ctx.font = "small-caps bold 50px Helvetica";
ctx.fillStyle = "#ccddff";
ctx.fillText("▶️ Play Will", 250, 300);
canvas_click.scrollTo(0, 0);
canvas_click.onclick = function() {
canvas_click.style.display = "none";
let canvas_amethyst = document.getElementById("amethyst-canvas");
canvas_amethyst.style.display = "block";
run();
};
};
</script>
</body>
</html>