-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1234 lines (1063 loc) · 46.3 KB
/
index.html
File metadata and controls
1234 lines (1063 loc) · 46.3 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WORLDSHELL // SYSTEM_INIT</title>
<!-- Load Google Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<!-- Orbitron: 几何感强的科幻字体 -->
<link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&display=swap" rel="stylesheet">
<!-- Rajdhani: 现代科技感,字母统一 -->
<link href="https://fonts.googleapis.com/css2?family=Rajdhani:wght@500;600;700&display=swap" rel="stylesheet">
<!-- Space Mono: 等宽,复古科幻 -->
<link href="https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&display=swap" rel="stylesheet">
<!-- Noto Sans: Google的万能Unicode字体,作为后备 -->
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans:wght@500;700;900&display=swap" rel="stylesheet">
<!-- Load Three.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<style>
:root {
--bg-color: #ffffff;
--text-color: #1a1a1a;
--accent-color: #0066cc; /* Deep Tech Blue */
--secondary-color: #ff3366; /* Vivid Pink/Red */
--panel-bg: rgba(255, 255, 255, 0.85);
--border-color: rgba(0, 102, 204, 0.3);
--font-main: 'Helvetica Neue', Helvetica, Arial, sans-serif;
--font-mono: 'Courier New', Courier, monospace;
}
body, html {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
background-color: var(--bg-color);
color: var(--text-color);
font-family: var(--font-main);
overflow: hidden; /* No scroll on main page */
}
/* Canvas fixed at back */
#canvas-container {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 0;
opacity: 0.9;
cursor: pointer; /* Hint that it's clickable */
transition: opacity 1s ease;
}
.main-container {
position: relative;
z-index: 1;
width: 100%;
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
pointer-events: none; /* Let clicks pass through to canvas initially */
}
/* Title Overlay - Always visible but separate */
.title-overlay {
position: absolute;
top: 15%;
text-align: center;
width: 100%;
z-index: 2;
pointer-events: auto;
}
h1 {
/* Orbitron 用于英文字母,Noto Sans 作为后备处理希腊/西里尔等字符 */
font-family: 'Orbitron', 'Noto Sans', sans-serif;
font-weight: 900;
font-size: 3.5rem;
margin: 0 0 0.5rem 0;
letter-spacing: 0.5rem;
text-transform: uppercase;
color: #000;
text-shadow: 0 0 10px rgba(255,255,255,0.8);
position: relative;
}
/* 单个字母的容器 */
h1 .letter {
display: inline-block;
position: relative;
}
/* 特殊字符(Ø等)使用后备字体并水平拉伸 */
h1 .letter.special-char {
font-family: 'Noto Sans', sans-serif;
font-weight: 700;
transform: scaleX(1.2); /* 水平拉伸 20% */
display: inline-block; /* transform 需要 */
}
/* Glitch effect - 只作用于单个字母 */
h1 .letter.glitch {
animation: glitch-anim 0.2s ease;
}
@keyframes glitch-anim {
0% {
transform: translate(0);
opacity: 1;
color: #000;
}
20% {
transform: translate(-3px, 2px);
opacity: 0.8;
color: #ff3366;
text-shadow: 2px 0 #0066cc, -2px 0 #ff3366;
}
40% {
transform: translate(3px, -2px);
opacity: 0.7;
color: #0066cc;
text-shadow: -2px 0 #ff3366, 2px 0 #0066cc;
}
60% {
transform: translate(-2px, 3px);
opacity: 0.8;
color: #ff3366;
}
80% {
transform: translate(2px, -1px);
opacity: 0.9;
color: #0066cc;
}
100% {
transform: translate(0);
opacity: 1;
color: #000;
text-shadow: none;
}
}
.subtitle {
font-family: var(--font-mono);
font-size: 0.9rem;
color: var(--accent-color);
text-transform: uppercase;
letter-spacing: 0.1rem;
font-weight: 600;
}
/* Login/Interaction Box - Hidden initially */
.content-box {
background: rgba(255, 255, 255, 0.9);
border: 1px solid var(--accent-color);
padding: 2rem;
padding-top: 2.5rem; /* 为关闭按钮留出空间 */
width: 300px;
text-align: center;
backdrop-filter: blur(15px);
box-shadow: 0 0 30px rgba(0, 102, 204, 0.2);
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%) scale(0.9);
opacity: 0;
pointer-events: none;
transition: all 0.5s cubic-bezier(0.22, 1, 0.36, 1);
z-index: 10;
}
.content-box.visible {
opacity: 1;
transform: translate(-50%, -50%) scale(1);
pointer-events: auto;
}
/* 关闭按钮 */
.close-btn {
position: absolute;
top: 10px;
right: 10px;
width: 24px;
height: 24px;
cursor: pointer;
opacity: 0.6;
transition: opacity 0.3s;
}
.close-btn:hover {
opacity: 1;
}
.close-btn::before,
.close-btn::after {
content: '';
position: absolute;
top: 50%;
left: 50%;
width: 16px;
height: 1px;
background: var(--accent-color);
}
.close-btn::before {
transform: translate(-50%, -50%) rotate(45deg);
}
.close-btn::after {
transform: translate(-50%, -50%) rotate(-45deg);
}
/* Decorative corners for box */
.content-box::before {
content: '';
position: absolute;
top: -2px; left: -2px;
width: 10px; height: 10px;
border-top: 2px solid var(--secondary-color);
border-left: 2px solid var(--secondary-color);
}
.content-box::after {
content: '';
position: absolute;
bottom: -2px; right: -2px;
width: 10px; height: 10px;
border-bottom: 2px solid var(--secondary-color);
border-right: 2px solid var(--secondary-color);
}
.input-group {
margin-bottom: 20px;
text-align: left;
}
.input-label {
font-family: var(--font-mono);
font-size: 0.7rem;
color: #666;
display: block;
margin-bottom: 5px;
}
.styled-input {
width: 100%;
padding: 8px;
background: rgba(0,0,0,0.02);
border: 1px solid #ddd;
border-bottom: 2px solid var(--accent-color);
font-family: var(--font-mono);
outline: none;
box-sizing: border-box;
transition: background 0.3s;
}
.styled-input:focus {
background: rgba(0, 102, 204, 0.05);
}
a.button {
display: block;
width: 100%;
padding: 10px 0;
background: transparent;
color: var(--accent-color);
text-decoration: none;
text-transform: uppercase;
font-family: 'Orbitron', var(--font-mono);
font-size: 0.75rem;
letter-spacing: 1.5px;
font-weight: 700;
border: 1px solid var(--accent-color);
cursor: pointer;
transition: all 0.3s;
}
a.button:hover {
background: rgba(0, 102, 204, 0.05);
color: #00aaff;
border-color: #00aaff;
box-shadow: 0 0 15px rgba(0, 102, 204, 0.5);
}
.secondary-link {
display: block;
margin-top: 15px;
font-family: var(--font-mono);
font-size: 0.7rem;
color: #999;
text-decoration: none;
}
.secondary-link:hover { text-decoration: underline; }
/* Error Message */
.error-message {
margin-top: 15px;
padding: 10px;
background: rgba(255, 51, 102, 0.1);
border: 1px solid var(--secondary-color);
color: var(--secondary-color);
font-family: var(--font-mono);
font-size: 0.75rem;
text-align: left;
display: none;
}
.error-message.visible {
display: block;
animation: error-shake 0.5s;
}
@keyframes error-shake {
0%, 100% { transform: translateX(0); }
25% { transform: translateX(-5px); }
75% { transform: translateX(5px); }
}
/* Footer */
footer {
position: fixed;
bottom: 20px;
width: 100%;
text-align: center;
font-family: var(--font-mono);
font-size: 0.7rem;
color: #999;
pointer-events: none;
}
/* Glitch effect */
.glitch-wrapper { position: relative; }
/* Scanlines */
.scanlines {
position: fixed;
left: 0; top: 0; width: 100vw; height: 100vh;
background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.02) 50%),
linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
background-size: 100% 4px, 6px 100%;
pointer-events: none;
z-index: 100;
}
/* Initialize Button */
#init-button {
position: fixed;
bottom: 80px;
left: 50%;
transform: translateX(-50%);
z-index: 20;
font-family: var(--font-mono);
font-size: 0.75rem;
padding: 10px 30px;
background: transparent;
color: var(--accent-color);
border: 1px solid var(--accent-color);
cursor: pointer;
transition: all 0.3s ease;
letter-spacing: 1.5px;
text-transform: uppercase;
animation: pulse 2s infinite;
pointer-events: auto;
}
@keyframes pulse {
0% {
opacity: 0.6;
box-shadow: 0 0 5px rgba(0, 102, 204, 0.3);
}
50% {
opacity: 1;
box-shadow: 0 0 15px rgba(0, 102, 204, 0.6);
}
100% {
opacity: 0.6;
box-shadow: 0 0 5px rgba(0, 102, 204, 0.3);
}
}
#init-button:hover {
background: rgba(0, 102, 204, 0.05);
color: #00aaff;
border-color: #00aaff;
box-shadow: 0 0 20px rgba(0, 102, 204, 0.8);
animation: none; /* 停止呼吸,保持高亮 */
}
</style>
</head>
<body>
<div class="scanlines"></div>
<div id="canvas-container"></div>
<div class="title-overlay">
<h1 id="main-title" class="glitch-wrapper"></h1>
<div class="subtitle" id="subtitle-text"></div>
</div>
<button id="init-button">[ CLICK TO INITIALIZE ]</button>
<div class="main-container">
<!-- Login Box (Hidden Initially) -->
<div class="content-box" id="login-panel">
<div class="close-btn" id="close-login"></div>
<div style="margin-bottom: 20px; font-family: var(--font-mono); font-size: 0.8rem; color: var(--accent-color);">
> AUTHENTICATION REQUIRED
</div>
<div class="input-group">
<label class="input-label">IDENTITY</label>
<input type="text" class="styled-input" id="username-input" placeholder="GHOST_ID" autocomplete="username">
</div>
<div class="input-group">
<label class="input-label">PASSPHRASE</label>
<input type="password" class="styled-input" id="password-input" placeholder="********" autocomplete="current-password">
</div>
<a href="#" class="button" id="login-btn">LOG IN</a>
<div class="error-message" id="error-msg">
> ERROR: AUTHENTICATION FAILED<br>
> Invalid credentials or insufficient privileges<br>
> Access to Layer 0 denied
</div>
<div id="success-msg" style="margin-top: 15px; padding: 10px; background: rgba(0, 102, 204, 0.1); border: 1px solid var(--accent-color); color: var(--accent-color); font-family: var(--font-mono); font-size: 0.75rem; text-align: left; display: none;">
> AUTHENTICATION SUCCESSFUL<br>
> Redirecting to Layer 0...
</div>
<a href="architecture.html" class="secondary-link">> VIEW SYSTEM ARCHITECTURE</a>
</div>
</div>
<footer>
WORLDSHELL INITIATIVE // TERMINAL_ID: 0x88A // LAYER 0<br>
粤ICP备2025509028号
</footer>
<script>
// --- SHADERS ---
// 我们在这里定义 Shader,用来实现那个"流动能量球"的效果
const vertexShader = `
varying vec2 vUv;
varying vec3 vPosition;
varying vec3 vNormal;
void main() {
vUv = uv;
vPosition = position;
vNormal = normalize(normalMatrix * normal);
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
`;
const fragmentShader = `
uniform float time;
uniform vec3 color;
varying vec2 vUv;
varying vec3 vPosition;
varying vec3 vNormal;
// --- Simplex 3D Noise 函数 (标准算法) ---
vec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }
vec4 mod289(vec4 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }
vec4 permute(vec4 x) { return mod289(((x*34.0)+1.0)*x); }
vec4 taylorInvSqrt(vec4 r) { return 1.79284291400159 - 0.85373472095314 * r; }
float snoise(vec3 v) {
const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;
const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
vec3 i = floor(v + dot(v, C.yyy) );
vec3 x0 = v - i + dot(i, C.xxx) ;
vec3 g = step(x0.yzx, x0.xyz);
vec3 l = 1.0 - g;
vec3 i1 = min( g.xyz, l.zxy );
vec3 i2 = max( g.xyz, l.zxy );
vec3 x1 = x0 - i1 + 1.0 * C.xxx;
vec3 x2 = x0 - i2 + 2.0 * C.xxx;
vec3 x3 = x0 - 1.0 + 3.0 * C.xxx;
i = mod289(i);
vec4 p = permute( permute( permute(
i.z + vec4(0.0, i1.z, i2.z, 1.0 ))
+ i.y + vec4(0.0, i1.y, i2.y, 1.0 ))
+ i.x + vec4(0.0, i1.x, i2.x, 1.0 ));
float n_ = 1.0/7.0;
vec3 ns = n_ * D.wyz - D.xzx;
vec4 j = p - 49.0 * floor(p * ns.z *ns.z);
vec4 x_ = floor(j * ns.z);
vec4 y_ = floor(j - 7.0 * x_ );
vec4 x = x_ *ns.x + ns.yyyy;
vec4 y = y_ *ns.x + ns.yyyy;
vec4 h = 1.0 - abs(x) - abs(y);
vec4 b0 = vec4( x.xy, y.xy );
vec4 b1 = vec4( x.zw, y.zw );
vec4 s0 = floor(b0)*2.0 + 1.0;
vec4 s1 = floor(b1)*2.0 + 1.0;
vec4 sh = -step(h, vec4(0.0));
vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;
vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;
vec3 p0 = vec3(a0.xy,h.x);
vec3 p1 = vec3(a0.zw,h.y);
vec3 p2 = vec3(a1.xy,h.z);
vec3 p3 = vec3(a1.zw,h.w);
vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));
p0 *= norm.x; p1 *= norm.y; p2 *= norm.z; p3 *= norm.w;
vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);
m = m * m;
return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1), dot(p2,x2), dot(p3,x3) ) );
}
void main() {
// 1. Fresnel Effect (边缘发光)
vec3 viewDirection = normalize(cameraPosition - vPosition);
float fresnel = dot(viewDirection, vNormal);
fresnel = clamp(1.0 - fresnel, 0.0, 1.0);
fresnel = pow(fresnel, 1.5); // 调整指数控制边缘宽度
// 2. Noise (流动纹理)
// 使用位置 + 时间作为参数,让噪点动起来
float noiseValue = snoise(vPosition * 2.5 + time * 0.4);
// 3. 组合颜色
// 基础色 + 菲涅尔亮边 + 噪点变化
vec3 finalColor = color + (vec3(1.0) * fresnel * 0.5);
// 降低透明度,让核心更通透飘渺
// 边缘亮一些,中心更透明
float alpha = 0.15 + (fresnel * 0.35) + (noiseValue * 0.1);
gl_FragColor = vec4(finalColor, alpha);
}
`;
// THREE.JS SETUP
const container = document.getElementById('canvas-container');
const scene = new THREE.Scene();
scene.fog = new THREE.FogExp2(0xffffff, 0.02);
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.z = 5;
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setClearColor(0xffffff, 0);
container.appendChild(renderer.domElement);
// Raycaster for interaction
const raycaster = new THREE.Raycaster();
const mouse = new THREE.Vector2();
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
// --- OBJECTS ---
const group = new THREE.Group();
scene.add(group);
// 1. The "Shell" - Outer Wireframe
const geometry = new THREE.IcosahedronGeometry(2.2, 2);
const material = new THREE.MeshBasicMaterial({
color: 0x222222,
wireframe: true,
transparent: true,
opacity: 0.3,
depthWrite: false, // 不写深度,避免遮挡核心
depthTest: true // 读取深度,会被核心遮挡
});
const shell = new THREE.Mesh(geometry, material);
shell.renderOrder = 1; // 后渲染
group.add(shell);
// 2. Inner Core - Shader Material (Flowing Energy)
const coreGeo = new THREE.IcosahedronGeometry(0.8, 4); // 增加细分程度(4)以获得更好的噪点效果
const coreMat = new THREE.ShaderMaterial({
vertexShader: vertexShader,
fragmentShader: fragmentShader,
uniforms: {
time: { value: 0 },
color: { value: new THREE.Color(0x3399ff) } // 更亮的蓝色,增加飘渺感
},
transparent: true,
side: THREE.DoubleSide,
depthWrite: true, // 写入深度,这样能遮挡后面的物体
depthTest: true, // 读取深度,这样不会被前面的物体穿透
blending: THREE.NormalBlending // 使用普通混合
});
const core = new THREE.Mesh(coreGeo, coreMat);
core.renderOrder = 0; // 先渲染核心,让它写入深度
group.add(core);
// 4. Particles
const particlesGeometry = new THREE.BufferGeometry();
const particleCount = 1200;
const posArray = new Float32Array(particleCount * 3);
for(let i = 0; i < particleCount * 3; i++) {
posArray[i] = (Math.random() - 0.5) * 15;
}
particlesGeometry.setAttribute('position', new THREE.BufferAttribute(posArray, 3));
const particlesMaterial = new THREE.PointsMaterial({
size: 0.04,
color: 0x0066cc,
transparent: true,
opacity: 0.6
});
const particlesMesh = new THREE.Points(particlesGeometry, particlesMaterial);
scene.add(particlesMesh);
// 5. Rings
const ringGeo = new THREE.TorusGeometry(3.5, 0.02, 16, 100);
const ringMat = new THREE.MeshBasicMaterial({
color: 0xff3366,
transparent: true,
opacity: 0.6,
depthWrite: false, // 不写深度
depthTest: true // 读取深度,会被核心遮挡
});
const ring = new THREE.Mesh(ringGeo, ringMat);
ring.rotation.x = Math.PI / 2;
ring.rotation.y = Math.PI / 6;
ring.renderOrder = 2; // 后渲染
group.add(ring);
const ring2 = ring.clone();
ring2.rotation.x = -Math.PI / 3;
ring2.scale.set(0.8, 0.8, 0.8);
ring2.renderOrder = 2; // 后渲染
ring2.material = ringMat.clone(); // 克隆材质避免共享
group.add(ring2);
// Animation Loop
const clock = new THREE.Clock();
let mouseX = 0;
let mouseY = 0;
let isExpanded = false;
document.addEventListener('mousemove', (event) => {
mouseX = (event.clientX - window.innerWidth / 2) * 0.001;
mouseY = (event.clientY - window.innerHeight / 2) * 0.001;
// Raycaster update
mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1;
mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
});
function animate() {
requestAnimationFrame(animate);
const elapsedTime = clock.getElapsedTime();
// Interaction: if not expanded, allow rotation
if (!isExpanded) {
group.rotation.y += 0.05 * (mouseX - group.rotation.y);
group.rotation.x += 0.05 * (mouseY - group.rotation.x);
group.rotation.y += 0.002;
} else {
// Slow rotation when login open
group.rotation.y += 0.0005;
}
// Pulse Core
// Update Shader Time
coreMat.uniforms.time.value = elapsedTime;
const pulse = 1 + Math.sin(elapsedTime * 2.5) * 0.05;
core.scale.set(pulse, pulse, pulse);
shell.scale.set(1.05, 1.05, 1.05);
particlesMesh.rotation.y = -elapsedTime * 0.05;
ring.rotation.z += 0.01;
ring.rotation.y += 0.005;
ring2.rotation.z -= 0.015;
ring2.rotation.x += 0.008;
renderer.render(scene, camera);
}
animate();
// Button Click Handler
document.getElementById('init-button').addEventListener('click', () => {
if (!isExpanded) {
window.location.href = 'under-construction.html';
}
});
function revealLogin() {
isExpanded = true;
document.getElementById('login-panel').classList.add('visible');
document.getElementById('init-button').style.display = 'none';
// Camera Zoom Effect - 缓慢推进
let targetZ = 3.5;
let currentZ = camera.position.z;
// 使用缓动函数实现平滑缓慢的 zoom
function zoomIn() {
if (camera.position.z > targetZ) {
// 每帧只移动剩余距离的 2%,产生缓慢减速效果
camera.position.z -= (camera.position.z - targetZ) * 0.02;
// 当距离很小时停止
if (Math.abs(camera.position.z - targetZ) > 0.01) {
requestAnimationFrame(zoomIn);
} else {
camera.position.z = targetZ;
}
}
}
zoomIn();
}
// 登录函数
async function handleLogin() {
console.log('Login function called');
const username = document.getElementById('username-input').value.trim();
const password = document.getElementById('password-input').value;
const errorMsg = document.getElementById('error-msg');
const successMsg = document.getElementById('success-msg');
const loginBtn = document.getElementById('login-btn');
console.log('Username:', username ? 'provided' : 'empty');
console.log('Password:', password ? 'provided' : 'empty');
// 隐藏之前的消息
errorMsg.classList.remove('visible');
successMsg.style.display = 'none';
// 验证输入
if (!username || !password) {
console.log('Validation failed: empty fields');
// 如果用户名和密码都为空,跳转到施工页面
if (!username && !password) {
window.location.href = 'under-construction.html';
return;
}
// 如果只缺少其中一个,显示错误消息
errorMsg.innerHTML = '> ERROR: AUTHENTICATION FAILED<br>' +
'> Please enter both username and password<br>' +
'> Access to Layer 0 denied';
errorMsg.classList.add('visible');
setTimeout(() => {
errorMsg.classList.remove('visible');
}, 3000);
return;
}
// 显示加载状态
const originalText = loginBtn.textContent;
loginBtn.textContent = 'AUTHENTICATING...';
loginBtn.style.pointerEvents = 'none';
// 获取当前页面的主机名,构建8000端口的URL
const currentHost = window.location.hostname;
const authUrl = `http://${currentHost}:8000/`;
console.log('Attempting login to:', authUrl);
console.log('Current location:', window.location.href);
// 由于CORS限制,直接使用URL中包含认证信息的方式跳转
// 这是最可靠的方式,浏览器会自动处理Basic Auth
try {
// 先尝试fetch验证(可能会因为CORS失败,但不影响后续跳转)
try {
const response = await fetch(authUrl, {
method: 'GET',
headers: {
'Authorization': 'Basic ' + btoa(username + ':' + password)
},
credentials: 'omit',
mode: 'cors'
});
console.log('Fetch response status:', response.status);
if (response.status === 200 || response.ok) {
// 认证成功
successMsg.style.display = 'block';
loginBtn.textContent = 'SUCCESS';
setTimeout(() => {
window.location.href = authUrl;
}, 1000);
return;
} else if (response.status === 401) {
// 401 - 认证失败
throw new Error('Invalid credentials');
}
} catch (fetchError) {
console.log('Fetch failed (likely CORS):', fetchError.message);
// 继续使用URL方式跳转
}
// 使用URL中包含认证信息的方式跳转(备用方案)
// 格式:http://username:password@host:port/
const authUrlWithCreds = `http://${encodeURIComponent(username)}:${encodeURIComponent(password)}@${currentHost}:8000/`;
console.log('Using URL-based auth, redirecting...');
// 显示成功消息
successMsg.style.display = 'block';
loginBtn.textContent = 'REDIRECTING...';
// 立即跳转
window.location.href = authUrlWithCreds;
} catch (error) {
console.error('Login error:', error);
errorMsg.innerHTML = '> ERROR: AUTHENTICATION FAILED<br>' +
'> ' + error.message + '<br>' +
'> Please check your credentials';
errorMsg.classList.add('visible');
loginBtn.textContent = originalText;
loginBtn.style.pointerEvents = 'auto';
setTimeout(() => {
errorMsg.classList.remove('visible');
}, 3000);
}
}
// 登录按钮点击事件
document.getElementById('login-btn').addEventListener('click', (e) => {
e.preventDefault();
e.stopPropagation();
console.log('Login button clicked');
handleLogin();
});
// 支持回车键提交
document.getElementById('password-input').addEventListener('keypress', (e) => {
if (e.key === 'Enter') {
document.getElementById('login-btn').click();
}
});
// 关闭登录框
document.getElementById('close-login').addEventListener('click', () => {
isExpanded = false;
document.getElementById('login-panel').classList.remove('visible');
document.getElementById('init-button').style.display = 'block';
// 缓慢后退
function zoomOut() {
if (camera.position.z < 5) {
camera.position.z += (5 - camera.position.z) * 0.02;
if (Math.abs(camera.position.z - 5) > 0.01) {
requestAnimationFrame(zoomOut);
} else {
camera.position.z = 5;
}
}
}
zoomOut();
});
// Subtitle Typewriter with Loop
const subtitleElement = document.getElementById('subtitle-text');
const subtitleTexts = [
"Bounded in the Shell, Counting Ourselves Kings of Infinite Space",
"THERE IS NO BEDRØCK // ØNLY THE NEXΤ SH∑LL",
"ΛS ΛBOVΞ, SO BΞLOW. RΞCURSIVΞ ∞ FOREVER."
];
let currentTextIndex = 0;
async function typeText(text) {
for (let i = 0; i < text.length; i++) {
subtitleElement.textContent += text.charAt(i);
await new Promise(r => setTimeout(r, 40));
}
}
async function deleteText() {
const currentText = subtitleElement.textContent;
for (let i = currentText.length; i > 0; i--) {
subtitleElement.textContent = currentText.substring(0, i - 1);
await new Promise(r => setTimeout(r, 20)); // 删除比打字快
}
}
async function subtitleLoop() {
// 打字
await typeText(subtitleTexts[currentTextIndex]);
// 暂停 3 秒
await new Promise(r => setTimeout(r, 3000));
// 删除
await deleteText();
// 暂停 0.5 秒
await new Promise(r => setTimeout(r, 500));
// 切换到下一句
currentTextIndex = (currentTextIndex + 1) % subtitleTexts.length;
// 递归循环
subtitleLoop();
}
// 初始延迟后开始
setTimeout(() => {
subtitleLoop();
}, 800);
// Glitch Effect: Random single letter switch to exotic characters
const titleElement = document.getElementById('main-title');
const originalText = 'WØRLDSHELL';
// 异世界字符池(希腊、西里尔、片假名、数学符号、卢恩文、盲文等)
const glitchChars = [
// 希腊字母
'Γ', 'Δ', 'Θ', 'Λ', 'Ξ', 'Π', 'Σ', 'Φ', 'Ψ', 'Ω',
// 西里尔字母
'Ф', 'Ж', 'Д',
// 半角片假名
'ア', 'イ', 'ウ', 'エ', 'オ', 'カ', 'キ', 'ク', 'ケ', 'コ', 'サ', 'シ', 'ス', 'セ', 'ソ',
'タ', 'チ', 'ツ', 'テ', 'ト', 'ナ', 'ニ', 'ヌ', 'ネ', 'ノ',
'ハ', 'ヒ', 'フ', 'ヘ', 'ホ', 'マ', 'ミ', 'ム', 'メ', 'モ',
'ヤ', 'ユ', 'ヨ', 'ラ', 'リ', 'ル', 'レ', 'ロ', 'ワ', 'ヲ', 'ン',
// 数学符号
'∀', '∃', '∅', '∇', '∫', '≠', '≡', '∑',
// 方块字符
'█', '▌', '▍', '▎',
// 卢恩符文
'ᚠ', 'ᚢ', 'ᚦ', 'ᚨ', 'ᚱ', 'ᚲ', 'ᚷ', 'ᚹ', 'ᚺ', 'ᚾ', 'ᛁ', 'ᛃ', 'ᛈ', 'ᛉ', 'ᛊ', 'ᛏ', 'ᛒ', 'ᛖ', 'ᛗ', 'ᛚ', 'ᛜ', 'ᛞ', 'ᛟ',
// 盲文点字
'⣿', '⣸', '⣯', '⣦', '⣛', '⠇', '⠕', '⠳', '⠿',
// 其他异文字
'Ⳉ', 'Ⳙ', 'ⴲ', 'ⴵ', 'ⵋ'
];
// Zalgo 组合符号(用于制造文字扭曲效果)
const zalgoMarks = [
'\u0300', '\u0301', '\u0302', '\u0303', '\u0304', '\u0305', '\u0306', '\u0307',
'\u0308', '\u0309', '\u030A', '\u030B', '\u030C', '\u030D', '\u030E', '\u030F',
'\u0310', '\u0311', '\u0312', '\u0313', '\u0314', '\u0315', '\u0316', '\u0317',
'\u0318', '\u0319', '\u031A', '\u031B', '\u031C', '\u031D', '\u031E', '\u031F',
'\u0320', '\u0321', '\u0322', '\u0323', '\u0324', '\u0325', '\u0326', '\u0327',
'\u0328', '\u0329', '\u032A', '\u032B', '\u032C', '\u032D', '\u032E', '\u032F',
'\u0330', '\u0331', '\u0332', '\u0333', '\u0334', '\u0335', '\u0336', '\u0337',
'\u0338', '\u0339', '\u033A', '\u033B', '\u033C', '\u033D', '\u033E', '\u033F'
];
// 初始化:将文本拆分为单独的 span
const letterSpans = [];
const specialChars = ['Ø', 'Ξ', 'Ψ', 'Φ', 'Θ']; // 需要用后备字体的字符
originalText.split('').forEach((char, index) => {
const span = document.createElement('span');
span.className = 'letter';
// 如果是特殊字符,添加额外的 class
if (specialChars.includes(char)) {
span.classList.add('special-char');
}
span.textContent = char;
span.dataset.index = index;
span.dataset.original = char;
titleElement.appendChild(span);
letterSpans.push(span);
});
let isGlitching = false;
function triggerGlitch() {
if (isGlitching) return;
isGlitching = true;
// 随机选择 1-3 个字母
const glitchCount = 1 + Math.floor(Math.random() * 3);
const indices = [];
// 随机选择不重复的位置
while (indices.length < glitchCount) {
const randomIndex = Math.floor(Math.random() * letterSpans.length);
if (!indices.includes(randomIndex)) {
indices.push(randomIndex);
}
}
const targets = [];
// 为每个选中的字母准备 glitch
indices.forEach(index => {