-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
33 lines (30 loc) · 1 KB
/
index.html
File metadata and controls
33 lines (30 loc) · 1 KB
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
<html xmlns="http://www.w3.org/1999/html">
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
<link rel="stylesheet" href="index.css">
</head>
<body>
<canvas id="canvas" height="150" width="150"></canvas>
<!-- Note the usage of `type=module` here as this is an ES6 module -->
<script type="module">
import init, {Env} from './pkg/RustyNEAT_envs.js';
async function run() {
var js = await init();
const resp = await fetch('map.png');
const buf = await resp.arrayBuffer();
const uint8View = new Uint8Array(buf);
var env = Env.new(uint8View);
var then = 0;
// Draw the scene repeatedly
function render(now) {
const deltaTime = now - then;
then = now;
env.draw(deltaTime);
requestAnimationFrame(render);
}
requestAnimationFrame(render);
}
run()
</script>
</body>
</html>