-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
622 lines (518 loc) · 22.2 KB
/
index.html
File metadata and controls
622 lines (518 loc) · 22.2 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
<!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>Happy Birthday Sofia 💫</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: #000;
overflow: hidden;
font-family: 'VT323', monospace;
}
/* START SCREEN */
#start-screen {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #000;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
z-index: 200;
cursor: pointer;
}
#start-screen .star {
font-size: 60px;
animation: pulse 2s ease-in-out infinite;
}
#start-screen .prompt {
color: #fff;
font-size: clamp(20px, 5vw, 32px);
margin-top: 30px;
animation: blink-text 1.5s ease-in-out infinite;
}
@keyframes pulse {
0%, 100% { transform: scale(1); opacity: 1; }
50% { transform: scale(1.2); opacity: 0.7; }
}
@keyframes blink-text {
0%, 100% { opacity: 1; }
50% { opacity: 0.3; }
}
#start-screen.hidden {
display: none;
}
/* INTRO SCREEN */
#intro {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #000;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
z-index: 100;
padding: 20px;
opacity: 0;
pointer-events: none;
}
#intro.active {
opacity: 1;
pointer-events: auto;
}
.text-line {
color: #fff;
font-size: clamp(18px, 5vw, 32px);
margin: 10px 0;
opacity: 0;
letter-spacing: 2px;
}
.text-line::before {
content: '> ';
color: #ffff00;
}
.typing {
opacity: 1;
overflow: hidden;
white-space: nowrap;
border-right: 3px solid #fff;
animation: blink 0.7s step-end infinite;
}
.typed {
border-right: none;
}
@keyframes blink {
50% { border-color: transparent; }
}
.fade-out {
animation: fadeOut 1.5s ease-out forwards;
}
@keyframes fadeOut {
to { opacity: 0; pointer-events: none; }
}
/* 3D CANVAS */
#canvas-container {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
transition: opacity 2s ease-in;
}
#canvas-container.visible {
opacity: 1;
}
/* BIRTHDAY TEXT OVERLAY */
#birthday-text {
position: fixed;
bottom: 10%;
left: 0;
width: 100%;
text-align: center;
color: #fff;
font-size: clamp(24px, 6vw, 48px);
text-shadow: 0 0 20px #ff69b4, 0 0 40px #ff69b4;
opacity: 0;
transition: opacity 2s ease-in 1s;
pointer-events: none;
z-index: 10;
}
#birthday-text.visible {
opacity: 1;
}
#age {
display: block;
font-size: clamp(48px, 12vw, 96px);
color: #ffff00;
text-shadow: 0 0 30px #ffff00, 0 0 60px #ff6600;
margin-top: 10px;
}
</style>
</head>
<body>
<!-- START SCREEN -->
<div id="start-screen">
<div class="star">⭐</div>
<div class="prompt">tap to start</div>
</div>
<!-- INTRO SCREEN -->
<div id="intro">
<div class="text-line" id="line1">sofia</div>
<div class="text-line" id="line2">today is your birthday</div>
<div class="text-line" id="line3">i wish you all the best</div>
<div class="text-line" id="line4">✨ let's celebrate ✨</div>
</div>
<!-- 3D SCENE -->
<div id="canvas-container"></div>
<!-- BIRTHDAY TEXT -->
<div id="birthday-text">
Happy Birthday!
<span id="age">26</span>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<script>
// ============ AUDIO SYSTEM ============
let audioCtx;
let musicGain;
let musicStarted = false;
function initAudio() {
audioCtx = new (window.AudioContext || window.webkitAudioContext)();
musicGain = audioCtx.createGain();
musicGain.gain.value = 0.15;
musicGain.connect(audioCtx.destination);
}
// Undertale-style typing sound
function playTypeSound() {
if (!audioCtx) return;
const osc = audioCtx.createOscillator();
const gain = audioCtx.createGain();
// Classic Undertale "blip" - square wave, short duration
osc.type = 'square';
osc.frequency.value = 400 + Math.random() * 100; // Slight variation
gain.gain.setValueAtTime(0.15, audioCtx.currentTime);
gain.gain.exponentialDecayTo = 0.01;
gain.gain.setValueAtTime(0.15, audioCtx.currentTime);
gain.gain.exponentialRampToValueAtTime(0.01, audioCtx.currentTime + 0.05);
osc.connect(gain);
gain.connect(audioCtx.destination);
osc.start(audioCtx.currentTime);
osc.stop(audioCtx.currentTime + 0.05);
}
// Ambient space music generator
function startMusic() {
if (!audioCtx || musicStarted) return;
musicStarted = true;
// Create dreamy pad synth
const notes = [220, 277.18, 329.63, 440, 554.37]; // A minor pentatonic
function playPad() {
const note = notes[Math.floor(Math.random() * notes.length)];
const osc1 = audioCtx.createOscillator();
const osc2 = audioCtx.createOscillator();
const gain = audioCtx.createGain();
const filter = audioCtx.createBiquadFilter();
osc1.type = 'sine';
osc2.type = 'triangle';
osc1.frequency.value = note;
osc2.frequency.value = note * 1.002; // Slight detune for thickness
filter.type = 'lowpass';
filter.frequency.value = 800;
gain.gain.setValueAtTime(0, audioCtx.currentTime);
gain.gain.linearRampToValueAtTime(0.3, audioCtx.currentTime + 2);
gain.gain.linearRampToValueAtTime(0, audioCtx.currentTime + 6);
osc1.connect(filter);
osc2.connect(filter);
filter.connect(gain);
gain.connect(musicGain);
osc1.start(audioCtx.currentTime);
osc2.start(audioCtx.currentTime);
osc1.stop(audioCtx.currentTime + 6);
osc2.stop(audioCtx.currentTime + 6);
}
// Play notes at intervals
playPad();
setInterval(playPad, 3000);
// Add subtle "sparkle" sounds
function playSparkle() {
const osc = audioCtx.createOscillator();
const gain = audioCtx.createGain();
osc.type = 'sine';
osc.frequency.value = 800 + Math.random() * 1200;
gain.gain.setValueAtTime(0.05, audioCtx.currentTime);
gain.gain.exponentialRampToValueAtTime(0.001, audioCtx.currentTime + 0.5);
osc.connect(gain);
gain.connect(musicGain);
osc.start(audioCtx.currentTime);
osc.stop(audioCtx.currentTime + 0.5);
}
setInterval(() => {
if (Math.random() > 0.5) playSparkle();
}, 800);
}
// ============ TYPING ANIMATION ============
const lines = [
{ el: document.getElementById('line1'), text: 'sofia', delay: 500 },
{ el: document.getElementById('line2'), text: 'today is your birthday', delay: 1500 },
{ el: document.getElementById('line3'), text: 'i wish you all the best', delay: 1500 },
{ el: document.getElementById('line4'), text: '✨ let\'s celebrate ✨', delay: 2000 }
];
async function typeText(element, text, speed = 70) {
element.classList.add('typing');
element.textContent = '';
for (let i = 0; i < text.length; i++) {
element.textContent += text[i];
if (text[i] !== ' ') {
playTypeSound();
}
await new Promise(r => setTimeout(r, speed));
}
element.classList.add('typed');
}
async function runIntro() {
document.getElementById('intro').classList.add('active');
await new Promise(r => setTimeout(r, 800));
for (const line of lines) {
await typeText(line.el, line.text);
await new Promise(r => setTimeout(r, line.delay));
}
// Wait then fade out intro
await new Promise(r => setTimeout(r, 2000));
document.getElementById('intro').classList.add('fade-out');
// Show 3D scene and start music
await new Promise(r => setTimeout(r, 500));
document.getElementById('canvas-container').classList.add('visible');
document.getElementById('birthday-text').classList.add('visible');
startMusic();
}
// ============ THREE.JS 3D SCENE ============
let scene, camera, renderer, cake, candles = [], planets = [];
function init3D() {
const container = document.getElementById('canvas-container');
// Scene
scene = new THREE.Scene();
scene.background = new THREE.Color(0x0a0015);
// Camera
camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.set(0, 3, 8);
// Renderer
renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
container.appendChild(renderer.domElement);
// Lights
const ambientLight = new THREE.AmbientLight(0x404040, 0.5);
scene.add(ambientLight);
const pointLight = new THREE.PointLight(0xffffff, 1, 100);
pointLight.position.set(5, 10, 5);
scene.add(pointLight);
// Create cake
createCake();
// Create stars
createStars();
// Create planets
createPlanets();
// Handle resize
window.addEventListener('resize', onWindowResize);
// Start animation
animate();
}
function createCake() {
cake = new THREE.Group();
// Naïve art style - chunky, simple shapes with bright colors
// Bottom layer (pink)
const bottomGeom = new THREE.CylinderGeometry(2, 2.2, 1.2, 8);
const bottomMat = new THREE.MeshLambertMaterial({ color: 0xff69b4 });
const bottom = new THREE.Mesh(bottomGeom, bottomMat);
bottom.position.y = 0.6;
cake.add(bottom);
// Middle layer (yellow)
const middleGeom = new THREE.CylinderGeometry(1.5, 1.7, 1, 8);
const middleMat = new THREE.MeshLambertMaterial({ color: 0xffff00 });
const middle = new THREE.Mesh(middleGeom, middleMat);
middle.position.y = 1.7;
cake.add(middle);
// Top layer (cyan)
const topGeom = new THREE.CylinderGeometry(1, 1.2, 0.8, 8);
const topMat = new THREE.MeshLambertMaterial({ color: 0x00ffff });
const top = new THREE.Mesh(topGeom, topMat);
top.position.y = 2.6;
cake.add(top);
// Frosting drips (white spheres)
const frostingMat = new THREE.MeshLambertMaterial({ color: 0xffffff });
for (let i = 0; i < 12; i++) {
const angle = (i / 12) * Math.PI * 2;
const drip = new THREE.Mesh(
new THREE.SphereGeometry(0.15, 6, 6),
frostingMat
);
drip.position.set(
Math.cos(angle) * 1.8,
1.2 + Math.random() * 0.3,
Math.sin(angle) * 1.8
);
cake.add(drip);
}
// Candles
const candleColors = [0xff0000, 0x00ff00, 0x0000ff, 0xff00ff, 0xffff00];
for (let i = 0; i < 5; i++) {
const angle = (i / 5) * Math.PI * 2;
const candleGroup = new THREE.Group();
// Candle stick
const candleGeom = new THREE.CylinderGeometry(0.08, 0.08, 0.6, 6);
const candleMat = new THREE.MeshLambertMaterial({ color: candleColors[i] });
const candle = new THREE.Mesh(candleGeom, candleMat);
candleGroup.add(candle);
// Flame (emissive)
const flameGeom = new THREE.ConeGeometry(0.1, 0.25, 6);
const flameMat = new THREE.MeshBasicMaterial({ color: 0xffaa00 });
const flame = new THREE.Mesh(flameGeom, flameMat);
flame.position.y = 0.4;
candleGroup.add(flame);
// Flame glow
const glowGeom = new THREE.SphereGeometry(0.15, 8, 8);
const glowMat = new THREE.MeshBasicMaterial({
color: 0xffff00,
transparent: true,
opacity: 0.3
});
const glow = new THREE.Mesh(glowGeom, glowMat);
glow.position.y = 0.4;
candleGroup.add(glow);
candleGroup.position.set(
Math.cos(angle) * 0.7,
3.1,
Math.sin(angle) * 0.7
);
candles.push({ flame, glow, baseY: 0.4 });
cake.add(candleGroup);
}
// Star on top
const starShape = new THREE.Shape();
const outerRadius = 0.4;
const innerRadius = 0.2;
for (let i = 0; i < 10; i++) {
const radius = i % 2 === 0 ? outerRadius : innerRadius;
const angle = (i / 10) * Math.PI * 2 - Math.PI / 2;
if (i === 0) {
starShape.moveTo(Math.cos(angle) * radius, Math.sin(angle) * radius);
} else {
starShape.lineTo(Math.cos(angle) * radius, Math.sin(angle) * radius);
}
}
const starGeom = new THREE.ExtrudeGeometry(starShape, { depth: 0.1, bevelEnabled: false });
const starMat = new THREE.MeshBasicMaterial({ color: 0xffff00 });
const star = new THREE.Mesh(starGeom, starMat);
star.rotation.x = -Math.PI / 2;
star.position.y = 3.5;
cake.add(star);
scene.add(cake);
}
function createStars() {
const starGeom = new THREE.BufferGeometry();
const starCount = 1500;
const positions = new Float32Array(starCount * 3);
const colors = new Float32Array(starCount * 3);
for (let i = 0; i < starCount; i++) {
// Spread stars in a sphere around the scene
const radius = 30 + Math.random() * 70;
const theta = Math.random() * Math.PI * 2;
const phi = Math.random() * Math.PI;
positions[i * 3] = radius * Math.sin(phi) * Math.cos(theta);
positions[i * 3 + 1] = radius * Math.sin(phi) * Math.sin(theta);
positions[i * 3 + 2] = radius * Math.cos(phi);
// Random star colors (white, yellow, light blue)
const colorChoice = Math.random();
if (colorChoice < 0.7) {
colors[i * 3] = 1; colors[i * 3 + 1] = 1; colors[i * 3 + 2] = 1;
} else if (colorChoice < 0.85) {
colors[i * 3] = 1; colors[i * 3 + 1] = 1; colors[i * 3 + 2] = 0.5;
} else {
colors[i * 3] = 0.5; colors[i * 3 + 1] = 0.8; colors[i * 3 + 2] = 1;
}
}
starGeom.setAttribute('position', new THREE.BufferAttribute(positions, 3));
starGeom.setAttribute('color', new THREE.BufferAttribute(colors, 3));
const starMat = new THREE.PointsMaterial({
size: 0.5,
vertexColors: true,
transparent: true,
opacity: 0.8
});
const stars = new THREE.Points(starGeom, starMat);
scene.add(stars);
}
function createPlanets() {
const planetData = [
{ color: 0xff6b9d, size: 1.5, distance: 12, speed: 0.0003, y: 2 },
{ color: 0x9b59b6, size: 0.8, distance: 8, speed: 0.0005, y: -1 },
{ color: 0x3498db, size: 1.2, distance: 15, speed: 0.0002, y: 4 },
{ color: 0x2ecc71, size: 0.6, distance: 10, speed: 0.0007, y: -3 },
{ color: 0xf39c12, size: 1.0, distance: 18, speed: 0.00015, y: 1 }
];
planetData.forEach((data, i) => {
const geom = new THREE.IcosahedronGeometry(data.size, 1); // Low-poly look
const mat = new THREE.MeshLambertMaterial({ color: data.color });
const planet = new THREE.Mesh(geom, mat);
// Add ring to one planet
if (i === 2) {
const ringGeom = new THREE.RingGeometry(1.5, 2, 16);
const ringMat = new THREE.MeshBasicMaterial({
color: 0x87ceeb,
side: THREE.DoubleSide,
transparent: true,
opacity: 0.6
});
const ring = new THREE.Mesh(ringGeom, ringMat);
ring.rotation.x = Math.PI / 2.5;
planet.add(ring);
}
planet.userData = {
distance: data.distance,
speed: data.speed,
angle: Math.random() * Math.PI * 2,
y: data.y
};
planets.push(planet);
scene.add(planet);
});
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
}
let time = 0;
function animate() {
requestAnimationFrame(animate);
time += 0.016;
// Rotate camera around cake
const cameraAngle = time * 0.2;
camera.position.x = Math.sin(cameraAngle) * 8;
camera.position.z = Math.cos(cameraAngle) * 8;
camera.position.y = 3 + Math.sin(time * 0.3) * 0.5;
camera.lookAt(0, 2, 0);
// Animate candle flames
candles.forEach((candle, i) => {
const flicker = Math.sin(time * 15 + i) * 0.05;
candle.flame.scale.set(1 + flicker, 1 + flicker * 2, 1 + flicker);
candle.glow.scale.set(1 + flicker * 2, 1 + flicker * 2, 1 + flicker * 2);
});
// Animate planets
planets.forEach(planet => {
planet.userData.angle += planet.userData.speed * 60;
planet.position.x = Math.cos(planet.userData.angle) * planet.userData.distance;
planet.position.z = Math.sin(planet.userData.angle) * planet.userData.distance;
planet.position.y = planet.userData.y + Math.sin(time * 0.5 + planet.userData.angle) * 0.5;
planet.rotation.y += 0.01;
});
// Gentle cake float
if (cake) {
cake.position.y = Math.sin(time * 0.8) * 0.1;
cake.rotation.y = time * 0.1;
}
renderer.render(scene, camera);
}
// ============ START ============
init3D();
// Wait for user interaction to enable audio
document.getElementById('start-screen').addEventListener('click', () => {
initAudio();
document.getElementById('start-screen').classList.add('hidden');
runIntro();
});
</script>
</body>
</html>