Repository navigation
Expand file tree
/
Copy pathlogo.html
More file actions
1171 lines (1078 loc) · 43.1 KB
/
Copy pathlogo.html
File metadata and controls
1171 lines (1078 loc) · 43.1 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">
<title>方案 10 · 桥端藏到方块内侧</title>
<style>
:root {
color-scheme: light dark;
--bg-center: #ffffff;
--bg-edge: #edf2f8;
--ui-bg: rgba(255, 255, 255, 0.72);
--ui-border: rgba(15, 35, 70, 0.10);
--ui-text: #1e293b;
--ui-muted: #64748b;
--focus: #2c74be;
}
@media (prefers-color-scheme: dark) {
:root {
--bg-center: #16213a;
--bg-edge: #0a101d;
--ui-bg: rgba(15, 23, 42, 0.66);
--ui-border: rgba(148, 180, 230, 0.16);
--ui-text: #e2e8f0;
--ui-muted: #94a3b8;
--focus: #5aa9ef;
}
}
html, body {
margin: 0;
height: 100%;
overflow: hidden;
font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
background: radial-gradient(ellipse at 50% 45%, var(--bg-center) 0%, var(--bg-edge) 100%);
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
outline: none;
}
canvas.dragging { cursor: grabbing; }
canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }
.ui {
position: fixed;
left: 50%;
bottom: 20px;
transform: translateX(-50%);
display: flex;
align-items: center;
gap: 12px;
padding: 6px 6px 6px 16px;
border: 1px solid var(--ui-border);
border-radius: 999px;
background: var(--ui-bg);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
font-size: 13px;
color: var(--ui-muted);
white-space: nowrap;
}
.hint { transition: opacity 0.6s ease; }
.hint.faded { opacity: 0.45; }
button {
display: inline-flex;
align-items: center;
gap: 6px;
font: inherit;
padding: 7px 14px;
border: 0;
border-radius: 999px;
background: transparent;
color: var(--ui-text);
cursor: pointer;
}
button:hover { background: var(--ui-border); }
button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button svg { width: 15px; height: 15px; }
@media (max-width: 480px) {
.hint { display: none; }
.ui { padding: 4px; }
}
.lights {
position: fixed;
top: 20px;
right: 20px;
display: grid;
grid-template-columns: auto minmax(100px, 160px) 3.5em;
align-items: center;
gap: 8px 10px;
margin: 0;
padding: 12px 14px 8px;
border: 1px solid var(--ui-border);
border-radius: 14px;
background: var(--ui-bg);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
font-size: 13px;
color: var(--ui-text);
}
.lights legend {
float: left;
grid-column: 1 / -1;
padding: 0;
color: var(--ui-muted);
}
.lights input[type="range"] {
width: 100%;
margin: 0;
accent-color: var(--focus);
}
.lights input[type="range"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.lights output {
text-align: right;
font-variant-numeric: tabular-nums;
color: var(--ui-muted);
}
.lights button {
grid-column: 1 / -1;
justify-self: end;
padding: 5px 10px;
}
@media (max-width: 480px) {
.lights { top: 10px; right: 10px; left: 10px; grid-template-columns: auto 1fr 3.5em; }
}
.error {
position: fixed;
inset: 0;
display: none;
align-items: center;
justify-content: center;
color: #b91c1c;
}
</style>
</head>
<body>
<canvas id="scene" tabindex="0" role="img"
aria-label="8 个蓝色立方体组成的等轴测场景,上下两层均由十字桥接,四组上下方块之间保留内侧百分之七十五截面积的半透明连接。拖拽旋转,滚轮或双指缩放,方向键旋转,加减号缩放,R 键重置视角。"></canvas>
<div class="ui">
<span class="hint" id="hint">拖拽旋转 · 滚轮缩放 · 双击重置</span>
<button id="reset" type="button">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<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>
<button id="export-svg" type="button" title="按默认机位和当前光照导出">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="M12 3v12"/><path d="m7 10 5 5 5-5"/><path d="M5 21h14"/>
</svg>
导出 SVG
</button>
</div>
<fieldset class="lights" id="lights">
<legend>光照俯仰角</legend>
<label for="key-pitch">主光</label>
<input id="key-pitch" type="range" min="-90" max="90" step="1" value="0" aria-describedby="key-pitch-out">
<output id="key-pitch-out" for="key-pitch">0°</output>
<label for="inner-pitch">内侧光</label>
<input id="inner-pitch" type="range" min="-90" max="90" step="1" value="0" aria-describedby="inner-pitch-out">
<output id="inner-pitch-out" for="inner-pitch">0°</output>
<button id="lights-reset" type="button">恢复默认</button>
</fieldset>
<div class="error" id="error" role="alert">当前浏览器不支持 WebGL2</div>
<script>
(() => {
'use strict';
// ---- Scene definition ----------------------------------------------------
// 2x2x2 lattice. Cube edge = 1, center spacing = 1.5 (gap 0.5).
// Box: [cx, cy, cz, sx, sy, sz, layer (1 upper / 0 lower), gradientBaseY, kind].
//
// Shading is kept SVG-friendly for the default view: every visible face (or half face) is a
// flat color times a vertical linear gradient, and glass is plain alpha-over compositing.
const KIND_CUBE = 0;
const KIND_FILL = 1; // opaque
const KIND_GLASS_SIDES = 2; // glass, side faces only (top/bottom would be coplanar with cubes)
const A = 0.75;
const OUTER = A + 0.5; // 1.25
const INNER = A - 0.5; // 0.25
const HALF = 0.5;
const box = (min, max, layer, kind) => [
(min[0] + max[0]) / 2, (min[1] + max[1]) / 2, (min[2] + max[2]) / 2,
max[0] - min[0], max[1] - min[1], max[2] - min[2],
layer, min[1], kind,
];
const cube = (x, y, z, layer) =>
box([x - 0.5, y - 0.5, z - 0.5], [x + 0.5, y + 0.5, z + 0.5], layer, KIND_CUBE);
const UPPER_BOTTOM = INNER; // 0.25
const LOWER_TOP = -INNER; // -0.25
const COLUMNS = [[A, A], [-A, A], [A, -A], [-A, -A]];
// 保留四号方块与连接柱,通过桥接长度和厚度调整遮挡关系。
const BRIDGE_UPPER = OUTER * 0.6;
const BRIDGE_LOWER = OUTER * 0.6;
const BRIDGE_HEIGHT = 0.5;
const OPAQUE_BOXES = [
...COLUMNS.map(([x, z]) => cube(x, A, z, 1)),
...COLUMNS.map(([x, z]) => cube(x, -A, z, 0)),
box([-BRIDGE_UPPER, UPPER_BOTTOM, -INNER], [BRIDGE_UPPER, UPPER_BOTTOM + BRIDGE_HEIGHT, INNER], 1, KIND_FILL),
box([-INNER, UPPER_BOTTOM, INNER], [INNER, UPPER_BOTTOM + BRIDGE_HEIGHT, BRIDGE_UPPER], 1, KIND_FILL),
box([-INNER, UPPER_BOTTOM, -BRIDGE_UPPER], [INNER, UPPER_BOTTOM + BRIDGE_HEIGHT, -INNER], 1, KIND_FILL),
box([-BRIDGE_LOWER, LOWER_TOP - BRIDGE_HEIGHT, -INNER], [BRIDGE_LOWER, LOWER_TOP, INNER], 0, KIND_FILL),
box([-INNER, LOWER_TOP - BRIDGE_HEIGHT, INNER], [INNER, LOWER_TOP, BRIDGE_LOWER], 0, KIND_FILL),
box([-INNER, LOWER_TOP - BRIDGE_HEIGHT, -BRIDGE_LOWER], [INNER, LOWER_TOP, -INNER], 0, KIND_FILL),
];
OPAQUE_BOXES.filter(b => b[8] === KIND_FILL && b[6] === 0).forEach(b => { b[7] = -A - HALF; });
// 四根连接柱以内侧角为锚点保留百分之七十五截面积,高度与半透明材质不变。
const LINK_AREA_RATIO = 0.75;
const LINK_WIDTH = Math.sqrt(LINK_AREA_RATIO);
const GLASS_BOXES = COLUMNS.map(([x, z]) => {
const innerX = x - Math.sign(x) * HALF;
const innerZ = z - Math.sign(z) * HALF;
const outerX = innerX + Math.sign(x) * LINK_WIDTH;
const outerZ = innerZ + Math.sign(z) * LINK_WIDTH;
return box(
[Math.min(outerX, innerX), LOWER_TOP, Math.min(outerZ, innerZ)],
[Math.max(outerX, innerX), UPPER_BOTTOM, Math.max(outerZ, innerZ)],
1, KIND_GLASS_SIDES,
);
});
// Default camera: true isometric, orthographic, looking along -(1,1,1) at the origin.
const DEFAULT_VIEW = {
azimuth: Math.PI / 4,
elevation: Math.atan(1 / Math.SQRT2), // 35.264 deg
// Reference: projected edge = 152px of 800px; isometric foreshortening is sqrt(2/3),
// so one world unit = 152 / 0.8165 = 186px and the half view = 400 / 186 (tuned to 2.13 by overlay).
halfExtent: 2.13,
};
const TARGET = [0, 0, 0];
const CAMERA_DISTANCE = 10;
const hex = (h) => [1, 3, 5].map((i) => parseInt(h.slice(i, i + 2), 16) / 255);
const PALETTE = {
topUpper: hex('#3ab0e6'),
sideUpperHi: hex('#2c74be'),
sideUpperLo: hex('#20438a'),
topLower: hex('#26497a'),
sideLowerHi: hex('#1c3964'),
sideLowerLo: hex('#122341'),
fillTint: [0.88, 0.93, 0.98], // cross fill: a touch deeper and cooler than the cubes
// Inner light on side faces facing the central channel (sampled from the reference's top cube).
innerHi: hex('#2192d3'), // at the top edge of the face
innerLo: hex('#28a0e2'), // at the bottom edge, slightly brighter near the fill
innerTop: hex('#4ec8f8'), // on top faces, once the inner light is pitched upward
glassTop: hex('#55b4f4'),
glassHi: hex('#4a9cf0'),
glassLo: hex('#2a68cc'),
glassAlpha: 0.48,
glassBackdrop: hex('#122a55'), // stands in for the page wherever nothing opaque is behind glass
};
const reducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)');
// ---- WebGL setup ---------------------------------------------------------
const canvas = document.getElementById('scene');
const gl = canvas.getContext('webgl2', { antialias: true, alpha: true, premultipliedAlpha: true });
if (!gl) {
document.getElementById('error').style.display = 'flex';
return;
}
const VS = `#version 300 es
layout(location = 0) in vec3 aPos;
layout(location = 1) in vec3 aNormal;
layout(location = 2) in vec3 aOffset;
layout(location = 3) in vec3 aScale;
layout(location = 4) in vec3 aStyle; // layer, gradient base height, kind
uniform mat4 uViewProj;
out vec3 vNormal;
out vec3 vWorld;
out vec3 vLocal;
flat out vec3 vScale;
flat out vec3 vStyle;
flat out vec3 vFaceCenter;
void main() {
vec3 world = aPos * aScale + aOffset;
vNormal = aNormal;
vWorld = world;
vLocal = aPos;
vScale = aScale;
vStyle = aStyle;
vFaceCenter = aOffset + aNormal * aScale * 0.5;
gl_Position = uViewProj * vec4(world, 1.0);
}`;
// Shared shading terms. Depth cue is evaluated once per face so each face stays a plain
// linear gradient (exportable as an SVG <linearGradient>).
const COMMON_GLSL = `
uniform vec3 uToCamera;
uniform vec3 uTarget;
uniform vec3 uKeyDir; // toward the key light; pitch 0 = horizontal (the reference look)
float keyLight(vec3 n) {
return 0.6 + 0.4 * max(dot(n, uKeyDir), 0.0);
}
// Palette top/bottom colors are what a horizontal key light gives (factor 0.6), so they are
// rescaled relative to that: pitch 0 reproduces the palette exactly.
float capLight(vec3 n) {
return keyLight(n) / 0.6;
}
float depthCue(vec3 faceCenter) {
return 1.0 + 0.06 * dot(faceCenter - uTarget, uToCamera);
}
// Brightens past 1.0 without washing the hue out to white.
vec3 fitRange(vec3 c) {
c = max(c, vec3(0.0));
return c / max(1.0, max(c.r, max(c.g, c.b)));
}`;
const OPAQUE_FS = `#version 300 es
precision highp float;
in vec3 vNormal;
in vec3 vWorld;
in vec3 vLocal;
flat in vec3 vScale;
flat in vec3 vStyle;
flat in vec3 vFaceCenter;
uniform vec3 uTopUpper, uSideUpperHi, uSideUpperLo;
uniform vec3 uTopLower, uSideLowerHi, uSideLowerLo;
uniform vec3 uFillTint;
uniform vec3 uInnerHi, uInnerLo, uInnerTop;
uniform vec2 uInnerPitch; // (sin, cos) of the inner light's pitch
out vec4 outColor;
${COMMON_GLSL}
void main() {
vec3 n = normalize(vNormal);
float layer = vStyle.x;
bool fill = vStyle.z > 0.5;
float t = clamp(vWorld.y - vStyle.y, 0.0, 1.0);
vec3 color;
vec3 inner;
float lam; // how squarely this face faces the inner light
if (n.y > 0.5) {
color = mix(uTopLower, uTopUpper, layer) * capLight(n);
inner = uInnerTop;
lam = uInnerPitch.x;
} else if (n.y < -0.5) {
color = mix(uSideLowerLo, uSideUpperLo, layer) * 0.7 * capLight(n);
inner = uInnerLo * 0.7;
lam = -uInnerPitch.x;
} else {
vec3 hi = mix(uSideLowerHi, uSideUpperHi, layer);
vec3 lo = mix(uSideLowerLo, uSideUpperLo, layer);
color = mix(lo, hi, t) * keyLight(n);
inner = mix(uInnerLo, uInnerHi, t);
// Only side faces that face the central cross channel see the inner light.
lam = step(0.0, dot(n.xz, -vFaceCenter.xz)) * uInnerPitch.y;
}
// Inner light: a cyan light inside the upper layer's cross channel, strongest toward the back
// corner, i.e. the farthest (top) cube in the default view. Its pitch moves it between the
// channel walls (0), the top faces (+90) and the bottom faces (-90). Constant per face, so
// faces stay plain linear gradients.
if (layer > 0.5 && !fill) {
float back = clamp(0.5 + 0.7 * dot(vFaceCenter.xz, vec2(-0.70710678)), 0.0, 1.0);
inner *= 0.9 + 0.1 * max(dot(n, uKeyDir), 0.0);
color = mix(color, inner, back * max(lam, 0.0));
}
if (fill) color *= uFillTint;
color *= depthCue(vFaceCenter);
outColor = vec4(fitRange(color), 1.0);
}`;
const GLASS_FS = `#version 300 es
precision highp float;
in vec3 vNormal;
in vec3 vWorld;
in vec3 vLocal;
flat in vec3 vScale;
flat in vec3 vStyle;
flat in vec3 vFaceCenter;
uniform vec3 uGlassTop, uGlassHi, uGlassLo, uBackdrop;
uniform float uAlpha;
uniform int uPass; // 0 = backdrop where the canvas is still empty, 1 = glass over
out vec4 outColor;
${COMMON_GLSL}
void main() {
if (uPass == 0) {
outColor = vec4(uBackdrop, 1.0);
return;
}
vec3 n = normalize(vNormal);
float t = clamp((vWorld.y - vStyle.y) / vScale.y, 0.0, 1.0);
vec3 color;
if (n.y > 0.5) color = uGlassTop * capLight(n);
else if (n.y < -0.5) color = uGlassLo * 0.7 * capLight(n);
else color = mix(uGlassLo, uGlassHi, t) * keyLight(n);
color *= depthCue(vFaceCenter);
outColor = vec4(fitRange(color), uAlpha);
}`;
function compile(type, src) {
const s = gl.createShader(type);
gl.shaderSource(s, src);
gl.compileShader(s);
if (!gl.getShaderParameter(s, gl.COMPILE_STATUS)) throw new Error(gl.getShaderInfoLog(s));
return s;
}
function createProgram(vs, fs, uniformNames) {
const program = gl.createProgram();
gl.attachShader(program, compile(gl.VERTEX_SHADER, vs));
gl.attachShader(program, compile(gl.FRAGMENT_SHADER, fs));
gl.linkProgram(program);
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) throw new Error(gl.getProgramInfoLog(program));
const u = {};
for (const name of uniformNames) u[name] = gl.getUniformLocation(program, name);
return { program, u };
}
const opaqueProg = createProgram(VS, OPAQUE_FS, [
'uViewProj', 'uToCamera', 'uTarget', 'uKeyDir',
'uTopUpper', 'uSideUpperHi', 'uSideUpperLo', 'uTopLower', 'uSideLowerHi', 'uSideLowerLo',
'uFillTint', 'uInnerHi', 'uInnerLo', 'uInnerTop', 'uInnerPitch',
]);
const glassProg = createProgram(VS, GLASS_FS, [
'uViewProj', 'uToCamera', 'uTarget', 'uKeyDir',
'uGlassTop', 'uGlassHi', 'uGlassLo', 'uBackdrop', 'uAlpha', 'uPass',
]);
// Unit cube, CCW winding seen from outside (u x v = n).
// The four side faces come first so SIDE_VERTEX_COUNT draws a top/bottom-less box.
const CUBE_VERTEX_COUNT = 36;
const SIDE_VERTEX_COUNT = 24;
const FACES = [
{ n: [ 1, 0, 0], u: [0, 0, -1], v: [0, 1, 0] },
{ n: [-1, 0, 0], u: [0, 0, 1], v: [0, 1, 0] },
{ n: [ 0, 0, 1], u: [1, 0, 0], v: [0, 1, 0] },
{ n: [ 0, 0,-1], u: [-1, 0, 0], v: [0, 1, 0] },
{ n: [ 0, 1, 0], u: [1, 0, 0], v: [0, 0, -1] },
{ n: [ 0,-1, 0], u: [1, 0, 0], v: [0, 0, 1] },
];
function buildCube() {
const quad = [[-1, -1], [1, -1], [1, 1], [-1, -1], [1, 1], [-1, 1]];
const data = [];
for (const { n, u, v } of FACES) {
for (const [su, sv] of quad) {
for (let i = 0; i < 3; i++) data.push(0.5 * (n[i] + su * u[i] + sv * v[i]));
data.push(...n);
}
}
return new Float32Array(data);
}
const cubeBuf = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, cubeBuf);
gl.bufferData(gl.ARRAY_BUFFER, buildCube(), gl.STATIC_DRAW);
function bindCubeGeometry() {
gl.bindBuffer(gl.ARRAY_BUFFER, cubeBuf);
gl.enableVertexAttribArray(0);
gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 24, 0);
gl.enableVertexAttribArray(1);
gl.vertexAttribPointer(1, 3, gl.FLOAT, false, 24, 12);
}
// Opaque boxes: one instanced draw.
const opaqueVao = gl.createVertexArray();
gl.bindVertexArray(opaqueVao);
bindCubeGeometry();
gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(OPAQUE_BOXES.flat()), gl.STATIC_DRAW);
[[2, 3, 0], [3, 3, 12], [4, 3, 24]].forEach(([loc, size, offset]) => {
gl.enableVertexAttribArray(loc);
gl.vertexAttribPointer(loc, size, gl.FLOAT, false, 9 * 4, offset);
gl.vertexAttribDivisor(loc, 1);
});
// Glass boxes: drawn one by one, back to front, with per-box constant attributes.
const glassVao = gl.createVertexArray();
gl.bindVertexArray(glassVao);
bindCubeGeometry();
gl.bindVertexArray(null);
// Static uniforms.
gl.useProgram(opaqueProg.program);
gl.uniform3fv(opaqueProg.u.uTarget, TARGET);
gl.uniform3fv(opaqueProg.u.uTopUpper, PALETTE.topUpper);
gl.uniform3fv(opaqueProg.u.uSideUpperHi, PALETTE.sideUpperHi);
gl.uniform3fv(opaqueProg.u.uSideUpperLo, PALETTE.sideUpperLo);
gl.uniform3fv(opaqueProg.u.uTopLower, PALETTE.topLower);
gl.uniform3fv(opaqueProg.u.uSideLowerHi, PALETTE.sideLowerHi);
gl.uniform3fv(opaqueProg.u.uSideLowerLo, PALETTE.sideLowerLo);
gl.uniform3fv(opaqueProg.u.uFillTint, PALETTE.fillTint);
gl.uniform3fv(opaqueProg.u.uInnerHi, PALETTE.innerHi);
gl.uniform3fv(opaqueProg.u.uInnerLo, PALETTE.innerLo);
gl.uniform3fv(opaqueProg.u.uInnerTop, PALETTE.innerTop);
gl.useProgram(glassProg.program);
gl.uniform3fv(glassProg.u.uTarget, TARGET);
gl.uniform3fv(glassProg.u.uGlassTop, PALETTE.glassTop);
gl.uniform3fv(glassProg.u.uGlassHi, PALETTE.glassHi);
gl.uniform3fv(glassProg.u.uGlassLo, PALETTE.glassLo);
gl.uniform3fv(glassProg.u.uBackdrop, PALETTE.glassBackdrop);
gl.uniform1f(glassProg.u.uAlpha, PALETTE.glassAlpha);
gl.enable(gl.DEPTH_TEST);
gl.depthFunc(gl.LEQUAL);
gl.enable(gl.CULL_FACE);
gl.cullFace(gl.BACK);
gl.clearColor(0, 0, 0, 0);
// ---- Math ----------------------------------------------------------------
const sub = (a, b) => [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
const dot = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
const cross = (a, b) => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
const normalize = (a) => { const l = Math.hypot(a[0], a[1], a[2]); return [a[0] / l, a[1] / l, a[2] / l]; };
const clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
function lookAt(eye, center, up) {
const z = normalize(sub(eye, center));
const x = normalize(cross(up, z));
const y = cross(z, x);
return [
x[0], y[0], z[0], 0,
x[1], y[1], z[1], 0,
x[2], y[2], z[2], 0,
-dot(x, eye), -dot(y, eye), -dot(z, eye), 1,
];
}
function ortho(l, r, b, t, n, f) {
return [
2 / (r - l), 0, 0, 0,
0, 2 / (t - b), 0, 0,
0, 0, -2 / (f - n), 0,
-(r + l) / (r - l), -(t + b) / (t - b), -(f + n) / (f - n), 1,
];
}
function multiply(a, b) {
const out = new Float32Array(16);
for (let c = 0; c < 4; c++) {
for (let r = 0; r < 4; r++) {
let s = 0;
for (let k = 0; k < 4; k++) s += a[k * 4 + r] * b[c * 4 + k];
out[c * 4 + r] = s;
}
}
return out;
}
// ---- Camera state & rendering -------------------------------------------
const MAX_ELEVATION = (89 * Math.PI) / 180;
const MIN_EXTENT = 1.2;
const MAX_EXTENT = 8;
const ROTATE_SPEED = 0.008; // radians per CSS pixel
const INERTIA_DECAY_MS = 220; // time constant of the spin-down after a flick
// Light pitch in degrees: 0 = horizontal, +90 = from straight above, -90 = from below.
// The key light's azimuth is fixed so +z faces stay slightly brighter than +x faces.
const KEY_AZIMUTH = Math.atan2(0.55, 1);
const DEFAULT_LIGHTS = { keyPitch: 0, innerPitch: 0 };
const lights = { ...DEFAULT_LIGHTS };
function keyDirFor(pitchDeg) {
const p = (pitchDeg * Math.PI) / 180;
return [Math.sin(KEY_AZIMUTH) * Math.cos(p), Math.sin(p), Math.cos(KEY_AZIMUTH) * Math.cos(p)];
}
function toCameraFor(v) {
const ce = Math.cos(v.elevation);
return [ce * Math.sin(v.azimuth), Math.sin(v.elevation), ce * Math.cos(v.azimuth)];
}
const view = { ...DEFAULT_VIEW };
const spin = { az: 0, el: 0 }; // radians per ms
let resetAnim = null;
let frameQueued = false;
let lastFrame = 0;
function resize() {
const dpr = Math.min(window.devicePixelRatio || 1, 2);
const w = Math.round(canvas.clientWidth * dpr);
const h = Math.round(canvas.clientHeight * dpr);
if (canvas.width !== w || canvas.height !== h) {
canvas.width = w;
canvas.height = h;
}
}
function step(now) {
const dt = lastFrame ? Math.min(now - lastFrame, 50) : 16;
lastFrame = now;
if (resetAnim) {
const t = clamp((now - resetAnim.start) / resetAnim.duration, 0, 1);
const e = 1 - Math.pow(1 - t, 3);
const from = resetAnim.from;
view.azimuth = from.azimuth + (DEFAULT_VIEW.azimuth - from.azimuth) * e;
view.elevation = from.elevation + (DEFAULT_VIEW.elevation - from.elevation) * e;
view.halfExtent = from.halfExtent * Math.pow(DEFAULT_VIEW.halfExtent / from.halfExtent, e);
if (t >= 1) resetAnim = null;
} else if (spin.az || spin.el) {
view.azimuth += spin.az * dt;
view.elevation = clamp(view.elevation + spin.el * dt, -MAX_ELEVATION, MAX_ELEVATION);
const decay = Math.exp(-dt / INERTIA_DECAY_MS);
spin.az *= decay;
spin.el *= decay;
if (Math.hypot(spin.az, spin.el) < 2e-5) spin.az = spin.el = 0;
}
return Boolean(resetAnim || spin.az || spin.el);
}
function render(now) {
frameQueued = false;
const animating = step(now);
resize();
gl.viewport(0, 0, canvas.width, canvas.height);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
const toCamera = toCameraFor(view);
const eye = toCamera.map((d, i) => TARGET[i] + d * CAMERA_DISTANCE);
// Keep the whole cluster visible on both landscape and portrait viewports.
const aspect = canvas.width / canvas.height;
const hh = aspect >= 1 ? view.halfExtent : view.halfExtent / aspect;
const hw = hh * aspect;
const viewProj = multiply(
ortho(-hw, hw, -hh, hh, 0.1, CAMERA_DISTANCE * 2),
lookAt(eye, TARGET, [0, 1, 0]),
);
const keyDir = keyDirFor(lights.keyPitch);
const innerPitch = (lights.innerPitch * Math.PI) / 180;
// 1. Opaque boxes.
gl.disable(gl.BLEND);
gl.depthMask(true);
gl.useProgram(opaqueProg.program);
gl.uniformMatrix4fv(opaqueProg.u.uViewProj, false, viewProj);
gl.uniform3fv(opaqueProg.u.uToCamera, toCamera);
gl.uniform3fv(opaqueProg.u.uKeyDir, keyDir);
gl.uniform2f(opaqueProg.u.uInnerPitch, Math.sin(innerPitch), Math.cos(innerPitch));
gl.bindVertexArray(opaqueVao);
gl.drawArraysInstanced(gl.TRIANGLES, 0, CUBE_VERTEX_COUNT, OPAQUE_BOXES.length);
// 2. Glass, back to front, front faces only, depth-tested against opaque geometry.
// Per box: fill still-empty pixels with a dark backdrop (so the page never shows through
// as a pale haze), then composite the glass with plain alpha-over.
gl.enable(gl.BLEND);
gl.depthMask(false);
gl.useProgram(glassProg.program);
gl.uniformMatrix4fv(glassProg.u.uViewProj, false, viewProj);
gl.uniform3fv(glassProg.u.uToCamera, toCamera);
gl.uniform3fv(glassProg.u.uKeyDir, keyDir);
gl.bindVertexArray(glassVao);
const sorted = GLASS_BOXES
.map((b) => ({ b, depth: dot([b[0], b[1], b[2]], toCamera) }))
.sort((p, q) => p.depth - q.depth);
for (const { b } of sorted) {
gl.vertexAttrib3f(2, b[0], b[1], b[2]);
gl.vertexAttrib3f(3, b[3], b[4], b[5]);
gl.vertexAttrib3f(4, b[6], b[7], b[8]);
const count = b[8] === KIND_GLASS_SIDES ? SIDE_VERTEX_COUNT : CUBE_VERTEX_COUNT;
gl.blendFunc(gl.ONE_MINUS_DST_ALPHA, gl.ONE);
gl.uniform1i(glassProg.u.uPass, 0);
gl.drawArrays(gl.TRIANGLES, 0, count);
gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ZERO, gl.ONE);
gl.uniform1i(glassProg.u.uPass, 1);
gl.drawArrays(gl.TRIANGLES, 0, count);
}
gl.depthMask(true);
gl.disable(gl.BLEND);
gl.bindVertexArray(null);
if (animating) requestRender();
else lastFrame = 0;
}
function requestRender() {
if (!frameQueued) {
frameQueued = true;
requestAnimationFrame(render);
}
}
function stopMotion() {
resetAnim = null;
spin.az = spin.el = 0;
}
function rotate(dAzimuth, dElevation) {
view.azimuth += dAzimuth;
view.elevation = clamp(view.elevation + dElevation, -MAX_ELEVATION, MAX_ELEVATION);
requestRender();
}
function zoom(factor) {
view.halfExtent = clamp(view.halfExtent * factor, MIN_EXTENT, MAX_EXTENT);
requestRender();
}
function resetView() {
stopMotion();
// Take the shortest path back to the default azimuth.
const tau = Math.PI * 2;
const az = DEFAULT_VIEW.azimuth + ((((view.azimuth - DEFAULT_VIEW.azimuth) % tau) + tau + Math.PI) % tau) - Math.PI;
if (reducedMotion.matches) {
Object.assign(view, DEFAULT_VIEW);
} else {
resetAnim = {
start: performance.now(),
duration: 650,
from: { azimuth: az, elevation: view.elevation, halfExtent: view.halfExtent },
};
}
requestRender();
}
// ---- SVG export ----------------------------------------------------------
// Rebuilds a view on the CPU as plain SVG: every visible face becomes one <polygon> with a flat
// fill or a two-stop <linearGradient>, painted back to front; glass uses fill-opacity.
// shadeOpaque / shadeGlass mirror OPAQUE_FS / GLASS_FS, so keep them in sync.
const QUAD = [[-1, -1], [1, -1], [1, 1], [-1, 1]];
const SAMPLES_PER_UNIT = 128; // visibility probes per world unit along each face edge
const lerp3 = (a, b, t) => a.map((x, i) => x + (b[i] - x) * t);
const scale3 = (a, s) => a.map((x) => x * s);
const mul3 = (a, b) => a.map((x, i) => x * b[i]);
const boxMin = (b) => [b[0] - b[3] / 2, b[1] - b[4] / 2, b[2] - b[5] / 2];
const boxMax = (b) => [b[0] + b[3] / 2, b[1] + b[4] / 2, b[2] + b[5] / 2];
const faceCenterOf = (b, n) => [0, 1, 2].map((i) => b[i] + n[i] * b[i + 3] * 0.5);
const facePoint = (b, f, su, sv) =>
[0, 1, 2].map((i) => b[i] + 0.5 * (f.n[i] + su * f.u[i] + sv * f.v[i]) * b[i + 3]);
const num = (x) => String(Math.round(x * 100) / 100);
const toHex = (c) => '#' + c.map((x) => Math.round(clamp(x, 0, 1) * 255).toString(16).padStart(2, '0')).join('');
function fitRange(c) {
const pos = c.map((x) => Math.max(x, 0));
const m = Math.max(1, ...pos);
return pos.map((x) => x / m);
}
function shadeOpaque(b, n, t, S) {
const P = PALETTE;
const layer = b[6];
const fill = b[8] === KIND_FILL;
const fc = faceCenterOf(b, n);
const key = 0.6 + 0.4 * Math.max(dot(n, S.keyDir), 0);
let color, inner, lam;
if (n[1] > 0.5) {
color = scale3(lerp3(P.topLower, P.topUpper, layer), key / 0.6);
inner = P.innerTop;
lam = S.sinI;
} else if (n[1] < -0.5) {
color = scale3(lerp3(P.sideLowerLo, P.sideUpperLo, layer), 0.7 * key / 0.6);
inner = scale3(P.innerLo, 0.7);
lam = -S.sinI;
} else {
const hi = lerp3(P.sideLowerHi, P.sideUpperHi, layer);
const lo = lerp3(P.sideLowerLo, P.sideUpperLo, layer);
color = scale3(lerp3(lo, hi, t), key);
inner = lerp3(P.innerLo, P.innerHi, t);
lam = (-(n[0] * fc[0] + n[2] * fc[2]) >= 0 ? 1 : 0) * S.cosI;
}
if (layer > 0.5 && !fill) {
const back = clamp(0.5 - 0.7 * 0.70710678 * (fc[0] + fc[2]), 0, 1);
inner = scale3(inner, 0.9 + 0.1 * Math.max(dot(n, S.keyDir), 0));
color = lerp3(color, inner, back * Math.max(lam, 0));
}
if (fill) color = mul3(color, P.fillTint);
return fitRange(scale3(color, 1 + 0.06 * dot(sub(fc, TARGET), S.toCamera)));
}
function shadeGlass(b, n, t, S) {
const P = PALETTE;
const key = 0.6 + 0.4 * Math.max(dot(n, S.keyDir), 0);
let color;
if (n[1] > 0.5) color = scale3(P.glassTop, key / 0.6);
else if (n[1] < -0.5) color = scale3(P.glassLo, 0.7 * key / 0.6);
else color = scale3(lerp3(P.glassLo, P.glassHi, t), key);
const fc = faceCenterOf(b, n);
return fitRange(scale3(color, 1 + 0.06 * dot(sub(fc, TARGET), S.toCamera)));
}
// Side faces vary only with world height, so they need the colors at their bottom and top edge.
function faceShading(b, f, S, glass) {
const shade = glass ? shadeGlass : shadeOpaque;
if (Math.abs(f.n[1]) > 0.5) return { flat: shade(b, f.n, 0, S) };
const y0 = b[1] - b[4] / 2;
const y1 = b[1] + b[4] / 2;
const tOf = (y) => clamp(glass ? (y - b[7]) / b[4] : y - b[7], 0, 1);
return { y0, y1, c0: shade(b, f.n, tOf(y0), S), c1: shade(b, f.n, tOf(y1), S) };
}
// Orthographic projection matching render() on a square canvas of `size` px.
function makeProjector(v, size) {
const z = toCameraFor(v);
const x = normalize(cross([0, 1, 0], z));
const y = cross(z, x);
const k = size / 2 / v.halfExtent;
return (p) => {
const d = sub(p, TARGET);
return [size / 2 + dot(d, x) * k, size / 2 - dot(d, y) * k];
};
}
// Does the ray p + s·d (s > 0) pass through the inside of any box other than `self`?
function rayBlocked(p, d, boxes, self) {
for (const b of boxes) {
if (b === self) continue;
const lo = boxMin(b);
const hi = boxMax(b);
let t0 = 0;
let t1 = Infinity;
let hit = true;
for (let i = 0; i < 3 && hit; i++) {
if (Math.abs(d[i]) < 1e-12) {
hit = p[i] > lo[i] && p[i] < hi[i];
continue;
}
let a = (lo[i] - p[i]) / d[i];
let c = (hi[i] - p[i]) / d[i];
if (a > c) [a, c] = [c, a];
t0 = Math.max(t0, a);
t1 = Math.min(t1, c);
hit = t1 - t0 > 1e-6;
}
if (hit) return true;
}
return false;
}
function faceSamples(b, f) {
const extent = (axis) => Math.abs(dot(axis, [b[3], b[4], b[5]]));
const nu = Math.max(2, Math.ceil(extent(f.u) * SAMPLES_PER_UNIT));
const nv = Math.max(2, Math.ceil(extent(f.v) * SAMPLES_PER_UNIT));
const pts = [];
for (let i = 0; i < nu; i++) {
for (let j = 0; j < nv; j++) {
pts.push(facePoint(b, f, ((i + 0.5) / nu) * 2 - 1, ((j + 0.5) / nv) * 2 - 1));
}
}
return pts;
}
function convexHull(points) {
const p = [...points].sort((a, b) => a[0] - b[0] || a[1] - b[1]);
const turn = (o, a, b) => (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]);
const half = (list) => {
const out = [];
for (const q of list) {
while (out.length >= 2 && turn(out[out.length - 2], out[out.length - 1], q) <= 1e-9) out.pop();
out.push(q);
}
out.pop();
return out;
};
return [...half(p), ...half([...p].reverse())];
}
// Separating-axis test; touching outlines don't count as overlap.
function hullsOverlap(A, B) {
for (const poly of [A, B]) {
for (let i = 0; i < poly.length; i++) {
const a = poly[i];
const b = poly[(i + 1) % poly.length];
const axis = [a[1] - b[1], b[0] - a[0]];
const range = (pts) => {
const d = pts.map((q) => q[0] * axis[0] + q[1] * axis[1]);
return [Math.min(...d), Math.max(...d)];
};
const [minA, maxA] = range(A);
const [minB, maxB] = range(B);
const eps = 1e-6 * Math.hypot(axis[0], axis[1]);
if (maxA <= minB + eps || maxB <= minA + eps) return false;
}
}
return true;
}
// -1 if a is behind b, 1 if b is behind a, 0 if they are not separated along a view-facing axis.
// Boxes never intersect, so any separating axis gives the same answer where they overlap on screen.
function compareDepth(a, b, toCamera) {
const aLo = boxMin(a), aHi = boxMax(a), bLo = boxMin(b), bHi = boxMax(b);
for (let k = 0; k < 3; k++) {
if (Math.abs(toCamera[k]) < 1e-9) continue;
const toward = toCamera[k] > 0 ? 1 : -1;
if (aHi[k] <= bLo[k] + 1e-9) return -toward;
if (bHi[k] <= aLo[k] + 1e-9) return toward;
}
return 0;
}
// Back-to-front box order: topological sort over pairs that overlap on screen.
function paintOrder(boxes, toCamera, project) {
const hulls = boxes.map((b) => {
const lo = boxMin(b), hi = boxMax(b);
const corners = [];
for (let i = 0; i < 8; i++) {
corners.push(project([i & 1 ? hi[0] : lo[0], i & 2 ? hi[1] : lo[1], i & 4 ? hi[2] : lo[2]]));
}
return convexHull(corners);
});
const depth = boxes.map((b) => dot(b, toCamera));
const pending = boxes.map(() => new Set());
for (let i = 0; i < boxes.length; i++) {
for (let j = i + 1; j < boxes.length; j++) {
if (!hullsOverlap(hulls[i], hulls[j])) continue;
const r = compareDepth(boxes[i], boxes[j], toCamera);
if (r < 0) pending[j].add(i);
else if (r > 0) pending[i].add(j);
}
}
const order = [];
const left = new Set(boxes.keys());
while (left.size) {
const candidates = [...left].filter((i) => [...pending[i]].every((j) => !left.has(j)));
const pool = candidates.length ? candidates : [...left]; // only on a cycle
const next = pool.reduce((best, i) => (depth[i] < depth[best] ? i : best));
order.push(next);
left.delete(next);
}
return order;
}
// World height is affine across a face's screen polygon; returns the screen points where it
// equals yA and yB, i.e. the endpoints of a userSpaceOnUse gradient.
function gradientLine(pts2, ys, yA, yB) {
const [s0, s1, s2] = pts2;
const e1 = [s1[0] - s0[0], s1[1] - s0[1]];
const e2 = [s2[0] - s0[0], s2[1] - s0[1]];
const r1 = ys[1] - ys[0];
const r2 = ys[2] - ys[0];
const det = e1[0] * e2[1] - e1[1] * e2[0];
const g = [(r1 * e2[1] - r2 * e1[1]) / det, (e1[0] * r2 - e2[0] * r1) / det];
const gg = g[0] * g[0] + g[1] * g[1];
const at = (y) => [s0[0] + (g[0] * (y - ys[0])) / gg, s0[1] + (g[1] * (y - ys[0])) / gg];
return [at(yA), at(yB)];
}
/**
* Builds an SVG string of the scene.
* options.view { azimuth, elevation, halfExtent }, defaults to the default (logo) view
* options.lights { keyPitch, innerPitch } in degrees, defaults to the current sliders
* options.size output width/height in px (default 800, same framing as the reference)
* options.seamStroke same-paint stroke width on opaque faces. Renderers anti-alias each polygon
* separately, so the page leaks through shared edges as faint lines; the
* stroke covers them and a clip to the exact silhouette keeps the outline
* unchanged. 0 disables both (default 1)
*/
function toSVG(options = {}) {
const v = { ...DEFAULT_VIEW, ...options.view };
const L = { ...lights, ...options.lights };
const size = options.size ?? 800;
const seam = options.seamStroke ?? 1;
const toCamera = toCameraFor(v);
const innerPitch = (L.innerPitch * Math.PI) / 180;
const S = { toCamera, keyDir: keyDirFor(L.keyPitch), sinI: Math.sin(innerPitch), cosI: Math.cos(innerPitch) };
const project = makeProjector(v, size);
const awayFromCamera = scale3(toCamera, -1);
const items = [
...OPAQUE_BOXES.map((b) => ({ b, glass: false })),
...GLASS_BOXES.map((b) => ({ b, glass: true })),
];
const order = paintOrder(items.map((it) => it.b), toCamera, project);
const defs = [];
const backdrops = [];
const shapes = [];
const outline = []; // every visible face as one subpath; a single path anti-aliases as a union
const paintFor = (shading, pts2, ys) => {
if (shading.flat) return toHex(shading.flat);
const h0 = toHex(shading.c0);
const h1 = toHex(shading.c1);
if (h0 === h1) return h0;
const [p0, p1] = gradientLine(pts2, ys, shading.y0, shading.y1);
const id = `g${defs.length}`;
defs.push(
`<linearGradient id="${id}" gradientUnits="userSpaceOnUse" x1="${num(p0[0])}" y1="${num(p0[1])}" x2="${num(p1[0])}" y2="${num(p1[1])}">` +
`<stop offset="0" stop-color="${h0}"/><stop offset="1" stop-color="${h1}"/></linearGradient>`,
);
return `url(#${id})`;
};
for (const index of order) {
const { b, glass } = items[index];
const faces = b[8] === KIND_GLASS_SIDES ? FACES.slice(0, 4) : FACES;
for (const f of faces) {
if (dot(f.n, toCamera) <= 1e-6) continue;
const samples = faceSamples(b, f);
if (!samples.some((p) => !rayBlocked(p, toCamera, OPAQUE_BOXES, b))) continue; // fully hidden