-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
4083 lines (3680 loc) · 231 KB
/
script.js
File metadata and controls
4083 lines (3680 loc) · 231 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
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
'use strict';
// ================================================================
// PROJECT DATA
// ================================================================
const PROJECTS = [
{
id: '001',
name: 'LOCATR',
tagline: 'Intelligent activity planning. Find your perfect venue.',
description: 'Multi-agent AI system built at DeerHacks V. A LangGraph workflow orchestrates five specialized agents — Commander, Scout, Vibe Matcher, Cost Analyst, and Critic — to discover, score, and validate perfect venues for any activity. Backed by Snowflake-powered memory and RAG.',
hackathon: 'DeerHacks V',
award: '★ Best Use of Auth0',
tech: ['Python', 'FastAPI', 'LangGraph', 'Next.js', 'Snowflake', 'Redis'],
github: 'https://github.com/Lushenwar/LOCATR',
devpost: 'https://devpost.com/software/pathfinder-6h8y1v',
demo: null,
color: '#60a5d4',
type: 'hackathon',
},
{
id: '002',
name: 'ECO-PULSE',
tagline: 'Mapping heat. Planting relief.',
description: 'AI-powered urban heat mitigation planner for Montreal. Visualizes ML-derived urban heat priority zones on an interactive map and generates Gemini-powered intervention blueprints — candidate planting sites, estimated tree counts, and full cost/benefit analysis. Built at GenAI Genesis.',
hackathon: 'GenAI Genesis',
award: '🏆 1st Place',
tech: ['TypeScript', 'React', 'Python', 'FastAPI', 'Gemini', 'Leaflet', 'Google Maps'],
github: 'https://github.com/Lushenwar/Eco-Pulse',
devpost: 'https://devpost.com/software/eco-pulse-fpbo15',
demo: null,
color: '#7ab87a',
type: 'hackathon',
},
{
id: '003',
name: 'INTERPREFY',
tagline: 'Break the language barrier. In real time.',
description: 'Desktop app that captures system audio via VB-Cable, transcribes it live with DeepGram + Whisper, translates via DeepL, and overlays dynamic subtitles on-screen. Supports multiple languages and logs full conversation history. Built at JAMHacks with Tony Tan.',
hackathon: 'JAMHacks',
award: null,
tech: ['Python', 'PyQt5', 'DeepGram', 'Whisper', 'DeepL', 'VB-Audio'],
github: 'https://github.com/Lushenwar/interprefy',
devpost: null,
demo: null,
color: '#e05555',
type: 'hackathon',
},
{
id: '004',
name: 'MASTERINGENZ',
tagline: 'The AI that speaks fluent Gen-Z.',
description: 'Full-stack app powered by a custom Sparse Graph Attention Network → GRU deep learning pipeline for real-time Gen-Z slang autocomplete. Gemini re-ranks suggestions by sentence context and generates human-like replies that naturally weave in slang.',
hackathon: null,
award: null,
tech: ['PyTorch', 'PyTorch Geometric', 'FastAPI', 'React', 'Gemini', 'GAT + GRU'],
github: 'https://github.com/Lushenwar/MasteringGenZ',
devpost: null,
demo: null,
color: '#c08fff',
type: 'personal',
},
{
id: '005',
name: 'IFYSHOP',
tagline: 'Snap it. Find it. Buy it smarter.',
description: 'AI-powered multi-agent shopping platform that takes a screenshot of any product and returns visual identification, scraped reviews, price comparisons, and AI-generated Eco Scores. Built with a Snowflake-backed vector search layer for intelligent product memory.',
hackathon: 'CxC 2026',
award: '★ Best Use of Snowflake',
tech: ['Python', 'FastAPI', 'Gemini', 'Snowflake', 'Tavily', 'React', 'Auth0'],
github: 'https://github.com/kyle-su1/ifyShop',
devpost: 'https://devpost.com/software/ifyshop',
demo: null,
color: '#f5c430',
type: 'hackathon',
},
{
id: '006',
name: 'OPENSCORE',
tagline: 'Credit for people who actually pay their bills.',
description: 'Fintech platform reimagining creditworthiness for the 3M+ credit-invisible Canadians. Uses Plaid to ingest real banking data, then scores across rent, income stability, cash flow, and education credentials using a weighted Gemini-powered model. Built at DeltaHacks 12.',
hackathon: 'DeltaHacks 12',
award: null,
tech: ['JavaScript', 'Plaid API', 'Gemini', 'React', 'FastAPI'],
github: 'https://github.com/aadya-khanna/OpenScore',
devpost: 'https://devpost.com/software/openscore-i4caqp',
demo: null,
color: '#4ecdc4',
type: 'hackathon',
},
{
id: '007',
name: 'FIXMYFEED',
tagline: 'Your feed, rewired.',
description: 'Behavior-aware social media filter that triages reels in real time — deciding SKIP, WAIT, or LIKE_AND_STAY via a multi-agent LLM pipeline. Uses grayscale as a friction budget, logs behavioral analytics, and provides AI coaching insights through a neural map dashboard.',
hackathon: 'YHacks',
award: '🏆 Finalist · 4 tracks',
tech: ['TypeScript', 'FastAPI', 'Python', 'Supabase', 'Chrome Extension', 'Lava Models'],
github: 'https://github.com/thejonathangu/FixMyFeed',
devpost: 'https://devpost.com/software/fixmyfeed',
demo: 'https://fix-my-feed.vercel.app',
color: '#f0984e',
type: 'hackathon',
},
{
id: '008',
name: 'SPOTLIGHT',
tagline: 'Stop interrupting content. Be part of it.',
description: 'AI platform that detects natural product placement opportunities inside video scenes — tables, shelves, billboards, handheld items — and seamlessly inserts brand products using Gemini + FFmpeg. Connects creators with brands through a dynamic marketplace with Backboard-powered persistent campaign memory.',
hackathon: 'HackCanada',
award: null,
tech: ['TypeScript', 'Python', 'Gemini', 'FFmpeg', 'Backboard', 'FastAPI'],
github: 'https://github.com/HetarthP/Spotlight',
devpost: 'https://devpost.com/software/spotlight-akypow',
demo: null,
color: '#e05555',
type: 'hackathon',
},
{
id: '009',
name: 'BWF PREDICTOR',
tagline: 'For those who love sports analysis.',
description: 'End-to-end ML pipeline predicting BWF World Tour badminton match outcomes at 75%+ accuracy. Uses Glicko-2 skill tracking, point-by-point momentum analysis, and LightGBM + XGBoost ensembles tuned with Optuna. Ships with a Streamlit dashboard and full tournament bracket simulator.',
hackathon: null,
award: null,
tech: ['Python', 'LightGBM', 'XGBoost', 'SHAP', 'Streamlit', 'Optuna', 'Pandas'],
github: 'https://github.com/Lushenwar/bwf',
devpost: null,
demo: null,
color: '#f5c430',
type: 'personal',
},
{
id: '010',
name: 'HEALTH ASSISTANT',
tagline: 'Your AI-powered daily life companion.',
description: 'Smart multi-tab web app combining GPT-3.5 mental health chat, customizable reminders with audio/browser alerts, and an interactive calendar. Features offline fallback responses, priority-based categorization, and persistent chat history. Built at Hack404.',
hackathon: 'Hack404',
award: '🥉 3rd Place · Beginner Stream',
tech: ['JavaScript', 'HTML/CSS', 'OpenAI GPT-3.5', 'Web APIs'],
github: 'https://github.com/Lushenwar/HealthAssistant',
devpost: 'https://devpost.com/software/beginner-track-portfolio',
demo: 'https://lushenwar.github.io/HealthAssistant/',
color: '#7ab87a',
type: 'hackathon',
},
{
id: '011',
name: 'MAZERACE',
tagline: 'Race through a castle. Beat the leaderboard.',
description: 'Java Swing 2D castle maze game with collectible coins, a persistent top-5 leaderboard saved to file, character and difficulty selection, directional animations for each movement, and original background music. A complete game built entirely from scratch in Java.',
hackathon: null,
award: null,
tech: ['Java', 'Java Swing', 'File I/O', 'Java Sound API'],
github: 'https://github.com/Lushenwar/MazeRace',
devpost: null,
demo: null,
color: '#f0984e',
type: 'personal',
},
{
id: '012',
name: 'PEARSTORE',
tagline: 'Answer a survey. Find your perfect laptop.',
description: 'Java Swing laptop recommendation tool that walks users through a preference survey, runs a weighted matching algorithm across a file-backed inventory, and presents the top 3 laptop matches with full specifications. Built as a group school project in Java.',
hackathon: null,
award: null,
tech: ['Java', 'Java Swing', 'File I/O'],
github: 'https://github.com/Lushenwar/PearStore',
devpost: null,
demo: null,
color: '#7ab87a',
type: 'personal',
},
{
id: '013',
name: 'CLASSESOBJECTSMODULE',
tagline: 'Learn OOP through a Witcher-themed adventure.',
description: 'Interactive Java OOP educational module targeting beginners in Java, Python, and C++. Features a Witcher-themed narrative framework, embedded quizzes, and matching mini-games that reinforce classes, objects, inheritance, and polymorphism concepts.',
hackathon: null,
award: null,
tech: ['Java', 'Java Swing', 'File I/O'],
github: 'https://github.com/Lushenwar/ClassesObjectsModule',
devpost: null,
demo: null,
color: '#c08fff',
type: 'personal',
},
{
id: '014',
name: 'WEATHERAPP',
tagline: 'Check the forecast. Dress for it.',
description: 'Browser-based weather app delivering current conditions, multi-day forecasts, and AI-generated clothing and activity recommendations tailored to the weather. Built entirely with vanilla JavaScript, HTML, and CSS — my first deployed web project.',
hackathon: null,
award: null,
tech: ['JavaScript', 'HTML/CSS', 'Weather API', 'Web APIs'],
github: 'https://github.com/Lushenwar/WeatherApp',
devpost: null,
demo: 'https://lushenwar.github.io/WeatherApp/',
color: '#60a5d4',
type: 'personal',
},
];
// ================================================================
// RENDER PROJECTS
// ================================================================
function renderProjects(filter = 'hackathon') {
const list = document.getElementById('projects-list');
list.innerHTML = '';
const filtered = PROJECTS.filter(p => p.type === filter);
filtered.forEach((p, i) => {
const card = document.createElement('article');
card.className = 'project-card';
card.style.setProperty('--accent', p.color);
card.style.transitionDelay = `${i * 0.05}s`;
card.setAttribute('aria-expanded', 'false');
card.dataset.projectId = p.id;
const hackBadge = p.hackathon
? `<span class="hackathon-tag">${p.hackathon}</span>` : '';
const awardBadge = p.award
? `<span class="award-tag">${p.award}</span>` : '';
const ghLink = p.github
? `<a href="${p.github}" target="_blank" rel="noopener" class="card-link" onclick="event.stopPropagation()">GitHub ↗</a>` : '';
const dpLink = p.devpost
? `<a href="${p.devpost}" target="_blank" rel="noopener" class="card-link" onclick="event.stopPropagation()">DevPost ↗</a>`
: `<span class="card-link disabled">DevPost</span>`;
const demoLink = p.demo
? `<a href="${p.demo}" target="_blank" rel="noopener" class="card-link" onclick="event.stopPropagation()">Live Demo ↗</a>` : '';
const pills = p.tech.map(t => `<span class="tech-pill">${t}</span>`).join('');
card.innerHTML = `
<div class="card-collapsed">
<div class="card-left">
<span class="card-number">${p.id}</span>
<div class="project-name">${p.name}</div>
<div class="card-meta">${hackBadge}${awardBadge}</div>
</div>
<div class="card-toggle">+</div>
</div>
<div class="card-expanded">
<div class="card-expanded-inner">
<svg class="card-divider" width="100%" height="12" viewBox="0 0 400 12" preserveAspectRatio="none" fill="none">
<path d="M 0 6 C 50 3, 100 9, 150 6 C 200 3, 250 9, 300 6 C 350 3, 380 8, 400 6"
stroke="rgba(240,232,213,0.1)" stroke-width="1.5" stroke-linecap="round"/>
</svg>
<p class="card-tagline">${p.tagline}</p>
<p class="card-description">${p.description}</p>
<div class="tech-pills">${pills}</div>
<div class="card-links">${ghLink}${dpLink}${demoLink}</div>
</div>
</div>
`;
card.addEventListener('click', () => {
if (card.classList.contains('open')) {
toggleCard(card);
return;
}
const beaten = sessionStorage.getItem(`proj_${p.id}`);
if (beaten) {
toggleCard(card);
} else {
AstronautGate.intercept(p.id, p.name, () => toggleCard(card));
}
});
list.appendChild(card);
});
requestAnimationFrame(() => requestAnimationFrame(initCardReveal));
}
function toggleCard(card) {
const isOpen = card.classList.toggle('open');
card.setAttribute('aria-expanded', String(isOpen));
}
function initProjectTabs() {
const tabs = document.querySelectorAll('.proj-tab');
tabs.forEach(tab => {
tab.addEventListener('click', () => {
tabs.forEach(t => t.classList.remove('active'));
tab.classList.add('active');
renderProjects(tab.dataset.filter);
});
});
}
// ================================================================
// INTERSECTION OBSERVER — card reveal
// ================================================================
function initCardReveal() {
const observer = new IntersectionObserver(
entries => entries.forEach(e => {
if (e.isIntersecting) { e.target.classList.add('visible'); observer.unobserve(e.target); }
}),
{ threshold: 0.06, rootMargin: '0px 0px -30px 0px' }
);
document.querySelectorAll('.project-card').forEach(c => observer.observe(c));
}
// ================================================================
// THREE.JS SCENE — interactive WebGL environment
// ================================================================
function initScene() {
const canvas = document.getElementById('bg');
if (!canvas || typeof THREE === 'undefined') return;
const renderer = new THREE.WebGLRenderer({ canvas, antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0x0d0c09, 1);
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.z = 60;
// ---- Custom shaders ----
const dustVert = `
attribute float aSize;
attribute vec3 aColor;
varying vec3 vColor;
void main() {
vColor = aColor;
vec4 mvPos = modelViewMatrix * vec4(position, 1.0);
gl_PointSize = aSize * (280.0 / -mvPos.z);
gl_Position = projectionMatrix * mvPos;
}
`;
const dustFrag = `
varying vec3 vColor;
void main() {
float d = distance(gl_PointCoord, vec2(0.5));
if (d > 0.5) discard;
float a = 1.0 - smoothstep(0.0, 0.5, d);
gl_FragColor = vec4(vColor, a * 0.85);
}
`;
// ---- Background starfield (static) ----
const N = 2800;
const sPos = new Float32Array(N * 3);
const sCol = new Float32Array(N * 3);
for (let i = 0; i < N; i++) {
sPos[i*3] = (Math.random()-0.5)*340;
sPos[i*3+1] = (Math.random()-0.5)*340;
sPos[i*3+2] = (Math.random()-0.5)*200 - 60;
const r = Math.random();
if (r < 0.50) { sCol[i*3]=0.90+Math.random()*0.10; sCol[i*3+1]=0.84+Math.random()*0.10; sCol[i*3+2]=0.70+Math.random()*0.15; }
else if (r < 0.70) { sCol[i*3]=0.96; sCol[i*3+1]=0.77; sCol[i*3+2]=0.19; }
else if (r < 0.84) { sCol[i*3]=0.38; sCol[i*3+1]=0.65; sCol[i*3+2]=0.83; }
else if (r < 0.93) { sCol[i*3]=0.88; sCol[i*3+1]=0.33; sCol[i*3+2]=0.33; }
else { sCol[i*3]=0.48; sCol[i*3+1]=0.72; sCol[i*3+2]=0.48; }
}
const sGeo = new THREE.BufferGeometry();
sGeo.setAttribute('position', new THREE.BufferAttribute(sPos, 3));
sGeo.setAttribute('color', new THREE.BufferAttribute(sCol, 3));
const stars = new THREE.Points(sGeo, new THREE.PointsMaterial({
size: 0.22, vertexColors: true, transparent: true, opacity: 0.72, sizeAttenuation: true,
}));
scene.add(stars);
// ---- Interactive dust particles (spring physics) ----
const D = 140;
const dPosArr = new Float32Array(D * 3);
const dSizes = new Float32Array(D);
const dColors = new Float32Array(D * 3);
const dustHome = [];
const dustPos = [];
const dustVel = [];
const DUST_COLORS = [
[0.96,0.77,0.19], [0.38,0.65,0.83], [0.88,0.33,0.33],
[0.48,0.72,0.48], [0.75,0.56,1.00], [0.94,0.60,0.30],
];
for (let i = 0; i < D; i++) {
const x = (Math.random()-0.5)*70;
const y = (Math.random()-0.5)*70;
const z = (Math.random()-0.5)*15 - 5;
dustHome.push(new THREE.Vector3(x, y, z));
dustPos.push(new THREE.Vector3(x, y, z));
dustVel.push(new THREE.Vector3(0, 0, 0));
dPosArr[i*3]=x; dPosArr[i*3+1]=y; dPosArr[i*3+2]=z;
dSizes[i] = 0.8 + Math.random() * 2.2;
const c = DUST_COLORS[Math.floor(Math.random()*DUST_COLORS.length)];
dColors[i*3]=c[0]; dColors[i*3+1]=c[1]; dColors[i*3+2]=c[2];
}
const dGeo = new THREE.BufferGeometry();
dGeo.setAttribute('position', new THREE.BufferAttribute(dPosArr, 3));
dGeo.setAttribute('aSize', new THREE.BufferAttribute(dSizes, 1));
dGeo.setAttribute('aColor', new THREE.BufferAttribute(dColors, 3));
const dustMat = new THREE.ShaderMaterial({
vertexShader: dustVert,
fragmentShader: dustFrag,
transparent: true,
depthWrite: false,
blending: THREE.AdditiveBlending,
});
const dustPoints = new THREE.Points(dGeo, dustMat);
scene.add(dustPoints);
// ---- Wireframe shapes ----
const SHAPES = [
{ g: new THREE.IcosahedronGeometry(9,1), p:[35,20,-44], c:0xf5c430, s:0.0022, ax:new THREE.Vector3(0.5,1,0.3).normalize() },
{ g: new THREE.TorusGeometry(8,1.1,8,24), p:[-40,-10,-55], c:0x60a5d4, s:0.0028, ax:new THREE.Vector3(0.3,0.5,1).normalize() },
{ g: new THREE.OctahedronGeometry(6,0), p:[20,-35,-30], c:0x7ab87a, s:0.004, ax:new THREE.Vector3(1,0.2,0.6).normalize() },
{ g: new THREE.TorusKnotGeometry(4.5,1,80,8), p:[-22,16,-62], c:0xc08fff, s:0.0018, ax:new THREE.Vector3(0.2,1,0.5).normalize() },
{ g: new THREE.DodecahedronGeometry(7,0), p:[6,-52,-72], c:0xe05555, s:0.002, ax:new THREE.Vector3(0.7,0.3,0.9).normalize() },
];
const meshes = SHAPES.map(({g,p,c,s,ax}) => {
const m = new THREE.Mesh(g, new THREE.MeshBasicMaterial({color:c,wireframe:true,transparent:true,opacity:0.09}));
m.position.set(...p); m.userData={s,ax}; scene.add(m); return m;
});
// ---- Mouse tracking in world space ----
let rawMx = window.innerWidth/2, rawMy = window.innerHeight/2;
let mX=0, mY=0, tX=0, tY=0;
let scrollY = 0;
function screenToWorld(sx, sy) {
const v = new THREE.Vector3(
(sx/window.innerWidth)*2-1,
-(sy/window.innerHeight)*2+1,
0.5
).unproject(camera);
const dir = v.sub(camera.position).normalize();
const dist = (0 - camera.position.z) / dir.z;
return camera.position.clone().add(dir.multiplyScalar(dist));
}
// ---- Click shockwaves ----
const shockwaves = [];
let hasDragged = false, _bgMouseDown = false;
canvas.addEventListener('mousedown', () => { hasDragged = false; _bgMouseDown = true; });
window.addEventListener('mouseup', () => { _bgMouseDown = false; });
canvas.addEventListener('mousemove', () => { if (_bgMouseDown) hasDragged = true; });
canvas.addEventListener('click', e => {
if (hasDragged) { hasDragged = false; return; }
const w = screenToWorld(e.clientX, e.clientY);
shockwaves.push({ pos: w, age: 0 });
// ripple: push wireframe shapes slightly
meshes.forEach(m => {
const d = m.position.distanceTo(w);
if (d < 50) {
const dir = m.position.clone().sub(w).normalize();
m.userData.impulse = dir.multiplyScalar(1.5 / (d+1));
m.userData.impulseDecay = 1;
}
});
});
document.addEventListener('mousemove', e => {
rawMx = e.clientX; rawMy = e.clientY;
tX = (e.clientX/window.innerWidth-0.5)*2;
tY = (e.clientY/window.innerHeight-0.5)*2;
});
window.addEventListener('scroll', () => { scrollY = window.scrollY; }, {passive:true});
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth/window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
// ---- Animation loop ----
(function animate() {
requestAnimationFrame(animate);
// Camera parallax
mX += (tX-mX)*0.03; mY += (tY-mY)*0.03;
camera.position.x += (mX*4 - camera.position.x)*0.025;
camera.position.y += (-mY*4 - camera.position.y)*0.025;
camera.position.z += (60 + scrollY*0.007 - camera.position.z)*0.04;
// Stars drift
stars.rotation.y += 0.00005; stars.rotation.x += 0.000025;
// Wireframe shapes rotate + impulse
meshes.forEach(m => {
m.rotateOnAxis(m.userData.ax, m.userData.s);
if (m.userData.impulse) {
m.position.add(m.userData.impulse);
m.userData.impulse.multiplyScalar(0.85);
if (m.userData.impulse.length() < 0.01) m.userData.impulse = null;
}
});
// Current mouse in world space
const mouseW = screenToWorld(rawMx, rawMy);
// Age & expire shockwaves
for (let s = shockwaves.length-1; s >= 0; s--) {
shockwaves[s].age += 0.018;
if (shockwaves[s].age > 1) shockwaves.splice(s, 1);
}
// Update dust particle physics
for (let i = 0; i < D; i++) {
const p = dustPos[i];
const v = dustVel[i];
const h = dustHome[i];
// Spring toward home
v.x += (h.x - p.x) * 0.018;
v.y += (h.y - p.y) * 0.018;
v.z += (h.z - p.z) * 0.018;
// Mouse repulsion
const dx = p.x - mouseW.x, dy = p.y - mouseW.y;
const md = Math.sqrt(dx*dx + dy*dy);
if (md < 14 && md > 0) {
const str = (14 - md) / 14 * 0.6;
v.x += (dx/md) * str;
v.y += (dy/md) * str;
}
// Shockwave forces
shockwaves.forEach(sw => {
const sx = p.x - sw.pos.x, sy = p.y - sw.pos.y;
const sd = Math.sqrt(sx*sx + sy*sy);
const ring = Math.abs(sd - sw.age * 38);
if (ring < 4 && sd > 0) {
const f = ((4 - ring) / 4) * 2.5;
v.x += (sx/sd) * f;
v.y += (sy/sd) * f;
}
});
// Gentle drift noise (makes them feel alive)
v.x += (Math.random()-0.5)*0.008;
v.y += (Math.random()-0.5)*0.008;
// Damping
v.x *= 0.88; v.y *= 0.88; v.z *= 0.92;
// Integrate
p.x += v.x; p.y += v.y; p.z += v.z;
dPosArr[i*3]=p.x; dPosArr[i*3+1]=p.y; dPosArr[i*3+2]=p.z;
}
dGeo.attributes.position.needsUpdate = true;
renderer.render(scene, camera);
})();
}
// ================================================================
// FALLING ASTRONAUT — sweeps full screen diagonally
// ================================================================
function initFaller() {
const faller = document.getElementById('faller');
if (!faller || window.innerWidth < 580) return;
let scrollY = 0, prevScrollY = 0;
let curY = 0, curAngle = -15, curSwayX = 0;
window.addEventListener('scroll', () => { scrollY = window.scrollY; }, { passive: true });
(function loop() {
requestAnimationFrame(loop);
if (typeof AstronautGate !== 'undefined' && AstronautGate.isPaused()) return;
const vel = scrollY - prevScrollY;
prevScrollY = scrollY;
// Falls with scroll at ~55% speed — classic parallax "falling through space" feel
const targetY = scrollY * 0.55;
// Gentle sinusoidal horizontal drift
const targetSwayX = Math.sin(scrollY * 0.0025) * 38;
// Tilts with scroll velocity; slow continuous tumble based on distance travelled
const targetAngle = -15 + scrollY * 0.03 + vel * 2.8;
// Lerp — floaty, weightless lag
curY += (targetY - curY) * 0.09;
curSwayX += (targetSwayX - curSwayX) * 0.06;
curAngle += (targetAngle - curAngle) * 0.09;
faller.style.transform = `translate(calc(-50% + ${curSwayX}px), ${curY}px) rotate(${curAngle}deg)`;
})();
}
// ================================================================
// CUSTOM CURSOR
// ================================================================
function initCursor() {
const ring = document.getElementById('cursor');
if (!ring) return;
let cx = 0, cy = 0, rx = 0, ry = 0;
let moved = false;
document.addEventListener('mousemove', e => {
cx = e.clientX;
cy = e.clientY;
if (!moved) { rx = cx; ry = cy; moved = true; }
ring.style.opacity = '1';
ring.style.display = 'block';
}, { passive: true });
(function loop() {
requestAnimationFrame(loop);
rx += (cx - rx) * 0.18;
ry += (cy - ry) * 0.18;
ring.style.left = rx + 'px';
ring.style.top = ry + 'px';
// Stay at absolute top of the stack (above overlays)
ring.style.zIndex = '999999';
ring.style.pointerEvents = 'none';
})();
}
// ================================================================
// GATE GAMES
// ================================================================
const GATEKEEPER_GAMES = ['mathlab', 'tictactoe', 'connect4', 'rps'];
function unlockPortfolio() {
const win = document.getElementById('gate-win');
win.classList.add('show');
setTimeout(() => {
const gate = document.getElementById('gate');
const portfolio = document.getElementById('portfolio');
gate.classList.add('unlocking');
portfolio.classList.add('visible');
sessionStorage.setItem('unlocked', '1');
setTimeout(() => { gate.style.display = 'none'; }, 900);
}, 1800);
}
// ================================================================
// ASTRONAUT GATE — unified gatekeeper state machine
// ================================================================
const AstronautGate = (() => {
let state = 'idle';
let fallerPaused = false;
let currentCleanup = null;
function closeModal() {
const modal = document.getElementById('mini-gate');
const container = document.getElementById('mini-game-container');
if (modal) modal.style.display = 'none';
if (container) container.innerHTML = '';
if (currentCleanup) { currentCleanup(); currentCleanup = null; }
}
function setDefeated(onDone) {
state = 'defeated';
const f = document.getElementById('faller');
if (f) {
f.classList.remove('astro-intercepting');
f.classList.add('astro-defeated');
setTimeout(() => {
f.classList.remove('astro-defeated');
state = 'idle';
fallerPaused = false;
if (onDone) onDone();
}, 700);
} else {
state = 'idle';
fallerPaused = false;
if (onDone) onDone();
}
}
return {
isPaused() { return fallerPaused; },
unlock(mode, payload = {}) {
if (mode === 'global') {
unlockPortfolio();
} else if (mode === 'project') {
closeModal();
setDefeated(() => {
if (payload.projectId) sessionStorage.setItem(`proj_${payload.projectId}`, '1');
if (payload.onProjectOpen) payload.onProjectOpen();
});
}
},
intercept(projectId, projectName, onProjectOpen) {
state = 'intercepting';
fallerPaused = true;
const f = document.getElementById('faller');
if (f) f.classList.add('astro-intercepting');
const modal = document.getElementById('mini-gate');
const container = document.getElementById('mini-game-container');
const titleEl = document.getElementById('mini-gate-title');
if (!modal || !container) return;
if (titleEl) titleEl.textContent = `defeat the Astronaut to unlock "${projectName}"`;
modal.style.display = 'flex';
// refresh close button listener
const oldBtn = modal.querySelector('.mini-gate-close');
const newBtn = oldBtn.cloneNode(true);
oldBtn.parentNode.replaceChild(newBtn, oldBtn);
newBtn.addEventListener('click', () => {
closeModal();
if (f) f.classList.remove('astro-intercepting');
state = 'idle'; fallerPaused = false;
});
modal.onclick = e => {
if (e.target === modal) {
closeModal();
if (f) f.classList.remove('astro-intercepting');
state = 'idle'; fallerPaused = false;
}
};
const gameId = GATEKEEPER_GAMES[Math.floor(Math.random() * GATEKEEPER_GAMES.length)];
const onWin = () => AstronautGate.unlock('project', { projectId, onProjectOpen });
currentCleanup = GameRegistry[gameId](container, onWin);
},
};
})();
// ================================================================
// INIT GATE
// ================================================================
function initGate() {
if (sessionStorage.getItem('unlocked') === '1') {
document.getElementById('gate').style.display = 'none';
document.getElementById('portfolio').classList.add('visible');
return;
}
const container = document.getElementById('game-container');
container.insertAdjacentHTML('afterend', `
<div id="gate-win">
<div style="font-size:3rem">🎉</div>
<div class="win-text">you're in.</div>
<div class="win-sub">welcome to the portfolio</div>
</div>
`);
const gameId = GATEKEEPER_GAMES[Math.floor(Math.random() * GATEKEEPER_GAMES.length)];
GameRegistry[gameId](container, () => AstronautGate.unlock('global'));
}
// ================================================================
// ORIGAMI — simulator + guides
// ================================================================
function initOrigami() {
// ---- Guide tab switching (new two-column layout) ----
document.querySelectorAll('.orig-guide-tab').forEach(tab => {
tab.addEventListener('click', () => {
document.querySelectorAll('.orig-guide-tab').forEach(t => t.classList.remove('active'));
document.querySelectorAll('.guide-content').forEach(c => c.classList.remove('active'));
tab.classList.add('active');
document.getElementById('guide-' + tab.dataset.guide)?.classList.add('active');
});
});
initSimulator();
initGuide('crane', CRANE_STEPS, 'crane-step-svg', 'crane-step-num', 'crane-step-total', 'crane-step-desc', 'crane-prev', 'crane-next');
initGuide('lotus', LOTUS_STEPS, 'lotus-step-svg', 'lotus-step-num', 'lotus-step-total', 'lotus-step-desc', 'lotus-prev', 'lotus-next');
initGuide('boat', BOAT_STEPS, 'boat-step-svg', 'boat-step-num', 'boat-step-total', 'boat-step-desc', 'boat-prev', 'boat-next');
initGuide('dragon', DRAGON_STEPS, 'dragon-step-svg', 'dragon-step-num', 'dragon-step-total', 'dragon-step-desc', 'dragon-prev', 'dragon-next');
initGuide('frog', FROG_STEPS, 'frog-step-svg', 'frog-step-num', 'frog-step-total', 'frog-step-desc', 'frog-prev', 'frog-next');
initGuide('heart', HEART_STEPS, 'heart-step-svg', 'heart-step-num', 'heart-step-total', 'heart-step-desc', 'heart-prev', 'heart-next');
initGuide('star', STAR_STEPS, 'star-step-svg', 'star-step-num', 'star-step-total', 'star-step-desc', 'star-prev', 'star-next');
initGuide('butterfly', BUTTERFLY_STEPS, 'butterfly-step-svg', 'butterfly-step-num', 'butterfly-step-total', 'butterfly-step-desc', 'butterfly-prev', 'butterfly-next');
initGuide('phoenix', PHOENIX_STEPS, 'phoenix-step-svg', 'phoenix-step-num', 'phoenix-step-total', 'phoenix-step-desc', 'phoenix-prev', 'phoenix-next');
}
// ---- Generic guide navigator ----
function initGuide(name, steps, svgId, numId, totalId, descId, prevId, nextId) {
const svgEl = document.getElementById(svgId);
const numEl = document.getElementById(numId);
const totalEl = document.getElementById(totalId);
const descEl = document.getElementById(descId);
const prevBtn = document.getElementById(prevId);
const nextBtn = document.getElementById(nextId);
if (!svgEl) return;
let step = 0;
const total = steps.length;
if (totalEl) totalEl.textContent = total;
function render() {
const s = steps[step];
if (numEl) numEl.textContent = step + 1;
if (descEl) descEl.textContent = s.desc;
if (svgEl) svgEl.innerHTML = `<svg width="220" height="220" viewBox="0 0 220 220" fill="none" xmlns="http://www.w3.org/2000/svg">${s.svg}</svg>`;
if (prevBtn) prevBtn.disabled = step === 0;
if (nextBtn) { nextBtn.disabled = step === total-1; nextBtn.textContent = step===total-1 ? 'done ✓' : 'next →'; }
}
prevBtn?.addEventListener('click', () => { if (step>0) { step--; render(); } });
nextBtn?.addEventListener('click', () => { if (step<total-1) { step++; render(); } });
render();
}
// ---- Simulator ----
function initSimulator() {
const canvas = document.getElementById('origami-canvas');
if (!canvas) return;
const ctx = canvas.getContext('2d');
// ── Canvas setup ──────────────────────────────────────────────────
const W = 460, H = 460;
canvas.width = W; canvas.height = H;
const CX = W / 2, CY = H / 2;
const HALF = 196; // paper half-size
// ── State ─────────────────────────────────────────────────────────
let rotation = 0; // radians — paper rotation
let foldMode = 'valley'; // 'valley'|'mountain'|'crease'|'pleat'
let foldAngle = 180; // degrees — for partial folds
let showRef = true; // reference points overlay
let animating = false;
let foldCount = 0;
let pending = null; // first click point (world space)
let mouse = null; // live mouse pos (world space)
let snapPt = null; // current snap target
let hasDragged = false;
const INIT_PAPER = () => [
{x:CX-HALF, y:CY-HALF}, {x:CX+HALF, y:CY-HALF},
{x:CX+HALF, y:CY+HALF}, {x:CX-HALF, y:CY+HALF},
];
let paper = INIT_PAPER();
let layers = [];
let creases = [];
let history = [];
// ── Math helpers ──────────────────────────────────────────────────
const dot = (a,b) => a.x*b.x + a.y*b.y;
const sub = (a,b) => ({x:a.x-b.x, y:a.y-b.y});
const add = (a,b) => ({x:a.x+b.x, y:a.y+b.y});
const scl = (v,s) => ({x:v.x*s, y:v.y*s});
const nrm = v => { const l=Math.hypot(v.x,v.y)||1; return {x:v.x/l,y:v.y/l}; };
const crs = (a,b,p) => (b.x-a.x)*(p.y-a.y)-(b.y-a.y)*(p.x-a.x);
// Rotate point around canvas centre
function rotPt(p, ang) {
const c=Math.cos(ang), s=Math.sin(ang), dx=p.x-CX, dy=p.y-CY;
return {x: CX+dx*c-dy*s, y: CY+dx*s+dy*c};
}
// Screen event → world space (inverse-rotate)
function toWorld(e) {
const r = canvas.getBoundingClientRect();
const sx = (e.clientX-r.left)*(W/r.width);
const sy = (e.clientY-r.top)*(H/r.height);
return rotPt({x:sx, y:sy}, -rotation);
}
function reflectPt(v, lp1, lp2) {
const dir=nrm(sub(lp2,lp1)), d=sub(v,lp1);
const foot=add(lp1, scl(dir, dot(d,dir)));
return {x:2*foot.x-v.x, y:2*foot.y-v.y};
}
// Polygon clip: splits poly into {near, far} halves across line lp1→lp2
function clipPoly(poly, lp1, lp2) {
const near=[], far=[], n=poly.length;
for (let i=0; i<n; i++) {
const a=poly[i], b=poly[(i+1)%n];
const ca=crs(lp1,lp2,a), cb=crs(lp1,lp2,b);
if (ca<=0) near.push({...a}); else far.push({...a});
if ((ca<0&&cb>0)||(ca>0&&cb<0)) {
const t=ca/(ca-cb);
const ix={x:a.x+t*(b.x-a.x), y:a.y+t*(b.y-a.y)};
near.push({...ix}); far.push({...ix});
}
}
return {near, far};
}
// Animated fold position for a vertex at angle theta (0→PI)
function animPt(v, lp1, lp2, theta) {
const dir=nrm(sub(lp2,lp1)), d=sub(v,lp1);
const foot=add(lp1, scl(dir, dot(d,dir)));
const perp=sub(v,foot), dAbs=Math.hypot(perp.x,perp.y);
const pn=nrm(perp);
return {
x: foot.x + pn.x*dAbs*Math.cos(theta),
y: foot.y + pn.y*dAbs*Math.cos(theta) - dAbs*Math.sin(theta)*0.28,
};
}
// ── Snap system ───────────────────────────────────────────────────
function getRefPoints() {
const pts = [];
const n = paper.length;
// Corners (orange)
paper.forEach(p => pts.push({...p, k:'corner'}));
// Edge subdivisions (halves, quarters, thirds, eighths)
for (let i=0; i<n; i++) {
const a=paper[i], b=paper[(i+1)%n];
[1/2,1/3,2/3,1/4,3/4,1/8,3/8,5/8,7/8].forEach(f => {
const k = f===0.5?'mid':f===0.25||f===0.75?'quarter':'eighth';
pts.push({x:a.x+f*(b.x-a.x), y:a.y+f*(b.y-a.y), k});
});
}
// Center (purple)
const cx=paper.reduce((s,p)=>s+p.x,0)/n, cy=paper.reduce((s,p)=>s+p.y,0)/n;
pts.push({x:cx, y:cy, k:'center'});
// Crease endpoints (blue)
creases.forEach(c => { pts.push({...c.p1,k:'crease'}); pts.push({...c.p2,k:'crease'}); });
// Crease-crease intersections inside paper (green)
for (let i=0; i<creases.length; i++) {
for (let j=i+1; j<creases.length; j++) {
const ix = lineX(creases[i].p1, creases[i].p2, creases[j].p1, creases[j].p2);
if (ix && inPoly(paper, ix)) pts.push({...ix, k:'xing'});
}
}
return pts;
}
function lineX(p1,p2,p3,p4) {
const dx1=p2.x-p1.x, dy1=p2.y-p1.y, dx2=p4.x-p3.x, dy2=p4.y-p3.y;
const d=dx1*dy2-dy1*dx2;
if (Math.abs(d)<1e-10) return null;
const t=((p3.x-p1.x)*dy2-(p3.y-p1.y)*dx2)/d;
return {x:p1.x+t*dx1, y:p1.y+t*dy1};
}
function inPoly(poly, pt) {
let inside=false;
for (let i=0,j=poly.length-1; i<poly.length; j=i++) {
const xi=poly[i].x,yi=poly[i].y,xj=poly[j].x,yj=poly[j].y;
if (((yi>pt.y)!==(yj>pt.y))&&pt.x<(xj-xi)*(pt.y-yi)/(yj-yi)+xi) inside=!inside;
}
return inside;
}
function findSnap(wp, R=22) {
let best=null, bd=R;
getRefPoints().forEach(p => {
const d=Math.hypot(p.x-wp.x, p.y-wp.y);
if (d<bd) { bd=d; best=p; }
});
return best;
}
// ── Rendering ─────────────────────────────────────────────────────
// Draw polygon in world space, applying rotation transform to screen
function drawPolyW(verts, fill, stroke, lw=1.5) {
if (verts.length<2) return;
ctx.beginPath();
const s0=rotPt(verts[0], rotation);
ctx.moveTo(s0.x, s0.y);
for (let i=1; i<verts.length; i++) { const s=rotPt(verts[i],rotation); ctx.lineTo(s.x,s.y); }
ctx.closePath();
if (fill) { ctx.fillStyle=fill; ctx.fill(); }
if (stroke) { ctx.strokeStyle=stroke; ctx.lineWidth=lw; ctx.stroke(); }
}
// Layer fill colors (slightly varying tones to show depth)
const LAYER_FILLS = ['rgba(240,232,213,0.10)','rgba(240,232,213,0.08)','rgba(220,218,205,0.07)','rgba(200,210,215,0.07)','rgba(210,200,220,0.06)'];
const LAYER_STROKES = ['rgba(240,232,213,0.65)','rgba(240,232,213,0.55)','rgba(240,232,213,0.45)','rgba(240,232,213,0.38)','rgba(240,232,213,0.30)'];
function render() {
ctx.clearRect(0,0,W,H);
ctx.setLineDash([]);
// Faint grid (screen space, doesn't rotate)
ctx.strokeStyle='rgba(240,232,213,0.022)'; ctx.lineWidth=0.5;
for (let x=0; x<=W; x+=40) { ctx.beginPath(); ctx.moveTo(x,0); ctx.lineTo(x,H); ctx.stroke(); }
for (let y=0; y<=H; y+=40) { ctx.beginPath(); ctx.moveTo(0,y); ctx.lineTo(W,y); ctx.stroke(); }
// Rotation indicator arc
if (rotation % (2*Math.PI) !== 0) {
ctx.save(); ctx.beginPath();
ctx.arc(CX,CY, HALF+16, -Math.PI/2, -Math.PI/2+rotation, rotation<0);
ctx.strokeStyle='rgba(240,152,78,0.25)'; ctx.lineWidth=2; ctx.setLineDash([4,4]); ctx.stroke();
ctx.restore(); ctx.setLineDash([]);
}
// Base paper
drawPolyW(paper, 'rgba(240,232,213,0.09)', 'rgba(240,232,213,0.65)', 2.0);
// Folded layers (stacked, each with depth shadow)
layers.forEach((layer, idx) => {
const fi = Math.min(idx, LAYER_FILLS.length-1);
ctx.save();
ctx.shadowColor='rgba(0,0,0,0.9)'; ctx.shadowBlur=8; ctx.shadowOffsetY=3;
drawPolyW(layer, LAYER_FILLS[fi], LAYER_STROKES[fi], 1.5);
ctx.restore();