Repository navigation
Expand file tree
/
Copy pathgeometry-demo.html
More file actions
1329 lines (1193 loc) · 61.6 KB
/
Copy pathgeometry-demo.html
File metadata and controls
1329 lines (1193 loc) · 61.6 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 http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' 'wasm-unsafe-eval' https://www.googletagmanager.com https://cdn.jsdelivr.net; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: https:; font-src 'self' data:; connect-src 'self' blob: https://www.google-analytics.com https://*.google-analytics.com https://*.analytics.google.com https://cdn.jsdelivr.net https://api.sketchfab.com https://media.sketchfab.com; frame-src https://app.rerun.io; worker-src 'self' blob:; base-uri 'self'; object-src 'none'">
<script>
(function() {
try {
var t = localStorage.getItem('sceneview-theme');
if (t !== 'dark' && t !== 'light') {
t = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
}
document.documentElement.setAttribute('data-theme', t);
} catch(e) {
document.documentElement.setAttribute('data-theme', 'dark');
}
})();
</script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Site analytics — GA4 loader shared by every static page (G-HX1JWGSMTH).
Synchronous on purpose: /go/* interstitials call gtag() right after it. -->
<script src="/assets/analytics.js"></script>
<title>SceneView Geometry — Interactive 3D Showcase</title>
<meta name="description" content="SceneView procedural 3D geometry renderer. Professional scenes with PBR shading — architecture, product display, data viz, landscapes.">
<meta name="robots" content="index, follow">
<link rel="canonical" href="https://sceneview.github.io/geometry-demo.html">
<meta property="og:title" content="SceneView Geometry — Interactive 3D Showcase">
<meta property="og:description" content="Professional 3D scenes rendered in the browser with PBR shading. Architecture, product display, data visualization, and landscapes.">
<meta property="og:type" content="website">
<meta property="og:url" content="https://sceneview.github.io/geometry-demo.html">
<meta property="og:image" content="https://sceneview.github.io/og-image.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:image:alt" content="SceneView Geometry — Interactive 3D Showcase">
<meta property="og:site_name" content="SceneView">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="SceneView Geometry — Interactive 3D Showcase">
<meta name="twitter:description" content="Professional 3D scenes rendered in the browser with PBR shading. Architecture, product display, data visualization, and landscapes.">
<meta name="twitter:image" content="https://sceneview.github.io/og-image.png">
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<style>
/* THEME — the page chrome follows the visitor's choice; the 3D scene does not.
The canvas is a rendered scene, not a page surface: its backdrop is tied to
the shader's `fogColor`, which has to match whatever the camera fades into
or the horizon shows a seam, and to a `skyColor`/`groundColor` pair that
lights every material through the image-based lighting. Swapping the clear
colour alone would break the fog; swapping all three is a re-lighting of
the demo, not a theme. So the viewport stays a lit studio in both themes —
the same choice Blender, Unity and Figma make — and only the chrome flips.
That is exactly why every ratio below is measured on COMPOSITED pixels with
the canvas forced white AND black: in light theme the panels are pale
surfaces floating over a dark scene, in dark theme they are dark surfaces
that a bright material can light up from behind. The outline colour is the
one value that cannot flip with the theme — a pale edge vanishes on a light
panel, a dark edge vanishes on a dark one — so it is a single neutral grey,
#767676, in both. Worst measured case 3.22:1 (dark chip over a forced-white
scene), best 4.62:1; it was 1.47:1 on the chips and 1.29:1 on the panel rule
before, which no declared-colour check could see.
The @media block is the no-JS path and comes after the :root defaults it
overrides; `:not([data-theme="dark"])` leaves a stored dark choice alone,
and the explicit [data-theme="light"] rule after it wins the other way. */
:root {
color-scheme: dark light;
--gd-bg: #0d1117;
--gd-panel: rgba(13,17,23,0.96);
--gd-chip: rgba(13,17,23,0.90);
--gd-ink: #ffffff; /* 18.95:1 on the panel over the real scene */
--gd-ink-soft: rgba(255,255,255,0.88);
--gd-muted: #b7bdc6; /* 10.01:1 on --gd-bg */
--gd-edge: #767676; /* 3.22–4.22:1, white and black scene */
--gd-edge-hover: #9aa0a6;
--gd-rule: rgba(255,255,255,0.28);
/* 0.10 white lifted the control's fill to #2d3136 over a white scene, and
the neutral edge measured 2.88:1 against it — the panel was fine, the
fill on top of it was not. 0.06 puts it back at 3.25:1 worst case. */
--gd-ctl-fill: rgba(255,255,255,0.06);
--gd-ctl-fill-hover: rgba(255,255,255,0.16);
--gd-accent: #1663c9; /* white label 5.73:1 */
--gd-accent-hover: #1a73e8;
--gd-accent-edge: #a8c7fa; /* 3.34:1 on the fill */
--gd-danger: #8c2f2f; /* white label 8.19:1 */
--gd-danger-hover: #a63a3a;
--gd-danger-edge: #f2b8b5; /* 4.80:1 on the fill */
--gd-link: #8ab4f8; /* 9.00:1 on the badge chip */
--gd-focus: #8ab4f8; /* 8.27:1 on the panel */
--gd-spin-track: rgba(26,115,232,0.25);
--gd-spin-head: #4a9af5; /* 6.52:1 on --gd-bg */
--gd-track: rgba(255,255,255,0.25);
}
@media (prefers-color-scheme: light) {
:root:not([data-theme="dark"]) {
--gd-bg: #f5f8fc;
--gd-panel: rgba(255,255,255,0.96);
--gd-chip: rgba(255,255,255,0.92);
--gd-ink: #0d2137; /* 13.73:1 on the chip over the real scene */
--gd-ink-soft: #1d3047;
--gd-muted: #45586c; /* 6.88:1 on --gd-bg */
--gd-edge: #767676; /* 3.80–4.54:1, white and black scene */
--gd-edge-hover: #4a4a4a;
--gd-rule: rgba(13,33,55,0.24);
--gd-ctl-fill: rgba(13,33,55,0.06);
--gd-ctl-fill-hover: rgba(13,33,55,0.12);
--gd-accent: #0b57d0; /* white label 6.39:1 */
--gd-accent-hover: #0847ad;
--gd-accent-edge: #cfe0ff; /* 4.79:1 on the fill */
--gd-danger: #a32a26; /* white label 7.20:1 */
--gd-danger-hover: #8a221e;
--gd-danger-edge: #ffd6d3; /* 5.42:1 on the fill */
--gd-link: #005bc1; /* 5.42:1 on the badge chip */
--gd-focus: #0b57d0; /* 5.86:1 on the panel */
--gd-spin-track: rgba(11,87,208,0.25);
--gd-spin-head: #0b57d0; /* 6.00:1 on --gd-bg */
--gd-track: rgba(13,33,55,0.28);
}
}
:root[data-theme="light"] {
--gd-bg: #f5f8fc;
--gd-panel: rgba(255,255,255,0.96);
--gd-chip: rgba(255,255,255,0.92);
--gd-ink: #0d2137;
--gd-ink-soft: #1d3047;
--gd-muted: #45586c;
--gd-edge: #767676;
--gd-edge-hover: #4a4a4a;
--gd-rule: rgba(13,33,55,0.24);
--gd-ctl-fill: rgba(13,33,55,0.06);
--gd-ctl-fill-hover: rgba(13,33,55,0.12);
--gd-accent: #0b57d0;
--gd-accent-hover: #0847ad;
--gd-accent-edge: #cfe0ff;
--gd-danger: #a32a26;
--gd-danger-hover: #8a221e;
--gd-danger-edge: #ffd6d3;
--gd-link: #005bc1;
--gd-focus: #0b57d0;
--gd-spin-track: rgba(11,87,208,0.25);
--gd-spin-head: #0b57d0;
--gd-track: rgba(13,33,55,0.28);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--gd-bg); font-family: 'Inter', system-ui, sans-serif; }
canvas { width: 100%; height: 100%; display: block; cursor: grab; }
canvas:active { cursor: grabbing; }
/* Everything below floats on a live WebGL canvas whose colours are whatever
the scene renders — a white product-display backdrop one moment, a black
sky the next. Contrast computed against a *declared* background is
therefore meaningless here: each floating element carries its own opaque
chip, so its ratios hold against its own fill whatever passes underneath.
The chip alpha (0.90 and up) is what keeps the worst case — a fully white
scene under a dark chip, a fully black one under a light chip — from
pulling the fill out of range. */
.chip {
background: var(--gd-chip);
border: 2px solid var(--gd-edge);
border-radius: 10px;
padding: 4px 9px;
backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
/* `#shapeCount` is empty until the first scene finishes loading; without this
the chip shows as a small empty box over the spinner. */
.chip:empty { display: none; }
.badge {
position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
padding: 5px 15px; border-radius: 20px;
background: var(--gd-chip); border: 2px solid var(--gd-edge);
color: var(--gd-ink); font-size: 12px; font-weight: 500;
backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
pointer-events: none; z-index: 10;
}
.badge a { color: var(--gd-link); text-decoration: none; pointer-events: auto; }
.info {
position: fixed; top: 16px; left: 16px; z-index: 10;
color: var(--gd-ink-soft); font-size: 11px; line-height: 1.6;
pointer-events: none;
}
.title {
position: fixed; top: 16px; right: 16px; z-index: 10;
font-size: 18px; font-weight: 700; color: var(--gd-ink);
}
/* Loading overlay */
#loading {
position: fixed; inset: 0; z-index: 100;
display: flex; flex-direction: column; align-items: center; justify-content: center;
background: var(--gd-bg);
transition: opacity 0.6s ease;
}
#loading.hidden { opacity: 0; pointer-events: none; }
.spinner {
width: 40px; height: 40px; border: 3px solid var(--gd-spin-track);
border-top-color: var(--gd-spin-head); border-radius: 50%;
animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--gd-muted); font-size: 13px; margin-top: 14px; }
/* Controls panel */
.controls {
position: fixed; bottom: 50px; left: 50%; transform: translateX(-50%);
display: flex; gap: 8px; align-items: center; z-index: 20;
padding: 8px 14px; border-radius: 14px;
background: var(--gd-panel); border: 2px solid var(--gd-edge);
backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
flex-wrap: wrap; justify-content: center;
}
/* The outline is 2px, not 1px, for a reason that only shows on composited
pixels: the panel is centred and wraps, so at 375px the buttons land on
fractional x and a 1px border is antialiased across two pixels, neither
at full strength (measured #6b6d71 and #45484d where #8c8e91 was meant) —
2.55:1 instead of 4:1. At 2px one whole pixel is always the real colour.
The padding is 1px short of the visual value to keep the buttons the size
they were before the border grew.
The colour no longer flips with the theme: a translucent white edge, which
is what this was, reads as nothing at all on a light panel. See the note at
the top for the measurements behind the single neutral grey. */
.controls select, .controls button {
font-family: inherit; font-size: 12px; font-weight: 500;
border: 2px solid var(--gd-edge); border-radius: 8px;
background: var(--gd-ctl-fill); color: var(--gd-ink);
padding: 5px 11px; cursor: pointer; outline: none;
transition: all 0.2s;
}
.controls select:hover, .controls button:hover {
background: var(--gd-ctl-fill-hover); border-color: var(--gd-edge-hover);
}
/* The swatch's fill is whatever colour the user picked, so the ring cannot
be measured against it — it is measured against the panel it sits on. */
.controls input[type="color"] {
width: 30px; height: 30px; border: 2px solid var(--gd-edge);
border-radius: 8px; cursor: pointer; background: transparent; padding: 1px;
}
.controls .add-btn {
background: var(--gd-accent); border-color: var(--gd-accent-edge);
color: #fff; font-weight: 600;
}
.controls .add-btn:hover { background: var(--gd-accent-hover); }
/* No vendor colour on any of them, and the same rule as the playground for
who gets a button: "the assistant has a link that accepts a prefilled
prompt" — a protocol fact, not a recommendation. Three qualify today.
Alphabetical, no featured slot. "Copy prompt" comes first because it is the
path that works for every assistant, including the ones with no link. */
.controls .ai-btn {
display: inline-flex; align-items: center; gap: 5px;
font-family: inherit; font-size: 12px; font-weight: 600;
border: 2px solid var(--gd-edge); border-radius: 8px;
background: var(--gd-ctl-fill); color: var(--gd-ink);
padding: 5px 11px; cursor: pointer; outline: none;
text-decoration: none; transition: all 0.2s;
}
.controls .ai-btn:hover {
background: var(--gd-ctl-fill-hover); border-color: var(--gd-edge-hover);
}
.controls .ai-btn:focus-visible {
outline: 2px solid var(--gd-focus); outline-offset: 2px;
}
/* Its own row, full width of the panel: on a phone the scene controls
already wrap, and without this the label lands beside "Reset" and reads
as a caption for it. */
.controls .ai-row {
flex-basis: 100%;
display: flex; flex-wrap: wrap; align-items: center;
justify-content: center; gap: 8px;
margin-top: 4px; padding-top: 8px;
border-top: 1px solid var(--gd-rule);
}
.controls .ai-label {
color: var(--gd-ink-soft); font-size: 11px; font-weight: 600;
letter-spacing: 0.04em; text-transform: uppercase;
}
/* `/go/codex` says this in visible text and refuses to auto-redirect,
because `codex://` is an application scheme and a browser with no handler
does nothing at all. The same caveat lived here in a `title` attribute,
which a touch device never shows. */
.controls .ai-note {
flex-basis: 100%; text-align: center;
color: var(--gd-ink-soft); font-size: 10px; line-height: 1.5;
}
.controls .reset-btn {
background: var(--gd-danger); border-color: var(--gd-danger-edge);
color: #fff; font-size: 11px;
}
.controls .reset-btn:hover { background: var(--gd-danger-hover); }
.controls label {
color: var(--gd-ink-soft); font-size: 11px; display: flex; align-items: center; gap: 4px;
}
.controls .slider {
-webkit-appearance: none; width: 60px; height: 4px;
border-radius: 2px; background: var(--gd-track);
outline: none;
}
.controls .slider::-webkit-slider-thumb {
-webkit-appearance: none; width: 12px; height: 12px;
border-radius: 50%; background: var(--gd-spin-head); cursor: pointer;
}
.shape-count {
position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
color: var(--gd-ink-soft); font-size: 11px; z-index: 10;
pointer-events: none;
}
/* Scene preset buttons */
.presets {
position: fixed; top: 50px; right: 16px; z-index: 10;
display: flex; flex-direction: column; gap: 6px;
}
/* These sit on the bare canvas with no panel under them, so the chip has to
be part of the button itself. */
.presets button {
font-family: inherit; font-size: 11px; font-weight: 500;
border: 2px solid var(--gd-edge); border-radius: 8px;
background: var(--gd-chip); color: var(--gd-ink);
padding: 4px 9px; cursor: pointer; outline: none;
backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
transition: all 0.2s; text-align: right;
}
.presets button:hover { border-color: var(--gd-edge-hover); }
.presets button.active { background: var(--gd-accent); border-color: var(--gd-accent-edge); color: #fff; }
/* On a phone the panel wraps to several rows and the "Powered by SceneView"
badge wraps to two lines; 50px of clearance is no longer enough and the
panel lands on top of it.
The top row is laid out again here for the same reason: `.info` is a fixed
single line 272px wide that does not wrap, so at 375px it ran straight
under `.title` and `#shapeCount`, and a screen reader — or a photograph of
the page — read the three of them as one run-on string. They are stacked
instead: title left, count right, hint centred underneath, presets below
that. */
@media (max-width: 600px) {
.controls { bottom: 72px; }
.title { top: 12px; left: 12px; right: auto; font-size: 15px; }
.shape-count { top: 14px; left: auto; right: 12px; transform: none; }
.info {
top: 44px; left: 50%; right: auto; transform: translateX(-50%);
max-width: calc(100% - 24px); text-align: center;
}
/* `.info` wraps to two lines at this width; measured bottom 91.2px. */
.presets { top: 100px; right: 12px; }
}
</style>
</head>
<body>
<div id="loading">
<div class="spinner"></div>
<div class="loading-text">Loading scene...</div>
</div>
<canvas id="c"></canvas>
<div class="info chip">Drag to orbit | Scroll to zoom | Add shapes below</div>
<div class="title chip">Geometry Demo</div>
<div class="shape-count chip" id="shapeCount"></div>
<div class="presets">
<button class="active" data-scene="architecture" onclick="loadScene('architecture')">Architecture</button>
<button data-scene="product" onclick="loadScene('product')">Product Display</button>
<button data-scene="dataviz" onclick="loadScene('dataviz')">Data Viz</button>
<button data-scene="landscape" onclick="loadScene('landscape')">Landscape</button>
</div>
<div class="controls">
<select id="shapeType">
<option value="cube">Cube</option>
<option value="sphere">Sphere</option>
<option value="cylinder">Cylinder</option>
<option value="cone">Cone</option>
<option value="torus">Torus</option>
<option value="capsule">Capsule</option>
<option value="plane">Plane</option>
</select>
<input type="color" id="shapeColor" value="#4a9af5" title="Shape color">
<label>Metal <input type="range" class="slider" id="metalSlider" min="0" max="100" value="20"></label>
<label>Rough <input type="range" class="slider" id="roughSlider" min="0" max="100" value="40"></label>
<button class="add-btn" onclick="addUserShape()">+ Add Shape</button>
<button class="reset-btn" onclick="loadScene(currentPreset)">Reset</button>
<div class="ai-row">
<span class="ai-label">Build this in</span>
<button class="ai-btn" id="aiCopy" type="button" title="Copy the prompt to your clipboard — works with any assistant">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" aria-hidden="true"><rect x="9" y="9" width="11" height="11" rx="2" stroke="currentColor" stroke-width="2"/><path d="M5 15V5a2 2 0 012-2h10" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>
<span id="aiCopyText">Copy prompt</span>
</button>
<a class="ai-btn" id="aiChatGPT" href="https://chatgpt.com/" target="_blank" rel="noopener" title="Open ChatGPT with this prompt">ChatGPT</a>
<a class="ai-btn" id="aiClaude" href="https://claude.ai/new" target="_blank" rel="noopener" title="Open Claude with this prompt">Claude</a>
<a class="ai-btn" id="aiCodex" href="codex://new" rel="noopener">Codex</a>
<p class="ai-note">Copy works anywhere. ChatGPT and Claude open in a new tab;
Codex opens the desktop app, which has to be installed.</p>
</div>
</div>
<div class="badge">Powered by <a href="https://sceneview.github.io" target="_blank">SceneView</a> — Procedural 3D Geometry</div>
<script>
// SceneView Geometry Renderer — procedural 3D shapes with PBR shading
// Zero dependencies, pure WebGL2, embeddable anywhere a single HTML file runs
const canvas = document.getElementById('c');
const gl = canvas.getContext('webgl2', { antialias: true, alpha: false });
if (!gl) { document.body.innerHTML = '<p style="color:#fff;padding:40px">WebGL2 not supported</p>'; throw new Error('no webgl2'); }
// ── Shaders ──────────────────────────────────────────────────────────────────
// PBR with 3-point lighting, shadow approximation, and fog
const VS = `#version 300 es
precision highp float;
in vec3 aPos;
in vec3 aNormal;
uniform mat4 uMVP;
uniform mat4 uModel;
uniform mat3 uNormalMatrix;
out vec3 vNormal;
out vec3 vWorldPos;
void main() {
vec4 worldPos = uModel * vec4(aPos, 1.0);
vWorldPos = worldPos.xyz;
vNormal = normalize(uNormalMatrix * aNormal);
gl_Position = uMVP * vec4(aPos, 1.0);
}`;
const FS = `#version 300 es
precision highp float;
in vec3 vNormal;
in vec3 vWorldPos;
uniform vec3 uCamPos;
uniform vec3 uBaseColor;
uniform float uMetallic;
uniform float uRoughness;
uniform float uTime;
out vec4 fragColor;
const float PI = 3.14159265;
// 3-point studio lighting (brighter, more contrast)
const vec3 KEY_DIR = normalize(vec3(0.5, 0.85, 0.3));
const vec3 KEY_COLOR = vec3(4.2, 3.8, 3.2);
const vec3 FILL_DIR = normalize(vec3(-0.7, 0.3, -0.5));
const vec3 FILL_COLOR = vec3(0.7, 0.8, 1.3);
const vec3 RIM_DIR = normalize(vec3(-0.2, -0.1, -0.9));
const vec3 RIM_COLOR = vec3(0.5, 0.5, 0.8);
float D_GGX(float NdotH, float roughness) {
float a = roughness * roughness;
float a2 = a * a;
float d = NdotH * NdotH * (a2 - 1.0) + 1.0;
return a2 / (PI * d * d);
}
vec3 F_Schlick(float cosTheta, vec3 F0) {
return F0 + (1.0 - F0) * pow(clamp(1.0 - cosTheta, 0.0, 1.0), 5.0);
}
float G_Smith(float NdotV, float NdotL, float roughness) {
float r = roughness + 1.0;
float k = (r * r) / 8.0;
float g1 = NdotV / (NdotV * (1.0 - k) + k);
float g2 = NdotL / (NdotL * (1.0 - k) + k);
return g1 * g2;
}
vec3 evalLight(vec3 N, vec3 V, vec3 L, vec3 lightColor, vec3 F0, float NdotV) {
vec3 H = normalize(V + L);
float NdotL = max(dot(N, L), 0.0);
float NdotH = max(dot(N, H), 0.0);
float HdotV = max(dot(H, V), 0.0);
if (NdotL <= 0.0) return vec3(0.0);
vec3 F = F_Schlick(HdotV, F0);
float D = D_GGX(NdotH, uRoughness);
float G = G_Smith(NdotV, NdotL, uRoughness);
vec3 spec = (D * F * G) / (4.0 * NdotV * NdotL + 0.001);
vec3 kD = (1.0 - F) * (1.0 - uMetallic);
vec3 diffuse = kD * uBaseColor / PI;
return (diffuse + spec) * lightColor * NdotL;
}
void main() {
vec3 N = normalize(vNormal);
vec3 V = normalize(uCamPos - vWorldPos);
float NdotV = max(dot(N, V), 0.001);
vec3 F0 = mix(vec3(0.04), uBaseColor, uMetallic);
vec3 color = vec3(0.0);
color += evalLight(N, V, KEY_DIR, KEY_COLOR, F0, NdotV);
color += evalLight(N, V, FILL_DIR, FILL_COLOR, F0, NdotV);
color += evalLight(N, V, RIM_DIR, RIM_COLOR, F0, NdotV);
// Hemisphere ambient with ground bounce
vec3 skyColor = vec3(0.15, 0.2, 0.38);
vec3 groundColor = vec3(0.06, 0.05, 0.04);
float hemisphere = dot(N, vec3(0, 1, 0)) * 0.5 + 0.5;
vec3 ambient = mix(groundColor, skyColor, hemisphere) * uBaseColor * 0.5;
// Fresnel rim (more pronounced)
float rim = pow(1.0 - NdotV, 4.0);
ambient += vec3(0.1, 0.15, 0.3) * rim * 0.9;
// AO approximation
float ao = smoothstep(-0.3, 0.5, dot(N, vec3(0, 1, 0))) * 0.3 + 0.7;
ambient *= ao;
// Fake contact shadow: darken near ground
float contactShadow = smoothstep(0.0, 0.3, vWorldPos.y);
ambient *= mix(0.4, 1.0, contactShadow);
color += ambient;
// Environment reflections for ALL surfaces (not just metallic > 0.3)
vec3 R = reflect(-V, N);
float envUp = max(R.y, 0.0);
vec3 envColor = mix(vec3(0.06, 0.04, 0.1), vec3(0.25, 0.45, 0.9), envUp);
envColor += vec3(0.85, 0.75, 0.55) * pow(max(dot(R, KEY_DIR), 0.0), 20.0); // sun highlight
envColor += vec3(0.3, 0.4, 0.65) * pow(max(dot(R, FILL_DIR), 0.0), 10.0); // fill highlight
float envFresnel = pow(1.0 - NdotV, 3.0);
float envIntensity = mix(uMetallic * 0.25, 0.7, envFresnel) * (1.0 - uRoughness * 0.85);
color += envColor * max(envIntensity, 0.02); // subtle env even on rough dielectrics
// Distance fog (slightly blue-tinted)
float fogDist = length(vWorldPos - uCamPos);
float fog = 1.0 - exp(-fogDist * 0.018);
vec3 fogColor = vec3(0.04, 0.055, 0.085);
color = mix(color, fogColor, fog * 0.5);
// ACES tone mapping
color = color * (2.51 * color + 0.03) / (color * (2.43 * color + 0.59) + 0.14);
color = pow(color, vec3(1.0 / 2.2));
fragColor = vec4(color, 1.0);
}`;
// ── Grid shader ──────────────────────────────────────────────────────────────
const GRID_VS = `#version 300 es
precision highp float;
in vec3 aPos;
uniform mat4 uMVP;
out float vDist;
out vec2 vXZ;
void main() {
gl_Position = uMVP * vec4(aPos, 1.0);
vDist = length(aPos.xz);
vXZ = aPos.xz;
}`;
const GRID_FS = `#version 300 es
precision highp float;
in float vDist;
in vec2 vXZ;
out vec4 fragColor;
void main() {
float fade = 1.0 - smoothstep(5.0, 14.0, vDist);
float center = 1.0 - smoothstep(0.0, 4.0, vDist);
float alpha = (0.05 + center * 0.05) * fade;
fragColor = vec4(0.25, 0.45, 0.9, alpha);
}`;
// ── Shader compilation ───────────────────────────────────────────────────────
function createShader(type, src) {
const s = gl.createShader(type);
gl.shaderSource(s, src);
gl.compileShader(s);
if (!gl.getShaderParameter(s, gl.COMPILE_STATUS)) { console.error(gl.getShaderInfoLog(s)); return null; }
return s;
}
function createProgram(vs, fs) {
const p = gl.createProgram();
gl.attachShader(p, vs);
gl.attachShader(p, fs);
gl.linkProgram(p);
if (!gl.getProgramParameter(p, gl.LINK_STATUS)) { console.error(gl.getProgramInfoLog(p)); return null; }
return p;
}
const prog = createProgram(createShader(gl.VERTEX_SHADER, VS), createShader(gl.FRAGMENT_SHADER, FS));
const loc = {
aPos: gl.getAttribLocation(prog, 'aPos'),
aNormal: gl.getAttribLocation(prog, 'aNormal'),
uMVP: gl.getUniformLocation(prog, 'uMVP'),
uModel: gl.getUniformLocation(prog, 'uModel'),
uNormalMatrix: gl.getUniformLocation(prog, 'uNormalMatrix'),
uCamPos: gl.getUniformLocation(prog, 'uCamPos'),
uBaseColor: gl.getUniformLocation(prog, 'uBaseColor'),
uMetallic: gl.getUniformLocation(prog, 'uMetallic'),
uRoughness: gl.getUniformLocation(prog, 'uRoughness'),
uTime: gl.getUniformLocation(prog, 'uTime'),
};
const gridProg = createProgram(createShader(gl.VERTEX_SHADER, GRID_VS), createShader(gl.FRAGMENT_SHADER, GRID_FS));
const gridLoc = {
aPos: gl.getAttribLocation(gridProg, 'aPos'),
uMVP: gl.getUniformLocation(gridProg, 'uMVP'),
};
// ── Geometry generators ──────────────────────────────────────────────────────
function generateSphere(radius, widthSeg, heightSeg) {
const pos = [], nrm = [], idx = [];
for (let y = 0; y <= heightSeg; y++) {
for (let x = 0; x <= widthSeg; x++) {
const u = x / widthSeg, v = y / heightSeg;
const theta = u * Math.PI * 2, phi = v * Math.PI;
const sp = Math.sin(phi), cp = Math.cos(phi);
const st = Math.sin(theta), ct = Math.cos(theta);
const nx = sp * ct, ny = cp, nz = sp * st;
pos.push(radius * nx, radius * ny, radius * nz);
nrm.push(nx, ny, nz);
}
}
for (let y = 0; y < heightSeg; y++)
for (let x = 0; x < widthSeg; x++) {
const a = y * (widthSeg + 1) + x, b = a + widthSeg + 1;
idx.push(a, b, a + 1, b, b + 1, a + 1);
}
return { positions: new Float32Array(pos), normals: new Float32Array(nrm), indices: new Uint16Array(idx) };
}
function generateCube(size) {
const s = size / 2;
const faces = [
{ n: [0,0,1], verts: [[-s,-s,s],[s,-s,s],[s,s,s],[-s,s,s]] },
{ n: [0,0,-1], verts: [[s,-s,-s],[-s,-s,-s],[-s,s,-s],[s,s,-s]] },
{ n: [0,1,0], verts: [[-s,s,s],[s,s,s],[s,s,-s],[-s,s,-s]] },
{ n: [0,-1,0], verts: [[-s,-s,-s],[s,-s,-s],[s,-s,s],[-s,-s,s]] },
{ n: [1,0,0], verts: [[s,-s,s],[s,-s,-s],[s,s,-s],[s,s,s]] },
{ n: [-1,0,0], verts: [[-s,-s,-s],[-s,-s,s],[-s,s,s],[-s,s,-s]] },
];
const pos = [], nrm = [], idx = [];
faces.forEach((f, i) => {
f.verts.forEach(v => { pos.push(...v); nrm.push(...f.n); });
const o = i * 4; idx.push(o, o+1, o+2, o, o+2, o+3);
});
return { positions: new Float32Array(pos), normals: new Float32Array(nrm), indices: new Uint16Array(idx) };
}
function generateCylinder(radiusTop, radiusBottom, height, segments) {
const pos = [], nrm = [], idx = [];
const halfH = height / 2;
for (let i = 0; i <= segments; i++) {
const u = i / segments, angle = u * Math.PI * 2;
const cos = Math.cos(angle), sin = Math.sin(angle);
const slope = (radiusBottom - radiusTop) / height;
const nLen = Math.sqrt(1 + slope * slope);
pos.push(radiusTop * cos, halfH, radiusTop * sin);
nrm.push(cos / nLen, slope / nLen, sin / nLen);
pos.push(radiusBottom * cos, -halfH, radiusBottom * sin);
nrm.push(cos / nLen, slope / nLen, sin / nLen);
}
for (let i = 0; i < segments; i++) {
const a = i * 2, b = a + 1, c = a + 2, d = a + 3;
idx.push(a, b, c, b, d, c);
}
const addCap = (y, radius, ny) => {
const center = pos.length / 3;
pos.push(0, y, 0); nrm.push(0, ny, 0);
for (let i = 0; i <= segments; i++) {
const angle = (i / segments) * Math.PI * 2;
pos.push(radius * Math.cos(angle), y, radius * Math.sin(angle));
nrm.push(0, ny, 0);
}
for (let i = 0; i < segments; i++) {
if (ny > 0) idx.push(center, center + i + 1, center + i + 2);
else idx.push(center, center + i + 2, center + i + 1);
}
};
addCap(halfH, radiusTop, 1);
addCap(-halfH, radiusBottom, -1);
return { positions: new Float32Array(pos), normals: new Float32Array(nrm), indices: new Uint16Array(idx) };
}
function generatePlane(width, depth, widthSeg, depthSeg) {
const pos = [], nrm = [], idx = [];
const hw = width / 2, hd = depth / 2;
for (let z = 0; z <= depthSeg; z++)
for (let x = 0; x <= widthSeg; x++) {
pos.push(x / widthSeg * width - hw, 0, z / depthSeg * depth - hd);
nrm.push(0, 1, 0);
}
for (let z = 0; z < depthSeg; z++)
for (let x = 0; x < widthSeg; x++) {
const a = z * (widthSeg + 1) + x, b = a + widthSeg + 1;
idx.push(a, b, a + 1, b, b + 1, a + 1);
}
return { positions: new Float32Array(pos), normals: new Float32Array(nrm), indices: new Uint16Array(idx) };
}
function generateTorus(majorR, minorR, majorSeg, minorSeg) {
const pos = [], nrm = [], idx = [];
for (let j = 0; j <= majorSeg; j++) {
const phi = (j / majorSeg) * Math.PI * 2;
const cp = Math.cos(phi), sp = Math.sin(phi);
for (let i = 0; i <= minorSeg; i++) {
const theta = (i / minorSeg) * Math.PI * 2;
const ct = Math.cos(theta), st = Math.sin(theta);
pos.push((majorR + minorR * ct) * cp, minorR * st, (majorR + minorR * ct) * sp);
nrm.push(ct * cp, st, ct * sp);
}
}
for (let j = 0; j < majorSeg; j++)
for (let i = 0; i < minorSeg; i++) {
const a = j * (minorSeg + 1) + i, b = a + minorSeg + 1;
idx.push(a, b, a + 1, b, b + 1, a + 1);
}
return { positions: new Float32Array(pos), normals: new Float32Array(nrm), indices: new Uint16Array(idx) };
}
function generateCapsule(radius, height, capStacks, slices) {
const pos = [], nrm = [], idx = [];
const halfH = height / 2;
// Top hemisphere
for (let s = 0; s <= capStacks; s++) {
const phi = (Math.PI / 2) * (1 - s / capStacks);
const cp = Math.cos(phi), sp = Math.sin(phi);
for (let i = 0; i <= slices; i++) {
const theta = (i / slices) * Math.PI * 2;
const ct = Math.cos(theta), st = Math.sin(theta);
pos.push(radius * cp * ct, radius * sp + halfH, radius * cp * st);
nrm.push(cp * ct, sp, cp * st);
}
}
// Bottom hemisphere
for (let s = 1; s <= capStacks; s++) {
const phi = -(Math.PI / 2) * (s / capStacks);
const cp = Math.cos(phi), sp = Math.sin(phi);
for (let i = 0; i <= slices; i++) {
const theta = (i / slices) * Math.PI * 2;
const ct = Math.cos(theta), st = Math.sin(theta);
pos.push(radius * cp * ct, radius * sp - halfH, radius * cp * st);
nrm.push(cp * ct, sp, cp * st);
}
}
const totalStacks = capStacks * 2, stride = slices + 1;
for (let s = 0; s < totalStacks; s++)
for (let i = 0; i < slices; i++) {
const a = s * stride + i, b = a + stride;
idx.push(a, b, a + 1, b, b + 1, a + 1);
}
return { positions: new Float32Array(pos), normals: new Float32Array(nrm), indices: new Uint16Array(idx) };
}
function generateGrid(size, divisions) {
const pos = [], nrm = [], idx = [];
const step = size / divisions, half = size / 2;
let vi = 0;
for (let i = 0; i <= divisions; i++) {
const t = i * step - half;
pos.push(-half, 0, t, half, 0, t); nrm.push(0,1,0, 0,1,0); idx.push(vi, vi+1); vi += 2;
pos.push(t, 0, -half, t, 0, half); nrm.push(0,1,0, 0,1,0); idx.push(vi, vi+1); vi += 2;
}
return { positions: new Float32Array(pos), normals: new Float32Array(nrm), indices: new Uint16Array(idx), mode: gl.LINES };
}
// ── Mesh creation ────────────────────────────────────────────────────────────
function createMesh(geom) {
const vao = gl.createVertexArray();
gl.bindVertexArray(vao);
const posBuf = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, posBuf);
gl.bufferData(gl.ARRAY_BUFFER, geom.positions, gl.STATIC_DRAW);
gl.enableVertexAttribArray(loc.aPos);
gl.vertexAttribPointer(loc.aPos, 3, gl.FLOAT, false, 0, 0);
const nrmBuf = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, nrmBuf);
gl.bufferData(gl.ARRAY_BUFFER, geom.normals, gl.STATIC_DRAW);
gl.enableVertexAttribArray(loc.aNormal);
gl.vertexAttribPointer(loc.aNormal, 3, gl.FLOAT, false, 0, 0);
const idxBuf = gl.createBuffer();
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, idxBuf);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, geom.indices, gl.STATIC_DRAW);
gl.bindVertexArray(null);
return { vao, count: geom.indices.length, mode: geom.mode || gl.TRIANGLES };
}
function createGridMesh(geom) {
const vao = gl.createVertexArray();
gl.bindVertexArray(vao);
const posBuf = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, posBuf);
gl.bufferData(gl.ARRAY_BUFFER, geom.positions, gl.STATIC_DRAW);
gl.enableVertexAttribArray(gridLoc.aPos);
gl.vertexAttribPointer(gridLoc.aPos, 3, gl.FLOAT, false, 0, 0);
const idxBuf = gl.createBuffer();
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, idxBuf);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, geom.indices, gl.STATIC_DRAW);
gl.bindVertexArray(null);
return { vao, count: geom.indices.length };
}
// ── Prototype meshes ─────────────────────────────────────────────────────────
const prototypes = {
cube: createMesh(generateCube(1)),
sphere: createMesh(generateSphere(0.5, 48, 32)),
cylinder: createMesh(generateCylinder(0.5, 0.5, 1, 48)),
cone: createMesh(generateCylinder(0.0, 0.5, 1, 48)),
plane: createMesh(generatePlane(1, 1, 4, 4)),
line: createMesh(generateCylinder(0.02, 0.02, 1, 8)),
torus: createMesh(generateTorus(0.35, 0.15, 48, 24)),
capsule: createMesh(generateCapsule(0.3, 0.6, 12, 32)),
};
const gridMesh = createGridMesh(generateGrid(16, 32));
// ── Math utilities ───────────────────────────────────────────────────────────
function mat4Perspective(fov, aspect, near, far) {
const f = 1 / Math.tan(fov / 2), nf = 1 / (near - far);
return new Float32Array([f/aspect,0,0,0, 0,f,0,0, 0,0,(far+near)*nf,-1, 0,0,2*far*near*nf,0]);
}
function mat4LookAt(eye, center, up) {
const z = vecNormalize(vecSub(eye, center));
const x = vecNormalize(vecCross(up, z));
const y = vecCross(z, x);
return new Float32Array([x[0],y[0],z[0],0, x[1],y[1],z[1],0, x[2],y[2],z[2],0, -vecDot(x,eye),-vecDot(y,eye),-vecDot(z,eye),1]);
}
function mat4Multiply(a, b) {
const r = new Float32Array(16);
for (let i = 0; i < 4; i++)
for (let j = 0; j < 4; j++) { let s = 0; for (let k = 0; k < 4; k++) s += a[k*4+j] * b[i*4+k]; r[i*4+j] = s; }
return r;
}
function mat4Identity() { return new Float32Array([1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1]); }
function mat4Translate(tx, ty, tz) { return new Float32Array([1,0,0,0, 0,1,0,0, 0,0,1,0, tx,ty,tz,1]); }
function mat4Scale(sx, sy, sz) { return new Float32Array([sx,0,0,0, 0,sy,0,0, 0,0,sz,0, 0,0,0,1]); }
function mat4RotateY(angle) {
const c = Math.cos(angle), s = Math.sin(angle);
return new Float32Array([c,0,s,0, 0,1,0,0, -s,0,c,0, 0,0,0,1]);
}
function mat3NormalFromMat4(m) { return new Float32Array([m[0],m[1],m[2], m[4],m[5],m[6], m[8],m[9],m[10]]); }
function vecNormalize(v) { const l = Math.sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]); return l > 0 ? [v[0]/l,v[1]/l,v[2]/l] : [0,0,0]; }
function vecSub(a,b) { return [a[0]-b[0],a[1]-b[1],a[2]-b[2]]; }
function vecCross(a,b) { return [a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0]]; }
function vecDot(a,b) { return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]; }
// ── Scene presets ────────────────────────────────────────────────────────────
function makeBuilding(x, z, w, h, d, color, metallic, roughness) {
return { type: 'cube', position: [x, h/2, z], scale: [w, h, d], color, metallic, roughness };
}
const SCENES = {
architecture: (function() {
const shapes = [];
// Ground plane — concrete plaza
shapes.push({ type: 'plane', position: [0, 0.001, 0], scale: [16, 1, 16], color: [0.18, 0.18, 0.17], metallic: 0.0, roughness: 0.85 });
// Subtle grid overlay on ground (thin lines as cubes)
for (let i = -6; i <= 6; i++) {
shapes.push({ type: 'cube', position: [i, 0.005, 0], scale: [0.02, 0.01, 14], color: [0.25, 0.25, 0.24], metallic: 0.0, roughness: 0.9 });
shapes.push({ type: 'cube', position: [0, 0.005, i], scale: [14, 0.01, 0.02], color: [0.25, 0.25, 0.24], metallic: 0.0, roughness: 0.9 });
}
// === Main tower — modern glass skyscraper ===
shapes.push({ type: 'cube', position: [0, 3.5, -1.5], scale: [2.0, 7.0, 1.8], color: [0.35, 0.55, 0.75], metallic: 1.0, roughness: 0.05 }); // Glass facade
// Floor lines (horizontal bands)
for (let f = 0; f < 7; f++) {
shapes.push({ type: 'cube', position: [0, f + 0.3, -1.5], scale: [2.05, 0.04, 1.85], color: [0.2, 0.22, 0.25], metallic: 0.8, roughness: 0.2 });
}
// Roof accent
shapes.push({ type: 'cube', position: [0, 7.05, -1.5], scale: [2.1, 0.1, 1.9], color: [0.9, 0.9, 0.92], metallic: 1.0, roughness: 0.1 });
// === Secondary building — shorter, wider ===
shapes.push({ type: 'cube', position: [-3.0, 2.0, 0.5], scale: [2.5, 4.0, 2.0], color: [0.6, 0.62, 0.65], metallic: 0.9, roughness: 0.08 }); // Silver glass
for (let f = 0; f < 4; f++) {
shapes.push({ type: 'cube', position: [-3.0, f + 0.3, 0.5], scale: [2.55, 0.04, 2.05], color: [0.15, 0.15, 0.18], metallic: 0.7, roughness: 0.3 });
}
shapes.push({ type: 'cube', position: [-3.0, 4.05, 0.5], scale: [2.6, 0.1, 2.1], color: [0.85, 0.85, 0.88], metallic: 1.0, roughness: 0.1 });
// === Third building — warm tones, mid-height ===
shapes.push({ type: 'cube', position: [3.2, 1.75, 1.0], scale: [1.6, 3.5, 2.2], color: [0.75, 0.65, 0.55], metallic: 0.1, roughness: 0.3 }); // Marble-like
for (let f = 0; f < 3; f++) {
shapes.push({ type: 'cube', position: [3.2, f + 0.5, 1.0], scale: [1.65, 0.03, 2.25], color: [0.6, 0.5, 0.42], metallic: 0.05, roughness: 0.5 });
}
// === Low building — entrance / lobby ===
shapes.push({ type: 'cube', position: [0.5, 0.75, 2.0], scale: [5.0, 1.5, 1.5], color: [0.85, 0.85, 0.82], metallic: 0.1, roughness: 0.3 }); // Marble lobby
// Glass entrance door
shapes.push({ type: 'cube', position: [0.5, 0.5, 2.77], scale: [1.5, 1.0, 0.04], color: [0.4, 0.6, 0.8], metallic: 0.9, roughness: 0.05 });
// === Landscaping — trees ===
const treePositions = [[-1.5, 0, 3.5], [2.5, 0, 3.5], [-5.0, 0, 3.0], [5.5, 0, -2.0], [-5.5, 0, -3.0], [5.0, 0, 3.5]];
for (const [tx, , tz] of treePositions) {
// Trunk (brown wood)
shapes.push({ type: 'cylinder', position: [tx, 0.5, tz], scale: [0.12, 1.0, 0.12], color: [0.35, 0.22, 0.1], metallic: 0.0, roughness: 0.8 });
// Canopy (green sphere)
shapes.push({ type: 'sphere', position: [tx, 1.3, tz], scale: [0.8, 0.9, 0.8], color: [0.1, 0.42, 0.08], metallic: 0.0, roughness: 0.85 });
}
// === Reflective water feature — decorative pool ===
shapes.push({ type: 'plane', position: [3.5, 0.02, -3.0], scale: [3.0, 1, 2.5], color: [0.08, 0.15, 0.35], metallic: 0.9, roughness: 0.05 });
// Pool edge
shapes.push({ type: 'cube', position: [3.5, 0.06, -1.76], scale: [3.1, 0.08, 0.08], color: [0.7, 0.7, 0.68], metallic: 0.1, roughness: 0.3 });
shapes.push({ type: 'cube', position: [3.5, 0.06, -4.26], scale: [3.1, 0.08, 0.08], color: [0.7, 0.7, 0.68], metallic: 0.1, roughness: 0.3 });
// === Street lamps ===
const lampPositions = [[-1.0, 0, 4.5], [2.0, 0, 4.5], [5.5, 0, 0.5], [-5.5, 0, 0.5]];
for (const [lx, , lz] of lampPositions) {
shapes.push({ type: 'cylinder', position: [lx, 1.2, lz], scale: [0.05, 2.4, 0.05], color: [0.25, 0.25, 0.25], metallic: 0.7, roughness: 0.3 });
shapes.push({ type: 'sphere', position: [lx, 2.5, lz], scale: [0.2, 0.15, 0.2], color: [1.0, 0.95, 0.7], metallic: 0.0, roughness: 0.3 });
}
return shapes;
})(),
product: (function() {
const shapes = [];
// Dark studio floor
shapes.push({ type: 'plane', position: [0, 0.001, 0], scale: [14, 1, 14], color: [0.04, 0.04, 0.05], metallic: 0.3, roughness: 0.4 });
// === Central pedestal — marble ===
shapes.push({ type: 'cylinder', position: [0, 0.4, 0], scale: [2.0, 0.8, 2.0], color: [0.88, 0.86, 0.82], metallic: 0.1, roughness: 0.3 });
// Pedestal top ring
shapes.push({ type: 'cylinder', position: [0, 0.82, 0], scale: [2.1, 0.04, 2.1], color: [0.92, 0.9, 0.86], metallic: 0.15, roughness: 0.25 });
// Pedestal base ring
shapes.push({ type: 'cylinder', position: [0, 0.02, 0], scale: [2.2, 0.04, 2.2], color: [0.8, 0.78, 0.74], metallic: 0.15, roughness: 0.35 });
// === Hero product — chrome torus (like a luxury ring) ===
shapes.push({ type: 'torus', position: [0, 1.6, 0], scale: [1.0, 1.0, 1.0], color: [0.95, 0.93, 0.88], metallic: 1.0, roughness: 0.08 });
// === Floating chrome sphere inside torus ===
shapes.push({ type: 'sphere', position: [0, 1.6, 0], scale: [0.5, 0.5, 0.5], color: [0.3, 0.5, 0.9], metallic: 1.0, roughness: 0.05 });
// === Secondary products on smaller pedestals ===
// Left pedestal + sphere
shapes.push({ type: 'cylinder', position: [-3.5, 0.25, 1.5], scale: [1.0, 0.5, 1.0], color: [0.85, 0.83, 0.8], metallic: 0.1, roughness: 0.3 });
shapes.push({ type: 'sphere', position: [-3.5, 0.8, 1.5], scale: [0.6, 0.6, 0.6], color: [0.9, 0.25, 0.2], metallic: 0.8, roughness: 0.12 });
// Right pedestal + cube (gemstone style)
shapes.push({ type: 'cylinder', position: [3.5, 0.25, 1.5], scale: [1.0, 0.5, 1.0], color: [0.85, 0.83, 0.8], metallic: 0.1, roughness: 0.3 });
shapes.push({ type: 'cube', position: [3.5, 0.85, 1.5], scale: [0.5, 0.5, 0.5], color: [0.15, 0.8, 0.5], metallic: 0.9, roughness: 0.05 });
// Back pedestal + cone (crystal)
shapes.push({ type: 'cylinder', position: [0, 0.25, -3.5], scale: [1.0, 0.5, 1.0], color: [0.85, 0.83, 0.8], metallic: 0.1, roughness: 0.3 });
shapes.push({ type: 'cone', position: [0, 1.0, -3.5], scale: [0.6, 1.2, 0.6], color: [0.6, 0.3, 0.9], metallic: 0.95, roughness: 0.05 });
// === Studio lighting accents (glowing spheres off-screen suggest spot lights) ===
shapes.push({ type: 'sphere', position: [-5.0, 5.0, -4.0], scale: [0.3, 0.3, 0.3], color: [1.0, 0.98, 0.9], metallic: 0.0, roughness: 0.2 });
shapes.push({ type: 'sphere', position: [5.0, 5.0, -4.0], scale: [0.3, 0.3, 0.3], color: [1.0, 0.98, 0.9], metallic: 0.0, roughness: 0.2 });
shapes.push({ type: 'sphere', position: [0, 6.0, 3.0], scale: [0.25, 0.25, 0.25], color: [0.9, 0.92, 1.0], metallic: 0.0, roughness: 0.2 });
// === Subtle floor reflection marks (very thin cubes) ===
shapes.push({ type: 'cube', position: [0, 0.003, 0], scale: [2.5, 0.002, 2.5], color: [0.08, 0.08, 0.1], metallic: 0.8, roughness: 0.1 });
return shapes;
})(),
dataviz: (function() {
const shapes = [];
// Ground plane — dark with grid
shapes.push({ type: 'plane', position: [0, 0.001, 0], scale: [14, 1, 14], color: [0.06, 0.07, 0.1], metallic: 0.2, roughness: 0.6 });
// Grid lines on ground
for (let i = -5; i <= 5; i++) {
shapes.push({ type: 'cube', position: [i, 0.004, 0], scale: [0.015, 0.005, 10], color: [0.15, 0.2, 0.35], metallic: 0.3, roughness: 0.5 });
shapes.push({ type: 'cube', position: [0, 0.004, i], scale: [10, 0.005, 0.015], color: [0.15, 0.2, 0.35], metallic: 0.3, roughness: 0.5 });
}
// === 3D Bar chart ===
const barData = [
{ x: -3, z: -1, h: 4.5, color: [0.2, 0.55, 0.95] }, // Blue
{ x: -1.5, z: -1, h: 3.2, color: [0.2, 0.55, 0.95] },
{ x: 0, z: -1, h: 5.8, color: [0.2, 0.55, 0.95] },
{ x: 1.5, z: -1, h: 2.5, color: [0.2, 0.55, 0.95] },
{ x: 3, z: -1, h: 4.0, color: [0.2, 0.55, 0.95] },
{ x: -3, z: 1, h: 3.0, color: [0.15, 0.75, 0.4] }, // Green
{ x: -1.5, z: 1, h: 4.8, color: [0.15, 0.75, 0.4] },
{ x: 0, z: 1, h: 2.2, color: [0.15, 0.75, 0.4] },
{ x: 1.5, z: 1, h: 5.5, color: [0.15, 0.75, 0.4] },
{ x: 3, z: 1, h: 3.8, color: [0.15, 0.75, 0.4] },
{ x: -3, z: 3, h: 2.0, color: [0.95, 0.5, 0.15] }, // Orange
{ x: -1.5, z: 3, h: 3.5, color: [0.95, 0.5, 0.15] },
{ x: 0, z: 3, h: 4.2, color: [0.95, 0.5, 0.15] },
{ x: 1.5, z: 3, h: 1.8, color: [0.95, 0.5, 0.15] },
{ x: 3, z: 3, h: 3.0, color: [0.95, 0.5, 0.15] },
];
for (const bar of barData) {
shapes.push({ type: 'cube', position: [bar.x, bar.h / 2, bar.z], scale: [0.8, bar.h, 0.8], color: bar.color, metallic: 0.4, roughness: 0.25 });
// Top cap (slightly brighter)
shapes.push({ type: 'cube', position: [bar.x, bar.h + 0.02, bar.z], scale: [0.82, 0.04, 0.82], color: [bar.color[0] + 0.1, bar.color[1] + 0.1, bar.color[2] + 0.1], metallic: 0.5, roughness: 0.2 });
}
// === Axes ===
// X axis
shapes.push({ type: 'cube', position: [0, 0.01, -2.5], scale: [8, 0.04, 0.04], color: [0.7, 0.7, 0.75], metallic: 0.5, roughness: 0.3 });
// Y axis
shapes.push({ type: 'cube', position: [-4.2, 3.0, -2.5], scale: [0.04, 6.0, 0.04], color: [0.7, 0.7, 0.75], metallic: 0.5, roughness: 0.3 });
// Z axis
shapes.push({ type: 'cube', position: [-4.2, 0.01, 1.0], scale: [0.04, 0.04, 7.0], color: [0.7, 0.7, 0.75], metallic: 0.5, roughness: 0.3 });
// Y-axis tick marks
for (let y = 1; y <= 6; y++) {
shapes.push({ type: 'cube', position: [-4.2, y, -2.5], scale: [0.2, 0.02, 0.02], color: [0.5, 0.5, 0.55], metallic: 0.3, roughness: 0.4 });
}
// === Legend ===
// Blue legend