-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
67 lines (59 loc) · 2.06 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
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>pony-bumblebee</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-color: #333;
}
main {
display: flex;
align-items: center;
justify-content: center;
width: 100vw;
height: 100vh;
}
.p5Canvas {
outline: 1px solid #666;
/* box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.5); */
width: auto !important;
height: 100% !important;
transform: transale3d(0,0,0);
}
</style>
</head>
<body>
<main></main>
<!-- <script src="./node_modules/p5/lib/p5.min.js"></script> -->
<!-- <script id="sketch" type="module" src="./app/sketch.js"></script> -->
<script type="module">
// Note: this is quite awful
// cache-busting: load main sketch file with query parameter taken from git-hash file or timestamp
let [res1, res2] = await Promise.all([ fetch('./git-hash'), fetch('./package.json') ]);
const hash = res1.status === 200 ? (await res1.text()).trim() : Date.now();
const package_json = await res2.json();
// console.log(hash, version);
const script = document.createElement('script');
script.src = './app/sketch.js?' + hash;
script.type = 'module';
script.id = 'sketch';
script.dataset.hash = hash;
script.dataset.version = package_json.version;
script.dataset.name = package_json.name;
script.addEventListener('load', () => {
// need to wait before loading p5
const p5script = document.createElement('script');
p5script.src = './node_modules/p5/lib/p5.min.js';
document.body.appendChild(p5script);
});
document.head.appendChild(script);
</script>
</body>
</html>