-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathindex.html
More file actions
351 lines (314 loc) · 8.51 KB
/
Copy pathindex.html
File metadata and controls
351 lines (314 loc) · 8.51 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
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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
<!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.dan.onl/" />
<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.dan.onl/" />
<link rel="author" href="https://dan.onl/" />
<link rel="publisher" href="https://dan.onl/" />
<!-- 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>
<h1>boids</h1>
<a
href="https://github.com/cubeDhuang/boids"
class="source"
target="_blank"
>
source code
</a>
</header>
<div class="info">
<p>
<key>left click</key> and <key>right click</key> to interact
with the boids, or just watch their flocking patterns!
</p>
<p><key>double click</key> to cause an explosion.</p>
<p><key>middle click</key> to toggle this menu.</p>
<p>
press <key>space</key> to pause, and use <key>.</key> to
advance one frame.
</p>
</div>
<div id="pauser">
<input type="checkbox" id="pauseButton" data-model="paused" />
<label for="pauseButton" aria-label="pause"> </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>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">
boids interact when their circles "collide" rather
than when their circles intersect each other's
centers.
</span>
</span>
</label>
</div>
<h4>boid movement</h4>
<div>
<input type="checkbox" id="particle" data-model="particle" />
<label for="particle"> particle mode</label>
<span class="tooltip">
?
<span class="tip">
turn off all flocking forces, making boids move like
particles affected only by noise, drag, and human input.
</span>
</span>
</div>
<div>
<input type="checkbox" id="bounce" data-model="bounce" />
<label for="bounce"> bounce off of edges</label>
</div>
<p>
movement accuracy
<span class="tooltip">
?
<span class="tip">
the maximum number of boids in vision that each boid
interacts with; higher values can cause lag with more
boids.
</span>
</span>
<span data-show="accuracy"></span>
</p>
<input
type="range"
min="2.25"
max="10"
step="0.25"
data-model="accuracyPower"
data-digits="2"
/>
<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"
data-digits="1"
/>
<p>
alignment bias
<span class="tooltip">
?
<span class="tip">
values greater than 1 cause boids to align more with
those facing the same direction, while values lower than
1 cause boids to align more with those facing different
directions.
</span>
</span>
<span data-show="bias"></span>
</p>
<input
type="range"
min="0.25"
max="4"
step="0.05"
data-model="bias"
data-digits="2"
/>
<p>cohesion force <span data-show="cohesion"></span></p>
<input
type="range"
min="0"
max="4"
step="0.1"
data-model="cohesion"
data-digits="1"
/>
<p>separation force <span data-show="separation"></span></p>
<input
type="range"
min="0"
max="4"
step="0.1"
data-model="separation"
data-digits="1"
/>
<p>steering force <span data-show="maxForce"></span></p>
<input
type="range"
min="0"
max="1"
step="0.05"
data-model="maxForce"
data-digits="2"
/>
<p>min speed <span data-show="minSpeed"></span></p>
<input
type="range"
min="0"
max="4"
step="0.05"
data-model="minSpeed"
data-digits="2"
/>
<p>max speed <span data-show="maxSpeed"></span></p>
<input
type="range"
min="0"
max="12"
step="0.25"
data-model="maxSpeed"
data-digits="2"
/>
<p>drag <span data-show="drag"></span></p>
<input
type="range"
min="0"
max="0.05"
step="0.001"
data-model="drag"
data-digits="3"
/>
<p>movement randomness <span data-show="noise"></span></p>
<input
type="range"
min="0"
max="10"
step="0.5"
data-model="noise"
data-digits="1"
/>
<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">
<h2>export settings</h2>
<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">
<h2>import settings</h2>
<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>