-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1992 lines (1856 loc) · 82.2 KB
/
index.html
File metadata and controls
1992 lines (1856 loc) · 82.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
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>3D Tile Builder</title>
<style>
*{margin:0;padding:0;box-sizing:border-box;}
html,body{background:#080810;min-height:100vh;font-family:system-ui,sans-serif;}
body{display:flex;flex-direction:column;align-items:center;padding:24px 0 48px;}
/* ── Page wrapper ── */
#page-wrap{width:90vw;display:flex;flex-direction:column;gap:0;}
/* ══════════════════════════════════════════════════════
APP BORDER — tech / futuristic quadrilateral frame
Palette: #0099dd (cyan-blue) · #5A0090 (deep violet)
Style: dark, understated, high-tech corner brackets
+ subtle animated scan line + corner accent dots
══════════════════════════════════════════════════════ */
#app-border{
position:relative;
display:flex;flex-direction:row;
background:#080810;
/* 1px gradient border */
border:1px solid transparent;
background-clip:padding-box;
outline:1px solid rgba(0,153,221,0.12);
box-shadow:
0 0 0 1px rgba(90,0,144,0.10),
0 0 32px rgba(0,153,221,0.06),
inset 0 0 60px rgba(90,0,144,0.03);
}
/* Corner bracket — top-left */
#app-border::before{
content:'';position:absolute;
top:-1px;left:-1px;
width:28px;height:28px;
border-top:2px solid #004466;
border-left:2px solid #004466;
box-shadow:0 0 8px rgba(0,80,120,0.25);
pointer-events:none;z-index:20;
}
/* Corner bracket — bottom-right */
#app-border::after{
content:'';position:absolute;
bottom:-1px;right:-1px;
width:28px;height:28px;
border-bottom:2px solid #004466;
border-right:2px solid #004466;
box-shadow:0 0 8px rgba(0,80,120,0.25);
pointer-events:none;z-index:20;
}
/* Corner bracket — top-right */
#app-corner-tr{
position:absolute;top:-1px;right:-1px;
width:28px;height:28px;
border-top:2px solid #004466;
border-right:2px solid #004466;
box-shadow:0 0 8px rgba(0,80,120,0.25);
pointer-events:none;z-index:20;
}
/* Corner bracket — bottom-left */
#app-corner-bl{
position:absolute;bottom:-1px;left:-1px;
width:28px;height:28px;
border-bottom:2px solid #004466;
border-left:2px solid #004466;
box-shadow:0 0 8px rgba(0,80,120,0.25);
pointer-events:none;z-index:20;
}
/* Animated horizontal scan line */
#app-scan{
position:absolute;left:0;right:0;height:1px;
background:linear-gradient(90deg,transparent 0%,rgba(0,153,221,0.18) 30%,rgba(90,0,144,0.18) 70%,transparent 100%);
pointer-events:none;z-index:19;
animation:appScan 6s ease-in-out infinite;
}
@keyframes appScan{
0% {top:0%; opacity:0;}
5% {opacity:1;}
95% {opacity:0.6;}
100%{top:100%; opacity:0;}
}
/* Top edge label — removed */
#viewer{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;flex:1;min-width:0;background:#080810;padding:16px 8px 44px;}
/* ── Panel toggle button (neon power style) ── */
#panelToggle{
position:absolute;top:14px;right:14px;
width:28px;height:28px;
background:transparent;border:none;padding:0;
cursor:pointer;z-index:100;
border-radius:5px;
}
#panelToggle .neon-button{
position:relative;
width:28px;height:28px;
border-radius:3px;
display:flex;justify-content:center;align-items:center;
transition:all 0.3s ease;
}
#panelToggle .neon-button::before{
content:'';position:absolute;
width:100%;height:100%;border-radius:3px;
background:linear-gradient(45deg,#0099dd,#5A0090,#0099dd);
opacity:0.35;filter:blur(3px);
animation:ntGlow 3s ease-in-out infinite;z-index:-2;
}
#panelToggle .neon-button::after{
content:'';position:absolute;
width:92%;height:92%;border-radius:2px;
border:1px solid transparent;
background:linear-gradient(45deg,#0099dd,#5A0090,#0099dd) border-box;
-webkit-mask:linear-gradient(#fff 0 0) padding-box,linear-gradient(#fff 0 0);
mask:linear-gradient(#fff 0 0) padding-box,linear-gradient(#fff 0 0);
-webkit-mask-composite:xor;mask-composite:exclude;
opacity:0.45;
}
#panelToggle .inner-ring{
position:absolute;width:88%;height:88%;
border-radius:2px;
border:1px solid rgba(90,0,144,0.2);
box-shadow:0 0 2px rgba(90,0,144,0.1);
}
#panelToggle .tech-pattern{
position:absolute;width:95%;height:95%;border-radius:2px;
background:repeating-linear-gradient(0deg,transparent,transparent 2px,rgba(90,0,144,0.06) 2px,rgba(90,0,144,0.06) 4px);
pointer-events:none;
}
#panelToggle .power-emoji{
font-size:14px;
background:linear-gradient(45deg,#0099dd,#5A0090);
-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text;
filter:drop-shadow(0 0 2px #0099dd) drop-shadow(0 0 3px #5A0090);
animation:ntPulse 2s ease-in-out infinite, ntSpin 8s linear infinite;
}
#panelToggle:hover .neon-button{transform:scale(1.03);}
#panelToggle:hover .neon-button::before{opacity:0.55;}
#panelToggle:hover .neon-button::after{opacity:0.65;}
#panelToggle:hover .power-emoji{animation:ntPulse 0.8s ease-in-out infinite, ntSpin 8s linear infinite;}
#panelToggle:active .neon-button{transform:scale(0.97);}
#panelToggle.open .power-emoji{filter:drop-shadow(0 0 3px #0099dd) drop-shadow(0 0 5px #5A0090);}
@keyframes ntGlow{
0%,100%{opacity:0.25;transform:scale(1);}
50%{opacity:0.45;transform:scale(1.03);}
}
@keyframes ntSpin{
0%{transform:rotate(0deg);}100%{transform:rotate(360deg);}
}
@keyframes ntPulse{
0%,100%{filter:drop-shadow(0 0 6px #0099dd) drop-shadow(0 0 12px #5A0090);transform:scale(1);}
50%{filter:drop-shadow(0 0 10px #0099dd) drop-shadow(0 0 22px #5A0090);transform:scale(1.05);}
}
/* ── Panel ── */
#panel{
width:260px;min-width:220px;max-height:100%;overflow-y:auto;overflow-x:hidden;
background:#0e0e1a;border-left:1px solid #1e1e35;
display:none;
flex-direction:column;
}
#panel.open{display:flex;}
/* ── Tab bar ── */
.tab-bar{
display:flex;border-bottom:1px solid #1e1e35;
flex-shrink:0;
}
.tab-btn{
flex:1;padding:9px 0;
background:transparent;border:none;
color:#4a5080;font:500 10px sans-serif;
letter-spacing:.1em;text-transform:uppercase;
cursor:pointer;transition:color .15s,border-bottom .15s;
border-bottom:2px solid transparent;margin-bottom:-1px;
}
.tab-btn:hover{color:#7788cc;}
.tab-btn.active{color:#aabeff;border-bottom:2px solid #4466cc;}
/* ── Tab panes ── */
.tab-pane{display:none;padding:14px 14px 24px;overflow-y:auto;overflow-x:hidden;flex:1;}
.tab-pane.active{display:block;}
/* ── Existing control styles (unchanged) ── */
#panel::-webkit-scrollbar{width:4px;}
#panel::-webkit-scrollbar-thumb{background:#2a2a45;border-radius:4px;}
.section-title{font:500 10px sans-serif;letter-spacing:.1em;text-transform:uppercase;color:#4a5080;margin:18px 0 8px;border-bottom:1px solid #1e1e35;padding-bottom:5px;}
.section-title:first-child{margin-top:4px;}
.row{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px;gap:6px;}
.row label{font:12px sans-serif;color:#8890b8;flex:0 0 auto;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:90px;}
input[type=range]{flex:1;min-width:0;accent-color:#4466ee;height:3px;}
.val{font:11px/1 monospace;color:#bbc;min-width:38px;text-align:right;}
input[type=color]{width:36px;height:22px;border:none;border-radius:4px;cursor:pointer;padding:0;background:none;}
input[type=text]{background:#1a1a2e;border:1px solid #2a2a45;color:#ccd;font:12px monospace;border-radius:4px;padding:3px 6px;width:100%;}
select{background:#1a1a2e;border:1px solid #2a2a45;color:#ccd;font:12px sans-serif;border-radius:4px;padding:3px 6px;width:100%;}
.toggle-row{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px;}
.toggle-row label.lbl{font:12px sans-serif;color:#8890b8;}
.tog{position:relative;display:inline-flex;width:36px;height:20px;flex-shrink:0;vertical-align:middle;}
.tog input{opacity:0;width:0;height:0;position:absolute;}
.tog-track{position:absolute;inset:0;background:#2a2a45;border-radius:10px;cursor:pointer;transition:background .2s;}
.tog-thumb{position:absolute;width:14px;height:14px;top:3px;left:3px;background:#6678bb;border-radius:50%;transition:transform .2s,background .2s;pointer-events:none;}
.tog input:checked ~ .tog-track{background:#3355cc;}
.tog input:checked ~ .tog-thumb{transform:translateX(16px);background:#fff;}
.copy-btn{width:100%;margin-top:14px;padding:7px 0;background:#1e2a66;border:1px solid #3044aa;color:#99aaff;font:12px sans-serif;border-radius:6px;cursor:pointer;letter-spacing:.04em;}
.copy-btn:hover{background:#263580;}
.badge{display:inline-block;font:10px monospace;background:#1a1a2e;border:1px solid #2a2a45;color:#778;padding:2px 6px;border-radius:4px;}
.info{font:10px sans-serif;color:#556;margin:-4px 0 8px;line-height:1.4;}
.mode-btns{display:flex;gap:6px;margin-bottom:10px;}
.mode-btn{flex:1;padding:6px 0;background:#12122a;border:1px solid #2a2a45;color:#7788cc;font:11px sans-serif;border-radius:5px;cursor:pointer;letter-spacing:.04em;transition:all .15s;}
.mode-btn.active{background:#1e2a66;border-color:#4466cc;color:#aabeff;}
.mode-btn:hover{background:#1a1a40;}
/* ── Bottom bar ── */
#bottomBar{
position:absolute;bottom:0;left:0;right:0;height:40px;
display:flex;align-items:center;justify-content:space-between;
padding:0 10px;z-index:10;
}
/* Logo section - left */
#bottomLogo{display:flex;align-items:center;gap:8px;cursor:pointer;flex:1;}
.logo-svg{flex-shrink:0;width:32px;height:32px;}
.logo-name{
font:600 11px/1 sans-serif;letter-spacing:1.5px;text-transform:uppercase;
background:linear-gradient(90deg,#f5a623,#ffcc44,#f5a623);
-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text;
filter:drop-shadow(0 0 4px rgba(245,166,35,0.5));
white-space:nowrap;
}
@keyframes lcFloat{
0%,100%{transform:translateY(0);}
50%{transform:translateY(-1px);}
}
@keyframes lcPulse{
0%,100%{opacity:0.7;}50%{opacity:1;}
}
/* Hint - center */
#hint{
flex:1;text-align:center;
font:11px sans-serif;letter-spacing:.06em;
background:linear-gradient(45deg,#0099dd,#5A0090);
-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text;
filter:drop-shadow(0 0 2px #0099dd);
}
/* Tile indicator + buttons - right */
#bottomRight{display:flex;align-items:center;gap:6px;flex:1;justify-content:flex-end;}
#tileIndicator{color:#4466aa;font:10px monospace;letter-spacing:.05em;}
#stackBtns{display:none;flex-direction:row;gap:4px;}
#btnAddTile,#btnRemTile{width:22px;height:22px;background:#0e0e1a;border:1px solid #2a3a5a;border-radius:4px;color:#6688cc;font:bold 14px sans-serif;cursor:pointer;line-height:1;}
#btnAddTile:hover,#btnRemTile:hover{border-color:#4466aa;color:#aabeff;}
#btnAddTile:disabled,#btnRemTile:disabled{opacity:0.3;cursor:default;}
/* ── Section 2 ── */
#section2{
width:100%;
padding:32px 40px;
background:#080810;
border:1px solid transparent;
outline:1px solid rgba(0,153,221,0.08);
box-shadow:0 0 24px rgba(90,0,144,0.04);
margin-top:2px;
}
#section2-text{
font:400 13px/1.6 monospace;
letter-spacing:.22em;
text-transform:uppercase;
color:rgba(100,120,180,0.75);
text-align:center;
}
</style>
</head>
<body>
<div id="page-wrap">
<div id="app-border">
<!-- Tech border accent elements -->
<div id="app-corner-tr"></div>
<div id="app-corner-bl"></div>
<div id="app-scan"></div>
<div id="viewer">
<canvas id="c"></canvas>
<div id="bottomBar">
<!-- Left: logo -->
<div id="bottomLogo">
<svg class="logo-svg" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="lg1" x1="0" y1="0" x2="1" y2="1">
<stop offset="0%" stop-color="#00d4ff"/>
<stop offset="100%" stop-color="#0066ff"/>
</linearGradient>
<linearGradient id="lg2" x1="0" y1="0" x2="1" y2="1">
<stop offset="0%" stop-color="#a855f7"/>
<stop offset="100%" stop-color="#6600cc"/>
</linearGradient>
<linearGradient id="lg3" x1="0" y1="0" x2="1" y2="1">
<stop offset="0%" stop-color="#00ffcc"/>
<stop offset="100%" stop-color="#0099aa"/>
</linearGradient>
<filter id="glow">
<feGaussianBlur stdDeviation="1" result="blur"/>
<feMerge><feMergeNode in="blur"/><feMergeNode in="SourceGraphic"/></feMerge>
</filter>
</defs>
<!-- Top tile -->
<g filter="url(#glow)" style="animation:lcFloat 3s ease-in-out infinite">
<polygon points="16,2 26,7 16,12 6,7" fill="url(#lg1)" opacity="0.95"/>
<polygon points="16,12 26,7 26,10 16,15" fill="#0044bb" opacity="0.8"/>
<polygon points="16,12 6,7 6,10 16,15" fill="#003399" opacity="0.6"/>
</g>
<!-- Middle tile -->
<g filter="url(#glow)" style="animation:lcFloat 3s ease-in-out infinite;animation-delay:0.4s">
<polygon points="16,13 26,18 16,23 6,18" fill="url(#lg2)" opacity="0.9"/>
<polygon points="16,23 26,18 26,21 16,26" fill="#440088" opacity="0.8"/>
<polygon points="16,23 6,18 6,21 16,26" fill="#330066" opacity="0.6"/>
</g>
<!-- Scan line accent -->
<line x1="4" y1="16" x2="28" y2="16" stroke="rgba(0,220,255,0.15)" stroke-width="0.5"/>
<!-- Corner dots -->
<circle cx="4" cy="4" r="0.8" fill="#00d4ff" opacity="0.6" style="animation:lcPulse 2s ease-in-out infinite"/>
<circle cx="28" cy="4" r="0.8" fill="#a855f7" opacity="0.6" style="animation:lcPulse 2s ease-in-out infinite;animation-delay:0.5s"/>
<circle cx="4" cy="28" r="0.8" fill="#00ffcc" opacity="0.6" style="animation:lcPulse 2s ease-in-out infinite;animation-delay:1s"/>
<circle cx="28" cy="28" r="0.8" fill="#00d4ff" opacity="0.6" style="animation:lcPulse 2s ease-in-out infinite;animation-delay:1.5s"/>
</svg>
<span class="logo-name">3D Tile Builder</span>
</div>
<!-- Center: drag hint -->
<div id="hint">DRAG TO ROTATE</div>
<!-- Right: tile indicator + +/- buttons -->
<div id="bottomRight">
<div id="tileIndicator">TILE 1</div>
<div id="stackBtns">
<button id="btnAddTile" title="Add tile">+</button>
<button id="btnRemTile" title="Remove tile">−</button>
</div>
</div>
</div>
<!-- Panel toggle: neon power button top-right of viewer -->
<button id="panelToggle" title="Toggle controls">
<div class="neon-button">
<div class="inner-ring"></div>
<div class="tech-pattern"></div>
<span class="power-emoji">🌀</span>
</div>
</button>
</div>
<div id="panel">
<!-- Tab bar -->
<div class="tab-bar">
<button class="tab-btn active" data-tab="scene">Scene</button>
<button class="tab-btn" data-tab="label">Label</button>
<button class="tab-btn" data-tab="tile">Tile</button>
</div>
<!-- ── SCENE TAB ── -->
<div class="tab-pane active" id="tab-scene">
<div class="section-title">Orientation</div>
<div class="mode-btns">
<button class="mode-btn active" id="btnFlat">⬜ Flat</button>
<button class="mode-btn" id="btnStand">▭ Standing</button>
</div>
<div class="section-title">Auto Rotation</div>
<div class="toggle-row">
<label class="lbl">Enabled</label>
<label class="tog"><input type="checkbox" id="autoOn" checked><span class="tog-track"></span><span class="tog-thumb"></span></label>
</div>
<div class="row">
<label>Speed</label>
<input type="range" id="autoSpeed" min="0" max="30" value="4" step="1">
<span class="val" id="autoSpeedV">4</span>
</div>
<div class="section-title">Scene</div>
<div class="row">
<label>Ambient</label>
<input type="range" id="ambientI" min="0" max="2" value="0.70" step="0.05">
<span class="val" id="ambientIV">0.70</span>
</div>
<div class="row">
<label>Sun</label>
<input type="range" id="sunI" min="0" max="3" value="1.5" step="0.1">
<span class="val" id="sunIV">1.50</span>
</div>
<div class="row">
<label>FOV</label>
<input type="range" id="camFOV" min="5" max="60" value="5" step="1">
<span class="val" id="camFOVV">5</span>
</div>
<div class="row">
<label>Cam height</label>
<input type="range" id="camY" min="1" max="20" value="5" step="0.1">
<span class="val" id="camYV">5.0</span>
</div>
<div class="row">
<label>Cam distance</label>
<input type="range" id="camDist" min="5" max="60" value="55" step="1">
<span class="val" id="camDistV">55</span>
</div>
<!-- canvasHeight kept hidden for JSON import/export compatibility -->
<input type="range" id="canvasHeight" min="300" max="900" value="500" step="50" style="display:none">
<span id="canvasHeightV" style="display:none">500</span>
<div style="display:flex;gap:8px;margin-top:14px;">
<button class="copy-btn" id="importBtn" style="flex:1;margin-top:0;">⤵ Import JSON</button>
<button class="copy-btn" id="exportBtn" style="flex:1;margin-top:0;">⤴ Export JSON</button>
</div>
<div style="display:flex;gap:8px;margin-top:8px;">
<button class="copy-btn" id="setDefaultBtn" style="flex:1;margin-top:0;">⭐ Set as Default</button>
<button class="copy-btn" id="resetDefaultBtn" style="flex:1;margin-top:0;">↺ Reset Default</button>
</div>
<input type="file" id="importFile" accept=".json" style="display:none">
<div class="section-title" id="stackCtrlSection">Stack (Flat)</div>
<div class="row" id="stackSpacingRow">
<label id="stackSpacingLabel">Tile spacing</label>
<input type="range" id="stackSpacing" min="0" max="2.0" value="0.8" step="0.05">
<span class="val" id="stackSpacingV">0.80</span>
</div>
<div class="toggle-row" id="syncWRow">
<label class="lbl" id="syncWLabel">Sync Width</label>
<label class="tog"><input type="checkbox" id="syncW"><span class="tog-track"></span><span class="tog-thumb"></span></label>
</div>
<div class="toggle-row" id="syncHRow">
<label class="lbl" id="syncHLabel">Sync Height</label>
<label class="tog"><input type="checkbox" id="syncH"><span class="tog-track"></span><span class="tog-thumb"></span></label>
</div>
<div class="toggle-row" id="syncDRow">
<label class="lbl" id="syncDLabel">Sync Depth</label>
<label class="tog"><input type="checkbox" id="syncD"><span class="tog-track"></span><span class="tog-thumb"></span></label>
</div>
</div>
<!-- ── LABEL TAB ── -->
<div class="tab-pane" id="tab-label">
<div class="section-title">Label Text</div>
<div class="row" style="flex-direction:column;align-items:stretch;gap:4px;">
<label>Content</label>
<input type="text" id="txtContent" value="Welcome">
</div>
<div class="row">
<label>Color</label>
<input type="color" id="txtColor" value="#0a1a4a">
<span class="val badge" id="txtColorV">#0a1a4a</span>
</div>
<div class="row">
<label>Size (px)</label>
<input type="range" id="txtSize" min="18" max="140" value="78" step="1">
<span class="val" id="txtSizeV">78</span>
</div>
<div class="row">
<label>Weight</label>
<select id="txtWeight"><option value="normal">Normal</option><option value="bold" selected>Bold</option></select>
</div>
<div class="row">
<label>Font</label>
<select id="txtFont">
<option value="Arial, sans-serif" selected>Arial</option>
<option value="Georgia, serif">Georgia</option>
<option value="'Courier New', monospace">Courier New</option>
<option value="Impact, sans-serif">Impact</option>
<option value="Verdana, sans-serif">Verdana</option>
</select>
</div>
<div class="row">
<label>Align</label>
<select id="txtAlign"><option value="left" selected>Left</option><option value="center">Center</option><option value="right">Right</option></select>
</div>
<div class="row">
<label>Style</label>
<select id="txtStyle">
<option value="flat" selected>Flat</option>
<option value="embossed">Embossed</option>
<option value="engraved">Engraved</option>
</select>
</div>
<div class="row">
<label>Depth / intensity</label>
<input type="range" id="txtDepth" min="1" max="12" value="5" step="1">
<span class="val" id="txtDepthV">5</span>
</div>
<div class="row">
<label>Highlight</label>
<input type="color" id="txtHighlight" value="#ffffff">
<span class="val badge" id="txtHighlightV">#ffffff</span>
</div>
<div class="row">
<label>Shadow color</label>
<input type="color" id="txtShadowColor" value="#000000">
<span class="val badge" id="txtShadowColorV">#000000</span>
</div>
<div class="section-title">Label Position</div>
<p class="info">X/Z keep the label inside the tile.</p>
<div class="row">
<label>X offset</label>
<input type="range" id="lblX" min="-1" max="1" value="-0.5" step="0.05">
<span class="val" id="lblXV">-0.50</span>
</div>
<div class="row">
<label>Z offset</label>
<input type="range" id="lblZ" min="-1" max="1" value="1" step="0.05">
<span class="val" id="lblZV">1</span>
</div>
<div class="row">
<label>Label width %</label>
<input type="range" id="lblWPct" min="10" max="95" value="80" step="1">
<span class="val" id="lblWPctV">80%</span>
</div>
<div class="row">
<label>Label height %</label>
<input type="range" id="lblHPct" min="5" max="70" value="22" step="1">
<span class="val" id="lblHPctV">22%</span>
</div>
</div>
<!-- ── TILE TAB ── -->
<div class="tab-pane" id="tab-tile">
<div class="section-title">Tile Shape</div>
<div class="row">
<label>Width</label>
<input type="range" id="tileW" min="0.5" max="5" value="1." step="0.1">
<span class="val" id="tileWV">1.2</span>
</div>
<div class="row">
<label>Depth</label>
<input type="range" id="tileD" min="0.5" max="5" value="1." step="0.1">
<span class="val" id="tileDV">1.2</span>
</div>
<div class="row">
<label>Height</label>
<input type="range" id="tileH" min="0.1" max="2" value="0.30" step="0.05">
<span class="val" id="tileHV">0.30</span>
</div>
<div class="row">
<label>Corner radius</label>
<input type="range" id="cornerR" min="0.01" max="0.45" value="0.1" step="0.01">
<span class="val" id="cornerRV">0.1</span>
</div>
<div class="row">
<label>Bevel size</label>
<input type="range" id="bevelS" min="0" max="0.3" value="0.02" step="0.01">
<span class="val" id="bevelSV">0.02</span>
</div>
<div class="section-title">Tile Color</div>
<div class="row">
<label>Top face</label>
<input type="color" id="colorTop" value="#5bc8f5">
<span class="val badge" id="colorTopV">#5bc8f5</span>
</div>
<div class="row">
<label>Side face</label>
<input type="color" id="colorSide" value="#2aaad8">
<span class="val badge" id="colorSideV">#2aaad8</span>
</div>
<div class="row">
<label>Roughness</label>
<input type="range" id="rough" min="0" max="1" value="0.18" step="0.01">
<span class="val" id="roughV">0.18</span>
</div>
<div class="row">
<label>Metalness</label>
<input type="range" id="metal" min="0" max="1" value="0.00" step="0.01">
<span class="val" id="metalV">0.00</span>
</div>
</div>
</div><!-- /#panel -->
</div><!-- /#app-border -->
<!-- Section 2 -->
<div id="section2">
<div id="section2-text">Pulse of the Digital Horizon</div>
</div>
</div><!-- /#page-wrap -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<script>
const cv = document.getElementById('c');
var canvasH = 500; // kept for JSON import/export compat — actual size computed below
function viewSz(){
const panelOpen = document.getElementById('panel') && document.getElementById('panel').classList.contains('open');
const totalW = window.innerWidth * 0.90;
const w = Math.max(totalW - (panelOpen ? 280 : 0) - 16, 260);
const h = Math.round(w); // square: height === width
canvasH = h; // keep in sync for JSON export
return { w, h };
}
let { w:W, h:H } = viewSz();
const renderer = new THREE.WebGLRenderer({ canvas:cv, antialias:true, alpha:true, stencil:true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(W, H);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x080810);
const camera = new THREE.PerspectiveCamera(14, W/H, 0.1, 500);
const ambient = new THREE.AmbientLight(0xffffff, 0.55);
scene.add(ambient);
const sun = new THREE.DirectionalLight(0xffffff, 1.3);
sun.position.set(5, 12, 7);
sun.castShadow = true;
sun.shadow.mapSize.width = sun.shadow.mapSize.height = 2048;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xffffff, 0.3);
fill.position.set(-5, 3, 3);
scene.add(fill);
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(40, 40),
new THREE.ShadowMaterial({ opacity:0.18 })
);
floor.rotation.x = -Math.PI / 2;
floor.receiveShadow = true;
scene.add(floor);
const group = new THREE.Group();
scene.add(group);
// ── Shared state ──────────────────────────────────────────────────────
let topMat = null;
let sideMat = null;
let labelMesh = null;
let tileMesh = null;
let standingMode = false;
let ry = -0.38, rx = 0;
// ── Tile-0 cfg stores and extra-tile state (declared early to avoid re-init) ──
var tile0FlatCfg = null;
var tile0StandCfg = null;
var savedFlatExtraCfgs = [];
var savedStandExtraCfgs = [];
var extraTiles = [];
var activeTileIdx = 0;
var flatSpacingVal = 0.8; // saved Flat mode spacing
var standSpacingVal = 0.0; // saved Standing mode spacing (default: touching)
function g(id) { return document.getElementById(id); }
function fv(id) { return parseFloat(g(id).value); }
function hexAlpha(a){
return Math.round(Math.max(0, Math.min(1, a)) * 255).toString(16).padStart(2, '0');
}
// ── Shared config ─────────────────────────────────────────────────────
function getCfg(){
const TW = fv('tileW'), TD = fv('tileD'), TH = fv('tileH');
const R = Math.min(fv('cornerR'), TW/2*0.9, TD/2*0.9);
const BS = Math.min(fv('bevelS'), R*0.8);
const inset = BS * 1.2;
const usableW = TW - inset*2;
const usableD = TD - inset*2;
const lblWPct = fv('lblWPct') / 100;
const lblHPct = fv('lblHPct') / 100;
const lblW = Math.min(lblWPct * usableW, usableW);
const lblH = Math.min(lblHPct * usableD, usableD);
const travelX = (usableW - lblW) / 2;
const travelZ = (usableD - lblH) / 2;
const lblX = fv('lblX') * travelX;
const lblZ = fv('lblZ') * travelZ;
return {
TW, TD, TH, R, BS,
colorTop: g('colorTop').value,
colorSide: g('colorSide').value,
rough: fv('rough'),
metal: fv('metal'),
txtContent: g('txtContent').value,
txtColor: g('txtColor').value,
txtSize: fv('txtSize'),
txtWeight: g('txtWeight').value,
txtFont: g('txtFont').value,
txtAlign: g('txtAlign').value,
txtStyle: g('txtStyle').value,
txtDepth: fv('txtDepth'),
txtHighlight: g('txtHighlight').value,
txtShadowColor:g('txtShadowColor').value,
lblW, lblH, lblX, lblZ,
};
}
// ── Camera ────────────────────────────────────────────────────────────
function updateCamera(){
const fov = fv('camFOV');
const camY = fv('camY');
const dist = fv('camDist');
camera.fov = fov;
camera.updateProjectionMatrix();
camera.position.set(0, camY, dist);
if(standingMode){
camera.lookAt(typeof standLookAtX !== 'undefined' ? standLookAtX : 0, 0, 0);
} else {
camera.lookAt(0, typeof stackLookAtY !== 'undefined' ? stackLookAtY : 0.4, 0);
}
}
// ── Shared: draw text onto a canvas, return CanvasTexture ─────────────
function makeTextCanvas(c){
const tc = document.createElement('canvas');
const canvasH = 128;
const canvasW = Math.min(Math.round((c.lblW / Math.max(c.lblH, 0.05)) * canvasH), 2048);
tc.width = canvasW;
tc.height = canvasH;
const ctx = tc.getContext('2d');
ctx.clearRect(0, 0, canvasW, canvasH);
const font = c.txtWeight + ' ' + c.txtSize + 'px ' + c.txtFont;
const d = c.txtDepth;
const ax = c.txtAlign === 'left' ? 16 : c.txtAlign === 'right' ? canvasW - 16 : canvasW / 2;
ctx.font = font;
ctx.textBaseline = 'middle';
ctx.textAlign = c.txtAlign;
if(c.txtStyle === 'flat'){
ctx.shadowColor = 'rgba(255,255,255,0.35)';
ctx.shadowBlur = 6;
ctx.shadowOffsetY = 1;
ctx.fillStyle = c.txtColor;
ctx.fillText(c.txtContent, ax, 64);
} else if(c.txtStyle === 'embossed'){
ctx.shadowColor = 'transparent'; ctx.shadowBlur = 0;
ctx.fillStyle = c.txtShadowColor + hexAlpha(0.7);
ctx.fillText(c.txtContent, ax + d*0.6, 64 + d*0.6);
ctx.fillStyle = c.txtHighlight + hexAlpha(0.85);
ctx.fillText(c.txtContent, ax - d*0.4, 64 - d*0.4);
ctx.fillStyle = c.txtColor;
ctx.fillText(c.txtContent, ax, 64);
} else {
ctx.shadowColor = 'transparent'; ctx.shadowBlur = 0;
ctx.fillStyle = c.txtHighlight + hexAlpha(0.6);
ctx.fillText(c.txtContent, ax + d*0.5, 64 + d*0.5);
ctx.fillStyle = c.txtShadowColor + hexAlpha(0.8);
ctx.fillText(c.txtContent, ax - d*0.5, 64 - d*0.5);
ctx.fillStyle = c.txtColor + hexAlpha(0.55);
ctx.fillText(c.txtContent, ax, 64);
}
return new THREE.CanvasTexture(tc);
}
// ── Shared: rounded-rectangle shape ──────────────────────────────────
function makeShape(hw, hd, R){
const s = new THREE.Shape();
s.moveTo(-hw + R, -hd);
s.lineTo( hw - R, -hd);
s.quadraticCurveTo( hw, -hd, hw, -hd + R);
s.lineTo( hw, hd - R);
s.quadraticCurveTo( hw, hd, hw - R, hd);
s.lineTo(-hw + R, hd);
s.quadraticCurveTo(-hw, hd, -hw, hd - R);
s.lineTo(-hw, -hd + R);
s.quadraticCurveTo(-hw, -hd, -hw + R, -hd);
return s;
}
// ── Shared: clear scene group ─────────────────────────────────────────
function clearGroup(){
while(group.children.length) group.remove(group.children[0]);
labelMesh = null;
tileMesh = null;
group.rotation.set(0, 0, 0);
}
// ── Shared: update material colors only ──────────────────────────────
function updateMats(){
const c = getCfg();
if(topMat){ topMat.color.set(c.colorTop); topMat.roughness = c.rough; topMat.metalness = c.metal; }
if(sideMat){ sideMat.color.set(c.colorSide); sideMat.roughness = c.rough + 0.07; sideMat.metalness = c.metal; }
}
// ══════════════════════════════════════════════════════════════════════
// FLAT MODE — tile lies horizontally
//
// Geometry pipeline:
// 1. Shape in XY plane (TW × TD)
// 2. ExtrudeGeometry along +Z, depth = TH
// 3. geo.rotateX(-PI/2) → extrusion now goes up (+Y)
// 4. geo.translate(0, -minY, 0) → tile bottom at Y=0
//
// Final bounding box:
// X : -TW/2 ~ +TW/2
// Y : 0 ~ TH+2·BS (bottom=0, top=bb.max.y)
// Z : -TD/2 ~ +TD/2
//
// Top-face normal = local +Y
// Label: rotation.x = -PI/2 (lies flat), position.y = bb.max.y + 0.002
//
// Drag: ry→Y-spin (left/right), rx→X-tilt (up/down) — natural ✓
// ══════════════════════════════════════════════════════════════════════
function addFlatLabel(c, bb){
const lGeo = new THREE.PlaneGeometry(c.lblW, c.lblH);
const lMat = new THREE.MeshBasicMaterial({
map: makeTextCanvas(c),
transparent:true, depthTest:false, depthWrite:false, alphaTest:0.01
});
labelMesh = new THREE.Mesh(lGeo, lMat);
labelMesh.renderOrder = 1;
labelMesh.rotation.x = -Math.PI / 2;
labelMesh.position.set(c.lblX, bb.max.y + 0.002, c.lblZ);
group.add(labelMesh);
}
function buildFlatTile(){
clearGroup();
const c = getCfg();
const hw = c.TW / 2, hd = c.TD / 2;
const geo = new THREE.ExtrudeGeometry(makeShape(hw, hd, c.R), {
depth: c.TH, bevelEnabled: c.BS > 0.001,
bevelThickness: c.BS, bevelSize: c.BS, bevelSegments: 10
});
geo.rotateX(-Math.PI / 2);
geo.computeBoundingBox();
geo.translate(0, -geo.boundingBox.min.y, 0); // bottom to Y=0
geo.computeBoundingBox();
floor.position.y = 0;
topMat = new THREE.MeshStandardMaterial({ color:c.colorTop, roughness:c.rough, metalness:c.metal });
sideMat = new THREE.MeshStandardMaterial({ color:c.colorSide, roughness:c.rough + 0.07, metalness:c.metal });
tileMesh = new THREE.Mesh(geo, [topMat, sideMat]);
group.add(tileMesh);
addFlatLabel(c, geo.boundingBox);
ry = -0.38;
rx = 0;
}
function rebuildFlatLabel(){
if(labelMesh){ group.remove(labelMesh); labelMesh = null; }
if(!tileMesh) return;
const c = getCfg();
tileMesh.geometry.computeBoundingBox();
addFlatLabel(c, tileMesh.geometry.boundingBox);
}
// ══════════════════════════════════════════════════════════════════════
// STANDING MODE — tile stands upright, large face toward camera
//
// Geometry pipeline:
// 1. Shape in XY plane (TW wide × TD tall)
// 2. ExtrudeGeometry along +Z, depth = TH — NO rotateX
// 3. Center geometry: translate(0, -cY, -cZ) so origin = tile center
//
// Final bounding box (symmetric around origin):
// X : -TW/2 ~ +TW/2 (width, horizontal on screen)
// Y : -TD/2 ~ +TD/2 (height, vertical on screen)
// Z : -(TH/2+BS) ~ +(TH/2+BS) (thickness, into/out of screen)
//
// Front face (closest to camera) = local +Z face at Z = bb.max.z
// Front face normal = local +Z → faces camera directly ✓
//
// Label:
// rotation = (0,0,0) — PlaneGeometry default
// normal = local +Z → toward camera ✓
// up = local +Y → world +Y ✓ text upright
// position = (c.lblX, c.lblZ, bb.max.z + 0.002)
// c.lblX → horizontal offset on face
// c.lblZ → vertical offset on face (repurposed from flat's depth offset)
//
// Drag: ry→Y-spin (left/right), rx→X-tilt (up/down)
// group.rotation.z is always 0 — drag is identical to flat mode ✓
// ══════════════════════════════════════════════════════════════════════
function addStandLabel(c, bb){
const lGeo = new THREE.PlaneGeometry(c.lblW, c.lblH);
const lMat = new THREE.MeshBasicMaterial({
map: makeTextCanvas(c),
transparent:true, depthTest:false, depthWrite:false, alphaTest:0.01
});
labelMesh = new THREE.Mesh(lGeo, lMat);
labelMesh.renderOrder = 1;
// rotation = (0,0,0): PlaneGeometry default normal = local +Z = toward camera ✓
// PlaneGeometry default up = local +Y = world up ✓
labelMesh.position.set(c.lblX, c.lblZ, bb.max.z + 0.002);
// Stencil guard: only draw where no extra tile's mask has written (stencil == 0)
// This prevents tile 0's label bleeding through an overlapping extra tile body.
labelMesh.onBeforeRender = function(renderer){
const gl = renderer.getContext();
gl.enable(gl.STENCIL_TEST);
gl.stencilMask(0x00);
gl.stencilFunc(gl.EQUAL, 0, 0xff);
gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP);
};
labelMesh.onAfterRender = function(renderer){
const gl = renderer.getContext();
gl.disable(gl.STENCIL_TEST);
gl.stencilMask(0xff);
};
group.add(labelMesh);
}
function buildStandTile(){
clearGroup();
const c = getCfg();
const hw = c.TW / 2, hd = c.TD / 2;
// Same rounded-rect shape as flat — TW wide, TD tall, in XY plane.
// ExtrudeGeometry goes along +Z (depth = TH = tile thickness).
// NO rotateX: tile already stands upright.
const geo = new THREE.ExtrudeGeometry(makeShape(hw, hd, c.R), {
depth: c.TH, bevelEnabled: c.BS > 0.001,
bevelThickness: c.BS, bevelSize: c.BS, bevelSegments: 10
});
// Center geometry around origin (Y and Z); X is already centered.
geo.computeBoundingBox();
const cY = (geo.boundingBox.max.y + geo.boundingBox.min.y) / 2;
const cZ = (geo.boundingBox.max.z + geo.boundingBox.min.z) / 2;
geo.translate(0, -cY, -cZ);
geo.computeBoundingBox();
// Floor at tile bottom edge
floor.position.y = geo.boundingBox.min.y;
topMat = new THREE.MeshStandardMaterial({ color:c.colorTop, roughness:c.rough, metalness:c.metal });
sideMat = new THREE.MeshStandardMaterial({ color:c.colorSide, roughness:c.rough + 0.07, metalness:c.metal });
tileMesh = new THREE.Mesh(geo, [topMat, sideMat]);
group.add(tileMesh);
addStandLabel(c, geo.boundingBox);
ry = 0.25;
rx = 0.;
}
function rebuildStandLabel(){
if(labelMesh){ group.remove(labelMesh); labelMesh = null; }
if(!tileMesh) return;
const c = getCfg();
tileMesh.geometry.computeBoundingBox();
addStandLabel(c, tileMesh.geometry.boundingBox);
}
// ── Unified rebuild entry point ───────────────────────────────────────
function rebuildLabel(){
if(standingMode) rebuildStandLabel();
else rebuildFlatLabel();
}
// ── Initial build ─────────────────────────────────────────────────────
buildFlatTile();
updateCamera();
// NOTE: tile0FlatCfg and tile0StandCfg are initialised AFTER snapCfgFromPanel
// is defined further below (see "Initial setup" section near the stack code).
// ── Orientation buttons ───────────────────────────────────────────────
// ── Update Stack section labels for current mode ──────────────────────
function updateStackPanelLabels(){
if(standingMode){
g('stackCtrlSection').textContent = 'Stack (Standing)';
g('stackSpacingLabel').textContent = 'Tile spacing';
g('syncWLabel').textContent = 'Sync Width';
g('syncHLabel').textContent = 'Sync Height';
g('syncDLabel').textContent = 'Sync Thickness';
g('stackSpacing').min = '-2.0';
} else {
g('stackCtrlSection').textContent = 'Stack (Flat)';
g('stackSpacingLabel').textContent = 'Tile spacing';
g('syncWLabel').textContent = 'Sync Width';
g('syncHLabel').textContent = 'Sync Height';
g('syncDLabel').textContent = 'Sync Depth';
g('stackSpacing').min = '0';
}
}
g('btnFlat').addEventListener('click', () => {
if(!standingMode) return; // already flat
// 1. Save current panel → tile0StandCfg + standing spacing
tile0StandCfg = snapCfgFromPanel();
standSpacingVal = parseFloat(g('stackSpacing').value);
// 2. Save standing extra tiles before removing them
savedStandExtraCfgs = extraTiles.map(et => ({...et.cfg}));
while(extraTiles.length > 0){ const et = extraTiles.pop(); scene.remove(et.grp); }
activeTileIdx = 0;
// 3. Switch mode flag and UI
standingMode = false;
g('btnFlat').classList.add('active');
g('btnStand').classList.remove('active');
// 4. Restore flat spacing
g('stackSpacing').value = flatSpacingVal;
g('stackSpacingV').textContent = parseFloat(flatSpacingVal).toFixed(2);
// 5. Restore tile0FlatCfg → panel so buildFlatTile reads correct values
loadCfgToPanel(tile0FlatCfg);
// 6. Build flat tile 0 from restored panel values (untouched function)
buildFlatTile();
// 7. Restore extra tiles that were saved when we switched to standing
savedFlatExtraCfgs.forEach((cfg, i) => {
const step = getStep();
const yWorld = -(i + 1) * step;
const et = buildExtraTile(cfg, yWorld, i);
et.grp.position.y = yWorld;
et.grp.rotation.x = group.rotation.x;