-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhologram.html
More file actions
713 lines (619 loc) · 22.5 KB
/
hologram.html
File metadata and controls
713 lines (619 loc) · 22.5 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>Hologram Card</title>
<link rel="icon" type="image/png" sizes="512x512" href="assets/appicons/idle-games-512x512px.png">
<link rel="apple-touch-icon" href="assets/appicons/icon-192.png">
<meta name="theme-color" content="#0a0a0f">
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
min-height: 100vh;
min-height: 100dvh;
background: linear-gradient(135deg, #0a0a0f 0%, #1a1a2e 50%, #0a0a0f 100%);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-family: system-ui, -apple-system, sans-serif;
color: #fff;
overflow: hidden;
perspective: 1000px;
}
.upload-area {
display: flex;
flex-direction: column;
align-items: center;
gap: 1rem;
padding: 2rem;
border: 2px dashed rgba(255, 255, 255, 0.3);
border-radius: 1rem;
background: rgba(255, 255, 255, 0.05);
cursor: pointer;
transition: all 0.3s ease;
}
.upload-area:hover {
border-color: rgba(255, 255, 255, 0.6);
background: rgba(255, 255, 255, 0.1);
}
.upload-area.hidden {
display: none;
}
.upload-icon {
font-size: 3rem;
opacity: 0.7;
}
.upload-text {
font-size: 1.1rem;
opacity: 0.8;
}
#file-input {
display: none;
}
.card-container {
display: none;
flex-direction: column;
align-items: center;
gap: 1.5rem;
}
.card-container.visible {
display: flex;
}
.card-wrapper {
position: relative;
transform-style: preserve-3d;
transition: transform 0.1s ease-out;
cursor: grab;
}
.card-wrapper:active {
cursor: grabbing;
}
.hologram-card {
position: relative;
width: min(85vw, 400px);
max-height: 70vh;
border-radius: 12px;
overflow: hidden;
box-shadow:
0 25px 50px rgba(0, 0, 0, 0.5),
0 0 30px rgba(100, 200, 255, 0.2),
inset 0 0 60px rgba(255, 255, 255, 0.05);
transform-style: preserve-3d;
}
.card-image {
width: 100%;
height: auto;
display: block;
filter: grayscale(0.7) contrast(0.8) brightness(0.95);
}
/* Angle-dependent color tint overlay for base image */
.color-tint {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
background: linear-gradient(
calc(var(--angle, 45deg)),
hsla(var(--hue-shift, 280), 100%, 50%, 0.4) 0%,
hsla(calc(var(--hue-shift, 280) + 60), 100%, 50%, 0.3) 50%,
hsla(calc(var(--hue-shift, 280) + 120), 100%, 50%, 0.4) 100%
);
mix-blend-mode: color;
}
/* Exaggerated color tint for logo layer (different depth = different hue shift) */
.color-tint-logo {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
background: linear-gradient(
calc(var(--angle, 45deg) + 30deg),
hsla(calc(var(--hue-shift, 280) + 45), 100%, 50%, 0.5) 0%,
hsla(calc(var(--hue-shift, 280) + 105), 100%, 50%, 0.4) 50%,
hsla(calc(var(--hue-shift, 280) + 165), 100%, 50%, 0.5) 100%
);
mix-blend-mode: color;
}
/* Chromatic aberration layers */
.aberration-layer {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
mix-blend-mode: screen;
opacity: 0;
transition: opacity 0.3s ease;
}
.aberration-red {
background: radial-gradient(ellipse at var(--aber-x, 50%) var(--aber-y, 50%),
rgba(255, 50, 100, 0.15) 0%,
transparent 60%);
transform: translate(calc(var(--tilt-x, 0) * 3px), calc(var(--tilt-y, 0) * 3px));
}
.aberration-cyan {
background: radial-gradient(ellipse at var(--aber-x, 50%) var(--aber-y, 50%),
rgba(50, 255, 200, 0.15) 0%,
transparent 60%);
transform: translate(calc(var(--tilt-x, 0) * -3px), calc(var(--tilt-y, 0) * -3px));
}
.aberration-blue {
background: radial-gradient(ellipse at var(--aber-x, 50%) var(--aber-y, 50%),
rgba(100, 100, 255, 0.1) 0%,
transparent 50%);
transform: translate(calc(var(--tilt-x, 0) * -2px), calc(var(--tilt-y, 0) * 2px));
}
/* Holographic foil overlay */
.holo-foil {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
opacity: 0.5;
mix-blend-mode: color-dodge;
background:
linear-gradient(
calc(var(--angle, 45deg) + 0deg),
transparent 0%,
rgba(255, 0, 128, 0.2) 20%,
rgba(0, 255, 255, 0.2) 40%,
rgba(255, 255, 0, 0.2) 60%,
rgba(128, 0, 255, 0.2) 80%,
transparent 100%
);
background-size: 200% 200%;
background-position: var(--bg-pos-x, 50%) var(--bg-pos-y, 50%);
transition: opacity 0.3s ease;
}
/* Holographic logo pattern overlay */
.holo-pattern {
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
pointer-events: none;
opacity: 1;
mix-blend-mode: normal;
transform-style: preserve-3d;
transition: transform 0.1s ease-out;
}
.holo-pattern svg {
width: 100%;
height: 100%;
}
.holo-pattern-clip {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow: hidden;
border-radius: 12px;
}
/* Rainbow shimmer effect */
.shimmer {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
opacity: 0.3;
background: linear-gradient(
calc(var(--angle, 45deg) + 90deg),
transparent 0%,
rgba(255, 255, 255, 0.4) 50%,
transparent 100%
);
background-size: 200% 200%;
background-position: var(--shimmer-x, 0%) var(--shimmer-y, 0%);
}
/* Specular highlight */
.specular {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
background: radial-gradient(
ellipse 40% 30% at var(--spec-x, 50%) var(--spec-y, 30%),
rgba(255, 255, 255, 0.3) 0%,
transparent 100%
);
opacity: 0.5;
}
/* Card edge glow */
.edge-glow {
position: absolute;
top: -2px;
left: -2px;
right: -2px;
bottom: -2px;
border-radius: 14px;
pointer-events: none;
background: linear-gradient(
calc(var(--angle, 45deg)),
rgba(255, 100, 200, 0.5),
rgba(100, 200, 255, 0.5),
rgba(200, 255, 100, 0.5),
rgba(255, 100, 200, 0.5)
);
background-size: 300% 300%;
background-position: var(--bg-pos-x, 50%) var(--bg-pos-y, 50%);
z-index: -1;
filter: blur(4px);
opacity: 0.6;
}
.controls {
display: flex;
gap: 1rem;
flex-wrap: wrap;
justify-content: center;
}
.btn {
padding: 0.75rem 1.5rem;
border: none;
border-radius: 0.5rem;
background: rgba(255, 255, 255, 0.1);
color: #fff;
font-size: 1rem;
cursor: pointer;
transition: all 0.2s ease;
backdrop-filter: blur(10px);
}
.btn:hover {
background: rgba(255, 255, 255, 0.2);
transform: translateY(-2px);
}
.btn:active {
transform: translateY(0);
}
.btn-experimental {
text-decoration: none;
background: linear-gradient(135deg, rgba(128, 0, 255, 0.2), rgba(0, 200, 255, 0.2));
border: 1px solid rgba(128, 100, 255, 0.3);
font-size: 0.85rem;
}
.btn-experimental:hover {
background: linear-gradient(135deg, rgba(128, 0, 255, 0.3), rgba(0, 200, 255, 0.3));
}
.instructions {
position: fixed;
bottom: 1rem;
left: 50%;
transform: translateX(-50%);
font-size: 0.85rem;
opacity: 0.5;
text-align: center;
pointer-events: none;
}
@media (max-width: 480px) {
.hologram-card {
width: 90vw;
}
.btn {
padding: 0.6rem 1rem;
font-size: 0.9rem;
}
}
</style>
</head>
<body>
<div class="upload-area" id="upload-area">
<div class="upload-icon">📸</div>
<div class="upload-text">Tap to choose an image</div>
<div class="upload-text" style="font-size: 0.85rem; opacity: 0.6;">PNG, JPG, JPEG, or WebP</div>
</div>
<input type="file" id="file-input" accept="image/png,image/jpeg,image/jpg,image/webp">
<div class="card-container" id="card-container">
<div class="card-wrapper" id="card-wrapper">
<div class="edge-glow"></div>
<div class="hologram-card" id="hologram-card">
<img class="card-image" id="card-image" alt="Hologram card">
<!-- Holographic pattern with parallax (rendered above image, below effects) -->
<div class="holo-pattern-clip">
<div class="holo-pattern" id="holo-pattern">
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%">
<defs>
<!-- Metallic grey base (50% grey, limited to 10-90% range) -->
<linearGradient id="foilSheen" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" style="stop-color:#6a6a6a"/>
<stop offset="25%" style="stop-color:#8a8a8a"/>
<stop offset="50%" style="stop-color:#999999"/>
<stop offset="75%" style="stop-color:#7a7a7a"/>
<stop offset="100%" style="stop-color:#666666"/>
</linearGradient>
<!-- Rainbow edge gradient (also mid-grey based) -->
<linearGradient id="rainbowEdge" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" style="stop-color:#b36699"/>
<stop offset="25%" style="stop-color:#66b399"/>
<stop offset="50%" style="stop-color:#6666b3"/>
<stop offset="75%" style="stop-color:#b39966"/>
<stop offset="100%" style="stop-color:#b36699"/>
</linearGradient>
<pattern id="logoPattern" width="160" height="160" patternUnits="userSpaceOnUse">
<!-- Smaller, fully opaque metallic logos -->
<g transform="translate(20, 20) scale(0.35)">
<path d="M50 10 L60 25 L90 25 L65 40 L75 70 L50 50 L25 70 L35 40 L10 25 L40 25 Z" fill="url(#foilSheen)" stroke="url(#rainbowEdge)" stroke-width="3"/>
</g>
<g transform="translate(100, 100) scale(0.25)">
<circle cx="50" cy="50" r="30" fill="url(#foilSheen)" stroke="url(#rainbowEdge)" stroke-width="4"/>
<path d="M35 50 L45 60 L65 40" fill="none" stroke="url(#rainbowEdge)" stroke-width="5" stroke-linecap="round" stroke-linejoin="round"/>
</g>
</pattern>
</defs>
<rect width="100%" height="100%" fill="url(#logoPattern)"/>
</svg>
</div>
<!-- Logo layer color tint (exaggerated hue shift for depth effect) -->
<div class="color-tint-logo"></div>
</div>
<!-- All effects below apply to BOTH image and logo layer -->
<!-- Angle-dependent color tint -->
<div class="color-tint"></div>
<!-- Chromatic aberration layers -->
<div class="aberration-layer aberration-red"></div>
<div class="aberration-layer aberration-cyan"></div>
<div class="aberration-layer aberration-blue"></div>
<!-- Holographic foil effect -->
<div class="holo-foil"></div>
<!-- Shimmer highlight -->
<div class="shimmer"></div>
<!-- Specular reflection -->
<div class="specular"></div>
</div>
</div>
<div class="controls">
<button class="btn" id="change-btn">Change Image</button>
<button class="btn" id="reset-btn">Reset Tilt</button>
<a href="hologram-depth.html" class="btn btn-experimental">🧪 Depth Map</a>
</div>
</div>
<div class="instructions" id="instructions">Move your finger or mouse to tilt the card</div>
<script>
const uploadArea = document.getElementById('upload-area');
const fileInput = document.getElementById('file-input');
const cardContainer = document.getElementById('card-container');
const cardWrapper = document.getElementById('card-wrapper');
const hologramCard = document.getElementById('hologram-card');
const cardImage = document.getElementById('card-image');
const holoPattern = document.getElementById('holo-pattern');
const changeBtn = document.getElementById('change-btn');
const resetBtn = document.getElementById('reset-btn');
const instructions = document.getElementById('instructions');
let isInteracting = false;
let currentTiltX = 0;
let currentTiltY = 0;
let targetTiltX = 0;
let targetTiltY = 0;
// File upload handling
uploadArea.addEventListener('click', () => fileInput.click());
fileInput.addEventListener('change', handleFileSelect);
changeBtn.addEventListener('click', () => fileInput.click());
resetBtn.addEventListener('click', resetTilt);
// Drag and drop
uploadArea.addEventListener('dragover', (e) => {
e.preventDefault();
uploadArea.style.borderColor = 'rgba(255, 255, 255, 0.8)';
});
uploadArea.addEventListener('dragleave', () => {
uploadArea.style.borderColor = 'rgba(255, 255, 255, 0.3)';
});
uploadArea.addEventListener('drop', (e) => {
e.preventDefault();
uploadArea.style.borderColor = 'rgba(255, 255, 255, 0.3)';
const file = e.dataTransfer.files[0];
if (file && file.type.match(/image\/(png|jpeg|jpg|webp)/)) {
loadImage(file);
}
});
function handleFileSelect(e) {
const file = e.target.files[0];
if (file) {
loadImage(file);
}
}
function loadImage(file) {
const reader = new FileReader();
reader.onload = (e) => {
cardImage.src = e.target.result;
cardImage.onload = () => {
uploadArea.classList.add('hidden');
cardContainer.classList.add('visible');
instructions.style.display = 'block';
resetTilt();
};
};
reader.readAsDataURL(file);
}
function resetTilt() {
targetTiltX = 0;
targetTiltY = 0;
updateCard(0, 0);
}
function updateCard(tiltX, tiltY) {
// Clamp tilt values
tiltX = Math.max(-25, Math.min(25, tiltX));
tiltY = Math.max(-25, Math.min(25, tiltY));
// Calculate angle for gradient effects
const angle = Math.atan2(tiltY, tiltX) * (180 / Math.PI) + 180;
// Calculate intensity based on tilt magnitude
const intensity = Math.sqrt(tiltX * tiltX + tiltY * tiltY) / 25;
// Update CSS custom properties
const root = hologramCard;
root.style.setProperty('--tilt-x', tiltX);
root.style.setProperty('--tilt-y', tiltY);
root.style.setProperty('--angle', `${angle}deg`);
// Aberration position (opposite to tilt for realism)
root.style.setProperty('--aber-x', `${50 - tiltX}%`);
root.style.setProperty('--aber-y', `${50 - tiltY}%`);
// Background position for gradient effects
root.style.setProperty('--bg-pos-x', `${50 + tiltX * 2}%`);
root.style.setProperty('--bg-pos-y', `${50 + tiltY * 2}%`);
// Shimmer position
root.style.setProperty('--shimmer-x', `${50 + tiltX * 3}%`);
root.style.setProperty('--shimmer-y', `${50 + tiltY * 3}%`);
// Specular highlight position
root.style.setProperty('--spec-x', `${50 - tiltX * 1.5}%`);
root.style.setProperty('--spec-y', `${30 - tiltY * 1.5}%`);
// Update aberration opacity based on intensity
const aberrationLayers = root.querySelectorAll('.aberration-layer');
aberrationLayers.forEach(layer => {
layer.style.opacity = intensity * 0.8;
});
// Calculate hue shift based on angle (0-360)
const hueShift = (angle + 180) % 360;
root.style.setProperty('--hue-shift', hueShift);
// Apply 3D transform to card wrapper with perspective distortion
// skewX/skewY create the widening near edge / narrowing far edge effect
const skewX = tiltY * 0.08;
const skewY = -tiltX * 0.08;
const scaleX = 1 + Math.abs(tiltX) * 0.003;
const scaleY = 1 + Math.abs(tiltY) * 0.003;
cardWrapper.style.transform = `
perspective(800px)
rotateY(${tiltX}deg)
rotateX(${-tiltY}deg)
skew(${skewX}deg, ${skewY}deg)
scale(${scaleX}, ${scaleY})
`;
// Apply exaggerated transform to holographic pattern for parallax
// Logo layer is parallel to card (no extra rotation), but translated to show depth
// The translation creates the parallax: higher layer shifts IN SAME direction as tilt
const parallaxHeight = 30; // virtual height of logo layer above card
const parallaxShiftX = tiltX * parallaxHeight / 15; // shift same direction as tilt for "above" effect
const parallaxShiftY = tiltY * parallaxHeight / 15;
holoPattern.style.transform = `
translateZ(${parallaxHeight}px)
translate(${parallaxShiftX}px, ${parallaxShiftY}px)
`;
}
// Smooth animation loop (delta-time based for smooth idle on mobile)
let _lastFrameTime = null;
function animate(timestamp) {
if (!_lastFrameTime) _lastFrameTime = timestamp;
const dt = Math.min(0.05, (timestamp - _lastFrameTime) / 1000); // clamp dt to avoid big jumps
_lastFrameTime = timestamp;
// Smooth lerp towards target using dt-scaled factor
const lerpSpeed = 10; // higher = snappier
const lerpFactor = 1 - Math.exp(-lerpSpeed * dt);
currentTiltX += (targetTiltX - currentTiltX) * lerpFactor;
currentTiltY += (targetTiltY - currentTiltY) * lerpFactor;
// Update card each frame (even small changes) for continuous transforms
updateCard(currentTiltX, currentTiltY);
// Idle animation handled here using dt (only when not interacting)
// lastInteractionTime is in ms
if (cardContainer.classList.contains('visible') && !isInteracting) {
const timeSinceInteraction = Date.now() - lastInteractionTime;
if (timeSinceInteraction > 3000) {
// Gentle idle animation driven by time
idleTime += dt * 1.0; // speed multiplier
targetTiltX = Math.sin(idleTime) * 8;
targetTiltY = Math.cos(idleTime * 0.7) * 6;
}
}
requestAnimationFrame(animate);
}
requestAnimationFrame(animate);
// Mouse interaction
document.addEventListener('mousemove', (e) => {
if (!cardContainer.classList.contains('visible')) return;
const rect = hologramCard.getBoundingClientRect();
const centerX = rect.left + rect.width / 2;
const centerY = rect.top + rect.height / 2;
// Calculate distance from center of card
const deltaX = e.clientX - centerX;
const deltaY = e.clientY - centerY;
// Normalize to -1 to 1 range based on viewport
const normalizedX = deltaX / (window.innerWidth / 2);
const normalizedY = deltaY / (window.innerHeight / 2);
// Apply tilt (scaled)
targetTiltX = normalizedX * 20;
targetTiltY = normalizedY * 20;
});
// Touch interaction - use cardContainer for larger hit area
let touchStartX = 0;
let touchStartY = 0;
let touchTiltX = 0;
let touchTiltY = 0;
cardContainer.addEventListener('touchstart', (e) => {
isInteracting = true;
const touch = e.touches[0];
touchStartX = touch.clientX;
touchStartY = touch.clientY;
touchTiltX = currentTiltX;
touchTiltY = currentTiltY;
}, { passive: true });
document.addEventListener('touchmove', (e) => {
if (!isInteracting || !cardContainer.classList.contains('visible')) return;
const touch = e.touches[0];
const deltaX = touch.clientX - touchStartX;
const deltaY = touch.clientY - touchStartY;
// Apply touch delta as tilt change
targetTiltX = touchTiltX + deltaX * 0.15;
targetTiltY = touchTiltY + deltaY * 0.15;
}, { passive: true });
document.addEventListener('touchend', () => {
isInteracting = false;
});
// Prevent context menu on long press (on container for full coverage)
cardContainer.addEventListener('contextmenu', (e) => e.preventDefault());
// Device orientation (for mobile)
if (window.DeviceOrientationEvent) {
let hasOrientationPermission = false;
// Request permission on iOS 13+
if (typeof DeviceOrientationEvent.requestPermission === 'function') {
document.body.addEventListener('click', async () => {
if (hasOrientationPermission) return;
try {
const permission = await DeviceOrientationEvent.requestPermission();
if (permission === 'granted') {
hasOrientationPermission = true;
enableDeviceOrientation();
}
} catch (err) {
console.log('Device orientation permission denied');
}
}, { once: true });
} else {
enableDeviceOrientation();
}
function enableDeviceOrientation() {
window.addEventListener('deviceorientation', (e) => {
if (!cardContainer.classList.contains('visible') || isInteracting) return;
// Use beta (front-back tilt) and gamma (left-right tilt)
const beta = e.beta || 0; // -180 to 180
const gamma = e.gamma || 0; // -90 to 90
// Map to reasonable tilt range
targetTiltX = gamma * 0.4;
targetTiltY = (beta - 45) * 0.4; // Assume phone held at ~45 degrees
});
}
}
// Auto-idle animation when not interacting
let idleTime = 0;
let lastInteractionTime = Date.now();
document.addEventListener('mousemove', () => lastInteractionTime = Date.now());
document.addEventListener('touchstart', () => lastInteractionTime = Date.now());
document.addEventListener('touchmove', () => lastInteractionTime = Date.now());
// Idle animation is now driven in the main animation loop using delta-time
</script>
<script src="parental.js" defer></script>
<script src="assets/js/pwa.js" defer></script>
</body>
</html>