-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.html
328 lines (291 loc) · 8.05 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
/>
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<meta name="author" content="cubedhuang" />
<meta name="description" content="2D flocking simulation!" />
<meta
name="keywords"
content="cubedhuang, boids, flocking, 2d, simulation"
/>
<meta name="theme-color" content="#2f86c9" />
<meta property="og:title" content="Boids Simulation" />
<meta property="description" content="2D flocking simulation!" />
<meta property="og:description" content="2D flocking simulation!" />
<meta property="og:url" content="https://boids.cubedhuang.com/" />
<meta property="og:image" content="https://cubedhuang.com/logo.png" />
<link rel="shortcut icon" href="https://cubedhuang.com/favicon.ico" />
<link rel="stylesheet" href="./style.css" />
<link rel="canonical" href="https://boids.cubedhuang.com/" />
<link rel="author" href="https://cubedhuang.com/" />
<link rel="publisher" href="https://cubedhuang.com/" />
<!-- Global site tag (gtag.js) - Google Analytics -->
<script
async
src="https://www.googletagmanager.com/gtag/js?id=UA-107754281-2"
></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag("js", new Date());
gtag("config", "UA-107754281-2");
</script>
<!-- Cloudflare Web Analytics -->
<script
defer
src="https://static.cloudflareinsights.com/beacon.min.js"
data-cf-beacon='{"token": "52dcb98c1a10492682592c6cfe35319d"}'
></script>
<!-- End Cloudflare Web Analytics -->
<title>Boids Simulation</title>
</head>
<body>
<div id="container">
<header>
<h3>boids</h3>
<a
href="https://github.com/cubeDhuang/boids"
class="source"
target="_blank"
>
source code
</a>
</header>
<p class="info">
left and right click to move the boids, or just watch their
flocking patterns!
<br />
double click to make an explosion <br />
middle click or click in the top right to toggle this menu
<br />
press space to pause, and use . to advance one frame
</p>
<div id="pauser">
<input type="checkbox" id="pauseButton" data-model="paused" />
<label for="pauseButton"> </label>
<button class="nexter" data-click="next">next frame</button>
</div>
<div class="resetters">
<button data-click="restart">restart simulation</button>
<button data-click="reset">reset settings</button>
</div>
<div class="resetters">
<button data-click="exportSave">export settings</button>
<button data-click="importMenu">import settings</button>
</div>
<p>number of boids: <span data-show="boids"></span></p>
<input
type="range"
min="50"
max="5000"
step="50"
data-model="boids"
/>
<h4>visual settings</h4>
<div>
<input type="checkbox" id="toggle" data-model="toggle" />
<label for="toggle"> hide menu toggle (still works)</label>
</div>
<div>
<input type="checkbox" id="desired" data-model="desired" />
<label for="desired"> show boid desired directions</label>
</div>
<div>
<input type="checkbox" id="hideBoids" data-model="hideBoids" />
<label for="hideBoids"> completely hide boids (for art?)</label>
</div>
<div>
<input type="checkbox" id="hues" data-model="hues" />
<label for="hues"> change hues to indicate speed</label>
</div>
<div>
<input type="checkbox" id="areas" data-model="areas" />
<label for="areas"> show vision areas</label>
</div>
<div>
<input type="checkbox" id="outlines" data-model="outlines" />
<label for="outlines"> show vision outlines</label>
</div>
<div>
<input type="checkbox" id="halfAreas" data-model="halfAreas" />
<label for="halfAreas">
halve shown vision area size
<span class="tooltip">
?
<span class="tip">
so boids interact when their circles "collide"
rather than when their circles intersect each
others' centers
</span>
</span>
</label>
</div>
<h4>boid movement</h4>
<div>
<input type="checkbox" id="particle" data-model="particle" />
<label for="particle"> particle mode</label>
</div>
<div>
<input type="checkbox" id="bounce" data-model="bounce" />
<label for="bounce"> bounce off of edges</label>
</div>
<p>
movement accuracy: <span data-show="accuracy"></span>
<span class="tooltip">
?
<span class="tip">
the maximum number of boids in vision that each boid
checks - higher values can cause lag with more boids
</span>
</span>
</p>
<input
type="range"
min="2.25"
max="10"
step="0.25"
data-model="accuracyPower"
/>
<p>boid vision: <span data-show="vision"></span></p>
<input
type="range"
min="0"
max="150"
step="5"
data-model="vision"
/>
<p>alignment force: <span data-show="alignment"></span></p>
<input
type="range"
min="0"
max="4"
step="0.1"
data-model="alignment"
/>
<p>
alignment bias: <span data-show="bias"></span>
<span class="tooltip">
?
<span class="tip">
how much a boid will align towards other boids. values
greater than 1 mean that it will be biased towards other
boids facing the same direction, while values lower than
1 mean the opposite.
</span>
</span>
</p>
<input
type="range"
min="0.25"
max="4"
step="0.05"
data-model="bias"
/>
<p>cohesion force: <span data-show="cohesion"></span></p>
<input
type="range"
min="0"
max="4"
step="0.1"
data-model="cohesion"
/>
<p>separation force: <span data-show="separation"></span></p>
<input
type="range"
min="0"
max="4"
step="0.1"
data-model="separation"
/>
<p>steering force: <span data-show="maxForce"></span></p>
<input
type="range"
min="0"
max="1"
step="0.05"
data-model="maxForce"
/>
<p>min speed: <span data-show="minSpeed"></span></p>
<input
type="range"
min="0"
max="4"
step="0.05"
data-model="minSpeed"
/>
<p>max speed: <span data-show="maxSpeed"></span></p>
<input
type="range"
min="0"
max="12"
step="0.25"
data-model="maxSpeed"
/>
<p>drag: <span data-show="drag"></span></p>
<input
type="range"
min="0"
max="0.05"
step="0.001"
data-model="drag"
/>
<p>movement randomness: <span data-show="noise"></span></p>
<input
type="range"
min="0"
max="10"
step="0.5"
data-model="noise"
/>
<h4>debug info</h4>
<input type="checkbox" id="debug" data-model="debug" />
<label for="debug">show debug info</label>
<div id="debug-opts">
<p>fps: <span id="fps"></span></p>
<div>
<input type="checkbox" id="buckets" data-model="buckets" />
<label for="buckets"> show spatial subdivision</label>
</div>
</div>
</div>
<div id="toggler" data-click="toggleMenu">
<div class="img">
<img src="./right-arrow.svg" alt="arrow" />
</div>
</div>
<div class="popupwindow" id="popupwindow">
<div class="popup" id="export-popup">
<h3>export settings</h3>
<textarea id="exporter" cols="30" rows="10" readonly></textarea>
<button data-click="copy">copy</button>
<button data-click="leaveMenu" class="close">close</button>
</div>
<div class="popup" id="import-popup">
<h3>import settings</h3>
<textarea
placeholder="paste your exported settings here..."
id="importer"
cols="30"
rows="10"
></textarea>
<button data-click="importSave">import</button>
<button data-click="leaveMenu" class="close">close</button>
</div>
</div>
<script src="./lib/pixi.min.js"></script>
<script src="./js/v2d.js"></script>
<script src="./js/util.js"></script>
<script src="./js/opt.js"></script>
<script src="./js/boid.js"></script>
<script src="./js/flock.js"></script>
<script src="./js/main.js"></script>
<script src="./js/events.js"></script>
</body>
</html>