-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
788 lines (697 loc) · 34.8 KB
/
Copy pathindex.html
File metadata and controls
788 lines (697 loc) · 34.8 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DIMENSION 3</title>
<!-- Open Graph / link previews -->
<meta property="og:title" content="DIMENSION 3" />
<meta property="og:type" content="website" />
<!-- Twitter / iMessage / SMS card -->
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="DIMENSION 3" />
<script src="https://cdn.tailwindcss.com"></script>
<style>
html, body {
margin: 0;
padding: 0;
height: 100%;
overflow: hidden;
}
body {
font-family: 'Inter', sans-serif;
background-color: #14131F;
position: relative;
isolation: isolate;
transition: filter 0.5s ease-in-out, background-color 0.7s ease-in-out;
}
.scene-backdrop {
position: fixed;
inset: -24px;
width: calc(100% + 48px);
height: calc(100% + 48px);
object-fit: cover;
z-index: 0;
pointer-events: none;
image-rendering: pixelated;
filter: blur(18px);
transform: scale(1.035);
transition: opacity 0.7s ease-in-out;
}
#sceneBackdropA { opacity: 0; }
#sceneBackdropB { opacity: 0; }
.scene-container {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
cursor: none;
width: 1137px;
height: 796px;
overflow: hidden;
z-index: 1;
}
.full-screen-gif {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
}
#colorOverlayGif {
z-index: 1;
pointer-events: none;
clip-path: url(#clipJaggedCircle);
-webkit-clip-path: url(#clipJaggedCircle);
transition: opacity 0.2s ease-out;
opacity: 0;
image-rendering: pixelated;
}
#backgroundSceneGifA,
#backgroundSceneGifB {
z-index: 0;
image-rendering: pixelated;
transition: opacity 0.7s ease-in-out;
}
#backgroundSceneGifA { opacity: 1; }
#backgroundSceneGifB { opacity: 0; }
/* Simple overlay for record store & shop — sits above bg layers, no clip-path */
#simpleSceneGif {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: contain;
z-index: 3;
opacity: 0;
pointer-events: none;
transition: opacity 0.7s ease-in-out;
image-rendering: pixelated;
}
#clipPathSvg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 2;
}
.planet-hitbox {
position: absolute;
border-radius: 50%;
background-color: transparent;
z-index: 4;
pointer-events: auto;
cursor: pointer;
}
#hitboxPlanet2 { width:80px; height:80px; left:660px; top:135px; transform:translate(-50%,-50%); }
#hitboxPlanet3 { width:60px; height:60px; left:470px; top:130px; transform:translate(-50%,-50%); }
#hitboxPlanet4 { width:180px; height:180px; left:240px; top:200px; transform:translate(-50%,-50%); }
#hitboxPlanet5 { width:60px; height:60px; left:480px; top:280px; transform:translate(-50%,-50%); }
#hitboxPlanet6 { width:80px; height:80px; left:660px; top:270px; transform:translate(-50%,-50%); }
#hitboxPlanet7 { width:60px; height:60px; left:820px; top:240px; transform:translate(-50%,-50%); }
#hitboxPlanet8 { width:180px; height:180px; left:1020px; top:200px; transform:translate(-50%,-50%); }
#hitboxHomeTransition {
position: absolute;
width: 120px;
height: 200px;
left: 500px;
top: 500px;
transform: translate(-50%, -50%);
z-index: 4;
cursor: pointer;
}
/* Record Store hitbox — left side of home scene */
#hitboxRecordStore {
position: absolute;
width: 120px;
height: 200px;
left: 800px;
top: 450px;
transform: translate(-50%, -50%);
z-index: 4;
cursor: pointer;
}
/* Shop hitbox — right side of home scene */
#hitboxShop {
position: absolute;
width: 120px;
height: 200px;
left: 650px;
top: 475px;
transform: translate(-50%, -50%);
z-index: 4;
cursor: pointer;
}
#backButton {
position: fixed;
bottom: 32px;
left: 32px;
z-index: 10;
display: none;
padding: 8px 18px;
font-family: 'Courier New', monospace;
font-size: 12px;
font-weight: normal;
letter-spacing: 1px;
text-transform: uppercase;
color: rgba(255, 45, 247, 0.6);
background: transparent;
border: 1px solid rgba(255, 45, 247, 0.35);
border-radius: 4px;
cursor: pointer;
text-shadow: 0 0 6px rgba(255, 45, 247, 0.4);
box-shadow:
0 0 4px rgba(255, 45, 247, 0.2),
inset 0 0 4px rgba(255, 45, 247, 0.05);
animation: neonPulse 2.4s ease-in-out infinite;
transition: opacity 0.4s ease, transform 0.2s ease;
}
#backButton:hover {
color: rgba(255, 45, 247, 0.9);
border-color: rgba(255, 45, 247, 0.6);
text-shadow: 0 0 8px rgba(255, 45, 247, 0.6);
box-shadow:
0 0 8px rgba(255, 45, 247, 0.35),
inset 0 0 6px rgba(255, 45, 247, 0.1);
}
@keyframes neonPulse {
0%, 100% {
box-shadow:
0 0 4px rgba(255, 45, 247, 0.2),
inset 0 0 4px rgba(255, 45, 247, 0.05);
border-color: rgba(255, 45, 247, 0.35);
}
50% {
box-shadow:
0 0 6px rgba(0, 240, 255, 0.2),
inset 0 0 4px rgba(0, 240, 255, 0.05);
border-color: rgba(0, 240, 255, 0.35);
text-shadow: 0 0 6px rgba(0, 240, 255, 0.4);
}
</style>
</head>
<body class="bg-[#14131F]">
<img id="sceneBackdropA" class="scene-backdrop" src="./homedark.gif" alt="" aria-hidden="true">
<img id="sceneBackdropB" class="scene-backdrop" src="" alt="" aria-hidden="true">
<div id="introBlackout" class="fixed inset-0 bg-black z-40" aria-hidden="true"></div>
<div id="soundPromptOverlay" class="fixed top-0 left-0 w-full h-full bg-black flex justify-center items-center z-50 cursor-pointer" style="transition: opacity 1s ease;">
<p class="text-white text-2xl">Please turn on your sound and press "Enter" or click to start</p>
</div>
<div id="loadingScreenOverlay" class="fixed top-0 left-0 w-full h-full flex justify-center items-center z-50 opacity-0 transition-opacity duration-1000" style="background:#000;">
<canvas id="starfieldCanvas" style="position:absolute;top:0;left:0;width:100%;height:100%;"></canvas>
<img id="loadingScreenGif" src="./LoadingScreen.gif" style="position:relative;z-index:1;">
</div>
<div id="sceneContainer" class="scene-container opacity-0 transition-opacity duration-1000">
<!-- Simple full-screen gif for record store / shop (no cutout) -->
<img id="simpleSceneGif" src="" alt="Simple Scene GIF" class="full-screen-gif">
<!-- Color overlay (clip-pathed) -->
<img id="colorOverlayGif" src="./homelight.gif" alt="Color Overlay GIF" class="full-screen-gif">
<!-- Two bg layers – cross-fade by swapping opacities -->
<img id="backgroundSceneGifA" src="./homedark.gif" alt="Background Scene A" class="full-screen-gif">
<img id="backgroundSceneGifB" src="" alt="Background Scene B" class="full-screen-gif">
<div id="hitboxHomeTransition"></div>
<div id="hitboxRecordStore"></div>
<div id="hitboxShop"></div>
<div id="hitboxPlanet2" class="planet-hitbox" style="display:none;"></div>
<div id="hitboxPlanet3" class="planet-hitbox" style="display:none;"></div>
<div id="hitboxPlanet4" class="planet-hitbox" style="display:none;"></div>
<div id="hitboxPlanet5" class="planet-hitbox" style="display:none;"></div>
<div id="hitboxPlanet6" class="planet-hitbox" style="display:none;"></div>
<div id="hitboxPlanet7" class="planet-hitbox" style="display:none;"></div>
<div id="hitboxPlanet8" class="planet-hitbox" style="display:none;"></div>
</div>
<svg id="clipPathSvg" width="0" height="0">
<defs>
<clipPath id="clipJaggedCircle">
<path id="jaggedCirclePath" d="M0,0"></path>
</clipPath>
</defs>
</svg>
<button id="backButton">← Back</button>
<script>
document.addEventListener('DOMContentLoaded', () => {
const soundPromptOverlay = document.getElementById('soundPromptOverlay');
const loadingScreenOverlay = document.getElementById('loadingScreenOverlay');
const loadingScreenGif = document.getElementById('loadingScreenGif');
const sceneContainer = document.getElementById('sceneContainer');
const introBlackout = document.getElementById('introBlackout');
const backdropA = document.getElementById('sceneBackdropA');
const backdropB = document.getElementById('sceneBackdropB');
const colorOverlayGif = document.getElementById('colorOverlayGif');
const bgGifA = document.getElementById('backgroundSceneGifA');
const bgGifB = document.getElementById('backgroundSceneGifB');
const simpleSceneGif = document.getElementById('simpleSceneGif');
const jaggedCirclePath = document.getElementById('jaggedCirclePath');
const body = document.body;
const planetHitboxes = document.querySelectorAll('.planet-hitbox');
const backButton = document.getElementById('backButton');
let activeBgLayer = 'A';
let currentScene = 'home'; // 'home' | 'museum' | 'recordStore' | 'shop'
const FADE_MS = 700;
function activeBg() { return activeBgLayer === 'A' ? bgGifA : bgGifB; }
function inactiveBg() { return activeBgLayer === 'A' ? bgGifB : bgGifA; }
function activeBackdrop() { return activeBgLayer === 'A' ? backdropA : backdropB; }
function inactiveBackdrop() { return activeBgLayer === 'A' ? backdropB : backdropA; }
function crossFadeBg(newBgSrc, newColorSrc, onComplete) {
const incoming = inactiveBg();
const outgoing = activeBg();
const incomingBackdrop = inactiveBackdrop();
const outgoingBackdrop = activeBackdrop();
incoming.src = newBgSrc;
incomingBackdrop.src = newBgSrc;
incoming.style.opacity = '1';
incomingBackdrop.style.opacity = '1';
outgoing.style.opacity = '0';
outgoingBackdrop.style.opacity = '0';
activeBgLayer = activeBgLayer === 'A' ? 'B' : 'A';
colorOverlayGif.src = newColorSrc;
if (onComplete) setTimeout(onComplete, FADE_MS);
}
// ── Show a simple full-screen gif (with cutout on top), hiding bg layers ──
function enterSimpleScene(gifSrc, sceneName) {
currentScene = sceneName;
// Disable home hitboxes while in simple scene
document.getElementById('hitboxHomeTransition').style.pointerEvents = 'none';
document.getElementById('hitboxRecordStore').style.pointerEvents = 'none';
document.getElementById('hitboxShop').style.pointerEvents = 'none';
// Reset mouse position so no stale cutout appears on entry
resetClipPath();
// Fade out background layers so they don't show through letterbox areas
bgGifA.style.opacity = '0';
bgGifB.style.opacity = '0';
backdropA.style.opacity = '0';
backdropB.style.opacity = '0';
// Load and fade in the simple gif on top
simpleSceneGif.src = gifSrc;
simpleSceneGif.style.opacity = '1';
simpleSceneGif.style.pointerEvents = 'auto';
activeBackdrop().src = gifSrc;
activeBackdrop().style.opacity = '1';
// Raise color overlay above simple gif so the cutout cursor is visible
colorOverlayGif.src = gifSrc;
colorOverlayGif.style.zIndex = '4';
colorOverlayGif.style.filter = 'brightness(1.8) saturate(1.6) contrast(1.1)';
setBackButtonVisible(true);
}
function setBackButtonVisible(visible) {
backButton.style.display = visible ? 'block' : 'none';
}
function returnHome() {
if (currentScene === 'museum') {
// Hide planet hitboxes, restore home hitboxes
planetHitboxes.forEach(h => { h.style.display = 'none'; h.style.pointerEvents = 'none'; });
document.getElementById('hitboxHomeTransition').style.display = '';
document.getElementById('hitboxRecordStore').style.pointerEvents = 'auto';
document.getElementById('hitboxShop').style.pointerEvents = 'auto';
body.style.backgroundColor = '#14131F';
activePlanetScene = 'default';
currentCutoutRadius = originalCutoutRadius;
permanentCutouts = [];
resetClipPath();
sceneContainer.removeEventListener('click', handleSceneClick);
crossFadeBg('./homedark.gif', './homelight.gif', null);
colorOverlayGif.src = './homelight.gif';
} else if (currentScene === 'recordStore' || currentScene === 'shop') {
// Fade out the simple scene gif and re-enable home hitboxes
simpleSceneGif.style.opacity = '0';
simpleSceneGif.style.pointerEvents = 'none';
setTimeout(() => { simpleSceneGif.src = ''; }, 700);
// Restore background layers
activeBg().style.opacity = '1';
activeBackdrop().src = './homedark.gif';
activeBackdrop().style.opacity = '1';
document.getElementById('hitboxHomeTransition').style.pointerEvents = 'auto';
document.getElementById('hitboxRecordStore').style.pointerEvents = 'auto';
document.getElementById('hitboxShop').style.pointerEvents = 'auto';
// Restore color overlay to home state
colorOverlayGif.style.zIndex = '1';
colorOverlayGif.style.filter = '';
colorOverlayGif.src = './homelight.gif';
}
currentScene = 'home';
setBackButtonVisible(false);
}
backButton.addEventListener('click', returnHome);
// ── Audio ──
const loadingScreenLoopAudio = new Audio('./room-welcome-sound.mp3');
loadingScreenLoopAudio.preload = 'auto';
loadingScreenLoopAudio.loop = true;
const loadingCompleteAudio = new Audio('./room-welcome-sound1.mp3');
loadingCompleteAudio.preload = 'auto';
let hasStarted = false;
// ── Per-planet hover audio ──
const planetHoverSounds = {
'hitboxPlanet2': new Audio('./planet-2.mp3'),
'hitboxPlanet3': new Audio('./planet-3.mp3'),
'hitboxPlanet4': new Audio('./planet-4.mp3'),
'hitboxPlanet5': new Audio('./planet-5.mp3'),
'hitboxPlanet6': new Audio('./planet-6.mp3'),
'hitboxPlanet7': new Audio('./planet-7.mp3'),
'hitboxPlanet8': new Audio('./planet-8.mp3'),
};
const isPlanetSoundPlaying = {};
Object.keys(planetHoverSounds).forEach(id => {
planetHoverSounds[id].preload = 'auto';
isPlanetSoundPlaying[id] = false;
});
function handlePlanetHoverEnter(e) {
if (currentScene !== 'museum' || activeBg().style.opacity === '0') return;
const activeSrc = activeBg().src.split('/').pop();
if (activeSrc === 'backround-museum.gif') {
const id = e.target.id;
const sound = planetHoverSounds[id];
if (sound && !isPlanetSoundPlaying[id]) {
sound.currentTime = 0;
sound.play().catch(err => console.error(`Planet sound failed (${id}):`, err));
isPlanetSoundPlaying[id] = true;
}
}
}
function handlePlanetHoverLeave(e) {
const id = e.target.id;
if (planetHoverSounds[id]) isPlanetSoundPlaying[id] = false;
}
// ── home → museum ──
function enterMuseumScene() {
currentScene = 'museum';
activePlanetScene = 'default';
currentCutoutRadius = originalCutoutRadius;
permanentCutouts = [];
resetClipPath();
body.style.backgroundColor = '#1E1E1E';
crossFadeBg('./backround-museum.gif', './color-backround.gif', () => {
planetHitboxes.forEach(h => { h.style.display = ''; h.style.pointerEvents = 'auto'; });
document.getElementById('hitboxHomeTransition').style.display = 'none';
document.getElementById('hitboxRecordStore').style.pointerEvents = 'none';
document.getElementById('hitboxShop').style.pointerEvents = 'none';
});
setBackButtonVisible(true);
}
// ── home → recordStore ──
document.getElementById('hitboxRecordStore').addEventListener('click', () => {
if (currentScene !== 'home') return;
enterSimpleScene('./recordstore.gif', 'recordStore');
});
// ── home → shop ──
document.getElementById('hitboxShop').addEventListener('click', () => {
if (currentScene !== 'home') return;
enterSimpleScene('./shop.gif', 'shop');
});
// ── Hover listeners for shop & record store hitboxes ──
document.getElementById('hitboxRecordStore').addEventListener('mousemove', handleHoverEffect);
document.getElementById('hitboxRecordStore').addEventListener('mouseleave', resetClipPath);
document.getElementById('hitboxShop').addEventListener('mousemove', handleHoverEffect);
document.getElementById('hitboxShop').addEventListener('mouseleave', resetClipPath);
// ── Step 1 → 2 ──
function showLoadingScreen() {
if (hasStarted) return;
hasStarted = true;
loadingScreenOverlay.style.opacity = '1';
soundPromptOverlay.style.opacity = '0';
soundPromptOverlay.style.pointerEvents = 'none';
setTimeout(() => soundPromptOverlay.remove(), 1000);
loadingScreenLoopAudio.play().catch(() => {});
}
// ── Step 2 → 3 ──
function showMainScene() {
if (!hasStarted) return;
loadingCompleteAudio.play().catch(() => {});
loadingScreenLoopAudio.pause();
loadingScreenLoopAudio.currentTime = 0;
introBlackout.remove();
loadingScreenOverlay.style.opacity = '0';
activeBackdrop().style.opacity = '1';
sceneContainer.style.opacity = '1';
document.removeEventListener('keydown', handleKeydown);
setTimeout(() => {
loadingScreenOverlay.remove();
sceneContainer.style.pointerEvents = 'auto';
}, 1000);
}
function handleKeydown(e) {
if (e.key === 'Enter' || e.keyCode === 13) showLoadingScreen();
}
function handleFirstInteraction(e) {
if (e.type === 'click' || e.key === 'Enter' || e.keyCode === 13) {
showLoadingScreen();
document.removeEventListener('click', handleFirstInteraction);
document.removeEventListener('keydown', handleFirstInteraction);
}
}
document.addEventListener('click', handleFirstInteraction);
document.addEventListener('keydown', handleFirstInteraction);
loadingScreenGif.addEventListener('click', showMainScene);
const hitboxHomeTransition = document.getElementById('hitboxHomeTransition');
hitboxHomeTransition.addEventListener('click', enterMuseumScene);
hitboxHomeTransition.addEventListener('mousemove', handleHoverEffect);
hitboxHomeTransition.addEventListener('mouseleave', resetClipPath);
// ── Clip-path / cutout logic ──
let currentCutoutRadius = 40;
const originalCutoutRadius = 40;
const minCutoutRadius = 10;
const maxCutoutRadius = 100;
const radiusStep = 5;
const pixelSize = 5;
const jitterOffsetRange = 2;
const jiggleFrameInterval = 10;
let activePlanetScene = 'default';
let permanentCutouts = [];
let clipPathOffsetX = 0;
let clipPathOffsetY = 0;
let frameCounter = 0;
const defaultColorOverlaySrc = './color-backround.gif';
const defaultBackgroundSceneSrc = './backround-museum.gif';
const altColorOverlaySrc = './yellowbackground.gif';
const redPlanetSceneSrc = './redplanet1.gif';
const yellowPlanetSceneSrc = './yellowplanet1.gif';
let currentHueRotation = 0;
const hueStep = 30;
let animationFrameId;
const numPoints = 64;
function generateJaggedCirclePath(cx, cy, radius, pixelGridSize) {
let pathData = '';
const angleIncrement = (Math.PI * 2) / numPoints;
let prevSnX = 0, prevSnY = 0;
for (let i = 0; i <= numPoints; i++) {
const angle = i * angleIncrement;
const snappedX = Math.round((cx + radius * Math.cos(angle)) / pixelGridSize) * pixelGridSize;
const snappedY = Math.round((cy + radius * Math.sin(angle)) / pixelGridSize) * pixelGridSize;
if (i === 0) {
pathData = `M${snappedX},${snappedY}`;
} else {
const dx = Math.abs(snappedX - prevSnX);
const dy = Math.abs(snappedY - prevSnY);
if (dx >= dy) pathData += `L${snappedX},${prevSnY} L${snappedX},${snappedY} `;
else pathData += `L${prevSnX},${snappedY} L${snappedX},${snappedY} `;
}
prevSnX = snappedX;
prevSnY = snappedY;
}
return pathData + 'Z';
}
let lastMouseX = -1;
let lastMouseY = -1;
function handleHoverEffect(e) {
const rect = sceneContainer.getBoundingClientRect();
const relX = e.clientX - rect.left;
const relY = e.clientY - rect.top;
if (relX >= 0 && relX <= rect.width && relY >= 0 && relY <= rect.height) {
lastMouseX = e.clientX;
lastMouseY = e.clientY;
} else {
resetClipPath();
}
}
function animateCutouts() {
const sceneRect = activeBg().getBoundingClientRect();
let combinedPathData = '';
let isColorOverlayVisible = false;
frameCounter++;
if (frameCounter % jiggleFrameInterval === 0) {
clipPathOffsetX = Math.random() * 2 * jitterOffsetRange - jitterOffsetRange;
clipPathOffsetY = Math.random() * 2 * jitterOffsetRange - jitterOffsetRange;
}
if (permanentCutouts.length > 0) {
permanentCutouts.forEach(c => {
combinedPathData += generateJaggedCirclePath(
c.originalX + clipPathOffsetX,
c.originalY + clipPathOffsetY,
c.radius, pixelSize
);
});
isColorOverlayVisible = true;
}
if (lastMouseX !== -1 && lastMouseY !== -1) {
const relX = lastMouseX - sceneRect.left;
const relY = lastMouseY - sceneRect.top;
let hoverRadius = currentCutoutRadius;
if (activePlanetScene === 'redPlanet') hoverRadius = minCutoutRadius;
else if (activePlanetScene === 'default') hoverRadius = originalCutoutRadius;
combinedPathData += generateJaggedCirclePath(
relX + clipPathOffsetX,
relY + clipPathOffsetY,
hoverRadius, pixelSize
);
isColorOverlayVisible = true;
}
jaggedCirclePath.setAttribute('d', combinedPathData);
colorOverlayGif.style.opacity = isColorOverlayVisible ? 1 : 0;
animationFrameId = requestAnimationFrame(animateCutouts);
}
function resetClipPath() {
lastMouseX = -1;
lastMouseY = -1;
}
window.addEventListener('wheel', (e) => {
e.preventDefault();
if (activePlanetScene === 'yellowPlanet') {
currentCutoutRadius = e.deltaY < 0
? Math.min(currentCutoutRadius + radiusStep, maxCutoutRadius)
: Math.max(currentCutoutRadius - radiusStep, minCutoutRadius);
}
}, { passive: false });
sceneContainer.addEventListener('mousemove', handleHoverEffect);
sceneContainer.addEventListener('mouseleave', resetClipPath);
planetHitboxes.forEach(hitbox => {
hitbox.addEventListener('mousemove', (e) => { if (currentScene !== 'museum') return; handleHoverEffect(e); });
hitbox.addEventListener('mouseleave', (e) => { if (currentScene !== 'museum') return; resetClipPath(); });
hitbox.addEventListener('mouseenter', handlePlanetHoverEnter);
hitbox.addEventListener('mouseleave', handlePlanetHoverLeave);
});
function handleSceneClick(e) {
const rect = activeBg().getBoundingClientRect();
const relX = e.clientX - rect.left;
const relY = e.clientY - rect.top;
if (e.clientX >= rect.left && e.clientX <= rect.right &&
e.clientY >= rect.top && e.clientY <= rect.bottom) {
let radius = currentCutoutRadius;
if (activePlanetScene === 'redPlanet') radius = minCutoutRadius;
else if (activePlanetScene === 'default') radius = originalCutoutRadius;
permanentCutouts.push({ originalX: relX, originalY: relY, radius });
}
}
function hideAllPlanetHitboxes() {
planetHitboxes.forEach(h => h.style.pointerEvents = 'none');
}
function showAllPlanetHitboxes() {
planetHitboxes.forEach(h => h.style.pointerEvents = 'auto');
}
document.getElementById('hitboxPlanet6').addEventListener('click', () => {
if (currentScene !== 'museum') return;
if (activePlanetScene === 'redPlanet') {
crossFadeBg(defaultBackgroundSceneSrc, defaultColorOverlaySrc, () => {
activePlanetScene = 'default';
currentCutoutRadius = originalCutoutRadius;
sceneContainer.removeEventListener('click', handleSceneClick);
showAllPlanetHitboxes();
body.style.backgroundColor = '#1E1E1E';
});
} else {
hideAllPlanetHitboxes();
document.getElementById('hitboxPlanet6').style.pointerEvents = 'auto';
body.style.backgroundColor = '#000000';
crossFadeBg(redPlanetSceneSrc, altColorOverlaySrc, () => {
activePlanetScene = 'redPlanet';
sceneContainer.addEventListener('click', handleSceneClick);
});
}
permanentCutouts = [];
resetClipPath();
});
document.getElementById('hitboxPlanet3').addEventListener('click', () => {
if (currentScene !== 'museum') return;
if (activePlanetScene === 'yellowPlanet') {
crossFadeBg(defaultBackgroundSceneSrc, defaultColorOverlaySrc, () => {
activePlanetScene = 'default';
currentCutoutRadius = originalCutoutRadius;
sceneContainer.removeEventListener('click', handleSceneClick);
showAllPlanetHitboxes();
body.style.backgroundColor = '#1E1E1E';
});
} else {
hideAllPlanetHitboxes();
document.getElementById('hitboxPlanet3').style.pointerEvents = 'auto';
body.style.backgroundColor = '#000000';
crossFadeBg(yellowPlanetSceneSrc, altColorOverlaySrc, () => {
activePlanetScene = 'yellowPlanet';
sceneContainer.addEventListener('click', handleSceneClick);
});
}
permanentCutouts = [];
resetClipPath();
});
sceneContainer.addEventListener('contextmenu', (e) => {
e.preventDefault();
if (colorOverlayGif.style.opacity == 1) {
currentHueRotation = (currentHueRotation + hueStep) % 360;
body.style.filter = `hue-rotate(${currentHueRotation}deg)`;
}
});
resetClipPath();
animateCutouts();
window.addEventListener('resize', () => {
cancelAnimationFrame(animationFrameId);
resetClipPath();
animateCutouts();
});
// ── Starfield ──
(function initStarfield() {
const canvas = document.getElementById('starfieldCanvas');
const ctx = canvas.getContext('2d');
let stars = [], sfRafId = null;
function resize() { canvas.width = canvas.offsetWidth; canvas.height = canvas.offsetHeight; }
function spawnStars(count) {
stars = [];
for (let i = 0; i < count; i++) {
stars.push({
x: Math.random() * canvas.width,
y: Math.random() * canvas.height,
w: (Math.random() < 0.15 ? 2.6 : 1.3) * 1.3,
h: ((Math.random() < 0.15 ? 2.6 : 1.3) * 1.3) * (2.5 + Math.random() * 1.5),
opacity: Math.random(),
speed: 0.005 + Math.random() * 0.015,
phase: Math.random() * Math.PI * 2,
drift: (Math.random() - 0.5) * 0.08,
});
}
}
function drawStars(ts) {
ctx.clearRect(0, 0, canvas.width, canvas.height);
const t = ts * 0.001;
stars.forEach(s => {
const twinkle = s.tiny
? 0.35 + 0.35 * Math.sin(t * s.speed * 60 + s.phase)
: 0.75 + 0.25 * Math.sin(t * s.speed * 60 + s.phase);
ctx.globalAlpha = twinkle;
ctx.fillStyle = Math.random() < 0.02 ? '#a8d8ff' : '#ffffff';
ctx.fillRect(Math.round(s.x), Math.round(s.y), s.w, s.h);
s.x += s.drift;
if (s.x < 0) s.x = canvas.width;
if (s.x > canvas.width) s.x = 0;
});
ctx.globalAlpha = 1;
sfRafId = requestAnimationFrame(drawStars);
}
function startStarfield() { resize(); spawnStars(420); sfRafId = requestAnimationFrame(drawStars); }
function stopStarfield() { if (sfRafId) cancelAnimationFrame(sfRafId); }
window.addEventListener('resize', () => { resize(); spawnStars(420); });
const sfObserver = new MutationObserver(() => {
if (loadingScreenOverlay.style.opacity === '1') startStarfield();
if (loadingScreenOverlay.style.opacity === '0') stopStarfield();
});
sfObserver.observe(loadingScreenOverlay, { attributes: true, attributeFilter: ['style'] });
})();
document.querySelectorAll('.full-screen-gif').forEach(gif => {
gif.onerror = () => {
console.error('Failed to load GIF:', gif.src);
gif.src = 'https://placehold.co/1920x1080/000000/FFFFFF?text=GIF+Loading+Failed';
};
});
});
</script>
</body>
</html>