-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
49 lines (44 loc) · 1.3 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WGPU Slicer</title>
<link rel="icon" type="image/x-icon" href="/assets/favicon.png">
</head>
<body>
<script type="module">
import init, { add_file } from './wasm_rend.js';
function loadFile(file) {
let reader = new FileReader();
reader.readAsArrayBuffer(file);
reader.onload = () => {
let arrayBuffer = reader.result;
let bytes = new Uint8Array(arrayBuffer);
add_file(bytes);
}
}
function initSetup(state) {
const canvas = document.getElementById("wgpu_canvas");
canvas.oncontextmenu = function (e) {
e.preventDefault();
};
const input = document.getElementById("file-input");
input.onchange = e => {
const file = e.target.files[0];
loadFile(file);
}
}
init().then((wasm) => {
initSetup();
});
</script>
<input id="file-input" type="file">
<canvas id="wgpu_canvas" width="1280" height="720"></canvas>
<div id="event_logger_container">
<h2>Event Log</h2>
<ul id="event_logger">
...
</ul>
</div>
</body>
</html>