-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.html
190 lines (153 loc) · 4.59 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<!doctype html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
<script src="twgl-full.min.js"></script>
<script src="dat.gui.min.js"></script>
<!-- <script src="seedrandom.min.js"></script> -->
<!-- <script src="live.js"></script> -->
<script src="pako.min.js"></script>
<script src="UPNG.min.js"></script>
<script type='module' src="demo.js"></script>
<script type='module' src="ca.js"></script>
<!-- <script src="Tone.js" integrity="sha512-nUjml8mN4CNYqBAy0ndDrd8pJV/eTtBNDsnvNtPqozx9/BccUeWSoKW14qWkQUnhuh8E3m+yra3qdzM68lqPEQ==" crossorigin="anonymous"></script> -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-15552566-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-15552566-1');
</script>
<style>
html, body {
margin: 0px;
font-family: 'Google Sans', Arial, Helvetica, sans-serif;
color: #FFF;
}
canvas {
width: 100vw;
height: 100vh;
}
#fsButton {
position: fixed;
z-index: 10;
bottom: 20px; left:20px;
}
.centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
#info{
width: 300px;
background-color: rgba(0, 0, 0, 0.75);
padding: 20px;
z-index:5;
}
a:link {
color: red;
}
a:visited {
color: red;
}
.hint {
font-size: min(10vw, 8vh);
pointer-events: none;
white-space: nowrap;
opacity: 0;
transition: opacity 1s;
text-align: center;
}
#ui {
display: none;
}
#status {
pointer-events: none;
position: absolute;
top: 0px;
width: 100%;
text-align: center;
background-color: rgba(0, 0, 0, 0.75);
transition: opacity 0.5s;
opacity: 0;
}
</style>
<canvas id="glCanvas"></canvas>
<div id='ui'>
<div id='status' class=''>sdfsladf;lk</div>
<div id='hint' class='centered hint'>⇧<br>⇦ Swipe ⇨</div>
<div id='info' class='centered'>
<b style="font-size: large;">Hexells</b>
<span style="font-size: smaller;">by <a href="https://twitter.com/zzznah">Alexander Mordvintsev</a></span>
<p>
is a Self-Organising System of cells, that was trained to build textures
using neighbour communication only. This work exposes the relation between
the life of an individual cell, and the cell collective as a whole.
</p>
<p> The system is based on
<a href="https://distill.pub/selforg/2021/textures/">Neural Cellular Automata</a>.
</p>
<p style="font-size: large;">
Touch to interact, swipe ⇦ or ⇨ to change the pattern.
Swipe ⇧ to share the pattern with others!
</p>
<div id="hideBtn" style="text-align: center;"><button>Hide</button></div>
</div>
<button id="fsButton">Fullscreen</button>
<!-- <meter style="position: fixed; top:20px; left: 20px;" id="volume" value="0" min="0" max="100"></meter> -->
</div>
<script type="module">
import { Demo } from "./demo.js"
const $ = q=>document.querySelector(q);
const canvas = $('#glCanvas');
const isScreenMode = window.self !== window.top;
console.log('isScreenMode:', isScreenMode);
if (!isScreenMode) {
$('#ui').style.display = 'inline';
}
window.demo = new Demo(canvas, isScreenMode);
const frame = document.body;
const requestFullscreen = frame.requestFullscreen
|| frame.webkitRequestFullscreen || frame.msRequestFullscreen;
if (requestFullscreen === undefined) {
$('#fsButton').style.display = 'none';
}
$('#fsButton').onclick = ()=>{
requestFullscreen.call(frame, {navigationUI: "hide" });
};
document.addEventListener('fullscreenchange', (event) => {
if (document.fullscreenElement) {
$('#fsButton').style.display = "none";
} else {
$('#fsButton').style.display = "block";
}
});
$('#hideBtn').onclick = ()=>{
$('#info').style.display = 'none';
$('#hint').style.opacity = 1;
setTimeout(()=>{$('#hint').style.opacity = 0}, 2000);
}
// $('#hideBtn').onclick = ()=>{
// $('#info').style.display = 'none';
// $('#hint').classList.add('hint-anim');
// const meter = new Tone.Meter({normalRange:true, smoothing: 0.5});
// const mic = new Tone.UserMedia().connect(meter);
// let maxVol = 0.0;
// mic.open().then(() => {
// // promise resolves when input is available
// console.log("mic open");
// setInterval(() => {
// const v = meter.getValue();
// $('#volume').value = v*100.0;
// if (v>0.04) {
// console.log(v);
// ca.disturb();
// }
// }, 100);
// }).catch(e => {
// // promise is rejected when the user doesn't have or allow mic access
// console.log("mic not open");
// });
// };
</script>