-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
890 lines (843 loc) · 49.9 KB
/
Copy pathindex.html
File metadata and controls
890 lines (843 loc) · 49.9 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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>webgpu-fly — a real fly brain you can play, in your browser</title>
<meta
name="description"
content="Control a fruit fly by firing real neurons in its connectome. The whole brain, spinal cord, and body run live in your browser tab — no install. The connectome simulation is real; the walking on top of it is an approximation, and we say exactly where."
/>
<meta property="og:title" content="webgpu-fly — a real fly brain you can play" />
<meta
property="og:description"
content="A real fruit-fly brain, spine, and body running live in a browser tab. Press a key, fire real neurons, and the cascade decides where the fly goes. The connectome simulation is real; the walking on top of it is an approximation we document. No install."
/>
<meta name="twitter:card" content="summary_large_image" />
<meta name="author" content="Ahmet Barış Günaydın" />
<meta name="theme-color" content="#04060b" />
<link rel="canonical" href="https://webgpu-fly.pages.dev/" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400..700;1,9..144,400..600&family=Spline+Sans:wght@400;500;600;700&family=Spline+Sans+Mono:wght@400;500&display=swap"
rel="stylesheet"
/>
<!--
Auto-forward deep links into the simulator so nothing breaks:
#r=… shared replay URLs (replay state lives in the hash)
?mode=science the researcher view
?play / ?app explicit "skip the landing" links
Runs before paint so a shared replay link never flashes the landing.
-->
<script>
(function () {
var h = window.location.hash || "";
var q = window.location.search || "";
var go =
/^#?r=/.test(h) ||
/[?&]mode=(science|game)\b/.test(q) ||
/[?&](play|app)\b/.test(q);
if (go) window.location.replace("app.html" + q + h);
})();
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "SoftwareApplication",
"name": "webgpu-fly",
"applicationCategory": "Science / Simulation",
"operatingSystem": "Any (WebGPU browser)",
"url": "https://webgpu-fly.pages.dev",
"codeRepository": "https://github.com/abgnydn/webgpu-fly",
"license": "https://opensource.org/licenses/MIT",
"description": "A real Drosophila brain, spinal cord, and body running live in a browser tab via WebGPU.",
"author": {
"@type": "Person",
"name": "Ahmet Barış Günaydın",
"email": "hi@barisgunaydin.com",
"url": "https://barisgunaydin.com",
"sameAs": [
"https://barisgunaydin.com",
"https://github.com/abgnydn",
"https://huggingface.co/abgunaydin",
"https://x.com/abgnydn_",
"https://www.linkedin.com/in/abgnydn/"
]
},
"isPartOf": {
"@type": "CreativeWork",
"name": "kernelfusion.dev research line",
"url": "https://kernelfusion.dev"
}
}
</script>
<style>
:root {
color-scheme: dark;
--bg: #04060b;
--bg2: #070b12;
--panel: rgba(12, 19, 30, 0.62);
--panel-solid: #0a1019;
--line: rgba(140, 200, 255, 0.10);
--line2: rgba(140, 200, 255, 0.20);
--ink: #eaf1f8;
--dim: #93a3b6;
--dimmer: #5e6b7d;
--cyan: #7fe3ff;
--cyan-deep: #3aa0d6;
--teal: #34e3c0;
--amber: #ffc06b;
--violet: #c08bff;
--maxw: 1080px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
margin: 0;
background: var(--bg);
color: var(--ink);
font-family: "Spline Sans", system-ui, sans-serif;
font-size: 16px;
line-height: 1.65;
-webkit-font-smoothing: antialiased;
overflow-x: hidden;
}
::selection { background: rgba(127, 227, 255, 0.28); color: #fff; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
/* custom scrollbar */
::-webkit-scrollbar { width: 11px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #16202e; border-radius: 9px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #1e2c3e; }
/* ── living connectome field behind everything ── */
#neural {
position: fixed; inset: 0; width: 100vw; height: 100vh;
z-index: 0; display: block; pointer-events: none;
-webkit-mask-image: linear-gradient(180deg, #000 0%, #000 34%, rgba(0,0,0,0.5) 58%, transparent 80%);
mask-image: linear-gradient(180deg, #000 0%, #000 34%, rgba(0,0,0,0.5) 58%, transparent 80%);
}
/* atmospheric glows + grain */
body::before {
content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
background:
radial-gradient(900px 540px at 76% -6%, rgba(52, 227, 192, 0.10), transparent 60%),
radial-gradient(1100px 620px at 12% 4%, rgba(127, 227, 255, 0.10), transparent 62%);
}
body::after {
content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.04;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
mix-blend-mode: overlay;
}
.wrap { position: relative; z-index: 2; max-width: var(--maxw); margin: 0 auto; padding: 0 28px; }
/* ── nav ── */
nav {
position: relative; z-index: 5;
display: flex; align-items: center; justify-content: space-between;
max-width: var(--maxw); margin: 0 auto; padding: 22px 28px;
font-family: "Spline Sans Mono", monospace; font-size: 13px;
}
nav .brand { display: flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 500; letter-spacing: 0.02em; }
nav .pulse {
width: 8px; height: 8px; border-radius: 50%; background: var(--teal);
box-shadow: 0 0 0 0 rgba(52, 227, 192, 0.6); animation: live 2.6s infinite;
}
@keyframes live {
0% { box-shadow: 0 0 0 0 rgba(52, 227, 192, 0.5); }
70% { box-shadow: 0 0 0 7px rgba(52, 227, 192, 0); }
100% { box-shadow: 0 0 0 0 rgba(52, 227, 192, 0); }
}
nav .links { display: flex; gap: 26px; }
nav .links a { color: var(--dim); }
nav .links a:hover { color: var(--cyan); text-decoration: none; }
@media (max-width: 680px) { nav .links a:not(.nav-cta) { display: none; } }
nav .nav-cta { color: var(--cyan) !important; }
/* ── hero ── */
header.hero {
position: relative; z-index: 2;
max-width: var(--maxw); margin: 0 auto; padding: 70px 28px 96px;
min-height: 78vh; display: flex; flex-direction: column; justify-content: center;
}
.eyebrow {
font-family: "Spline Sans Mono", monospace; font-size: 12.5px;
letter-spacing: 0.16em; text-transform: uppercase; color: var(--teal);
display: flex; align-items: center; gap: 12px; margin-bottom: 30px;
opacity: 0; animation: rise 0.8s 0.05s cubic-bezier(.2,.7,.2,1) forwards;
}
.eyebrow::before { content: ""; width: 34px; height: 1px; background: linear-gradient(90deg, var(--teal), transparent); }
h1.head {
font-family: "Fraunces", serif;
font-weight: 600; font-size: clamp(42px, 8.2vw, 96px); line-height: 0.98;
letter-spacing: -0.025em; margin: 0 0 26px; max-width: 14ch;
opacity: 0; animation: rise 0.9s 0.14s cubic-bezier(.2,.7,.2,1) forwards;
}
h1.head .fire {
font-style: italic; font-weight: 500;
background: linear-gradient(95deg, #ffd79a, var(--amber) 55%, #ff9b57);
-webkit-background-clip: text; background-clip: text; color: transparent;
text-shadow: 0 0 44px rgba(255, 192, 107, 0.35);
}
.lede {
font-size: clamp(17px, 2.1vw, 21px); color: var(--dim); max-width: 60ch;
margin: 0 0 38px; line-height: 1.6;
opacity: 0; animation: rise 0.9s 0.26s cubic-bezier(.2,.7,.2,1) forwards;
}
.lede b { color: #cdd9e6; font-weight: 500; }
.cta { display: flex; gap: 14px; flex-wrap: wrap; align-items: center;
opacity: 0; animation: rise 0.9s 0.38s cubic-bezier(.2,.7,.2,1) forwards; }
.btn {
display: inline-flex; align-items: center; gap: 10px;
font-family: "Spline Sans", sans-serif; font-weight: 600; font-size: 15px;
padding: 15px 28px; border-radius: 11px; cursor: pointer; border: 1px solid transparent;
transition: transform .14s cubic-bezier(.2,.7,.2,1), box-shadow .2s, background .2s;
}
.btn.primary {
color: #04141b;
background: linear-gradient(180deg, #aef0ff, var(--cyan));
box-shadow: 0 10px 36px -10px rgba(127, 227, 255, 0.6), inset 0 1px 0 rgba(255,255,255,0.5);
}
.btn.primary:hover { transform: translateY(-2px); text-decoration: none; box-shadow: 0 16px 46px -10px rgba(127, 227, 255, 0.75); }
.btn.ghost { color: var(--ink); background: rgba(140, 200, 255, 0.05); border-color: var(--line2); backdrop-filter: blur(8px); }
.btn.ghost:hover { transform: translateY(-2px); text-decoration: none; background: rgba(140, 200, 255, 0.1); }
.hero-note {
margin-top: 22px; font-family: "Spline Sans Mono", monospace; font-size: 12px; color: var(--dimmer);
opacity: 0; animation: rise 0.9s 0.5s cubic-bezier(.2,.7,.2,1) forwards;
}
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
/* ── numbers band ── */
.numbers {
position: relative; z-index: 3;
max-width: var(--maxw); margin: -52px auto 0; padding: 0 28px;
}
.numbers .inner {
display: grid; grid-template-columns: repeat(4, 1fr);
background: linear-gradient(180deg, rgba(12,19,30,0.86), rgba(8,13,21,0.86));
border: 1px solid var(--line2); border-radius: 18px; overflow: hidden;
backdrop-filter: blur(14px);
box-shadow: 0 30px 80px -40px rgba(0,0,0,0.9), inset 0 1px 0 rgba(255,255,255,0.04);
}
.numbers .cell { padding: 26px 22px; border-right: 1px solid var(--line); text-align: center; }
.numbers .cell:last-child { border-right: none; }
.numbers .n {
font-family: "Fraunces", serif; font-weight: 600; font-size: clamp(26px, 3.6vw, 40px);
line-height: 1; color: var(--cyan); text-shadow: 0 0 30px rgba(127,227,255,0.25);
font-variant-numeric: tabular-nums;
}
.numbers .l {
margin-top: 9px; font-family: "Spline Sans Mono", monospace; font-size: 11px;
letter-spacing: 0.06em; text-transform: uppercase; color: var(--dimmer);
}
@media (max-width: 720px) { .numbers .inner { grid-template-columns: repeat(2, 1fr); } .numbers .cell:nth-child(2) { border-right: none; } .numbers .cell:nth-child(1), .numbers .cell:nth-child(2) { border-bottom: 1px solid var(--line); } }
/* ── sections ── */
section { position: relative; z-index: 2; max-width: var(--maxw); margin: 0 auto; padding: 92px 28px; }
.kicker {
font-family: "Spline Sans Mono", monospace; font-size: 12px; letter-spacing: 0.16em;
text-transform: uppercase; color: var(--teal); margin: 0 0 18px;
display: flex; align-items: center; gap: 11px;
}
.kicker::before { content: ""; width: 26px; height: 1px; background: var(--teal); opacity: 0.6; }
h2.title {
font-family: "Fraunces", serif; font-weight: 600; font-size: clamp(27px, 4vw, 42px);
line-height: 1.06; letter-spacing: -0.02em; margin: 0 0 22px; max-width: 22ch;
}
section p.body { color: var(--dim); font-size: 17px; max-width: 64ch; margin: 0 0 16px; }
section p.body:last-child { margin-bottom: 0; }
section p.body b { color: #cdd9e6; font-weight: 500; }
.accent { color: var(--cyan); }
/* reveal-on-scroll */
.reveal { opacity: 0; transform: translateY(26px); transition: opacity .8s cubic-bezier(.2,.7,.2,1), transform .8s cubic-bezier(.2,.7,.2,1); }
.reveal.in { opacity: 1; transform: none; }
/* ── layers (what's inside) ── */
.layers { margin-top: 14px; display: flex; flex-direction: column; gap: 14px; }
.layer {
display: grid; grid-template-columns: 56px 132px 1fr; gap: 20px; align-items: start;
padding: 22px 24px; border-radius: 16px;
background: var(--panel); border: 1px solid var(--line);
backdrop-filter: blur(10px); position: relative; overflow: hidden;
transition: border-color .2s, transform .2s;
}
.layer::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--lc, var(--cyan)); box-shadow: 0 0 22px var(--lc, var(--cyan)); }
.layer:hover { transform: translateX(4px); border-color: var(--line2); }
.layer .idx { font-family: "Fraunces", serif; font-size: 30px; font-weight: 500; color: var(--lc, var(--cyan)); line-height: 1; opacity: 0.85; }
.layer .tag { font-family: "Spline Sans Mono", monospace; font-size: 13px; font-weight: 500; color: var(--lc, var(--cyan)); text-transform: uppercase; letter-spacing: 0.06em; padding-top: 6px; }
.layer .desc { color: var(--dim); font-size: 14.5px; line-height: 1.6; padding-top: 3px; }
.layer .desc b { color: var(--ink); font-weight: 500; }
@media (max-width: 600px) { .layer { grid-template-columns: 44px 1fr; gap: 12px; } .layer .tag { grid-column: 2; padding-top: 0; } .layer .idx { font-size: 24px; } }
/* ── duo (is / isn't) ── */
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 14px; }
@media (max-width: 640px) { .duo { grid-template-columns: 1fr; } }
.duo .col { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 26px 26px; backdrop-filter: blur(10px); }
.duo .col.is { border-top: 2px solid var(--teal); }
.duo .col.isnt { border-top: 2px solid var(--amber); }
.duo h4 { margin: 0 0 16px; font-family: "Spline Sans Mono", monospace; font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; }
.duo .is h4 { color: var(--teal); }
.duo .isnt h4 { color: var(--amber); }
.duo ul { margin: 0; padding: 0; list-style: none; }
.duo li { position: relative; padding-left: 24px; color: var(--dim); font-size: 14.5px; margin-bottom: 14px; line-height: 1.55; }
.duo li:last-child { margin-bottom: 0; }
.duo li b { color: var(--ink); font-weight: 500; }
.duo .is li::before { content: "→"; position: absolute; left: 0; color: var(--teal); }
.duo .isnt li::before { content: "×"; position: absolute; left: 2px; color: var(--amber); }
/* ── keys ── */
.keys { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 16px; }
.kbd {
display: inline-flex; align-items: center; gap: 9px;
font-family: "Spline Sans Mono", monospace; font-size: 13px; color: var(--dim);
background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 9px 13px;
backdrop-filter: blur(8px);
}
.kbd .cap {
font-weight: 500; color: var(--cyan); background: #0a141d;
border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 6px; padding: 3px 9px;
box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}
/* ── perf bars ── */
.perf { margin-top: 16px; display: flex; flex-direction: column; gap: 18px; max-width: 640px; }
.bar-row { display: grid; grid-template-columns: 132px 1fr 76px; gap: 16px; align-items: center; }
.bar-row .who { font-family: "Spline Sans Mono", monospace; font-size: 13px; color: var(--dim); }
.bar-row.us .who { color: var(--cyan); font-weight: 500; }
.bar-track { height: 12px; background: rgba(140,200,255,0.06); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.bar-fill { height: 100%; border-radius: 99px; transform-origin: left; transform: scaleX(0); transition: transform 1.1s cubic-bezier(.2,.7,.2,1); }
.reveal.in .bar-fill { transform: scaleX(var(--w)); }
.bar-row .val { font-family: "Spline Sans Mono", monospace; font-size: 13px; color: var(--dim); text-align: right; font-variant-numeric: tabular-nums; }
.bar-row.us .val { color: var(--cyan); }
.perf-note { margin-top: 6px; font-size: 13.5px; color: var(--dimmer); max-width: 60ch; }
/* ── companion cards ── */
.demos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 16px; }
@media (max-width: 820px) { .demos { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .demos { grid-template-columns: 1fr; } }
.demo-card {
display: flex; flex-direction: column; border-radius: 16px; overflow: hidden;
background: var(--panel); border: 1px solid var(--line); text-decoration: none; color: inherit;
backdrop-filter: blur(10px); transition: transform .18s cubic-bezier(.2,.7,.2,1), border-color .18s, box-shadow .2s;
}
.demo-card:hover { transform: translateY(-4px); border-color: var(--line2); text-decoration: none; box-shadow: 0 20px 50px -28px rgba(0,0,0,0.9); }
.demo-card .preview {
height: 84px; display: flex; align-items: center; justify-content: center;
font-family: "Fraunces", serif; font-weight: 600; font-size: 30px; letter-spacing: 0.02em;
position: relative;
}
.demo-card .preview::after { content: ""; position: absolute; inset: 0; background: radial-gradient(120px 60px at 50% 130%, rgba(255,255,255,0.12), transparent); }
.demo-card .cbody { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.demo-card h4 { margin: 0; font-size: 15.5px; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 7px; }
.demo-card h4 .arrow { color: var(--dimmer); font-weight: 400; transition: transform .18s; }
.demo-card:hover h4 { color: var(--cyan); }
.demo-card:hover h4 .arrow { transform: translate(2px, -2px); }
.demo-card p { margin: 0; font-size: 12.5px; color: var(--dim); line-height: 1.55; flex: 1; }
.demo-card .meta { display: flex; flex-wrap: wrap; gap: 6px; }
.demo-card .meta span { font-family: "Spline Sans Mono", monospace; font-size: 10px; color: var(--dimmer); background: #0a141d; border: 1px solid var(--line); border-radius: 99px; padding: 3px 9px; }
/* ── honest callout ── */
.callout {
margin-top: 14px; background: linear-gradient(180deg, rgba(255,192,107,0.05), rgba(12,19,30,0.6));
border: 1px solid var(--line2); border-left: 2px solid var(--amber); border-radius: 16px; padding: 28px 30px;
backdrop-filter: blur(10px);
}
.callout p { color: var(--dim); margin: 0 0 14px; font-size: 15.5px; line-height: 1.62; }
.callout p:last-child { margin: 0; }
.callout b { color: var(--ink); font-weight: 500; }
ul.clean { margin: 14px 0 0; padding-left: 0; list-style: none; max-width: 64ch; }
ul.clean li { position: relative; padding-left: 26px; color: var(--dim); font-size: 16px; margin-bottom: 14px; line-height: 1.55; }
ul.clean li::before { content: ""; position: absolute; left: 4px; top: 10px; width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 12px var(--cyan); }
ul.clean li b { color: var(--ink); font-weight: 500; }
/* ── bottom cta ── */
.closer { position: relative; z-index: 2; max-width: var(--maxw); margin: 0 auto; padding: 30px 28px 96px; text-align: center; }
.closer h2 { font-family: "Fraunces", serif; font-weight: 600; font-size: clamp(26px, 4.4vw, 46px); letter-spacing: -0.02em; margin: 0 0 28px; }
.closer h2 .fire { font-style: italic; color: var(--amber); }
/* ── footer ── */
footer { position: relative; z-index: 2; border-top: 1px solid var(--line); }
footer .fwrap { max-width: var(--maxw); margin: 0 auto; padding: 46px 28px 64px; }
.foot-top { display: flex; justify-content: space-between; gap: 28px; flex-wrap: wrap; align-items: flex-start; }
.foot-brand { font-family: "Fraunces", serif; font-size: 22px; font-weight: 600; color: var(--ink); margin-bottom: 10px; }
.foot-by { font-size: 14px; color: var(--dim); }
.foot-by a { color: var(--cyan); }
.foot-line { margin-top: 14px; font-family: "Spline Sans Mono", monospace; font-size: 11.5px; color: var(--dimmer); }
.foot-links { display: flex; gap: 22px; font-family: "Spline Sans Mono", monospace; font-size: 13px; }
.foot-links a { color: var(--dim); }
.foot-links a:hover { color: var(--cyan); text-decoration: none; }
.refs { margin-top: 34px; padding-top: 24px; border-top: 1px solid var(--line); font-size: 12px; color: var(--dimmer); line-height: 1.9; }
.refs b { color: var(--dim); font-weight: 500; }
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
html { scroll-behavior: auto; }
.reveal { opacity: 1; transform: none; }
}
</style>
</head>
<body>
<canvas id="neural" aria-hidden="true"></canvas>
<nav>
<span class="brand"><span class="pulse"></span>webgpu-fly</span>
<span class="links">
<a href="#inside">What's inside</a>
<a href="#play">Play</a>
<a href="#line">Research line</a>
<a href="https://github.com/abgnydn/webgpu-fly" target="_blank" rel="noopener">GitHub</a>
<a class="nav-cta" href="app.html">Launch ▸</a>
</span>
</nav>
<header class="hero">
<div class="eyebrow">A real fly brain · in your browser · no install</div>
<h1 class="head">You drive a fly by firing its <span class="fire">real neurons</span>.</h1>
<p class="lede">
Scientists mapped every neuron in a fruit fly's brain. This puts that
whole map — plus its spinal cord and its body — live in your browser tab.
Press a key, a real neuron fires, the spike spreads through the real
wiring, and the fly walks. <b>The cascade is real; the leg rhythm it
drives is hand-written, and we tell you which is which.</b>
</p>
<div class="cta">
<a class="btn primary" href="play.html">▸ Launch the simulator</a>
<a class="btn ghost" href="#what">How does it work?</a>
</div>
<div class="hero-note">
needs a WebGPU browser (Chrome · Edge · recent Safari) — first visit streams ~300 MB, then it's cached
</div>
</header>
<!-- numbers band -->
<div class="numbers">
<div class="inner reveal">
<div class="cell"><div class="n">139,255</div><div class="l">brain neurons</div></div>
<div class="cell"><div class="n">23,188</div><div class="l">spinal-cord neurons</div></div>
<div class="cell"><div class="n">20M+</div><div class="l">wired connections</div></div>
<div class="cell"><div class="n">67</div><div class="l">body parts · real physics</div></div>
</div>
</div>
<main>
<!-- 30-second version -->
<section id="what">
<div class="kicker reveal">The 30-second version</div>
<h2 class="title reveal">A whole animal nervous system, end to end, running on your GPU.</h2>
<p class="body reveal">
A real fly's brain was reconstructed neuron-by-neuron from electron
microscopy — the <a href="https://flywire.ai" target="_blank" rel="noopener">FlyWire</a>
project. We loaded that exact wiring diagram into the browser and turn
it into a living simulation: each neuron charges up, fires when it
hits threshold, and passes the spike on to whatever it's connected to.
The same rule, 139,255 times, every millisecond.
</p>
<p class="body reveal">
The brain talks to the fly's <span class="accent">spinal cord</span>
(a second real connectome), and what the spinal cord decides steers a
<span class="accent">physically simulated body</span>. Press a key and
you inject current into specific command neurons, then watch the
consequences ripple all the way down to the legs. What comes out of
the connectome is a walking speed and a turn — the stepping rhythm
itself is a hand-written tripod gait, not neuron-by-neuron muscle
control.
</p>
<p class="body reveal">
And in this default view the body is <em>moved</em> by that speed and
turn directly, rather than being pushed along by its own legs. So the
brain really does decide where the fly goes; the legs you see stepping
are not what carries it there. There is a switch that turns the
shortcut off — with it off, the connectome-driven fly pivots on the
spot and covers almost no ground. The one thing that does walk on its
legs is the trained policy below, and even that leans on a stabiliser.
</p>
</section>
<!-- what's inside -->
<section id="inside">
<div class="kicker reveal">What's actually inside</div>
<h2 class="title reveal">Four real datasets, wired together.</h2>
<div class="layers">
<div class="layer reveal" style="--lc:#7fe3ff">
<div class="idx">01</div><div class="tag">Brain</div>
<div class="desc"><b>FlyWire connectome</b> — the full reconstructed brain of an adult fly: 139,255 neurons and ~15 million connections (Dorkenwald et al. 2024, <i>Nature</i>). Runs as a leaky integrate-and-fire network in a fused WebGPU kernel.</div>
</div>
<div class="layer reveal" style="--lc:#34e3c0">
<div class="idx">02</div><div class="tag">Spine</div>
<div class="desc"><b>Janelia MANC connectome</b> — the fly's ventral nerve cord, its "spinal cord": 23,188 neurons, 5.2 million connections. A second live network that turns brain commands into a walking drive.</div>
</div>
<div class="layer reveal" style="--lc:#ffc06b">
<div class="idx">03</div><div class="tag">Body</div>
<div class="desc"><b>TuragaLab flybody</b> — a physically accurate fruit-fly model with 67 body parts and 111 muscles, simulated with real physics (MuJoCo) compiled to run in the browser.</div>
</div>
<div class="layer reveal" style="--lc:#c08bff">
<div class="idx">04</div><div class="tag">Eyes</div>
<div class="desc">A tiny <b>64×16 retina</b> rendered from the fly's own head position each frame, fed back into the brain's optic neurons — so the fly can actually see the target it's walking toward.</div>
</div>
</div>
<p class="body reveal" style="margin-top:24px">
The brain and the spine are joined by <i>name</i>, not by wire: a
command neuron called <code>DNa01</code> in the brain is matched to the
neuron with the same name in the spinal cord. Biology motivates the
match — that cell really does keep its body in the brain and send its
axon down the cord — but the two maps come from two different flies (a
female brain, a male nerve cord), and no reconstructed connection
crosses between them. What crosses is a number: the brain neuron's
recent firing rate, averaged over its left and right copies and scaled
by a constant we picked, dropped into the spinal neurons that share its
name. The spiking on either side is real; the handoff is ours. Past the
spinal cord it changes again: the motor neurons set a walking speed and
a turn, the choice of forward or backward comes from a small hand-wired
spine rather than from the real one, and a hand-written leg rhythm does
the actual stepping.
</p>
<p class="body reveal">
There is also a second mode that hands the legs to a
<b>trained walking policy</b> published with the body model. With the
push we normally give the body switched off, the forward motion is
genuinely the legs' doing — the fly covers 2.019 cm per simulated
second against a 2.0 cm/s command, pushing off the ground. Staying
upright is not: a stabiliser bleeds off the fly's pitch and roll on
every physics substep, and with that switched off too it topples over
and gets nowhere (0.068 cm per simulated second). The forward motion
is earned; the balance is propped up. It is also worth being clear
about what the policy is: a neural network someone trained with
reinforcement learning, not the fly's own brain — the connectome plays
no part in it.
</p>
</section>
<!-- is / isn't -->
<section id="straight">
<div class="kicker reveal">Straight about it</div>
<h2 class="title reveal">What this is — and what it deliberately isn't.</h2>
<div class="duo">
<div class="col is reveal">
<h4>What it is</h4>
<ul>
<li>A <b>whole-animal nervous system</b> — brain, spine, and body — running end to end in a browser tab, no install.</li>
<li>Built from <b>real, published data</b>: two connectomes, a physical body model, and a trained policy, each peer-reviewed.</li>
<li><b>Reproducible by design</b> — every shared run re-executes the same neurons deterministically.</li>
</ul>
</div>
<div class="col isnt reveal">
<h4>What it isn't</h4>
<ul>
<li><b>Not a replacement for scientific simulators</b> (NEST, Brian2, NEURON) — those are faster, more detailed, validated.</li>
<li><b>Not biophysically detailed</b>: neurons are simple integrate-and-fire units — no ion channels or neuromodulation.</li>
<li><b>Not quantitatively validated</b> whole-brain, and it runs slower than real time. Full list in <a href="https://github.com/abgnydn/webgpu-fly/blob/main/LIMITATIONS.md" target="_blank" rel="noopener">LIMITATIONS.md</a>.</li>
</ul>
</div>
</div>
</section>
<!-- how to play -->
<section id="play">
<div class="kicker reveal">How to play</div>
<h2 class="title reveal">Race the fly to the target, on as few spikes as you can.</h2>
<p class="body reveal">
Each key fires a famous <b>descending neuron</b> — a command cell that
carries instructions from brain to body. Tap them to steer:
</p>
<div class="keys reveal">
<span class="kbd"><span class="cap">Q W</span> forward</span>
<span class="kbd"><span class="cap">E</span> backward</span>
<span class="kbd"><span class="cap">R</span> turn</span>
<span class="kbd"><span class="cap">A</span> escape jump</span>
<span class="kbd"><span class="cap">S</span> looming dodge</span>
<span class="kbd"><span class="cap">F</span> backward (MDN)</span>
<span class="kbd"><span class="cap">SPACE</span> new round</span>
<span class="kbd"><span class="cap">M</span> science view</span>
</div>
<p class="body reveal" style="margin-top:24px">
Reach the red target in the least time × fewest spikes. When you win,
you get a <span class="accent">replay link</span> — whoever opens it
watches the <b>exact same simulation</b> re-run: same target, your same
keystrokes, against the same brain. You're sharing a brain trace, not a
video.
</p>
</section>
<!-- how fast -->
<section id="fast">
<div class="kicker reveal">How fast — honestly</div>
<h2 class="title reveal">Slower than real time. The only one behind a single URL.</h2>
<p class="body reveal">
The brain kernel is limited by memory speed, not math. We benchmarked
it against the scientific standards on the same M2 Pro laptop —
biological-time rate, higher is faster:
</p>
<div class="perf reveal">
<div class="bar-row"><div class="who">NEST 3.10 (C++)</div><div class="bar-track"><div class="bar-fill" style="--w:0.67; background:linear-gradient(90deg,#34e3c0,#1f9e87)"></div></div><div class="val">0.67 kHz</div></div>
<div class="bar-row"><div class="who">Rust (multicore)</div><div class="bar-track"><div class="bar-fill" style="--w:0.45; background:linear-gradient(90deg,#34e3c0,#1f9e87)"></div></div><div class="val">0.45 kHz</div></div>
<div class="bar-row us"><div class="who">webgpu-fly</div><div class="bar-track"><div class="bar-fill" style="--w:0.25; background:linear-gradient(90deg,#aef0ff,#3aa0d6)"></div></div><div class="val">0.25 kHz</div></div>
</div>
<p class="perf-note reveal">
The original 1 kHz real-time target was unreachable for <i>all three</i>
on that hardware — so we report what we measured, not what we hoped. The
point was never "faster than NEST." It's <b style="color:var(--ink)">a real fly brain on a phone in
30 seconds</b> — the part the others can't do. Full disclosure in
<a href="https://github.com/abgnydn/webgpu-fly/blob/main/LIMITATIONS.md" target="_blank" rel="noopener">LIMITATIONS.md</a>.
</p>
</section>
<!-- why different -->
<section id="why">
<div class="kicker reveal">Why this one's different</div>
<h2 class="title reveal">Other groups simulate fly brains too. None of them open in a tab.</h2>
<ul class="clean reveal">
<li><b>It's just a link.</b> Comparable projects need Python, a GPU, and a setup hour. This needs one click.</li>
<li><b>All three layers, wired together</b> — brain <i>and</i> spine <i>and</i> body — not just brain plus body.</li>
<li><b>Every shared run is reproducible.</b> A replay URL re-executes the real neurons deterministically — anyone can verify, study, or remix it.</li>
</ul>
</section>
<!-- research line -->
<section id="line">
<div class="kicker reveal">Part of a research line</div>
<h2 class="title reveal">One front of a broader effort: Geant4-class simulators, ported to WebGPU, in a browser tab.</h2>
<p class="body reveal" style="margin-bottom:26px">
webgpu-fly is built by
<a href="https://barisgunaydin.com" target="_blank" rel="noopener">Ahmet Barış Günaydın</a>,
an independent researcher. It shares its thesis — and its kernel-fusion
and viewer machinery — with these sibling projects:
</p>
<div class="demos">
<a class="demo-card reveal" href="https://webgpu-q.vercel.app" target="_blank" rel="noopener">
<div class="preview" style="background:linear-gradient(135deg,#08222a,#0c3340);color:#7fe3ff">Q</div>
<div class="cbody">
<h4>webgpu-q <span class="arrow">↗</span></h4>
<p>The closest sibling. Browser-native quantum chemistry — Hartree–Fock, CCSD(T), DFT, EOM-CCSD — ported from PySCF and GPU-accelerated. Same "real science in a tab" thesis, different physics.</p>
<div class="meta"><span>CCSD(T)</span><span>WebGPU</span></div>
</div>
</a>
<a class="demo-card reveal" href="https://webgpudna.com" target="_blank" rel="noopener">
<div class="preview" style="background:linear-gradient(135deg,#0c1a26,#15293c);color:#9ad7ff">🧬</div>
<div class="cbody">
<h4>webgpu-dna <span class="arrow">↗</span></h4>
<p>Sister project: Geant4-DNA radiobiology — Monte-Carlo electron tracks, radiolysis chemistry, DNA-damage scoring — in the browser, within 0.985× of the reference. The 4D-viewer pattern came from here.</p>
<div class="meta"><span>Geant4-DNA</span><span>Monte Carlo</span></div>
</div>
</a>
<a class="demo-card reveal" href="https://kernelfusion.dev" target="_blank" rel="noopener">
<div class="preview" style="background:linear-gradient(135deg,#0a1f1a,#103a30);color:#5fe6bd">⊗</div>
<div class="cbody">
<h4>kernelfusion.dev <span class="arrow">↗</span></h4>
<p>The research umbrella. Single-kernel fusion for GPU workloads — collapsing per-dispatch overhead — which is exactly what makes a 140k-neuron LIF step feasible per frame here.</p>
<div class="meta"><span>Umbrella</span><span>Two preprints</span></div>
</div>
</a>
<a class="demo-card reveal" href="https://gpubench.dev" target="_blank" rel="noopener">
<div class="preview" style="background:linear-gradient(135deg,#1a0e1f,#2c1636);color:#ffb56e">▤</div>
<div class="cbody">
<h4>gpubench.dev <span class="arrow">↗</span></h4>
<p>"How fast is your GPU in the browser?" Real WebGPU compute tests — 794 runs published across 119 distinct GPU/browser/OS combinations, the honest hardware baseline behind any number on this page.</p>
<div class="meta"><span>794 runs</span><span>119 devices</span></div>
</div>
</a>
<a class="demo-card reveal" href="https://neuropulse.live" target="_blank" rel="noopener">
<div class="preview" style="background:linear-gradient(135deg,#190a26,#2c1142);color:#c08bff">◗</div>
<div class="cbody">
<h4>neuropulse.live <span class="arrow">↗</span></h4>
<p>Watch a real 3.8B-parameter transformer think, tensor by tensor — every glow is a live activation read back from WebGPU. The same read-back-and-render idea as this fly's retina.</p>
<div class="meta"><span>Live activations</span><span>No server</span></div>
</div>
</a>
<a class="demo-card reveal" href="https://barisgunaydin.com" target="_blank" rel="noopener">
<div class="preview" style="background:linear-gradient(135deg,#11141d,#1c2334);color:#e6e9f0;font-style:italic">A·B·G</div>
<div class="cbody">
<h4>barisgunaydin.com <span class="arrow">↗</span></h4>
<p>The author's site — an index of every project, paper, and note behind this research line, plus contact. Ahmet Barış Günaydın, independent researcher.</p>
<div class="meta"><span>About</span><span>Papers</span><span>Contact</span></div>
</div>
</a>
</div>
</section>
<!-- honest callout -->
<section id="honest">
<div class="kicker reveal">The honest part</div>
<div class="callout reveal">
<p>
This isn't the fastest fly-brain simulator — it's the most
<i>reachable</i> one. It trades scientific completeness for
<b>a real connectome on a phone in 30 seconds</b>. Treat it as a
teaching, demonstration, and intuition-building tool — not a validated
platform for publishing fly-brain dynamics.
</p>
<p>
The full, honest list of what's simplified, untested, or approximate —
the performance ceiling, the LIF simplifications, the
brain→spine→body approximations, the browser matrix — lives in
<a href="https://github.com/abgnydn/webgpu-fly/blob/main/LIMITATIONS.md" target="_blank" rel="noopener">LIMITATIONS.md</a>.
</p>
</div>
</section>
</main>
<div class="closer reveal">
<h2>Press a key. Fire a <span class="fire">real neuron</span>.</h2>
<a class="btn primary" href="play.html">▸ Launch the simulator</a>
</div>
<footer>
<div class="fwrap">
<div class="foot-top">
<div>
<div class="foot-brand">webgpu-fly</div>
<div class="foot-by">
MIT · by <a href="https://barisgunaydin.com" target="_blank" rel="noopener">Ahmet Barış Günaydın</a>,
independent researcher · <a href="mailto:hi@barisgunaydin.com">hi@barisgunaydin.com</a>
</div>
<div class="foot-line">
Part of the <a href="https://kernelfusion.dev" target="_blank" rel="noopener">kernelfusion.dev</a>
research line · related:
<a href="https://webgpu-q.vercel.app" target="_blank" rel="noopener">webgpu-q</a> ·
<a href="https://webgpudna.com" target="_blank" rel="noopener">webgpudna.com</a> ·
<a href="https://gpubench.dev" target="_blank" rel="noopener">gpubench.dev</a>
</div>
</div>
<div class="foot-links">
<a href="play.html">Play</a>
<a href="app.html?mode=science">Nerd mode</a>
<a href="https://github.com/abgnydn/webgpu-fly" target="_blank" rel="noopener">GitHub</a>
<a href="https://github.com/abgnydn/webgpu-fly/blob/main/NOTICE" target="_blank" rel="noopener">Licenses</a>
</div>
</div>
<div class="refs">
Built on open science · code MIT · data CC-BY 4.0 / Apache-2.0 (see <a href="https://github.com/abgnydn/webgpu-fly/blob/main/NOTICE" target="_blank" rel="noopener">NOTICE</a>)<br/>
<b>Dorkenwald et al. 2024</b> — Neuronal wiring diagram of an adult brain. Nature 634:124–138. ·
<b>Takemura et al. 2024</b> — A connectome of the male Drosophila ventral nerve cord. eLife. ·
<b>Vaxenburg et al. 2025</b> — Whole-body simulation of fruit-fly locomotion. Nature. ·
<b>Shiu et al. 2024</b> — A leaky integrate-and-fire model of the Drosophila brain. Nature 632:210–217.
</div>
</div>
</footer>
<script>
/* ── the living connectome ──────────────────────────────────────────
Neurons as points, real-ish edges between nearby cells, and spikes
that travel along the wiring and cascade — literally what the
product does, used as the page's atmosphere. Cheap canvas 2D. */
(function () {
var canvas = document.getElementById("neural");
if (!canvas) return;
var ctx = canvas.getContext("2d");
var reduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
var W = 0, H = 0, DPR = 1;
var nodes = [], edges = [], spikes = [];
var mx = -1e3, my = -1e3;
function resize() {
DPR = Math.min(2, window.devicePixelRatio || 1);
W = canvas.clientWidth = window.innerWidth;
H = canvas.clientHeight = window.innerHeight;
canvas.width = Math.floor(W * DPR);
canvas.height = Math.floor(H * DPR);
ctx.setTransform(DPR, 0, 0, DPR, 0, 0);
build();
}
function build() {
nodes = []; edges = []; spikes = [];
var area = W * H;
var N = Math.max(46, Math.min(132, Math.round(area / 13000)));
// a few cluster centres so it reads like brain regions
var clusters = [];
var cc = 5;
for (var c = 0; c < cc; c++) clusters.push({ x: (0.12 + 0.76 * ((c + 0.5) / cc)) * W, y: (0.18 + 0.5 * pseudo(c * 7.3)) * H });
for (var i = 0; i < N; i++) {
var k = (Math.random() < 0.7) ? clusters[(Math.random() * cc) | 0] : { x: Math.random() * W, y: Math.random() * H * 0.85 };
var r = (Math.random() < 0.7) ? 70 + Math.random() * 130 : 0;
var a = Math.random() * Math.PI * 2;
nodes.push({
x: Math.min(W, Math.max(0, k.x + Math.cos(a) * r)),
y: Math.min(H * 0.92, Math.max(0, k.y + Math.sin(a) * r)),
ph: Math.random() * Math.PI * 2, fl: 0
});
}
// edges: each node to its 2–3 nearest neighbours
for (var p = 0; p < nodes.length; p++) {
var d = [];
for (var qn = 0; qn < nodes.length; qn++) {
if (qn === p) continue;
var dx = nodes[p].x - nodes[qn].x, dy = nodes[p].y - nodes[qn].y;
d.push({ j: qn, d2: dx * dx + dy * dy });
}
d.sort(function (u, v) { return u.d2 - v.d2; });
var deg = 2 + ((Math.random() * 2) | 0);
for (var e = 0; e < deg && e < d.length; e++) {
if (d[e].d2 > 280 * 280) continue;
if (p < d[e].j) edges.push({ a: p, b: d[e].j, inh: Math.random() < 0.22 });
}
}
// adjacency for cascades
for (var n2 = 0; n2 < nodes.length; n2++) nodes[n2].adj = [];
edges.forEach(function (ed, ix) { nodes[ed.a].adj.push(ix); nodes[ed.b].adj.push(ix); });
}
function pseudo(x) { var s = Math.sin(x) * 43758.5453; return s - Math.floor(s); }
function fire(i, depth) {
var node = nodes[i]; if (!node) return;
node.fl = 1;
var adj = node.adj || [];
for (var a = 0; a < adj.length; a++) {
var ed = edges[adj[a]];
var other = ed.a === i ? ed.b : ed.a;
if (spikes.length > 90) break;
spikes.push({ e: adj[a], from: i, to: other, t: 0, sp: 0.012 + Math.random() * 0.016, inh: ed.inh, depth: depth });
}
}
var last = 0, acc = 0;
function frame(ts) {
var dt = Math.min(50, ts - last); last = ts; acc += dt;
// ambient seed firing
if (acc > 520) { acc = 0; if (spikes.length < 60) fire((Math.random() * nodes.length) | 0, 0); }
ctx.clearRect(0, 0, W, H);
// edges
ctx.lineWidth = 1;
for (var e = 0; e < edges.length; e++) {
var A = nodes[edges[e].a], B = nodes[edges[e].b];
ctx.strokeStyle = edges[e].inh ? "rgba(192,139,255,0.05)" : "rgba(127,200,255,0.055)";
ctx.beginPath(); ctx.moveTo(A.x, A.y); ctx.lineTo(B.x, B.y); ctx.stroke();
}
// spikes travelling along edges
for (var s = spikes.length - 1; s >= 0; s--) {
var sp = spikes[s];
sp.t += sp.sp * (dt / 16.6);
var A2 = nodes[sp.from], B2 = nodes[sp.to];
var x = A2.x + (B2.x - A2.x) * sp.t, y = A2.y + (B2.y - A2.y) * sp.t;
var col = sp.inh ? "192,139,255" : "255,192,107";
// glow head
var g = ctx.createRadialGradient(x, y, 0, x, y, 9);
g.addColorStop(0, "rgba(" + col + ",0.9)"); g.addColorStop(1, "rgba(" + col + ",0)");
ctx.fillStyle = g; ctx.beginPath(); ctx.arc(x, y, 9, 0, 6.2832); ctx.fill();
ctx.fillStyle = "rgba(" + col + ",1)"; ctx.beginPath(); ctx.arc(x, y, 1.6, 0, 6.2832); ctx.fill();
if (sp.t >= 1) {
spikes.splice(s, 1);
if (!sp.inh && sp.depth < 3 && Math.random() < 0.62) fire(sp.to, sp.depth + 1);
else { var nn = nodes[sp.to]; if (nn) nn.fl = Math.max(nn.fl, 0.85); }
}
}
// nodes
for (var i = 0; i < nodes.length; i++) {
var nd = nodes[i];
nd.ph += 0.012;
var dxm = nd.x - mx, dym = nd.y - my;
var near = Math.max(0, 1 - (dxm * dxm + dym * dym) / (150 * 150));
var base = 0.18 + 0.12 * Math.sin(nd.ph) + near * 0.5;
var bright = Math.min(1, base + nd.fl);
nd.fl *= 0.92;
var rr = 1.3 + nd.fl * 2.4 + near * 1.2;
if (nd.fl > 0.05 || near > 0.05) {
var gg = ctx.createRadialGradient(nd.x, nd.y, 0, nd.x, nd.y, 14 + nd.fl * 14);
var fc = nd.fl > 0.3 ? "255,192,107" : "127,227,255";
gg.addColorStop(0, "rgba(" + fc + "," + (0.28 * bright) + ")"); gg.addColorStop(1, "rgba(" + fc + ",0)");
ctx.fillStyle = gg; ctx.beginPath(); ctx.arc(nd.x, nd.y, 14 + nd.fl * 14, 0, 6.2832); ctx.fill();
}
ctx.fillStyle = "rgba(170,235,255," + (0.4 + bright * 0.6) + ")";
ctx.beginPath(); ctx.arc(nd.x, nd.y, rr, 0, 6.2832); ctx.fill();
}
if (running) requestAnimationFrame(frame);
}
var running = true;
window.addEventListener("resize", resize, { passive: true });
window.addEventListener("mousemove", function (e) { mx = e.clientX; my = e.clientY; }, { passive: true });
document.addEventListener("visibilitychange", function () {
running = !document.hidden;
if (running && !reduce) { last = performance.now(); requestAnimationFrame(frame); }
});
resize();
if (reduce) {
// one calm static frame, no animation
for (var z = 0; z < 6; z++) fire((Math.random() * nodes.length) | 0, 2);
frame(0); running = false;
} else {
// a little life on load
for (var z2 = 0; z2 < 4; z2++) setTimeout(function () { fire((Math.random() * nodes.length) | 0, 0); }, z2 * 180);
requestAnimationFrame(frame);
}
/* ── scroll reveals ── */
if ("IntersectionObserver" in window && !reduce) {
var io = new IntersectionObserver(function (entries) {
entries.forEach(function (en) { if (en.isIntersecting) { en.target.classList.add("in"); io.unobserve(en.target); } });
}, { rootMargin: "0px 0px -8% 0px", threshold: 0.12 });
document.querySelectorAll(".reveal").forEach(function (el) { io.observe(el); });
} else {
document.querySelectorAll(".reveal").forEach(function (el) { el.classList.add("in"); });
}
})();
</script>
</body>
</html>