-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviewer.html
More file actions
2146 lines (1846 loc) · 91.3 KB
/
viewer.html
File metadata and controls
2146 lines (1846 loc) · 91.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="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>3DGS Artistic Viewer</title>
<!-- 引入优雅的衬线字体 -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;1,400&family=Inter:wght@300;400;500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@300;500;700&display=swap" rel="stylesheet">
<style>
:root {
/* Palette: Art Gallery / Dark Luxury */
--bg-color: #121212;
--bg-gradient-center: #1a1a1a;
/* 玻璃拟态:高透、极薄边框 */
--glass-surface: rgba(20, 20, 20, 0.6);
--glass-border: rgba(255, 255, 255, 0.08);
--glass-highlight: rgba(255, 255, 255, 0.05);
/* 香槟金点缀 */
--accent-primary: #d4af37;
--accent-glow: rgba(212, 175, 55, 0.15);
--text-main: #e0e0e0;
--text-muted: #666;
--font-serif: 'Cormorant Garamond', 'Noto Serif SC', serif;
--font-ui: 'Inter', 'Noto Serif SC', sans-serif;
}
body {
margin: 0; overflow: hidden; background-color: var(--bg-color);
font-family: var(--font-ui); color: var(--text-main);
-webkit-font-smoothing: antialiased;
font-weight: 300;
}
#canvas-container {
width: 100vw; height: 100vh; display: block;
background: radial-gradient(circle at center, var(--bg-gradient-center) 0%, var(--bg-color) 80%);
}
/* --- UI 模块通用样式 --- */
.hud-panel {
position: absolute;
background: var(--glass-surface);
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
border: 1px solid var(--glass-border);
padding: 16px 24px;
border-radius: 4px; /* 硬朗的圆角 */
transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
pointer-events: auto;
z-index: 10;
}
.hud-panel:hover {
background: rgba(30, 30, 30, 0.8);
border-color: rgba(255,255,255,0.15);
box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
/* 隐藏 UI 时的状态 */
body.ui-hidden .hud-panel {
opacity: 0;
transform: translateY(20px);
pointer-events: none;
}
body.ui-hidden #top-header, body.ui-hidden #top-stats {
transform: translateY(-20px);
}
body.ui-hidden #watermark { opacity: 0; }
/* --- 1. 顶部标题 (左上) --- */
#top-header {
top: 30px; left: 30px;
background: transparent; border: none; padding: 0;
backdrop-filter: none; pointer-events: auto; /* Allow interaction for lang btn */
display: flex; flex-direction: column; align-items: flex-start;
}
h1 {
font-family: var(--font-serif); font-size: 2.2rem; font-weight: 400; margin: 0;
color: var(--accent-primary); letter-spacing: 1px; font-style: italic;
text-shadow: 0 20px 40px rgba(0,0,0,0.5);
}
.header-row {
display: flex; align-items: center; gap: 12px; margin-top: 4px;
}
.subtitle {
font-size: 0.6rem; text-transform: uppercase; letter-spacing: 4px;
color: var(--text-muted); display: block;
}
/* 语言切换按钮 */
.lang-btn {
background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border);
color: var(--text-muted); font-size: 0.6rem; padding: 2px 6px;
border-radius: 2px; cursor: pointer; transition: all 0.3s;
font-family: var(--font-ui); letter-spacing: 1px;
}
.lang-btn:hover {
background: var(--accent-primary); color: #000; border-color: var(--accent-primary);
}
/* --- 2. 顶部状态 (右上) --- */
#top-stats {
top: 30px; right: 30px;
display: flex; gap: 30px;
background: transparent; border: none; padding: 0;
backdrop-filter: none; pointer-events: none;
}
.stat-item { text-align: right; }
.stat-value { font-family: var(--font-ui); font-size: 1.1rem; color: var(--text-main); font-weight: 300; display: block;}
.stat-label { font-size: 0.6rem; color: var(--text-muted); letter-spacing: 1px; text-transform: uppercase; margin-top: 2px; display: block;}
/* --- 3. 底部控制台 (底部中央) --- */
#control-deck {
bottom: 30px; left: 50%; transform: translateX(-50%);
display: flex; align-items: center; gap: 32px;
padding: 16px 32px;
border-radius: 50px; /* 胶囊形状 */
height: 50px; /* 固定高度 */
z-index: 20; /* 确保在 Flow Panel 之上 */
}
.slider-group {
display: flex; flex-direction: column; gap: 4px;
width: 120px;
position: relative;
}
.slider-group label {
font-size: 0.6rem; color: var(--text-muted); letter-spacing: 1px; text-transform: uppercase;
position: absolute; top: -18px; left: 0; width: 100%; text-align: center;
}
input[type="range"] {
-webkit-appearance: none; width: 100%; height: 2px;
background: rgba(255,255,255,0.2);
margin: 0; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none; width: 10px; height: 10px;
background: var(--text-main); border-radius: 50%;
transition: transform 0.2s, background 0.2s;
margin-top: -4px; /* 居中 */
}
input[type="range"]::-webkit-slider-thumb:hover {
transform: scale(1.5); background: var(--accent-primary);
}
/* 轨道背景修正 */
input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: transparent; }
.deck-divider { width: 1px; height: 24px; background: rgba(255,255,255,0.1); }
.icon-btn {
background: transparent; border: none; color: var(--text-main);
cursor: pointer; padding: 8px; border-radius: 50%;
transition: all 0.2s; display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--accent-primary); background: rgba(255,255,255,0.05); }
.icon-btn.active { color: #000; background: var(--accent-primary); box-shadow: 0 0 15px var(--accent-glow); }
.icon-btn svg { width: 20px; height: 20px; }
/* --- 新增:流体设置面板 (控制台上方) --- */
#flow-panel {
bottom: 95px; left: 50%; transform: translateX(-50%) translateY(10px);
display: flex; gap: 24px; padding: 12px 24px;
border-radius: 30px;
opacity: 0; pointer-events: none;
transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
z-index: 15;
}
#flow-panel.visible {
opacity: 1; pointer-events: auto;
transform: translateX(-50%) translateY(0);
}
#flow-panel .slider-group { width: 80px; } /* 更紧凑 */
/* --- 4. 导入模块 (底部左侧) --- */
#import-panel {
bottom: 30px; left: 30px;
width: 180px; padding: 0;
overflow: hidden;
display: flex; flex-direction: column;
}
.drop-zone {
padding: 20px; text-align: center; cursor: pointer;
transition: all 0.3s;
}
.drop-zone:hover { background: rgba(255,255,255,0.02); }
.drop-zone:hover .drop-icon { color: var(--accent-primary); transform: scale(1.1); }
.drop-icon { display: block; font-size: 1.2rem; color: var(--text-muted); margin-bottom: 8px; transition: transform 0.3s; }
.drop-text { font-family: var(--font-serif); font-size: 1rem; color: var(--text-main); }
.drop-sub { font-size: 0.65rem; color: var(--text-muted); margin-top: 4px; }
/* Model List Panel */
#model-list-panel {
position: absolute;
top: 100px;
left: 30px;
width: 220px;
max-height: 300px;
overflow-y: auto;
display: none;
scrollbar-width: thin;
scrollbar-color: var(--accent-primary) transparent;
z-index: 5;
}
#model-list-panel::-webkit-scrollbar { width: 4px; }
#model-list-panel::-webkit-scrollbar-thumb { background: var(--accent-primary); border-radius: 2px; }
#model-list-panel.visible { display: block; }
.model-item {
padding: 12px 16px;
margin-bottom: 8px;
background: rgba(255,255,255,0.03);
border: 1px solid rgba(255,255,255,0.05);
border-radius: 4px;
cursor: pointer;
transition: all 0.2s;
position: relative;
}
.model-item:hover {
background: rgba(255,255,255,0.06);
border-color: rgba(212, 175, 55, 0.3);
}
.model-item.active {
border-color: var(--accent-primary);
background: rgba(212, 175, 55, 0.1);
}
.model-item-name {
font-size: 0.75rem;
color: var(--text-main);
font-weight: 500;
margin-bottom: 4px;
}
.model-item-info {
display: flex;
justify-content: space-between;
color: var(--text-muted);
font-size: 0.65rem;
}
.model-item-actions {
display: flex;
gap: 8px;
margin-top: 6px;
}
.model-btn {
flex: 1;
padding: 4px 8px;
font-size: 0.6rem;
background: rgba(255,255,255,0.05);
border: 1px solid rgba(255,255,255,0.1);
color: var(--text-muted);
border-radius: 2px;
cursor: pointer;
transition: all 0.2s;
}
.model-btn:hover {
background: var(--accent-primary);
color: #000;
border-color: var(--accent-primary);
}
.model-btn.delete:hover {
background: #ff4444;
border-color: #ff4444;
}
/* --- 5. 导航指南 (底部右侧) --- */
#nav-hint {
bottom: 30px; right: 30px;
text-align: right;
border: none; background: transparent; backdrop-filter: none;
pointer-events: none;
min-width: 140px;
}
.key-row { margin-bottom: 6px; font-size: 0.75rem; color: var(--text-muted); }
.kbd {
color: var(--accent-primary); font-family: var(--font-serif); font-style: italic;
margin-right: 6px; font-weight: 600;
}
/* 社交媒体链接样式 */
#social-links {
margin-top: 12px; border-top: 1px solid rgba(255,255,255,0.1); padding-top: 12px;
display: flex; flex-direction: column; gap: 8px; pointer-events: auto;
}
.social-link {
display: flex; align-items: center; justify-content: flex-end; gap: 8px;
text-decoration: none; color: var(--text-muted); font-size: 0.75rem;
transition: all 0.2s;
}
.social-link:hover { color: var(--accent-primary); transform: translateX(-4px); }
.social-link svg { width: 14px; height: 14px; opacity: 0.8; }
/* --- Watermark (Updated with Image) --- */
#watermark {
position: absolute; bottom: 10px; right: 30px;
color: var(--text-muted); font-size: 0.55rem;
font-family: var(--font-ui); letter-spacing: 1px;
opacity: 0.6; pointer-events: none; z-index: 10;
transition: opacity 0.4s;
/* Flex layout for image + text */
display: flex; align-items: center; gap: 8px;
}
#watermark img {
height: 24px; /* Scale down the 1080px image to UI scale */
width: auto;
border-radius: 4px; /* Soft rounding instead of full circle to prevent cropping */
filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}
/* --- 开关按钮 --- */
#toggle-ui-btn {
position: absolute; bottom: 30px; right: 30px;
/* 把它放在导航提示上方一点,或者让它不那么显眼 */
display: none; /* 这种布局下可以隐藏,通过键盘H控制,或者放在右上角 */
}
/* Loading Overlay with Interaction */
#loading-overlay {
position: absolute; inset: 0; background: #121212;
z-index: 100;
display: flex; flex-direction: column; align-items: center; justify-content: center;
opacity: 0; pointer-events: none; transition: opacity 0.8s ease;
cursor: none; overflow: hidden;
}
#loading-overlay.active { opacity: 1; pointer-events: auto; }
#loading-canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 0; opacity: 1.0; }
.loading-content {
position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center;
pointer-events: none; width: 100%; max-width: 400px;
background: rgba(18, 18, 18, 0.4); padding: 20px; border-radius: 20px; backdrop-filter: blur(5px);
}
.loader {
width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.1);
border-top-color: var(--accent-primary); animation: spin 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
margin-bottom: 24px; box-shadow: 0 0 30px rgba(212, 175, 55, 0.1);
}
#loading-text {
font-family: var(--font-serif); font-size: 1.2rem; letter-spacing: 2px; color: var(--text-main); font-style: italic;
text-shadow: 0 2px 10px rgba(0,0,0,0.5); margin-bottom: 10px;
}
#tutorial-text {
font-family: var(--font-ui); font-size: 0.8rem; letter-spacing: 1px; color: var(--accent-primary); text-transform: uppercase;
margin-bottom: 20px; animation: blink 2s infinite;
}
@keyframes blink { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }
.progress-container { width: 200px; height: 2px; background: rgba(255,255,255,0.1); position: relative; margin-bottom: 16px; overflow: hidden; }
.progress-bar { position: absolute; top: 0; left: 0; bottom: 0; width: 0%; background: var(--accent-primary); box-shadow: 0 0 10px var(--accent-glow); transition: width 0.2s linear; }
#loading-quote { font-family: var(--font-serif); font-style: italic; color: var(--text-muted); font-size: 0.95rem; opacity: 0.8; max-width: 400px; text-align: center; min-height: 1.5em; transition: opacity 0.5s; }
@keyframes spin { 100% { transform: rotate(360deg); } }
</style>
<script type="importmap">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.module.js",
"three/addons/": "https://cdn.jsdelivr.net/npm/three@0.160.0/examples/jsm/"
}
}
</script>
</head>
<body>
<!-- Loading Screen -->
<div id="loading-overlay" class="active">
<canvas id="loading-canvas"></canvas>
<div class="loading-content">
<div class="loader"></div>
<div id="loading-text" data-key="loading_init">INITIALIZING SYSTEM</div>
<div id="tutorial-text" data-key="tutorial_text">[ WASD ] TO FLY & COLLECT</div>
<div class="progress-container"><div class="progress-bar" id="loading-bar"></div></div>
<div id="loading-quote">"Light is the first of painters."</div>
</div>
</div>
<!-- 1. Top Header -->
<div id="top-header" class="hud-panel">
<h1>3DGS.ART</h1>
<div class="header-row">
<span class="subtitle" data-key="subtitle">HIGH FIDELITY VIEWER .01</span>
<button class="lang-btn" onclick="toggleLanguage()">中 / EN</button>
</div>
</div>
<!-- 2. Top Stats -->
<div id="top-stats" class="hud-panel">
<div class="stat-item">
<span class="stat-value" id="stat-points">--</span>
<span class="stat-label" data-key="stat_points">Points</span>
</div>
<div class="stat-item">
<span class="stat-value" id="stat-fps">--</span>
<span class="stat-label" data-key="stat_fps">FPS</span>
</div>
</div>
<!-- Extra: Flow Settings Panel (Hidden by default) -->
<div id="flow-panel" class="hud-panel">
<div class="slider-group">
<label data-key="flow_amp">Amp</label>
<input type="range" min="1.0" max="20.0" step="0.5" value="8.0" id="input-flow-amp" title="Dispersion Amount">
</div>
<div class="deck-divider"></div>
<div class="slider-group">
<label data-key="flow_freq">Freq</label>
<input type="range" min="0.1" max="1.0" step="0.1" value="0.3" id="input-flow-freq" title="Noise Frequency">
</div>
<div class="deck-divider"></div>
<div class="slider-group">
<label data-key="flow_speed">Speed</label>
<input type="range" min="0.1" max="2.0" step="0.1" value="0.6" id="input-flow-speed" title="Flow Speed">
</div>
</div>
<!-- 3. Control Deck (Center Bottom) -->
<div id="control-deck" class="hud-panel">
<!-- Scale (Default 2.5) -->
<div class="slider-group">
<label data-key="ctrl_scale">Scale</label>
<input type="range" min="0.1" max="3.0" step="0.1" value="2.5" id="input-scale" title="Splat Scale">
</div>
<div class="deck-divider"></div>
<!-- Opacity -->
<div class="slider-group">
<label data-key="ctrl_opacity">Opacity</label>
<input type="range" min="0.1" max="2.0" step="0.1" value="1.0" id="input-opacity" title="Global Opacity">
</div>
<div class="deck-divider"></div>
<!-- Exposure -->
<div class="slider-group">
<label data-key="ctrl_exposure">Exposure</label>
<input type="range" min="0.5" max="3.0" step="0.1" value="1.0" id="input-brightness" title="Exposure">
</div>
<div class="deck-divider"></div>
<!-- Speed (New) -->
<div class="slider-group">
<label data-key="ctrl_speed">Speed</label>
<input type="range" min="1" max="100" step="1" value="10" id="input-speed" title="Camera Speed">
</div>
<div class="deck-divider"></div>
<!-- Turbulence Toggle (New) -->
<button class="icon-btn" onclick="toggleTurbulence()" id="btn-flow" title="Dispersion Flow">
<!-- Wave Icon -->
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M2 12c.6 0 1.2.4 1.6.9.6.7 1.4 1.1 2.4 1.1 1.9 0 2.4-1.9 4.4-1.9 1 0 1.8.4 2.4 1.1.4.5 1 .9 1.6.9"/>
<path d="M2 8c.6 0 1.2.4 1.6.9.6.7 1.4 1.1 2.4 1.1 1.9 0 2.4-1.9 4.4-1.9 1 0 1.8.4 2.4 1.1.4.5 1 .9 1.6.9"/>
<path d="M2 16c.6 0 1.2.4 1.6.9.6.7 1.4 1.1 2.4 1.1 1.9 0 2.4-1.9 4.4-1.9 1 0 1.8.4 2.4 1.1.4.5 1 .9 1.6.9"/>
<path d="M16 12c.5-.5 1.1-.9 1.6-.9.6 0 1.2.4 1.6.9.6.7 1.4 1.1 2.4 1.1.2 0 .4 0 .6-.1"/>
</svg>
</button>
<div class="deck-divider"></div>
<!-- Download Btn (New) -->
<button class="icon-btn" onclick="downloadModel()" id="btn-download" title="Download Model">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/>
</svg>
</button>
<div class="deck-divider"></div>
<!-- Reset Btn -->
<button class="icon-btn" onclick="autoFocusCamera()" title="Reset View">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/></svg>
</button>
</div>
<!-- 4. Import Panel (Bottom Left) -->
<div id="import-panel" class="hud-panel">
<div class="drop-zone" id="drop-area">
<span class="drop-icon">✦</span>
<div class="drop-text" data-key="import_main">Import</div>
<div class="drop-sub" data-key="import_sub">Drag & Drop Image/.PLY</div>
<input type="file" id="file-input" accept="image/*,.ply" multiple style="display:none">
</div>
</div>
<!-- Model List Panel -->
<div id="model-list-panel" class="hud-panel">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px;">
<span style="font-size: 0.7rem; color: var(--accent-primary); letter-spacing: 1px; text-transform: uppercase;">MODELS</span>
<span id="model-count" style="font-size: 0.65rem; color: var(--text-muted);">0</span>
</div>
<div id="model-list-container"></div>
</div>
<!-- 5. Nav Hint (Bottom Right) -->
<div id="nav-hint" class="hud-panel">
<div class="key-row"><span class="kbd">WASD</span> <span data-key="nav_move">Move</span></div>
<div class="key-row"><span class="kbd">Q / E</span> <span data-key="nav_lift">Lift</span></div>
<div class="key-row"><span class="kbd">Shift</span> <span data-key="nav_fast">Fast</span></div>
<div class="key-row"><span class="kbd">Mouse</span> <span data-key="nav_look">Look</span></div>
<!-- Social Media Links (Dynamic) -->
<div id="social-links">
<!-- Populated by JS -->
</div>
</div>
<!-- Watermark -->
<div id="watermark">
<img src="Watermark.png" alt="Logo" onerror="this.style.display='none'">
<span>多多GemosDodo制作</span>
</div>
<div id="canvas-container"></div>
<script type="module">
import * as THREE from 'three';
// --- I18N System ---
const dictionary = {
en: {
subtitle: "HIGH FIDELITY VIEWER .01",
stat_points: "Points",
stat_fps: "FPS",
ctrl_scale: "Scale",
ctrl_opacity: "Opacity",
ctrl_exposure: "Exposure",
ctrl_speed: "Speed",
flow_amp: "Amp",
flow_freq: "Freq",
flow_speed: "Flow Spd",
import_main: "Import",
import_sub: "Drag & Drop Image/.PLY",
nav_move: "Move",
nav_lift: "Lift",
nav_fast: "Fast",
nav_look: "Look",
loading_init: "INITIALIZING SYSTEM",
tutorial_text: "[ WASD ] TO FLY & COLLECT",
loading_processing: "PROCESSING ARTWORK",
loading_downloading: "DOWNLOADING GEOMETRY",
loading_parsing: "PARSING DATA...",
loading_generating: "GENERATING ARTWORK",
loading_importing: "IMPORTING MODEL",
loading_download_general: "DOWNLOADING...",
btn_flow_tooltip: "Disperse / Reset Flow",
btn_download_tooltip: "Download Model (.ply)",
// 批处理相关
loading_batch_processing: "BATCH PROCESSING",
loading_batch: "Processing {} files...",
loading_batch_item: "Loading model {}/{}...",
batch_limit_warning: "Maximum {} files allowed. Extra files will be ignored.",
batch_result_summary: "Batch complete: {} success, {} failed\nTotal time: {}s",
batch_failed_details: "Failed files",
batch_all_failed: "All files failed to process",
batch_error: "Batch processing error",
unknown_error: "Unknown error"
},
zh: {
subtitle: "高保真可视化 .01",
stat_points: "点云数",
stat_fps: "帧率",
ctrl_scale: "缩放",
ctrl_opacity: "透明度",
ctrl_exposure: "曝光",
ctrl_speed: "速度",
flow_amp: "强度",
flow_freq: "频率",
flow_speed: "流速",
import_main: "导入模型",
import_sub: "拖拽 .PLY 文件",
nav_move: "移动",
nav_lift: "升降",
nav_fast: "加速",
nav_look: "视角",
loading_init: "系统初始化中",
tutorial_text: "[ WASD ] 飞行与探索",
loading_processing: "正在处理作品",
loading_downloading: "正在下载几何数据",
loading_parsing: "数据解析中...",
loading_generating: "生成演示模型",
loading_importing: "正在导入模型",
loading_download_general: "下载中...",
btn_flow_tooltip: "散开 / 复原 (湍流效果)",
btn_download_tooltip: "下载模型 (.ply)",
// 批处理相关
loading_batch_processing: "批量处理中",
loading_batch: "正在处理 {} 个文件...",
loading_batch_item: "加载模型 {}/{}...",
batch_limit_warning: "最多支持 {} 个文件,多余的文件将被忽略。",
batch_result_summary: "批处理完成:{} 成功,{} 失败\n总耗时:{}秒",
batch_failed_details: "失败文件",
batch_all_failed: "所有文件处理失败",
batch_error: "批处理错误",
unknown_error: "未知错误"
}
};
const socialData = {
zh: [
{ name: "小红书", url: "https://www.xiaohongshu.com/user/profile/5e59ee3200000000010091d9", icon: '<path d="M4 4h16v16H4z"/>' }, // 简化的方形作为书本替代
{ name: "Bilibili", url: "https://space.bilibili.com/488258780?spm_id_from=333.33.0.0", icon: '<path d="M4 8h16v12H4z M7 8l-2-3 M17 8l2-3"/>' },
{ name: "QQ群", url: "https://qm.qq.com/q/VgSlMQwwA6", icon: '<path d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2z"/>' }
],
en: [
{ name: "X", url: "https://x.com/duoqian1421848", icon: '<path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/>' },
{ name: "YouTube", url: "https://www.youtube.com/@Gemos_Dodo", icon: '<path d="M22.54 6.42a2.78 2.78 0 0 0-1.94-2C18.88 4 12 4 12 4s-6.88 0-8.6.46a2.78 2.78 0 0 0-1.94 2A29 29 0 0 0 1 11.75a29 29 0 0 0 .46 5.33A2.78 2.78 0 0 0 3.4 19c1.72.46 8.6.46 8.6.46s6.88 0 8.6-.46a2.78 2.78 0 0 0 1.94-2 29 29 0 0 0 .46-5.25 29 29 0 0 0-.46-5.33zM9.75 15.02l5.75-3.27-5.75-3.27z"/>' },
{ name: "Discord", url: "https://discord.gg/jXyCNc7q", icon: '<path d="M19.27 5.33C17.94 4.71 16.5 4.26 15 4a.09.09 0 0 0-.07.03c-.18.33-.39.76-.53 1.09a16.09 16.09 0 0 0-4.8 0c-.14-.34-.35-.76-.54-1.09c-.01-.02-.04-.03-.07-.03c-1.5.26-2.93.71-4.27 1.33c-.01 0-.02.01-.03.02c-2.72 4.07-3.47 8.03-3.1 11.95c0 .02.01.04.03.05c1.8 1.32 3.53 2.12 5.24 2.65c.03.01.06 0 .07-.02c.4-.55.76-1.13 1.07-1.74c.02-.04 0-.08-.04-.09c-.57-.22-1.11-.48-1.64-.78c-.04-.02-.04-.08.01-.11c.11-.08.22-.17.33-.25c.02-.02.05-.02.07-.01c3.44 1.57 7.15 1.57 10.55 0c.02-.01.05-.01.07.01c.11.09.22.17.33.26c.04.03.04.09-.01.11c-.52.31-1.07.56-1.64.78c-.04.01-.05.06-.04.09c.32.61.68 1.19 1.07 1.74c.03.01.06.02.09.01c1.72-.53 3.45-1.33 5.25-2.65c.02-.01.03-.03.03-.05c.44-4.53-.73-8.46-3.1-11.95c-.01-.01-.02-.02-.04-.02zM8.52 14.91c-1.03 0-1.89-.95-1.89-2.12s.84-2.12 1.89-2.12c1.06 0 1.9.96 1.89 2.12c0 1.17-.85 2.12-1.89 2.12z"/>' }
]
};
let currentLang = 'zh'; // Default to Chinese
window.toggleLanguage = () => {
currentLang = currentLang === 'en' ? 'zh' : 'en';
applyLanguage();
};
function applyLanguage() {
const data = dictionary[currentLang];
// Update all elements with data-key attribute
document.querySelectorAll('[data-key]').forEach(el => {
const key = el.getAttribute('data-key');
if (data[key]) el.innerText = data[key];
});
// Tooltips
document.getElementById('btn-flow').title = data['btn_flow_tooltip'];
document.getElementById('btn-download').title = data['btn_download_tooltip'];
// Update Social Links
const socialContainer = document.getElementById('social-links');
socialContainer.innerHTML = ''; // Clear existing
const links = socialData[currentLang];
links.forEach(link => {
const a = document.createElement('a');
a.href = link.url;
a.className = 'social-link';
a.target = '_blank';
a.innerHTML = `<svg viewBox="0 0 24 24" fill="currentColor">${link.icon}</svg> ${link.name}`;
socialContainer.appendChild(a);
});
}
function getTrans(key) {
return dictionary[currentLang][key] || key;
}
// --- Loading Screen Game System (Tutorial) ---
class LoadingGameSystem {
constructor() {
this.overlay = document.getElementById('loading-overlay');
this.canvas = document.getElementById('loading-canvas');
this.bar = document.getElementById('loading-bar');
this.ctx = this.canvas.getContext('2d');
this.isActive = true;
this.quoteEl = document.getElementById('loading-quote');
this.player = { x: window.innerWidth/2, y: window.innerHeight/2, vx: 0, vy: 0, size: 8 };
this.targets = [];
this.particles = [];
this.quotes = [
"Light is the first of painters. - Emerson",
"Simulating photons...",
"Art is not what you see, but what you make others see. - Degas",
"Constructing Gaussian Splats...",
"In order to see, we must forget the name of the thing we are looking at. - Monet"
];
this.resize();
window.addEventListener('resize', () => this.resize());
this.quoteInterval = setInterval(() => this.rotateQuote(), 3000);
this.rotateQuote();
for(let i=0; i<5; i++) this.spawnTarget();
this.animate();
}
resize() {
this.canvas.width = window.innerWidth;
this.canvas.height = window.innerHeight;
}
spawnTarget() {
const padding = 50;
this.targets.push({
x: padding + Math.random() * (this.canvas.width - padding*2),
y: padding + Math.random() * (this.canvas.height - padding*2),
radius: 0, maxRadius: 6 + Math.random() * 4
});
}
spawnParticle(x, y, color) {
for(let i=0; i<5; i++) {
this.particles.push({
x: x, y: y,
vx: (Math.random() - 0.5) * 4, vy: (Math.random() - 0.5) * 4,
life: 1.0, color: color || '#d4af37'
});
}
}
rotateQuote() {
if(!this.isActive) return;
this.quoteEl.style.opacity = 0;
setTimeout(() => {
const idx = Math.floor(Math.random() * this.quotes.length);
this.quoteEl.innerText = this.quotes[idx];
this.quoteEl.style.opacity = 0.8;
}, 500);
}
updatePlayer() {
const ax = (physics.move.r - physics.move.l) * 0.8;
const ay = (physics.move.b - physics.move.f) * 0.8;
this.player.vx += ax;
this.player.vy += ay;
this.player.vx *= 0.92;
this.player.vy *= 0.92;
this.player.x += this.player.vx;
this.player.y += this.player.vy;
if(this.player.x < 0) { this.player.x = 0; this.player.vx *= -0.5; }
if(this.player.x > this.canvas.width) { this.player.x = this.canvas.width; this.player.vx *= -0.5; }
if(this.player.y < 0) { this.player.y = 0; this.player.vy *= -0.5; }
if(this.player.y > this.canvas.height) { this.player.y = this.canvas.height; this.player.vy *= -0.5; }
}
animate() {
if (!this.isActive) return;
requestAnimationFrame(() => this.animate());
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
this.updatePlayer();
this.ctx.save();
this.ctx.translate(this.player.x, this.player.y);
const angle = Math.atan2(this.player.vy, this.player.vx);
this.ctx.rotate(angle + Math.PI/2);
this.ctx.beginPath();
this.ctx.moveTo(0, -this.player.size * 1.5);
this.ctx.lineTo(-this.player.size, this.player.size);
this.ctx.lineTo(this.player.size, this.player.size);
this.ctx.closePath();
this.ctx.fillStyle = '#d4af37';
this.ctx.fill();
if(Math.random() > 0.5 && (Math.abs(this.player.vx) > 0.1 || Math.abs(this.player.vy) > 0.1)) {
this.particles.push({
x: this.player.x, y: this.player.y,
vx: (Math.random()-0.5), vy: (Math.random()-0.5),
life: 0.5, color: 'rgba(255,255,255,0.5)'
});
}
this.ctx.restore();
for (let i = this.targets.length - 1; i >= 0; i--) {
const t = this.targets[i];
if(t.radius < t.maxRadius) t.radius += 0.2;
const grad = this.ctx.createRadialGradient(t.x, t.y, 0, t.x, t.y, t.radius * 2);
grad.addColorStop(0, 'rgba(212, 175, 55, 0.8)');
grad.addColorStop(1, 'rgba(212, 175, 55, 0)');
this.ctx.fillStyle = grad;
this.ctx.beginPath();
this.ctx.arc(t.x, t.y, t.radius * 2, 0, Math.PI*2);
this.ctx.fill();
this.ctx.fillStyle = '#fff';
this.ctx.beginPath();
this.ctx.arc(t.x, t.y, 2, 0, Math.PI*2);
this.ctx.fill();
const dx = this.player.x - t.x;
const dy = this.player.y - t.y;
const dist = Math.sqrt(dx*dx + dy*dy);
if(dist < t.radius + 10) {
this.spawnParticle(t.x, t.y, '#d4af37');
this.targets.splice(i, 1);
this.spawnTarget();
}
}
for (let i = this.particles.length - 1; i >= 0; i--) {
const p = this.particles[i];
p.x += p.vx;
p.y += p.vy;
p.life -= 0.02;
if (p.life <= 0) {
this.particles.splice(i, 1);
} else {
this.ctx.fillStyle = p.color;
this.ctx.globalAlpha = p.life;
this.ctx.beginPath();
this.ctx.arc(p.x, p.y, 2, 0, Math.PI * 2);
this.ctx.fill();
this.ctx.globalAlpha = 1.0;
}
}
}
setProgress(percent) {
if(this.bar) this.bar.style.width = (percent * 100) + '%';
}
stop() {
this.isActive = false;
this.setProgress(1.0);
setTimeout(() => {
this.overlay.classList.remove('active');
}, 500);
clearInterval(this.quoteInterval);
}
start(messageKey) {
this.isActive = true;
this.setProgress(0);
this.overlay.classList.add('active');
if(messageKey) document.getElementById('loading-text').innerText = getTrans(messageKey);
this.animate();
}
}
// --- Global Variables & Params ---
let scene, camera, renderer, splatMesh;
let rawPlyData = null; // Store raw buffer for download
const clock = new THREE.Clock();
const SH_C0 = 0.28209479177387814;
let geometryData = null;
let isUiVisible = true;
// Multi-model support
let models = [];
let currentModelId = null;
let modelIdCounter = 0;
const _vMoveDir = new THREE.Vector3();
const _vForward = new THREE.Vector3();
const _vRight = new THREE.Vector3();
const _vUp = new THREE.Vector3(0,1,0);
const physics = {
velocity: new THREE.Vector3(),
inputVector: new THREE.Vector3(),
move: { f:0, b:0, l:0, r:0, u:0, d:0 },
boost: false,
mouseDown: false,
mouseLast: { x:0, y:0 },
targetRot: new THREE.Euler(0, 0, 0, 'YXZ'),
currRot: new THREE.Euler(0, 0, 0, 'YXZ')
};
const loadingSys = new LoadingGameSystem();
const state = {
mode: 'Fly',
splatScale: 2.5, // Default Value
opacity: 1.0,
brightness: 1.0,
flySpeed: 10.0,
acceleration: 100.0,
friction: 10.0,
minOpacity: 0.05,
turbulence: 0.0, // Target turbulence state (0 or 1)
// Flow Params (tuned for "Fish Schools")
flowAmp: 8.0,
flowFreq: 0.3, // Slightly higher base freq for groups
flowSpeed: 0.6
};
let currentTurbulence = 0.0; // Current uniform value for smooth transition
init();
animate();
function init() {
// Initialize Language
applyLanguage();
const container = document.getElementById('canvas-container');
scene = new THREE.Scene();
scene.background = new THREE.Color(0x121212);
scene.fog = new THREE.FogExp2(0x121212, 0.02);
const grid = new THREE.GridHelper(100, 100, 0x333333, 0x1a1a1a);
grid.position.y = -5;
grid.material.opacity = 0.3;
grid.material.transparent = true;
scene.add(grid);
camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.1, 5000);
camera.position.set(0, 5, 10);
physics.targetRot.setFromQuaternion(camera.quaternion, 'YXZ');
physics.currRot.copy(physics.targetRot);
renderer = new THREE.WebGLRenderer({
antialias: false,
powerPreference: "high-performance",
stencil: false,
depth: true
});
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.0));
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.0;
container.appendChild(renderer.domElement);
bindUI();
setupDragAndDrop();
setupKeyboard();
window.addEventListener('resize', onWindowResize);
window.addEventListener('contextmenu', e => e.preventDefault());
// Initial Logic
const params = new URLSearchParams(window.location.search);
const modelUrl = params.get('url');
if (modelUrl) {
loadingSys.start("loading_importing");
loadFileFromUrl(modelUrl);
} else {
generateExampleSplat();
}
}
// --- Procedural Generation for Example Model ---
function generateExampleSplat() {
loadingSys.start("loading_generating");
// Clear rawPlyData since we are generating new data
rawPlyData = null;
const count = 50000;
const posBuffer = new Float32Array(count * 3);
const rotBuffer = new Float32Array(count * 4);
const scaleBuffer = new Float32Array(count * 3);
const colBuffer = new Float32Array(count * 4);
const color1 = new THREE.Color(0xd4af37); // Gold
const color2 = new THREE.Color(0x2a2a2a); // Dark Grey
const color3 = new THREE.Color(0xffffff); // White
for(let i=0; i<count; i++) {
const t = i / count;
const angle = t * Math.PI * 20; // Spiral
const radius = t * 15;
const x = Math.cos(angle) * radius + (Math.random()-0.5) * (t * 2);
const y = (Math.random() - 0.5) * (t * 3);
const z = Math.sin(angle) * radius + (Math.random()-0.5) * (t * 2);
posBuffer[i*3] = x;
posBuffer[i*3+1] = y;
posBuffer[i*3+2] = z;
const q = new THREE.Quaternion();
q.setFromEuler(new THREE.Euler(Math.random()*Math.PI, Math.random()*Math.PI, Math.random()*Math.PI));
rotBuffer[i*4] = q.x;
rotBuffer[i*4+1] = q.y;
rotBuffer[i*4+2] = q.z;
rotBuffer[i*4+3] = q.w;
const s = Math.random() * 0.15 + 0.05;
scaleBuffer[i*3] = s;
scaleBuffer[i*3+1] = s;
scaleBuffer[i*3+2] = s;
const c = new THREE.Color();
if(Math.random() > 0.95) c.copy(color3);
else c.lerpColors(color2, color1, Math.pow(t, 0.5));
colBuffer[i*4] = c.r;
colBuffer[i*4+1] = c.g;
colBuffer[i*4+2] = c.b;
colBuffer[i*4+3] = 0.8;
}