Repository navigation
Expand file tree
/
Copy pathplaza.js
More file actions
892 lines (856 loc) · 53.8 KB
/
Copy pathplaza.js
File metadata and controls
892 lines (856 loc) · 53.8 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
// ============================================================================
// GENESIS PLAZA: DECENTRALAND-STYLE BUILDERS AT HUMAN SCALE
// ============================================================================
// Warm cobblestone, a theatre with a bulb marquee, round trees, classic lamp
// posts, shops with awnings, a neon tower, a casino and a hot-air balloon.
// The avatar is ~2.5m tall: doors are 3.5m, buildings 12-35m.
(() => {
const {
material, glow, shade, mesh, box, cylinder, sphere, facedBox, animate, orientation, textSprite,
labelTexture, windowsTexture, repeated, cobbleTexture, brickTexture, plankTexture, stuccoTexture, roofTileTexture, roundedSlab
} = PropKit.kit;
const ACCENT = '#1877f2';
function texturedMaterial(texture, repeatX, repeatY, options = {}) {
return new THREE.MeshStandardMaterial({ map: repeated(texture, repeatX, repeatY), roughness: 0.85, ...options });
}
// Row of glowing marquee bulbs along a straight line (instanced)
function bulbRow(group, from, to, count, color = '#fff3c4') {
const bulbs = new THREE.InstancedMesh(new THREE.SphereGeometry(0.16, 8, 6), glow(color, 1.6), count);
const matrix = new THREE.Matrix4();
for (let i = 0; i < count; i++) {
const t = count === 1 ? 0.5 : i / (count - 1);
matrix.makeTranslation(from.x + (to.x - from.x) * t, from.y + (to.y - from.y) * t, from.z + (to.z - from.z) * t);
bulbs.setMatrixAt(i, matrix);
}
group.add(bulbs);
return bulbs;
}
function bulbArc(group, radius, startAngle, endAngle, y, count, color = '#fff3c4') {
const bulbs = new THREE.InstancedMesh(new THREE.SphereGeometry(0.18, 8, 6), glow(color, 1.6), count);
const matrix = new THREE.Matrix4();
for (let i = 0; i < count; i++) {
const angle = startAngle + (endAngle - startAngle) * (i / (count - 1));
matrix.makeTranslation(Math.cos(angle) * radius, y, Math.sin(angle) * radius);
bulbs.setMatrixAt(i, matrix);
}
group.add(bulbs);
animate(bulbs, (time) => { bulbs.material.emissiveIntensity = 1.2 + Math.sin(time * 5) * 0.5; });
return bulbs;
}
function door(group, x, y, z, rotationY = 0, color = '#5d4037') {
const frame = new THREE.Group();
frame.add(box(3.4, 0.3, 0.4, material('#e9d8b4'), 0, 3.6, 0));
[-1.6, 1.6].forEach((side) => frame.add(box(0.3, 3.6, 0.4, material('#e9d8b4'), side, 1.8, 0)));
frame.add(box(3, 3.4, 0.12, material(color, { roughness: 0.6 }), 0, 1.7, 0.08));
frame.add(sphere(0.12, material('#ffd166', { metalness: 0.8 }), 1, 1.7, 0.2, 8));
frame.position.set(x, y, z);
frame.rotation.y = rotationY;
group.add(frame);
}
function windowRow(group, width, y, z, count, glassColor = '#9fd3ff') {
const step = width / count;
for (let i = 0; i < count; i++) {
const x = -width / 2 + step * (i + 0.5);
group.add(box(step * 0.55, 2.2, 0.15, material('#e9d8b4'), x, y, z));
group.add(box(step * 0.45, 1.9, 0.2, material(glassColor, { roughness: 0.1, metalness: 0.3, emissive: '#ffe9a8', emissiveIntensity: 0.15 }), x, y, z + 0.03));
}
}
const builders = {
// Round cobblestone plaza (no square block), with an optional square hole
// for the underground entrance pool, a lighter inner circle and four paths
plazaFloor(group, { w, h, data }) {
const radius = w / 2;
const shape = new THREE.Shape();
shape.absarc(0, 0, radius, 0, Math.PI * 2, false);
((data && data.holes) || []).forEach(([hx, hz, size]) => {
const half = size / 2;
const hole = new THREE.Path();
hole.moveTo(hx - half, -(hz - half));
hole.lineTo(hx + half, -(hz - half));
hole.lineTo(hx + half, -(hz + half));
hole.lineTo(hx - half, -(hz + half));
hole.closePath();
shape.holes.push(hole);
});
const floorTexture = repeated(cobbleTexture('#c98b5a'), 1, 1);
floorTexture.repeat.set(1 / 6, 1 / 6);
const top = mesh(new THREE.ShapeGeometry(shape, 64), new THREE.MeshStandardMaterial({ map: floorTexture, roughness: 0.9 }), 0, h / 2, 0);
top.rotation.x = -Math.PI / 2;
top.castShadow = false;
group.add(top);
const curb = mesh(new THREE.CylinderGeometry(radius, radius + 0.6, h + 0.3, 96, 1, true), texturedMaterial(stuccoTexture('#d9b38c'), 40, 1), 0, 0, 0);
group.add(curb);
const inner = cylinder(42, 42, 0.06, texturedMaterial(cobbleTexture('#e0b27c'), 14, 14), 0, h / 2 + 0.03, 0, 64);
inner.castShadow = false;
group.add(inner);
const ring = mesh(new THREE.RingGeometry(41.5, 43, 64), material('#8d5524'), 0, h / 2 + 0.07, 0);
ring.rotation.x = -Math.PI / 2;
group.add(ring);
for (let i = 0; i < 4; i++) {
const path = box(8, 0.05, radius - 43, texturedMaterial(cobbleTexture('#e0b27c'), 2, 8), 0, h / 2 + 0.03, -(43 + (radius - 43) / 2));
const pivot = new THREE.Group();
pivot.rotation.y = (i * Math.PI) / 2;
pivot.add(path);
group.add(pivot);
}
},
fountain(group, { w, h, color }) {
const radius = w / 2;
group.add(cylinder(radius, radius + 0.4, h, texturedMaterial(stuccoTexture('#e9d8b4'), 8, 1), 0, 0, 0, 48));
const water = cylinder(radius - 0.6, radius - 0.6, h * 0.2, material(color, { transparent: true, opacity: 0.8, roughness: 0.1, metalness: 0.2 }), 0, h * 0.42, 0, 48);
water.castShadow = false;
group.add(water);
for (let i = 0; i < 12; i++) {
const angle = (i / 12) * Math.PI * 2;
const jet = cylinder(0.08, 0.2, 2.2, glow('#bde0fe', 0.4, { transparent: true, opacity: 0.6 }), Math.cos(angle) * (radius - 1.2), h / 2 + 1, Math.sin(angle) * (radius - 1.2), 6);
jet.rotation.z = Math.cos(angle) * -0.4;
jet.rotation.x = Math.sin(angle) * 0.4;
group.add(jet);
animate(jet, (time) => jet.scale.set(1, 0.8 + Math.sin(time * 4 + i) * 0.2, 1));
}
},
// The theatre with the curved marquee from Decentraland, here as the Multiverse Theatre
theatre(group, { w, h, d, label, block }) {
const o = orientation(block, w, d, false);
const inner = new THREE.Group();
inner.rotation.y = o.rotationY;
const radius = o.w / 2;
const wall = texturedMaterial(brickTexture('#7b2d26'), 10, 4);
// Curved back drum
const drum = mesh(new THREE.CylinderGeometry(radius, radius, h, 48, 1, true, Math.PI, Math.PI), new THREE.MeshStandardMaterial({ map: repeated(brickTexture('#7b2d26'), 12, 4), roughness: 0.9, side: THREE.DoubleSide }), 0, h / 2, 0);
group.add(inner);
inner.add(drum);
// Roof dome
const roof = mesh(new THREE.SphereGeometry(radius, 48, 12, 0, Math.PI * 2, 0, Math.PI / 2), material('#4a1d1a'), 0, h, 0);
roof.scale.set(1, 0.18, 1);
inner.add(roof);
// Front facade pillars with an open entrance
[-1, 1].forEach((side) => inner.add(box(radius * 0.45, h, 2, wall, side * radius * 0.78, h / 2, 0)));
inner.add(box(radius * 2, h * 0.3, 2, wall, 0, h * 0.85, 0));
// Marquee: curved band with bulbs and the big sign
const marquee = mesh(new THREE.CylinderGeometry(radius * 0.9, radius * 0.9, 4, 48, 1, true, -Math.PI * 0.95, Math.PI * 0.9), material('#2b0f0d', { side: THREE.DoubleSide }), 0, h * 0.62, radius * 0.25);
marquee.rotation.y = Math.PI;
inner.add(marquee);
const signText = (label || 'GITHUB MULTIVERSE THEATRE').toUpperCase();
inner.add(facedBox(radius * 1.3, 3.2, 0.4, material('#2b0f0d'), new THREE.MeshBasicMaterial({ map: labelTexture(signText, { bg: '#fff8e7', fg: '#2b0f0d', width: 1024, height: 160, font: 'bold 78px Georgia, serif' }) }), 0, h * 0.62, radius * 1.16));
bulbArc(inner, radius * 1.17, Math.PI * 0.12, Math.PI * 0.88, h * 0.62 + 2.1, 40);
bulbArc(inner, radius * 1.17, Math.PI * 0.12, Math.PI * 0.88, h * 0.62 - 2.1, 40);
// Interior: wooden floor, stage, seats and a screen with the logo
inner.add(cylinder(radius - 0.5, radius - 0.5, 0.2, texturedMaterial(plankTexture('#8d5a2b'), 8, 8), 0, 0.1, -0.5, 32));
inner.add(box(radius * 1.2, 1.4, radius * 0.45, texturedMaterial(plankTexture('#5d3a1a'), 4, 2), 0, 0.7, -radius * 0.65));
for (let i = 0; i < 3; i++) inner.add(box(2.4, 0.35, 1, material('#5d3a1a'), 0, 0.18 + i * 0.35 * 0, -radius * 0.65 + radius * 0.225 + 0.5 + i * 0.01));
const screenTexture = BrandLogos.billboardTexture('GitHub', { tagline: 'Multiverse Live', background: '#0d1117', foreground: '#ffffff' });
const stageScreen = box(radius * 1.1, radius * 0.55, 0.2, new THREE.MeshBasicMaterial({ map: screenTexture }), 0, 1.4 + radius * 0.4, -radius * 0.86);
inner.add(stageScreen);
// The stage screen plays the official WWDC keynotes (muted autoplay, click for sound)
VideoScreens.register(stageScreen, radius * 1.1, radius * 0.55, VideoScreens.youtubeEmbed(['GEZhD3J89ZE', '0TD96VTf0Xs', 'q5D55G7Ejs8', 'GYkq9Rgoj8E', 'RXeOiIDNNek', '0_DjDdfqtUE']));
const seats = new THREE.InstancedMesh(new THREE.BoxGeometry(0.9, 0.9, 0.9), material('#b5262b', { roughness: 0.9 }), 60);
const matrix = new THREE.Matrix4();
for (let row = 0; row < 5; row++) {
for (let col = 0; col < 12; col++) {
matrix.makeTranslation(-radius * 0.55 + col * (radius * 1.1 / 11), 0.65, radius * 0.05 + row * 1.6 - radius * 0.15);
seats.setMatrixAt(row * 12 + col, matrix);
}
}
inner.add(seats);
// Purple banners on both sides like the reference screenshot
[-1, 1].forEach((side) => {
inner.add(box(0.2, 8, 0.2, material('#9e9e9e'), side * radius * 1.05, 4, radius * 0.9));
inner.add(facedBox(2.4, 5, 0.1, material('#6a2fb8'), new THREE.MeshBasicMaterial({ map: BrandLogos.billboardTexture('GitHub', { tagline: 'Multiverse', background: '#3d1a78', foreground: '#ffffff', width: 512, height: 1024 }) }), side * radius * 1.05 + side * 1.3, 5, radius * 0.9));
});
// Wide front staircase like the Decentraland Theatre, with red flower planters,
// brass handrails, warm lamps and stage spotlights on the marquee
const stepMaterial = texturedMaterial(cobbleTexture('#c98b5a'), 6, 1);
for (let i = 0; i < 5; i++) inner.add(box(radius * 1.2 - i * 0.6, 0.3 * (5 - i), 1.4, stepMaterial, 0, 0.15 * (5 - i), radius + 0.6 + i * 1.4));
[-1, 1].forEach((side) => {
inner.add(box(0.12, 0.12, 7, material('#d4a017', { metalness: 0.8, roughness: 0.3 }), side * radius * 0.55, 1.6, radius + 3.4));
[radius + 1, radius + 6].forEach((z) => {
inner.add(cylinder(0.9, 0.8, 1, texturedMaterial(stuccoTexture('#e9d8b4'), 2, 1), side * radius * 0.72, 0.5, z, 12));
for (let f = 0; f < 6; f++) inner.add(sphere(0.3, material(f % 2 ? '#d62828' : '#ff4d6d'), side * radius * 0.72 + Math.cos(f) * 0.45, 1.15, z + Math.sin(f) * 0.45, 8));
});
const lamp = new THREE.Group();
lamp.add(cylinder(0.08, 0.12, 4.5, material('#263238', { metalness: 0.6 }), 0, 2.25, 0, 8));
lamp.add(sphere(0.35, glow('#fff3c4', 1.2), 0, 4.7, 0, 10));
lamp.position.set(side * radius * 0.95, 0, radius + 4);
inner.add(lamp);
const spot = cylinder(0.3, 0.45, 0.8, material('#212529', { metalness: 0.6 }), side * radius * 0.5, h * 0.62 + 3.2, radius * 1.15, 10);
spot.rotation.x = 0.8;
inner.add(spot);
});
},
roundTree(group, { w, h, color }) {
group.add(cylinder(w * 0.08, w * 0.12, h * 0.55, material('#6d4c41'), 0, -h * 0.22, 0, 8));
const crown = material(color, { roughness: 0.9, flatShading: false });
[[0, 0.18, 0, 0.42], [0.22, 0.08, 0.1, 0.3], [-0.2, 0.1, -0.12, 0.32], [0.05, 0.36, -0.05, 0.3]].forEach(([x, y, z, r]) =>
group.add(sphere(w * r, crown, x * w, h * y + h * 0.1, z * w, 14)));
},
lampPost(group, { h, color }) {
const iron = material('#263238', { metalness: 0.6, roughness: 0.4 });
group.add(cylinder(0.12, 0.2, h, iron, 0, 0, 0, 8));
group.add(cylinder(0.35, 0.45, 0.6, iron, 0, -h / 2 + 0.3, 0, 8));
[-1, 1].forEach((side) => {
group.add(box(1.4, 0.1, 0.1, iron, side * 0.6, h / 2 - 0.3, 0));
const globe = sphere(0.38, glow(color || '#fff3c4', 0.9), side * 1.25, h / 2 - 0.7, 0, 12);
group.add(globe);
});
},
bench(group, { w, color, block }) {
const o = orientation(block, w, 1, false);
const inner = new THREE.Group();
inner.rotation.y = o.rotationY;
const wood = texturedMaterial(plankTexture(color || '#a8743f'), 1, 1);
inner.add(box(w, 0.12, 0.7, wood, 0, 0.55, 0));
inner.add(box(w, 0.6, 0.1, wood, 0, 0.95, -0.35));
[-1, 1].forEach((side) => inner.add(box(0.12, 0.55, 0.7, material('#263238'), side * (w / 2 - 0.2), 0.27, 0)));
group.add(inner);
},
flowerBed(group, { w, h, d }) {
group.add(roundedSlab(w, h, d, 0.6, texturedMaterial(brickTexture('#9c6644'), w / 2, 1)));
group.children[group.children.length - 1].position.y = -h / 2;
group.add(box(w - 0.4, 0.1, d - 0.4, material('#5d4037'), 0, h / 2, 0));
const colors = ['#ff6b6b', '#ffd43b', '#f783ac', '#ffffff', '#b197fc'];
for (let i = 0; i < Math.floor(w * d / 2); i++) {
group.add(sphere(0.22, material(colors[i % colors.length]), (((i * 37) % 100) / 100 - 0.5) * (w - 0.8), h / 2 + 0.25, (((i * 61) % 100) / 100 - 0.5) * (d - 0.8), 6));
}
},
// Decentraland-style shop: stucco walls, tile roof, awning, sign, door, windows
shop(group, { w, h, d, color, label, block }) {
const o = orientation(block, w, d, false);
const inner = new THREE.Group();
inner.rotation.y = o.rotationY;
const walls = roundedSlab(o.w, h, o.d, 1.2, texturedMaterial(stuccoTexture(shade(color, 0.3)), 2, 2));
walls.position.y = -h / 2;
inner.add(walls);
const roof = mesh(new THREE.ConeGeometry(Math.max(o.w, o.d) * 0.72, h * 0.45, 4), texturedMaterial(roofTileTexture(color), 3, 2, { flatShading: true }), 0, h / 2 + h * 0.22, 0);
roof.rotation.y = Math.PI / 4;
roof.scale.set(o.w / Math.max(o.w, o.d), 1, o.d / Math.max(o.w, o.d));
inner.add(roof);
door(inner, 0, -h / 2, o.d / 2 + 0.05);
windowRow(inner, o.w * 0.9, h * 0.15, o.d / 2 + 0.05, 3);
// Striped awning
const awningTexture = PropKit.kit.canvasTexture(`awning|${color}`, 128, 32, (ctx, cw, ch) => {
for (let i = 0; i < 8; i++) { ctx.fillStyle = i % 2 ? '#ffffff' : color; ctx.fillRect(i * 16, 0, 16, ch); }
});
const awning = box(o.w * 0.95, 0.15, 2.2, new THREE.MeshStandardMaterial({ map: awningTexture }), 0, -h / 2 + 4.4, o.d / 2 + 1.1);
awning.rotation.x = 0.3;
inner.add(awning);
if (label) {
inner.add(facedBox(o.w * 0.75, 1.6, 0.3, material('#3e2723'), new THREE.MeshBasicMaterial({ map: labelTexture(label, { bg: '#3e2723', fg: '#ffe8a3', font: 'bold 54px Georgia, serif' }) }), 0, h / 2 - 1.4, o.d / 2 + 0.2));
}
inner.add(box(1.2, 0.8, 0.8, material('#f8f9fa'), o.w * 0.35, -h / 2 + 0.4, o.d / 2 + 1.6));
group.add(inner);
},
// Purple neon tower (Aetheria boundary), like the right side of Decentraland's plaza
neonTower(group, { w, h, d, label, block }) {
const o = orientation(block, w, d, false);
const inner = new THREE.Group();
inner.rotation.y = o.rotationY;
const body = roundedSlab(o.w, h, o.d, 2, new THREE.MeshStandardMaterial({ map: repeated(windowsTexture('#3b1a5a', '#ff6ec7'), 3, Math.round(h / 4)), emissiveMap: repeated(windowsTexture('#000000', '#ff6ec7'), 3, Math.round(h / 4)), emissive: '#ffffff', emissiveIntensity: 0.35, roughness: 0.5 }));
body.position.y = -h / 2;
inner.add(body);
for (let i = 0; i < 4; i++) {
const strip = box(o.w + 0.3, 0.25, o.d + 0.3, glow(i % 2 ? '#ff6ec7' : '#8a5cff', 1.6), 0, -h / 2 + 4 + i * (h / 4.5), 0);
inner.add(strip);
animate(strip, (time) => { strip.material.emissiveIntensity = 1.1 + Math.sin(time * 3 + i) * 0.6; });
}
door(inner, 0, -h / 2, o.d / 2 + 0.05, 0, '#2a0f45');
inner.add(facedBox(o.w * 0.9, 3, 0.3, material('#1b0b2e'), new THREE.MeshBasicMaterial({ map: labelTexture(label || 'Aetheria', { bg: '#1b0b2e', fg: '#ff6ec7', border: '#8a5cff', font: 'bold 56px Segoe UI, Arial, sans-serif' }) }), 0, h / 2 - 3, o.d / 2 + 0.2));
group.add(inner);
},
casino(group, { w, h, d, label, block }) {
const o = orientation(block, w, d, false);
const inner = new THREE.Group();
inner.rotation.y = o.rotationY;
const body = roundedSlab(o.w, h, o.d, 1.5, texturedMaterial(stuccoTexture('#d81159'), 3, 3));
body.position.y = -h / 2;
inner.add(body);
inner.add(box(o.w + 1, 0.6, o.d + 1, material('#ffd166', { metalness: 0.6 }), 0, h / 2, 0));
door(inner, 0, -h / 2, o.d / 2 + 0.05, 0, '#2b0f0d');
const sign = facedBox(o.w * 0.9, 4, 0.4, material('#2b0f0d'), new THREE.MeshBasicMaterial({ map: labelTexture(label || 'Vegas', { bg: '#2b0f0d', fg: '#ffd166', font: 'bold 64px Georgia, serif' }) }), 0, h * 0.18, o.d / 2 + 0.3);
inner.add(sign);
const bulbs = bulbRow(inner, new THREE.Vector3(-o.w * 0.45, h * 0.18 + 2.2, o.d / 2 + 0.6), new THREE.Vector3(o.w * 0.45, h * 0.18 + 2.2, o.d / 2 + 0.6), 24, '#ffd166');
bulbRow(inner, new THREE.Vector3(-o.w * 0.45, h * 0.18 - 2.2, o.d / 2 + 0.6), new THREE.Vector3(o.w * 0.45, h * 0.18 - 2.2, o.d / 2 + 0.6), 24, '#ffd166');
animate(bulbs, (time) => { bulbs.material.emissiveIntensity = Math.sin(time * 8) > 0 ? 2 : 0.4; });
windowRow(inner, o.w * 0.9, h * 0.38, o.d / 2 + 0.05, 4, '#ffe066');
group.add(inner);
},
archGate(group, { w, h, d, label, block }) {
const o = orientation(block, w, d, true);
const inner = new THREE.Group();
inner.rotation.y = o.rotationY;
const stone = texturedMaterial(stuccoTexture('#e9d8b4'), 2, 4);
[-1, 1].forEach((side) => inner.add(roundedSlab(3, h * 0.6, o.d + 1, 0.8, stone)));
inner.children[0].position.set(-o.w / 2 + 1.5, -h / 2, 0);
inner.children[1].position.set(o.w / 2 - 1.5, -h / 2, 0);
const arch = mesh(new THREE.TorusGeometry(o.w / 2 - 1.5, 1.4, 12, 40, Math.PI), stone, 0, -h / 2 + h * 0.6, 0);
arch.scale.z = (o.d + 1) / 2.8;
inner.add(arch);
inner.add(facedBox(o.w * 0.6, 2.4, 0.5, material('#0d1b3e'), new THREE.MeshBasicMaterial({ map: labelTexture(label || 'GENESIS PLAZA', { bg: '#0d1b3e', fg: '#ffffff', border: ACCENT, font: 'bold 60px Segoe UI, Arial, sans-serif' }) }), 0, -h / 2 + h * 0.6 + o.w / 2 - 1.5, (o.d + 1) / 2 + 0.3));
group.add(inner);
},
plazaTower(group, { w, h, d, label, block }) {
const o = orientation(block, w, d, false);
const inner = new THREE.Group();
inner.rotation.y = o.rotationY;
const body = roundedSlab(o.w, h, o.d, 2.5, new THREE.MeshStandardMaterial({ map: repeated(windowsTexture('#d6dde8', '#ffe9a8'), 3, Math.round(h / 4)), roughness: 0.4, metalness: 0.2 }));
body.position.y = -h / 2;
inner.add(body);
const crown = cylinder(o.w * 0.4, o.w * 0.55, 4, glow(ACCENT, 0.6), 0, h / 2 + 2, 0, 24);
inner.add(crown);
inner.add(cylinder(0.2, 0.2, 8, material('#b0bec5'), 0, h / 2 + 8, 0, 6));
door(inner, 0, -h / 2, o.d / 2 + 0.05, 0, '#1b2a4a');
inner.add(facedBox(o.w * 0.9, 2.6, 0.3, material('#0d1b3e'), new THREE.MeshBasicMaterial({ map: labelTexture(label || 'Info', { bg: '#0d1b3e', fg: '#ffffff', border: ACCENT, font: 'bold 50px Segoe UI, Arial, sans-serif' }) }), 0, -h / 2 + 6, o.d / 2 + 0.2));
group.add(inner);
},
hotAirBalloon(group, { w, h, color }) {
const balloon = new THREE.Group();
const stripes = PropKit.kit.canvasTexture(`balloon|${color}`, 256, 64, (ctx, cw, ch) => {
for (let i = 0; i < 8; i++) { ctx.fillStyle = i % 2 ? '#ffd166' : color; ctx.fillRect(i * 32, 0, 32, ch); }
});
const envelope = mesh(new THREE.SphereGeometry(w / 2, 24, 18), new THREE.MeshStandardMaterial({ map: stripes, roughness: 0.7 }));
envelope.scale.y = 1.15;
balloon.add(envelope);
balloon.add(box(w * 0.25, w * 0.18, w * 0.25, texturedMaterial(plankTexture('#8d5a2b'), 1, 1), 0, -h / 2 + w * 0.09, 0));
[[-1, -1], [1, -1], [-1, 1], [1, 1]].forEach(([sx, sz]) => balloon.add(cylinder(0.04, 0.04, h - w * 0.55, material('#5d4037'), sx * w * 0.11, -h / 2 + w * 0.18 + (h - w * 0.55) / 2 - 0.1, sz * w * 0.11, 4)));
group.add(balloon);
const baseY = group.position.y;
animate(group, (time) => { group.position.y = baseY + Math.sin(time * 0.4) * 3; balloon.rotation.y = time * 0.1; });
},
hydrant(group, { h }) {
group.add(cylinder(0.25, 0.3, h, material('#d62828'), 0, 0, 0, 10));
group.add(sphere(0.27, material('#d62828'), 0, h / 2, 0, 10));
[-1, 1].forEach((side) => { const nozzle = cylinder(0.1, 0.1, 0.3, material('#d62828'), side * 0.3, h * 0.15, 0, 8); nozzle.rotation.z = Math.PI / 2; group.add(nozzle); });
},
infoKiosk(group, { h, label }) {
group.add(cylinder(0.6, 0.7, h, material('#0d1b3e'), 0, 0, 0, 12));
group.add(cylinder(0.75, 0.75, 0.3, glow(ACCENT, 0.8), 0, h / 2, 0, 12));
const caption = textSprite(label || 'Info', { width: 6, background: 'rgba(24, 119, 242, 0.85)' });
caption.position.y = h / 2 + 1.6;
group.add(caption);
}
};
// Decentraland-style posters and event cards
function posterTexture(title, subtitle, colors) {
return PropKit.kit.canvasTexture(`poster|${title}`, 512, 768, (ctx, w, h) => {
const gradient = ctx.createLinearGradient(0, 0, 0, h);
gradient.addColorStop(0, colors[0]);
gradient.addColorStop(1, colors[1]);
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, w, h);
ctx.fillStyle = 'rgba(255, 255, 255, 0.15)';
for (let i = 0; i < 12; i++) { ctx.beginPath(); ctx.arc((i * 97) % w, (i * 151) % h, 20 + (i % 4) * 18, 0, Math.PI * 2); ctx.fill(); }
ctx.fillStyle = '#ffffff';
ctx.textAlign = 'center';
ctx.font = 'bold 76px Segoe UI, Arial, sans-serif';
title.split(' ').forEach((word, index) => ctx.fillText(word.toUpperCase(), w / 2, 220 + index * 86));
ctx.font = '36px Segoe UI, Arial, sans-serif';
ctx.fillText(subtitle, w / 2, h - 150);
ctx.font = 'bold 34px Segoe UI, Arial, sans-serif';
ctx.fillText('GitHub Multiverse', w / 2, h - 70);
});
}
function eventCardTexture(world) {
return PropKit.kit.canvasTexture(`eventcard|${world.key}`, 512, 640, (ctx, w, h) => {
ctx.fillStyle = '#0d1b3e';
ctx.fillRect(0, 0, w, h);
const gradient = ctx.createLinearGradient(0, 0, w, 360);
gradient.addColorStop(0, world.color);
gradient.addColorStop(1, '#0d1b3e');
ctx.fillStyle = gradient;
ctx.fillRect(16, 16, w - 32, 360);
ctx.fillStyle = 'rgba(255, 255, 255, 0.18)';
for (let i = 0; i < 6; i++) ctx.fillRect(40 + i * 72, 300 - ((i * 53) % 160), 52, 60 + ((i * 53) % 160));
ctx.fillStyle = '#ffffff';
ctx.font = 'bold 44px Segoe UI, Arial, sans-serif';
ctx.fillText(world.name.slice(0, 20), 28, 430);
ctx.font = '26px Segoe UI, Arial, sans-serif';
ctx.fillStyle = '#c9d6f2';
const words = world.description.split(' ');
let line = '';
let y = 474;
words.forEach((word) => {
if (ctx.measureText(`${line} ${word}`).width > w - 60) { ctx.fillText(line, 28, y); line = word; y += 32; } else { line = line ? `${line} ${word}` : word; }
});
if (y < 540) ctx.fillText(line, 28, y);
ctx.fillStyle = '#e63946';
ctx.fillRect(28, h - 82, 200, 56);
ctx.fillStyle = '#ffffff';
ctx.font = 'bold 30px Segoe UI, Arial, sans-serif';
ctx.fillText('JUMP IN', 62, h - 44);
});
}
Object.assign(builders, {
// Round Welcome Hall inspired by Decentraland's: wooden floor, glass waterfall
// tube with a "Welcome" ring, curved mezzanine, hanging lamps, cafe tables
welcomeHall(group, { w, h, label }) {
const radius = w / 2;
const wood = texturedMaterial(plankTexture('#b07a45'), 10, 10);
const wall = new THREE.MeshStandardMaterial({ map: repeated(plankTexture('#8a5a33'), 16, 3), roughness: 0.8, side: THREE.DoubleSide });
group.add(cylinder(radius, radius, 0.3, wood, 0, 0.15, 0, 64));
// Curved walls with a wide entrance and big windows
const wallSegment = mesh(new THREE.CylinderGeometry(radius, radius, h, 64, 1, true, Math.PI * 0.62, Math.PI * 1.76), wall, 0, h / 2, 0);
group.add(wallSegment);
const windows = mesh(new THREE.CylinderGeometry(radius - 0.05, radius - 0.05, h * 0.35, 64, 1, true, Math.PI * 0.62, Math.PI * 1.76), material('#bfe3ff', { transparent: true, opacity: 0.5, roughness: 0.05, side: THREE.DoubleSide, emissive: '#bfe3ff', emissiveIntensity: 0.2 }), 0, h * 0.3, 0);
windows.castShadow = false;
group.add(windows);
// Ceiling ring with an open skylight
const ceiling = mesh(new THREE.RingGeometry(radius * 0.45, radius + 0.5, 64), material('#3a2416', { side: THREE.DoubleSide }), 0, h, 0);
ceiling.rotation.x = -Math.PI / 2;
group.add(ceiling);
const goldRing = mesh(new THREE.TorusGeometry(radius * 0.47, 0.25, 8, 64), glow('#ffb703', 1.2), 0, h - 0.2, 0);
goldRing.rotation.x = Math.PI / 2;
group.add(goldRing);
// Mezzanine balcony (walkable) with a glass railing and a ramp up to it
const mezzanine = mesh(new THREE.RingGeometry(radius * 0.72, radius - 0.3, 64, 1, Math.PI * 0.75, Math.PI * 1.5), wood, 0, h * 0.5, 0);
mezzanine.rotation.x = -Math.PI / 2;
group.add(mezzanine);
const balconyEdge = mesh(new THREE.CylinderGeometry(radius * 0.72, radius * 0.72, 0.6, 64, 1, true, Math.PI * 0.75 + Math.PI / 2, Math.PI * 1.5), material('#5d3a1a', { side: THREE.DoubleSide }), 0, h * 0.5 - 0.3, 0);
group.add(balconyEdge);
const railing = mesh(new THREE.CylinderGeometry(radius * 0.72, radius * 0.72, 1.1, 64, 1, true, Math.PI * 0.75 + Math.PI / 2, Math.PI * 1.5), material('#cfe8ff', { transparent: true, opacity: 0.35, side: THREE.DoubleSide }), 0, h * 0.5 + 0.55, 0);
railing.castShadow = false;
group.add(railing);
const steps = 14;
for (let i = 0; i < steps; i++) {
const angle = Math.PI * 0.62 - (i / steps) * 0.9;
group.add(box(3, 0.3, 1.6, wood, Math.cos(angle) * (radius - 2.2), (h * 0.5 * (i + 1)) / steps - 0.15, Math.sin(angle) * (radius - 2.2)));
group.children[group.children.length - 1].rotation.y = -angle;
}
// Central glass tube with falling water and the welcome ring sign
const tube = cylinder(3.2, 3.2, h - 0.3, material('#cfe8ff', { transparent: true, opacity: 0.25, roughness: 0.05, side: THREE.DoubleSide }), 0, h / 2, 0, 32);
tube.castShadow = false;
group.add(tube);
const rainTexture = PropKit.kit.canvasTexture('hallRain', 128, 256, (ctx, cw, ch) => {
ctx.clearRect(0, 0, cw, ch);
ctx.fillStyle = 'rgba(255, 255, 255, 0.8)';
for (let i = 0; i < 40; i++) ctx.fillRect((i * 29) % cw, (i * 53) % ch, 2, 18 + (i % 4) * 6);
});
const rainMap = repeated(rainTexture, 4, 2);
const rain = cylinder(2.9, 2.9, h - 0.4, new THREE.MeshBasicMaterial({ map: rainMap, transparent: true, depthWrite: false, side: THREE.DoubleSide }), 0, h / 2, 0, 24);
rain.castShadow = false;
group.add(rain);
animate(rain, (time) => { rainMap.offset.y = time * 1.2; });
group.add(cylinder(3.6, 3.8, 0.6, glow('#ffb703', 0.4), 0, 0.4, 0, 32));
const signTexture = PropKit.kit.canvasTexture(`welcomeRing|${label}`, 2048, 128, (ctx, cw, ch) => {
ctx.fillStyle = '#1b1208';
ctx.fillRect(0, 0, cw, ch);
ctx.fillStyle = '#ffd166';
ctx.font = 'bold 84px Segoe UI, Arial, sans-serif';
ctx.textBaseline = 'middle';
const text = `${label || 'Welcome to GitHub Multiverse'} ✦ `;
ctx.fillText(text + text, 0, ch / 2);
});
// Readable from outside (front faces) and from inside (back faces with a mirrored texture)
const ringSign = new THREE.Group();
ringSign.add(mesh(new THREE.CylinderGeometry(3.7, 3.7, 1.2, 48, 1, true), new THREE.MeshBasicMaterial({ map: signTexture, side: THREE.FrontSide })));
const mirrored = signTexture.clone();
mirrored.needsUpdate = true;
mirrored.wrapS = THREE.RepeatWrapping;
mirrored.repeat.x = -1;
ringSign.add(mesh(new THREE.CylinderGeometry(3.68, 3.68, 1.2, 48, 1, true), new THREE.MeshBasicMaterial({ map: mirrored, side: THREE.BackSide })));
ringSign.position.y = h * 0.55;
group.add(ringSign);
animate(ringSign, (time) => { ringSign.rotation.y = time * 0.25; });
// Hanging lamps, cafe tables with chairs and laptops, rugs and plants
for (let i = 0; i < 8; i++) {
const angle = (i / 8) * Math.PI * 2;
const lamp = new THREE.Group();
lamp.add(cylinder(0.05, 0.05, 3, material('#333'), 0, 1.5, 0, 4));
lamp.add(cylinder(0.9, 1.1, 0.5, material('#2b2d42'), 0, 0, 0, 16));
lamp.add(cylinder(0.85, 0.85, 0.1, glow('#ffd166', 1.5), 0, -0.25, 0, 16));
lamp.position.set(Math.cos(angle) * radius * 0.6, h - 3, Math.sin(angle) * radius * 0.6);
group.add(lamp);
}
const rugMaterial = material('#7a1f2b', { roughness: 1 });
for (let i = 0; i < 4; i++) {
const angle = Math.PI * 0.95 + i * (Math.PI * 1.1 / 3);
const x = Math.cos(angle) * radius * 0.55;
const z = Math.sin(angle) * radius * 0.55;
group.add(box(6, 0.04, 4, rugMaterial, x, 0.32, z));
group.add(cylinder(1, 1, 0.08, material('#7d8597', { metalness: 0.5 }), x, 1.25, z, 20));
group.add(cylinder(0.08, 0.15, 0.9, material('#555'), x, 0.8, z, 8));
group.add(PropKit.kit.laptop(x, 1.29, z + 0.2, 0));
[[-1.6, 0], [1.6, 0], [0, -1.6], [0, 1.6]].forEach(([dx, dz]) => {
const chair = new THREE.Group();
chair.add(box(0.7, 0.1, 0.7, material('#8fa3bf'), 0, 0.75, 0));
chair.add(box(0.7, 0.8, 0.1, material('#8fa3bf'), 0, 1.15, -0.3));
chair.add(cylinder(0.05, 0.05, 0.5, material('#555'), 0, 0.45, 0, 6));
chair.position.set(x + dx, 0, z + dz);
chair.rotation.y = Math.atan2(-dx, -dz);
group.add(PropKit.kit.interactive(chair, 'sit', 'Chair'));
});
group.add(sphere(0.6, material('#2f9e44'), x + 3.5, 1.2, z, 10));
group.add(cylinder(0.4, 0.3, 0.8, material('#e9d8b4'), x + 3.5, 0.6, z, 10));
}
},
// Curved wall of event cards: each card jumps into a World
eventsWall(group, { w, h, label }) {
const radius = w / 2;
const worlds = (window.MULTIVERSE_WORLDS || []).filter((world) => world.world);
const count = Math.max(worlds.length, 1);
const arc = Math.PI * 0.7;
group.add(mesh(new THREE.CylinderGeometry(radius + 0.4, radius + 0.4, h + 1, 48, 1, true, -arc / 2 - 0.08 + Math.PI, arc + 0.16), material('#2a1450', { side: THREE.DoubleSide }), 0, h / 2, 0));
worlds.forEach((world, index) => {
const angle = Math.PI - arc / 2 + (index + 0.5) * (arc / count);
const card = box(4.2, 5.2, 0.2, new THREE.MeshBasicMaterial({ map: eventCardTexture(world) }), Math.sin(angle) * radius, h / 2, Math.cos(angle) * radius);
card.rotation.y = angle + Math.PI;
card.userData.label = `${world.name} — JUMP IN`;
group.add(PropKit.kit.interactive(card, 'jump', world.key));
});
const title = textSprite(label || 'Events & Worlds', { width: 14, background: 'rgba(24, 119, 242, 0.9)' });
title.position.set(0, h + 2.5, -radius);
group.add(title);
},
glowRing(group, { w, color }) {
[0, 1.4].forEach((offset, index) => {
const ring = mesh(new THREE.TorusGeometry(w / 2 - offset, 0.12, 6, 96), glow(color || '#ffb703', 1.8), 0, 0.08, 0);
ring.rotation.x = Math.PI / 2;
ring.castShadow = false;
group.add(ring);
animate(ring, (time) => { ring.material.emissiveIntensity = 1.4 + Math.sin(time * 2 + index) * 0.5; });
});
},
// Announcement kiosk with a big screen and purple hexagon glow panels
announcementKiosk(group, { w, h, label }) {
const frame = material('#3a3f4b', { metalness: 0.5 });
[-1, 1].forEach((side) => group.add(box(0.4, h, 0.4, frame, side * (w / 2 - 0.2), 0, 0)));
const screenTexture = PropKit.kit.canvasTexture(`announce|${label}`, 512, 384, (ctx, cw, ch) => {
ctx.fillStyle = '#2a1450';
ctx.fillRect(0, 0, cw, ch);
ctx.fillStyle = '#1877f2';
ctx.beginPath(); ctx.arc(cw / 2, 70, 40, 0, Math.PI * 2); ctx.fill();
ctx.fillStyle = '#ffffff'; ctx.font = 'bold 40px Segoe UI, Arial'; ctx.textAlign = 'center'; ctx.fillText('GM', cw / 2, 84);
ctx.fillStyle = '#ffb3c7';
ctx.font = 'bold 40px Segoe UI, Arial';
(label || 'Get ready for the next Supply Drop!').split('|').forEach((line, index) => ctx.fillText(line, cw / 2, 170 + index * 52));
});
group.add(box(w, h * 0.42, 0.3, new THREE.MeshBasicMaterial({ map: screenTexture }), 0, h * 0.28, 0));
group.add(box(w + 0.3, h * 0.46, 0.2, frame, 0, h * 0.28, -0.12));
const hexTexture = PropKit.kit.canvasTexture('hexes', 256, 256, (ctx, cw, ch) => {
ctx.fillStyle = '#1a0b30';
ctx.fillRect(0, 0, cw, ch);
ctx.strokeStyle = '#c86bff';
ctx.lineWidth = 3;
for (let row = 0; row < 6; row++) {
for (let col = 0; col < 5; col++) {
const cx = col * 52 + (row % 2) * 26 + 10;
const cy = row * 45 + 10;
ctx.beginPath();
for (let k = 0; k < 6; k++) { const a = (k / 6) * Math.PI * 2; ctx.lineTo(cx + Math.cos(a) * 22, cy + Math.sin(a) * 22); }
ctx.closePath();
ctx.stroke();
}
}
});
group.add(box(w * 0.9, h * 0.35, 0.2, new THREE.MeshStandardMaterial({ map: hexTexture, emissiveMap: hexTexture, emissive: '#ffffff', emissiveIntensity: 0.9 }), 0, -h * 0.2, 0));
},
// Pond with lily pads (sit on them), cattails, a wooden bridge and fishing spots
pond(group, { w, h, d, color }) {
const water = mesh(new THREE.CylinderGeometry(1, 1, h, 48), material(color || '#3fb6c6', { transparent: true, opacity: 0.85, roughness: 0.1, metalness: 0.2 }), 0, 0, 0);
water.scale.set(w / 2, 1, d / 2);
water.castShadow = false;
group.add(water);
const curb = mesh(new THREE.TorusGeometry(1, 0.06, 8, 48), texturedMaterial(stuccoTexture('#d9b38c'), 8, 1), 0, h / 2, 0);
curb.scale.set(w / 2, d / 2, 8);
curb.rotation.x = Math.PI / 2;
group.add(curb);
const padMaterial = material('#6ab04c', { roughness: 0.8, side: THREE.DoubleSide });
[[-0.25, 0.1], [0.1, -0.2], [0.3, 0.2], [-0.05, 0.3], [-0.3, -0.25]].forEach(([px, pz], index) => {
const pad = mesh(new THREE.CircleGeometry(1.4, 20, 0.3, Math.PI * 2 - 0.6), padMaterial, px * w, h / 2 + 0.05, pz * d);
pad.rotation.x = -Math.PI / 2;
group.add(PropKit.kit.interactive(pad, 'sit', 'Lily pad'));
animate(pad, (time) => { pad.position.y = h / 2 + 0.05 + Math.sin(time + index) * 0.04; });
});
for (let i = 0; i < 16; i++) {
const angle = (i / 16) * Math.PI * 2 + 0.2;
const cattail = new THREE.Group();
cattail.add(cylinder(0.04, 0.05, 2.4, material('#8d9440'), 0, 1.2, 0, 4));
cattail.add(cylinder(0.12, 0.12, 0.5, material('#7a4b2a'), 0, 2.2, 0, 6));
cattail.position.set(Math.cos(angle) * w * 0.47, 0, Math.sin(angle) * d * 0.47);
cattail.rotation.z = (i % 3 - 1) * 0.1;
group.add(cattail);
}
// Arched wooden bridge across the pond
const bridge = new THREE.Group();
const wood = texturedMaterial(plankTexture('#a8743f'), 1, 4);
for (let i = 0; i <= 12; i++) {
const t = i / 12;
const plank = box(3.2, 0.25, w * 0.95 / 12 + 0.05, wood, 0, Math.sin(t * Math.PI) * 2 + h / 2 + 0.2, -w * 0.475 + t * w * 0.95);
plank.rotation.x = -Math.cos(t * Math.PI) * 0.25;
bridge.add(plank);
[-1.5, 1.5].forEach((x) => bridge.add(cylinder(0.08, 0.08, 1.1, wood, x, Math.sin(t * Math.PI) * 2 + h / 2 + 0.8, -w * 0.475 + t * w * 0.95, 6)));
}
bridge.rotation.y = Math.PI / 2;
group.add(bridge);
// Fishing spots on the shore
[[w * 0.5 + 0.8, 0], [-w * 0.5 - 0.8, d * 0.15]].forEach(([x, z]) => {
const spot = new THREE.Group();
spot.add(box(1.6, 0.15, 1.6, wood, 0, 0.08, 0));
const rod = cylinder(0.03, 0.05, 3, material('#5d3a1a'), 0, 1.3, 0, 6);
rod.rotation.z = x > 0 ? 0.9 : -0.9;
spot.add(rod);
spot.add(sphere(0.12, material('#ff6b6b'), x > 0 ? -2.2 : 2.2, 0.15, 0, 8));
spot.position.set(x, h / 2, z);
spot.userData.label = 'Fishing spot (E)';
group.add(PropKit.kit.interactive(spot, 'fish', 'Fishing spot'));
});
},
posterWall(group, { w, h, d, block }) {
const o = orientation(block, w, d, true);
const inner = new THREE.Group();
inner.rotation.y = o.rotationY;
inner.add(roundedSlab(o.w, h, o.d, 0.3, texturedMaterial(brickTexture('#b5533c'), o.w / 3, h / 3)));
inner.children[0].position.y = -h / 2;
const posters = [
['Hackathon Fridays', '48h of shipping · prizes', ['#ff5f6d', '#6a2fb8']],
['Career Mondays', 'Meet hiring teams · 2PM UTC', ['#1877f2', '#0d1b3e']],
['Cozy Fishing', 'Relax at the pond (press E)', ['#ffb703', '#fb5607']],
['Open Source Sundays', 'Pair on good first issues', ['#2da44e', '#0d4429']]
];
posters.forEach(([title, subtitle, colors], index) => {
const x = -o.w / 2 + (index + 0.5) * (o.w / posters.length);
inner.add(box(o.w / posters.length - 1, h * 0.75, 0.1, new THREE.MeshBasicMaterial({ map: posterTexture(title, subtitle, colors) }), x, 0, o.d / 2 + 0.06));
inner.add(box(o.w / posters.length - 0.7, h * 0.78, 0.06, material('#3e2723'), x, 0, o.d / 2 + 0.02));
});
group.add(inner);
}
});
// --------------------------------------------------------------------------
// Underground: square pool with submerged doors, water tunnel and the hall
// --------------------------------------------------------------------------
Object.assign(builders, {
// Square pool; its doors slide open when a cursor gets close, revealing a
// square vertical water tunnel down to the underground hall (main.js runs the fall)
squarePool(group, { w, data }) {
const size = w;
const depth = (data && data.depth) || 60;
const stone = texturedMaterial(stuccoTexture('#e9d8b4'), 4, 1);
// Rim around the opening
[[0, size / 2 + 0.5, size + 2, 1], [0, -size / 2 - 0.5, size + 2, 1], [size / 2 + 0.5, 0, 1, size], [-size / 2 - 0.5, 0, 1, size]].forEach(([x, z, rw, rd]) => group.add(box(rw, 0.5, rd, stone, x, 0.25, z)));
// Water surface (not solid) and glowing edge
const water = box(size, 0.1, size, material('#2ec4f2', { transparent: true, opacity: 0.55, roughness: 0.05, metalness: 0.2, emissive: '#1ea0d6', emissiveIntensity: 0.25 }), 0, -0.2, 0);
water.castShadow = false;
water.raycast = () => {};
group.add(water);
// Two submerged doors that slide apart
const doorMaterial = material('#37474f', { metalness: 0.7, roughness: 0.3 });
const doors = [-1, 1].map((side) => {
const door = box(size / 2, 0.3, size, doorMaterial, side * size / 4, -1.4, 0);
door.userData.side = side;
group.add(door);
return door;
});
// Square water tunnel walls going down, with streaming bubbles
const bubbles = PropKit.kit.canvasTexture('tunnelBubbles', 128, 256, (ctx, cw, ch) => {
ctx.fillStyle = 'rgba(30, 160, 214, 0.55)';
ctx.fillRect(0, 0, cw, ch);
ctx.fillStyle = 'rgba(255, 255, 255, 0.7)';
for (let i = 0; i < 40; i++) { ctx.beginPath(); ctx.arc((i * 37) % cw, (i * 61) % ch, 1 + (i % 4), 0, Math.PI * 2); ctx.fill(); }
});
const bubbleMap = repeated(bubbles, 2, depth / 8);
const tunnelMaterial = new THREE.MeshBasicMaterial({ map: bubbleMap, transparent: true, opacity: 0.8, side: THREE.DoubleSide, depthWrite: false });
[[0, size / 2, size, 0.1], [0, -size / 2, size, 0.1], [size / 2, 0, 0.1, size], [-size / 2, 0, 0.1, size]].forEach(([x, z, tw, td]) => {
const wall = box(tw, depth, td, tunnelMaterial, x, -1.6 - depth / 2, z);
wall.castShadow = false;
wall.raycast = () => {};
group.add(wall);
});
// Light shaft: sunlight entering through the pool water
const shaft = box(size * 0.85, depth, size * 0.85, new THREE.MeshBasicMaterial({ color: '#bfeaff', transparent: true, opacity: 0.12, depthWrite: false, blending: THREE.AdditiveBlending }), 0, -1.6 - depth / 2, 0);
shaft.raycast = () => {};
group.add(shaft);
animate(group, (time) => {
bubbleMap.offset.y = -time * 0.6;
const avatarPosition = typeof avatar !== 'undefined' ? avatar.position : null;
const center = group.getWorldPosition(new THREE.Vector3());
const near = avatarPosition && Math.hypot(avatarPosition.x - center.x, avatarPosition.z - center.z) < 10;
doors.forEach((door) => {
const target = near ? door.userData.side * (size * 0.75 + 0.5) : door.userData.side * size / 4;
door.position.x += (target - door.position.x) * 0.06;
});
group.userData.doorsOpen = Math.abs(doors[0].position.x) > size * 0.6;
});
group.userData.label = 'Underground entrance: step in and fall for 5 seconds';
window.undergroundEntrances = window.undergroundEntrances || [];
window.undergroundEntrances.push({ group, size, depth });
},
// Underground hall under the pool: closed rock cave around a Welcome Hall,
// a cozy bar/cafe social area, an elevator back to the surface
undergroundHall(group, { w, h, label }) {
const radius = w / 2;
builders.welcomeHall(group, { w, h, label: label || 'Welcome to the Underground' });
const rock = new THREE.MeshStandardMaterial({ color: '#5d4a3a', roughness: 1, flatShading: true, side: THREE.DoubleSide });
// Rock wall with an opening at +x where the history corridor starts
const gap = 2 * Math.asin(5.5 / (radius + 4));
group.add(mesh(new THREE.CylinderGeometry(radius + 4, radius + 4, h + 4, 24, 1, true, Math.PI / 2 + gap / 2, Math.PI * 2 - gap), rock, 0, h / 2, 0));
// Rock floor between the hall and the cave wall, plus a landing into the corridor
const caveFloor = material('#4a3b2e', { roughness: 1 });
group.add(cylinder(radius + 4, radius + 4, 0.3, caveFloor, 0, 0.12, 0, 48));
group.add(box(6, 0.3, 11, caveFloor, radius + 3, 0.12, 0));
// Ceiling with a square opening for the tunnel
const ceiling = new THREE.Shape();
ceiling.absarc(0, 0, radius + 4, 0, Math.PI * 2, false);
const opening = new THREE.Path();
opening.moveTo(-4, -4); opening.lineTo(4, -4); opening.lineTo(4, 4); opening.lineTo(-4, 4); opening.closePath();
ceiling.holes.push(opening);
const roof = mesh(new THREE.ShapeGeometry(ceiling, 24), rock, 0, h + 2, 0);
roof.rotation.x = Math.PI / 2;
group.add(roof);
// Glowing light where the tunnel enters
const skylight = box(8.4, 0.2, 8.4, glow('#bfeaff', 1.2), 0, h + 1.9, 0);
skylight.raycast = () => {};
group.add(skylight);
// Warm hanging lamps all around the cave
for (let i = 0; i < 10; i++) {
const angle = (i / 10) * Math.PI * 2;
group.add(sphere(0.45, glow('#ffb703', 1.8), Math.cos(angle) * (radius + 1.5), h - 1, Math.sin(angle) * (radius + 1.5), 10));
}
// Underground cafe: curved counter with stools, espresso machine, menu board, tables
const counterWood = new THREE.MeshStandardMaterial({ map: repeated(plankTexture('#6b3f22'), 6, 1), side: THREE.DoubleSide });
const counter = mesh(new THREE.CylinderGeometry(6, 6, 1.2, 32, 1, true, Math.PI * 0.15, Math.PI * 0.7), counterWood, radius * 0.45, 0.9, radius * 0.3);
group.add(counter);
group.add(PropKit.kit.interactive(box(0.7, 0.8, 0.5, material('#495057', { metalness: 0.7 }), radius * 0.45 + 2, 1.9, radius * 0.3 - 4.5), 'coffee', 'Underground Cafe espresso'));
for (let i = 0; i < 6; i++) {
const angle = Math.PI * 0.2 + i * (Math.PI * 0.6 / 5);
const stool = new THREE.Group();
stool.add(cylinder(0.35, 0.35, 0.12, material('#212529'), 0, 0.9, 0, 16));
stool.add(cylinder(0.05, 0.05, 0.9, material('#868e96', { metalness: 0.8 }), 0, 0.45, 0, 6));
stool.position.set(radius * 0.45 + Math.cos(angle) * 7.2, 0.3, radius * 0.3 + Math.sin(angle) * 7.2);
group.add(PropKit.kit.interactive(stool, 'sit', 'Cafe stool'));
}
const menu = facedBox(5, 2.4, 0.15, material('#2b1b12'), new THREE.MeshBasicMaterial({ map: labelTexture('UNDERGROUND CAFE · espresso · cold brew · git pull-over', { bg: '#2b1b12', fg: '#ffd166', font: 'bold 40px Georgia, serif' }) }), radius * 0.45 + 3, 4, radius * 0.3 - 6.5);
group.add(menu);
// Elevator back to Genesis Plaza
const elevator = new THREE.Group();
elevator.add(cylinder(1.6, 1.6, 0.3, glow('#1877f2', 0.8), 0, 0.45, 0, 24));
elevator.add(mesh(new THREE.CylinderGeometry(1.7, 1.7, 4, 24, 1, true), material('#cfe8ff', { transparent: true, opacity: 0.25, side: THREE.DoubleSide }), 0, 2.4, 0));
const caption = textSprite('Elevator · back to the surface (E)', { width: 7, background: 'rgba(24, 119, 242, 0.9)' });
caption.position.y = 5.2;
elevator.add(caption);
elevator.position.set(-radius * 0.6, 0, -radius * 0.45);
group.add(PropKit.kit.interactive(elevator, 'jump', 'plaza'));
},
// Firepit: circular fire surrounded by concentric rings of benches
firepit(group, { w }) {
const radius = w / 2;
group.add(cylinder(2.2, 2.4, 0.5, material('#7d7d7d', { roughness: 1, flatShading: true }), 0, 0.25, 0, 10));
const flame = mesh(new THREE.ConeGeometry(1.2, 3, 8), glow('#ff8c1a', 2.2, { transparent: true, opacity: 0.9 }), 0, 1.9, 0);
group.add(flame);
const inner = mesh(new THREE.ConeGeometry(0.7, 2, 8), glow('#ffe066', 2.5, { transparent: true, opacity: 0.9 }), 0, 1.5, 0);
group.add(inner);
animate(flame, (time) => { flame.scale.set(1, 0.85 + Math.sin(time * 12) * 0.15, 1); inner.scale.set(1, 0.8 + Math.sin(time * 17) * 0.2, 1); });
[radius * 0.45, radius * 0.75].forEach((ringRadius, ringIndex) => {
const count = ringIndex ? 12 : 8;
for (let i = 0; i < count; i++) {
const angle = (i / count) * Math.PI * 2 + ringIndex * 0.2;
const bench = new THREE.Group();
const wood = texturedMaterial(plankTexture('#a8743f'), 1, 1);
bench.add(box(2.6, 0.2, 0.8, wood, 0, 0.5 + ringIndex * 0.4, 0));
bench.add(box(2.6, 0.5 + ringIndex * 0.4, 0.6, material('#8d5524'), 0, (0.5 + ringIndex * 0.4) / 2, 0));
bench.position.set(Math.cos(angle) * ringRadius, 0, Math.sin(angle) * ringRadius);
bench.rotation.y = -angle + Math.PI / 2;
group.add(PropKit.kit.interactive(bench, 'sit', 'Firepit bench'));
}
});
group.userData.label = 'The Firepit: sit around the fire and chat';
},
// Modular mini-game arena: floating blocks, jump pads and a goal ring
miniGameArena(group, { w }) {
const radius = w / 2;
group.add(cylinder(radius, radius, 0.4, texturedMaterial(cobbleTexture('#7a5cff'), 10, 10), 0, 0.2, 0, 48));
{ const added = mesh(new THREE.TorusGeometry(radius, 0.3, 8, 64), glow('#9775fa', 1.4), 0, 0.5, 0); added.rotation.x = Math.PI / 2; group.add(added); }
const colors = ['#ff6b6b', '#ffd43b', '#69db7c', '#4dabf7', '#da77f2'];
for (let i = 0; i < 10; i++) {
const angle = (i / 10) * Math.PI * 2;
const height = 1 + (i % 5) * 1.4;
group.add(box(3, 0.8, 3, material(colors[i % colors.length], { roughness: 0.5 }), Math.cos(angle) * radius * 0.6, height, Math.sin(angle) * radius * 0.6));
}
for (let i = 0; i < 4; i++) {
const angle = (i / 4) * Math.PI * 2 + Math.PI / 4;
const pad = cylinder(1.4, 1.4, 0.25, glow('#40c057', 1.2), Math.cos(angle) * radius * 0.3, 0.55, Math.sin(angle) * radius * 0.3, 20);
group.add(pad);
window.jumpPads = window.jumpPads || [];
window.jumpPads.push(pad);
animate(pad, (time) => { pad.material.emissiveIntensity = 0.8 + Math.abs(Math.sin(time * 4 + i)) * 1.2; });
}
const goal = mesh(new THREE.TorusGeometry(2.5, 0.3, 10, 32), glow('#ffd43b', 1.6), 0, 12, 0);
group.add(goal);
animate(goal, (time) => { goal.rotation.y = time; });
const sign = textSprite('Mini-Game Arena · jump pads & floating blocks', { width: 14, background: 'rgba(119, 76, 255, 0.9)' });
sign.position.y = 16;
group.add(sign);
},
// Teleport portal: walk through the arch to jump into a World
teleportPortal(group, { w, h, color, label, data, block }) {
const facing = Math.atan2(-block.position[0], -block.position[2]);
const inner = new THREE.Group();
inner.rotation.y = facing;
const stone = texturedMaterial(stuccoTexture('#e9d8b4'), 2, 2);
inner.add(mesh(new THREE.TorusGeometry(w / 2, 0.6, 12, 40, Math.PI), stone, 0, 0.3, 0));
const energy = mesh(new THREE.CircleGeometry(w / 2 - 0.6, 40, 0, Math.PI), new THREE.MeshBasicMaterial({ color: color || '#4dabf7', transparent: true, opacity: 0.55, side: THREE.DoubleSide }), 0, 0.3, 0);
energy.raycast = () => {};
inner.add(energy);
animate(energy, (time) => { energy.material.opacity = 0.4 + Math.sin(time * 3) * 0.15; });
const sign = textSprite(label || 'Portal', { width: 9, background: 'rgba(24, 119, 242, 0.9)' });
sign.position.y = w / 2 + 2.2;
inner.add(sign);
group.add(inner);
window.teleportPortals = window.teleportPortals || [];
window.teleportPortals.push({ group, target: (data && data.target) || 'plaza', radius: w / 2 });
},
// Metro station: roundel sign, platform and a map kiosk (E opens the transit map)
metroStation(group, { w, label }) {
group.add(box(w, 0.4, 4, texturedMaterial(cobbleTexture('#b0a08a'), 4, 1), 0, 0.2, 0));
group.add(box(w, 0.1, 0.4, material('#ffd43b'), 0, 0.42, 1.8));
group.add(cylinder(0.12, 0.12, 4.5, material('#495057', { metalness: 0.6 }), -w / 2 + 1, 2.25, -1.4, 8));
const roundel = new THREE.Group();
roundel.add(mesh(new THREE.TorusGeometry(1, 0.28, 10, 32), material('#e03131')));
roundel.add(facedBox(2.8, 0.55, 0.1, material('#1877f2'), new THREE.MeshBasicMaterial({ map: labelTexture('METRO', { bg: '#1877f2', fg: '#ffffff', width: 256, height: 64, font: 'bold 44px Segoe UI, Arial' }) }), 0, 0, 0.15));
roundel.position.set(-w / 2 + 1, 4.6, -1.4);
group.add(roundel);
const kiosk = new THREE.Group();
kiosk.add(box(2.2, 2.6, 0.3, material('#0d1b3e'), 0, 1.7, 0));
kiosk.add(box(1.9, 2.2, 0.05, new THREE.MeshBasicMaterial({ map: labelTexture('Transit map · press E', { bg: '#ffffff', fg: '#0d1b3e', width: 256, height: 300, font: 'bold 30px Segoe UI, Arial' }) }), 0, 1.75, 0.18));
kiosk.position.set(w / 2 - 1.5, 0.4, -1);
group.add(PropKit.kit.interactive(kiosk, 'metro', label || 'Metro station'));
},
// Panoramic upper platform reachable by elevator, with Hall of Fame and Newsroom
skyPlatform(group, { w, h }) {
const radius = w / 2;
const deck = cylinder(radius, radius * 0.92, 1, texturedMaterial(plankTexture('#c49a6c'), 10, 10), 0, h, 0, 48);
group.add(deck);
group.add(mesh(new THREE.CylinderGeometry(radius, radius, 1.2, 48, 1, true), material('#cfe8ff', { transparent: true, opacity: 0.3, side: THREE.DoubleSide }), 0, h + 1.1, 0));
[0, 1, 2, 3, 4, 5].forEach((i) => {
const angle = (i / 6) * Math.PI * 2;
group.add(cylinder(0.6, 0.8, h, material('#e9d8b4'), Math.cos(angle) * radius * 0.7, h / 2, Math.sin(angle) * radius * 0.7, 12));
});
// Elevator shaft with pads at the bottom and at the top
group.add(mesh(new THREE.CylinderGeometry(1.8, 1.8, h + 4, 24, 1, true), material('#cfe8ff', { transparent: true, opacity: 0.2, side: THREE.DoubleSide }), 0, (h + 4) / 2, -radius - 1));
const up = cylinder(1.6, 1.6, 0.3, glow('#1877f2', 0.9), 0, 0.15, -radius - 1, 24);
up.userData.destination = new THREE.Vector3(0, h + 0.6, -radius * 0.6);
group.add(PropKit.kit.interactive(up, 'warp', 'Elevator up to the Panorama Deck'));
const down = cylinder(1.4, 1.4, 0.2, glow('#1877f2', 0.9), 0, h + 0.6, -radius * 0.75, 24);
down.userData.destination = new THREE.Vector3(0, 0.3, -radius - 4);
group.add(PropKit.kit.interactive(down, 'warp', 'Elevator down to the plaza'));
// Hall of Fame (top committers) and Newsroom (dev news) boards on the deck
const fame = TechBoards.board('hallOfFame');
group.add(box(8, 4.5, 0.3, new THREE.MeshBasicMaterial({ map: fame }), -radius * 0.45, h + 3.3, radius * 0.2));
group.children[group.children.length - 1].rotation.y = Math.PI / 2.5;
const news = TechBoards.board('newsroom');
group.add(box(8, 4.5, 0.3, new THREE.MeshBasicMaterial({ map: news }), radius * 0.45, h + 3.3, radius * 0.2));
group.children[group.children.length - 1].rotation.y = -Math.PI / 2.5;
const sign = textSprite('Panorama Deck · Hall of Fame · Newsroom', { width: 14, background: 'rgba(24, 119, 242, 0.9)' });
sign.position.y = h + 8;
group.add(sign);
}
});
const rules = [
[/plaza_floor/, 'plazaFloor'], [/^fountain/, 'fountain'], [/theatre/, 'theatre'], [/round_tree/, 'roundTree'],
[/lamp_post/, 'lampPost'], [/^bench/, 'bench'], [/flower_bed/, 'flowerBed'], [/^shop_/, 'shop'],
[/neon_tower|aetheria/, 'neonTower'], [/casino|vegas/, 'casino'], [/arch_gate|plaza_gate/, 'archGate'],
[/plaza_tower/, 'plazaTower'], [/hot_air_balloon/, 'hotAirBalloon'], [/hydrant/, 'hydrant'], [/info_kiosk/, 'infoKiosk'],
[/welcome_hall/, 'welcomeHall'], [/events_wall/, 'eventsWall'], [/glow_ring/, 'glowRing'], [/announcement_kiosk/, 'announcementKiosk'],
[/^pond/, 'pond'], [/poster_wall/, 'posterWall'], [/square_pool/, 'squarePool'], [/underground_hall/, 'undergroundHall'],
[/^firepit/, 'firepit'], [/mini_game_arena/, 'miniGameArena'], [/teleport_portal/, 'teleportPortal'], [/sky_platform/, 'skyPlatform'], [/metro_station/, 'metroStation']
];
rules.slice().reverse().forEach(([pattern, name]) => PropKit.registerBuilder(pattern, name, builders[name]));
})();