-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
586 lines (516 loc) · 15.6 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>2025新年倒數</title>
<style>
.fireworks-container {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100vh;
z-index: 9998; /* 確保煙火容器在最上層 */
}
#countdown {
color: #fff; /* 白色文字 */
font-family: 'Noto Sans TC', sans-serif; /* 使用指定字体 */
font-weight: 900; /* 设置字体粗细 */
font-size: 24px;
text-align: center;
position: absolute; /* 絕對定位 */
top: 50%; /* 垂直置中 */
left: 50%; /* 水平置中 */
transform: translate(-50%, -50%); /* 水平和垂直置中 */
z-index: 9998; /* 最上層 */
}
.new-year-message {
font-family: 'Noto Sans TC', sans-serif; /* 使用指定字体 */
font-weight: 900; /* 设置字体粗细 */
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 48px;
text-align: center;
opacity: 0;
transition: opacity 2s, font-size 2s;
z-index: 9998;
color: #fff; /* 白色文字 */
}
.test-button {
position: absolute;
top: calc(50% - 60px); /* 位于 .lua .textura 上方 */
left: calc(50% - 60px); /* 居中 */
width: 120px;
height: 120px;
background-color: transparent; /* 设为透明 */
color: #fff;
border: none;
font-size: 24px;
cursor: pointer;
border-radius: 50%; /* 圆形按钮 */
z-index: 10000; /* 确保在最上层 */
display: flex;
align-items: center;
justify-content: center;
}
.overlay {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
justify-content: center;
align-items: center;
z-index: 9999
}
.instructions {
background-color: rgba(0, 0, 0, 0.3); /* 修改為純黑,透明度 30% */
padding: 20px;
border-radius: 10px;
text-align: center;
z-index: 9999
}
.instructions h2 {
margin-top: 0;
color: #fff; /* 指示文字顏色為白色 */
text-align: center; /* 讓 <h2> 元素置中 */
z-index: 9999
}
.instructions p {
margin-bottom: 10px;
color: #fff; /* 指示文字顏色為白色 */
text-align: left; /* 讓 <p> 元素靠左對齊 */
z-index: 9999
}
/* 添加一些自定義樣式來渲染鍵盤按鈕 */
.keyboard-key {
display: inline-block;
border: 1px solid #fff;
border-radius: 5px;
padding: 5px 10px;
margin: 0 5px;
font-size: 16px;
cursor: pointer;
z-index: 9999
}
/* 鼠标悬停时的样式 */
</style>
<link rel="stylesheet" href="css/StarrySky.css">
<link rel="stylesheet" href="css/snow.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/index.umd.js"></script>
<script src="js/StarrySky.js"></script>
<script src="js/switch.js"></script>
<script src="js/snow.js"></script>
<script src="js/sakura.js"></script>
<script id="sakura_point_vsh" type="x-shader/x_vertex">
uniform mat4 uProjection;
uniform mat4 uModelview;
uniform vec3 uResolution;
uniform vec3 uOffset;
uniform vec3 uDOF; //x:focus distance, y:focus radius, z:max radius
uniform vec3 uFade; //x:start distance, y:half distance, z:near fade start
attribute vec3 aPosition;
attribute vec3 aEuler;
attribute vec2 aMisc; //x:size, y:fade
varying vec3 pposition;
varying float psize;
varying float palpha;
varying float pdist;
//varying mat3 rotMat;
varying vec3 normX;
varying vec3 normY;
varying vec3 normZ;
varying vec3 normal;
varying float diffuse;
varying float specular;
varying float rstop;
varying float distancefade;
void main(void) {
// Projection is based on vertical angle
vec4 pos = uModelview * vec4(aPosition + uOffset, 1.0);
gl_Position = uProjection * pos;
gl_PointSize = aMisc.x * uProjection[1][1] / -pos.z * uResolution.y * 0.5;
pposition = pos.xyz;
psize = aMisc.x;
pdist = length(pos.xyz);
palpha = smoothstep(0.0, 1.0, (pdist - 0.1) / uFade.z);
vec3 elrsn = sin(aEuler);
vec3 elrcs = cos(aEuler);
mat3 rotx = mat3(
1.0, 0.0, 0.0,
0.0, elrcs.x, elrsn.x,
0.0, -elrsn.x, elrcs.x
);
mat3 roty = mat3(
elrcs.y, 0.0, -elrsn.y,
0.0, 1.0, 0.0,
elrsn.y, 0.0, elrcs.y
);
mat3 rotz = mat3(
elrcs.z, elrsn.z, 0.0,
-elrsn.z, elrcs.z, 0.0,
0.0, 0.0, 1.0
);
mat3 rotmat = rotx * roty * rotz;
normal = rotmat[2];
mat3 trrotm = mat3(
rotmat[0][0], rotmat[1][0], rotmat[2][0],
rotmat[0][1], rotmat[1][1], rotmat[2][1],
rotmat[0][2], rotmat[1][2], rotmat[2][2]
);
normX = trrotm[0];
normY = trrotm[1];
normZ = trrotm[2];
const vec3 lit = vec3(0.6917144638660746, 0.6917144638660746, -0.20751433915982237);
float tmpdfs = dot(lit, normal);
if(tmpdfs < 0.0) {
normal = -normal;
tmpdfs = dot(lit, normal);
}
diffuse = 0.4 + tmpdfs;
vec3 eyev = normalize(-pos.xyz);
if(dot(eyev, normal) > 0.0) {
vec3 hv = normalize(eyev + lit);
specular = pow(max(dot(hv, normal), 0.0), 20.0);
}
else {
specular = 0.0;
}
rstop = clamp((abs(pdist - uDOF.x) - uDOF.y) / uDOF.z, 0.0, 1.0);
rstop = pow(rstop, 0.5);
//-0.69315 = ln(0.5)
distancefade = min(1.0, exp((uFade.x - pdist) * 0.69315 / uFade.y));
}
</script>
<script id="sakura_point_fsh" type="x-shader/x_fragment">
#ifdef GL_ES
//precision mediump float;
precision highp float;
#endif
uniform vec3 uDOF; //x:focus distance, y:focus radius, z:max radius
uniform vec3 uFade; //x:start distance, y:half distance, z:near fade start
const vec3 fadeCol = vec3(0.08, 0.03, 0.06);
varying vec3 pposition;
varying float psize;
varying float palpha;
varying float pdist;
//varying mat3 rotMat;
varying vec3 normX;
varying vec3 normY;
varying vec3 normZ;
varying vec3 normal;
varying float diffuse;
varying float specular;
varying float rstop;
varying float distancefade;
float ellipse(vec2 p, vec2 o, vec2 r) {
vec2 lp = (p - o) / r;
return length(lp) - 1.0;
}
void main(void) {
vec3 p = vec3(gl_PointCoord - vec2(0.5, 0.5), 0.0) * 2.0;
vec3 d = vec3(0.0, 0.0, -1.0);
float nd = normZ.z; //dot(-normZ, d);
if(abs(nd) < 0.0001) discard;
float np = dot(normZ, p);
vec3 tp = p + d * np / nd;
vec2 coord = vec2(dot(normX, tp), dot(normY, tp));
//angle = 15 degree
const float flwrsn = 0.258819045102521;
const float flwrcs = 0.965925826289068;
mat2 flwrm = mat2(flwrcs, -flwrsn, flwrsn, flwrcs);
vec2 flwrp = vec2(abs(coord.x), coord.y) * flwrm;
float r;
if(flwrp.x < 0.0) {
r = ellipse(flwrp, vec2(0.065, 0.024) * 0.5, vec2(0.36, 0.96) * 0.5);
}
else {
r = ellipse(flwrp, vec2(0.065, 0.024) * 0.5, vec2(0.58, 0.96) * 0.5);
}
if(r > rstop) discard;
vec3 col = mix(vec3(1.0, 0.8, 0.75), vec3(1.0, 0.9, 0.87), r);
float grady = mix(0.0, 1.0, pow(coord.y * 0.5 + 0.5, 0.35));
col *= vec3(1.0, grady, grady);
col *= mix(0.8, 1.0, pow(abs(coord.x), 0.3));
col = col * diffuse + specular;
col = mix(fadeCol, col, distancefade);
float alpha = (rstop > 0.001)? (0.5 - r / (rstop * 2.0)) : 1.0;
alpha = smoothstep(0.0, 1.0, alpha) * palpha;
gl_FragColor = vec4(col * 0.5, alpha);
}
</script>
<script id="fx_common_vsh" type="x-shader/x_vertex">
uniform vec3 uResolution;
attribute vec2 aPosition;
varying vec2 texCoord;
varying vec2 screenCoord;
void main(void) {
gl_Position = vec4(aPosition, 0.0, 1.0);
texCoord = aPosition.xy * 0.5 + vec2(0.5, 0.5);
screenCoord = aPosition.xy * vec2(uResolution.z, 1.0);
}
</script>
<script id="bg_fsh" type="x-shader/x_fragment">
#ifdef GL_ES
//precision mediump float;
precision highp float;
#endif
uniform vec2 uTimes;
varying vec2 texCoord;
varying vec2 screenCoord;
void main(void) {
discard; // 將整個背景設置為透明
}
</script>
<script id="fx_brightbuf_fsh" type="x-shader/x_fragment">
#ifdef GL_ES
//precision mediump float;
precision highp float;
#endif
uniform sampler2D uSrc;
uniform vec2 uDelta;
varying vec2 texCoord;
varying vec2 screenCoord;
void main(void) {
discard; // 將整個背景設置為透明
}
</script>
<script id="fx_dirblur_r4_fsh" type="x-shader/x_fragment">
#ifdef GL_ES
//precision mediump float;
precision highp float;
#endif
uniform sampler2D uSrc;
uniform vec2 uDelta;
uniform vec4 uBlurDir; //dir(x, y), stride(z, w)
varying vec2 texCoord;
varying vec2 screenCoord;
void main(void) {
discard; // 將整個背景設置為透明
}
</script>
<script id="fx_common_fsh" type="x-shader/x_fragment">
#ifdef GL_ES
//precision mediump float;
precision highp float;
#endif
uniform sampler2D uSrc;
uniform vec2 uDelta;
varying vec2 texCoord;
varying vec2 screenCoord;
void main(void) {
gl_FragColor = texture2D(uSrc, texCoord);
}
</script>
<script id="pp_final_vsh" type="x-shader/x_vertex">
uniform vec3 uResolution;
attribute vec2 aPosition;
varying vec2 texCoord;
varying vec2 screenCoord;
void main(void) {
gl_Position = vec4(aPosition, 0.0, 1.0);
texCoord = aPosition.xy * 0.5 + vec2(0.5, 0.5);
screenCoord = aPosition.xy * vec2(uResolution.z, 1.0);
}
</script>
<script id="pp_final_fsh" type="x-shader/x_fragment">
#ifdef GL_ES
//precision mediump float;
precision highp float;
#endif
uniform sampler2D uSrc;
uniform sampler2D uBloom;
uniform vec2 uDelta;
varying vec2 texCoord;
varying vec2 screenCoord;
void main(void) {
vec4 srccol = texture2D(uSrc, texCoord) * 2.0;
vec4 bloomcol = texture2D(uBloom, texCoord);
vec4 col;
col = srccol + bloomcol * (vec4(1.0) + srccol);
col *= smoothstep(1.0, 0.0, pow(length((texCoord - vec2(0.5)) * 2.0), 1.2) * 0.5);
col = pow(col, vec4(0.45454545454545)); //(1.0 / 2.2)
gl_FragColor = vec4(col.rgb, 1.0);
gl_FragColor.a = 0.0;
}
</script>
</head>
<body>
<div class="overlay" id="overlay">
<div class="instructions">
<h2>使用提示</h2>
<p>點擊月亮可以預覽跨年特效</p>
<p>開始施放煙火時點擊畫面可以指定施放位置</p><br>
<h2>特效切換</h2>
<p>按 <span class="keyboard-key">S</span> 切換下雪</p>
<p>按 <span class="keyboard-key">R</span> 切換下雨</p>
<p>按 <span class="keyboard-key">J</span> 切換櫻花雨</p>
</div>
</div>
<div id="countdown"></div>
<div class="fireworks-container"></div>
<div class="noite"><canvas id="rainCanvas"></canvas><canvas id="sakura"></canvas></div>
<div class="constelacao"></div>
<div class="lua">
<div class="textura"></div>
<button class="test-button" onclick="startCountdown(); playAudio();"></button>
</div>
<div class="snow-container" style="display: none;"></div>
<div class="chuvaMeteoro"></div>
<div class="floresta">
<img src="image/city.png" alt="" />
</div>
<script src="js/rain.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {
const overlay = document.getElementById('overlay');
// Function to show the overlay
function showOverlay() {
overlay.style.display = 'flex';
}
// Function to hide the overlay
function hideOverlay() {
overlay.style.display = 'none';
}
// Show overlay initially
showOverlay();
// Hide overlay when clicking anywhere on the overlay
overlay.addEventListener('click', hideOverlay);
// Hide overlay when pressing the Esc key
document.addEventListener('keydown', function(event) {
if (event.key === 'Escape') {
hideOverlay();
}
});
});
// 设置跨年的时间点
const newYearTime = new Date('January 1, 2025 00:00:00').getTime();
//'January 1, 2024 00:00:00'
//'December 31, 2023 23:59:59'
// 更新倒计时和特殊效果
const updateCountdown = () => {
const now = new Date().getTime();
const distance = newYearTime - now;
if (distance < 0) {
clearInterval(interval);
countdown.style.display = 'none';
startFireworks();
displayHappyNewYearMessage();
return;
}
let days = Math.floor(distance / (1000 * 60 * 60 * 24));
let hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
let minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
let seconds = Math.floor((distance % (1000 * 60)) / 1000);
let countdownText = '';
if (days > 0) {
countdownText += `${days} 天 `;
}
if (hours > 0 || days > 0) {
countdownText += `${hours} 小時 `;
}
if (minutes > 0 || hours > 0 || days > 0) {
countdownText += `${minutes} 分鐘 `;
}
countdownText += `${seconds} 秒`;
countdown.innerHTML = `${countdownText}`;
if (distance <= 11000) {
countdown.style.fontSize = '100px';
} else {
countdown.style.fontSize = '48px';
}
};
function displayHappyNewYearMessage() {
const happyNewYearMessage = document.createElement('div');
happyNewYearMessage.textContent = '2025新年快樂';
happyNewYearMessage.className = 'new-year-message';
document.body.appendChild(happyNewYearMessage);
setTimeout(() => {
happyNewYearMessage.style.opacity = '1';
happyNewYearMessage.style.fontSize = '72px';
}, 10);
setTimeout(() => {
happyNewYearMessage.style.opacity = '0';
}, 2000);
setTimeout(() => {
happyNewYearMessage.style.display = 'none';
}, 3000);
}
const interval = setInterval(updateCountdown, 1000);
// 在特定時間啟動煙火效果
function startFireworks() {
const container = document.querySelector('.fireworks-container');
const fireworksConfig = {
autoresize: true,
opacity: 0.5,
acceleration: 1.05,
friction: 0.97,
gravity: 1.5,
particles: 50,
traceLength: 3,
traceSpeed: 10,
explosion: 5,
intensity: 100,
flickering: 50,
lineStyle: 'round',
hue: {
min: 0,
max: 360
},
delay: {
min: 30,
max: 60
},
rocketsPoint: {
min: 50,
max: 50
},
lineWidth: {
explosion: {
min: 1,
max: 3
},
trace: {
min: 1,
max: 2
}
},
brightness: {
min: 55,
max: 100
},
decay: {
min: 0.015,
max: 0.03
},
mouse: {
click: true,
move: false,
max: 10
},
sound: {
enabled: true,
files: ["https://fireworks.js.org/sounds/explosion0.mp3", "https://fireworks.js.org/sounds/explosion1.mp3", "https://fireworks.js.org/sounds/explosion2.mp3"],
volume: {
min: 4,
max: 8
}
}
};
const fireworks = new Fireworks.default(container, fireworksConfig);
fireworks.start();
}
function startCountdown() {
displayHappyNewYearMessage(); // 首先显示新年祝福信息
startFireworks(); // 然后开始烟火效果
clearInterval(interval); // 清除现有的倒计时
updateCountdown(); // 立即更新倒计时
document.getElementById('countdown').style.display = 'none';
}
</script>
</body>
</html>