@adatechnology/game-urban-three 0.5.2 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -39,6 +39,13 @@ scene.add(drawn.root)
39
39
  // each frame: drawn.animate(t); when the camera moved: drawn.setFocus(x, z)
40
40
  ```
41
41
 
42
+
43
+ `drawNetworkSurface(networks, { surfaceAt })` draws what shows of the buried networks (`surfacePiecesOf`): PV and gallery box covers flush with the road
44
+ (2 mm over the frame, 2 mm over the lid), the inlets' grates, cleanout and valve covers, hydrants, the outfalls' wing walls, and at each lot the inspection
45
+ cover, the meter box and the downspout's mouth, in two instanced draw calls. `remove(id)` takes a piece off the ground (a cover thrown by a blast).
46
+ `drawBuriedNetworks(networks, { surfaceAt })` draws the pipes (two instanced halves each, so `sever(id, share)` can break one) and the pits under the covers
47
+ at their depths, in three draw calls: the terrain hides them and a crater deeper than their cover shows them.
48
+
42
49
  - Each `concrete_distribution` pole (or any registry pole with `slots`) stands at its node, turned with its arm toward its lamp: the mast
43
50
  instanced per spec, the hardware of `distributionHardwareOf` (crossarm and pin insulators where it carries medium voltage, the low-voltage
44
51
  clamp, one telecom clamp per cable, the arm and luminaire, the transformer's bracket and bushings) one instanced mesh of boxes, the
@@ -1,13 +1,14 @@
1
1
  // src/test-area/module.ts
2
+ import { createFixedFootprintRainCover } from "@adatechnology/game-contracts";
2
3
  import { isLightBudget } from "@adatechnology/game-render-three";
3
4
  import { discardObject3D } from "@adatechnology/game-shapes-three";
4
5
  import { createPlantProvider as createPlantProvider2, createUrban as createUrban2, createVehicleProvider as createVehicleProvider2, SAMPLE_CELLS } from "@adatechnology/game-urban";
5
- import { shapeGeometries as shapeGeometries5 } from "@adatechnology/game-shapes-three";
6
+ import { shapeGeometries as shapeGeometries8 } from "@adatechnology/game-shapes-three";
6
7
 
7
8
  // src/draw.ts
8
- import { markKitOrigin as markKitOrigin2 } from "@adatechnology/game-contracts";
9
+ import { markKitOrigin as markKitOrigin5 } from "@adatechnology/game-contracts";
9
10
  import { LIGHT_PRIORITY as LIGHT_PRIORITY2 } from "@adatechnology/game-render-three";
10
- import { shapeGeometries as shapeGeometries4, standOutCoincident } from "@adatechnology/game-shapes-three";
11
+ import { shapeGeometries as shapeGeometries7, standOutCoincident } from "@adatechnology/game-shapes-three";
11
12
 
12
13
  // src/lamp-light.ts
13
14
  var LAMP_FLICKER = { dim: 0.15, fast: 23, slow: 3.1, fastAbove: 0.3, slowAbove: 0.85, groups: 4 };
@@ -552,6 +553,307 @@ function drawNetworks(THREE, { networks, options, budget, physicalLights }) {
552
553
  };
553
554
  }
554
555
 
556
+ // src/networks/draw-buried.ts
557
+ import { markKitOrigin as markKitOrigin2 } from "@adatechnology/game-contracts";
558
+ import { shapeGeometries as shapeGeometries4 } from "@adatechnology/game-shapes-three";
559
+ import { pipePiecesOf, surfacePiecesOf } from "@adatechnology/game-urban/networks";
560
+ var PIPE_COLOR = { sewage: 12090186, water: 3108014, stormwater: 9342343 };
561
+ var SHAFT_COLOR = { concrete: 9342343, plastic: 12090186, cast_iron: 3882562 };
562
+ var PIPE_SEGMENTS = 8;
563
+ var SHAFT_SEGMENTS = 14;
564
+ var BREAK_GAP = 1.2;
565
+ var FLOOR = 0.1;
566
+ var ROOF_DEPTH = 4e-3;
567
+ function drawBuried(THREE, { networks, root, options }) {
568
+ const T = shapeGeometries4(THREE);
569
+ const group = markKitOrigin2(root ?? new THREE.Group(), { owner: "game-urban-three", kind: "network-buried" });
570
+ const pipes = pipePiecesOf(networks);
571
+ const shafts = surfacePiecesOf(networks, options).flatMap((piece) => piece.shaft === void 0 ? [] : [{ piece, shaft: piece.shaft }]);
572
+ const round2 = shafts.filter(({ shaft }) => shaft.shape === "round");
573
+ const square = shafts.filter(({ shaft }) => shaft.shape === "square");
574
+ const material = new THREE.MeshStandardMaterial({ color: 16777215, roughness: 0.85 });
575
+ const openMaterial = new THREE.MeshStandardMaterial({ color: 16777215, roughness: 0.85, side: THREE.DoubleSide });
576
+ const geometries = [new T.CylinderGeometry(1, 1, 1, PIPE_SEGMENTS), new T.CylinderGeometry(1, 1, 1, SHAFT_SEGMENTS, 1, true), new T.BoxGeometry(1, 1, 1)];
577
+ const make = (geometry, count, name, using) => {
578
+ const mesh = new THREE.InstancedMesh(geometry, using, Math.max(count, 1));
579
+ mesh.name = name;
580
+ mesh.count = count;
581
+ mesh.frustumCulled = false;
582
+ return mesh;
583
+ };
584
+ const pipeMesh = make(geometries[0], pipes.length * 2, "network:buried:pipes", material);
585
+ const roundMesh = make(geometries[1], round2.length, "network:buried:shafts", openMaterial);
586
+ const squareMesh = make(geometries[2], square.length, "network:buried:boxes", material);
587
+ const up = new THREE.Vector3(0, 1, 0);
588
+ const matrix = new THREE.Matrix4();
589
+ const color = new THREE.Color();
590
+ const place = (mesh, slot, from, to, radius) => {
591
+ const axis = new THREE.Vector3(to[0] - from[0], to[1] - from[1], to[2] - from[2]);
592
+ const length = axis.length();
593
+ const quaternion = new THREE.Quaternion().setFromUnitVectors(up, length === 0 ? up : axis.clone().normalize());
594
+ mesh.setMatrixAt(slot, matrix.compose(new THREE.Vector3((from[0] + to[0]) / 2, (from[1] + to[1]) / 2, (from[2] + to[2]) / 2), quaternion, new THREE.Vector3(radius, length, radius)));
595
+ };
596
+ const along = (pipe, share) => [pipe.from[0] + (pipe.to[0] - pipe.from[0]) * share, pipe.from[1] + (pipe.to[1] - pipe.from[1]) * share, pipe.from[2] + (pipe.to[2] - pipe.from[2]) * share];
597
+ const trimmed = (pipe, index) => {
598
+ const length = Math.hypot(pipe.to[0] - pipe.from[0], pipe.to[1] - pipe.from[1], pipe.to[2] - pipe.from[2]);
599
+ if (length < 0.1) return pipe;
600
+ const [start, end] = [(index % 7 + 1) * 3e-3, (index % 5 + 1) * 4e-3];
601
+ const at = (share) => along(pipe, share);
602
+ return { ...pipe, from: at(start / length), to: at(1 - end / length) };
603
+ };
604
+ const halves = (whole, index, gap) => {
605
+ const pipe = trimmed(whole, index);
606
+ if (gap[0] === gap[1]) {
607
+ place(pipeMesh, index * 2, pipe.from, pipe.to, pipe.diameter / 2);
608
+ pipeMesh.setMatrixAt(index * 2 + 1, matrix.makeScale(0, 0, 0));
609
+ return;
610
+ }
611
+ place(pipeMesh, index * 2, pipe.from, along(pipe, gap[0]), pipe.diameter / 2);
612
+ place(pipeMesh, index * 2 + 1, along(pipe, gap[1]), pipe.to, pipe.diameter / 2);
613
+ };
614
+ const slotOf = new Map(pipes.map((pipe, index) => [pipe.id, index]));
615
+ pipes.forEach((pipe, index) => {
616
+ halves(pipe, index, [0.5, 0.5]);
617
+ for (const slot of [index * 2, index * 2 + 1]) pipeMesh.setColorAt(slot, color.set(PIPE_COLOR[pipe.content]));
618
+ });
619
+ round2.forEach(({ piece, shaft }, slot) => {
620
+ const [x, , z] = piece.at;
621
+ place(roundMesh, slot, [x, shaft.bottom - FLOOR, z], [x, shaft.top, z], shaft.width / 2);
622
+ roundMesh.setColorAt(slot, color.set(SHAFT_COLOR[shaft.material]));
623
+ });
624
+ square.forEach(({ piece, shaft }, slot) => {
625
+ const height = shaft.top - ROOF_DEPTH - shaft.bottom + FLOOR;
626
+ squareMesh.setMatrixAt(slot, matrix.compose(new THREE.Vector3(piece.at[0], shaft.top - ROOF_DEPTH - height / 2, piece.at[2]), new THREE.Quaternion().setFromAxisAngle(up, piece.ry), new THREE.Vector3(shaft.width, height, shaft.depth)));
627
+ squareMesh.setColorAt(slot, color.set(SHAFT_COLOR[shaft.material]));
628
+ });
629
+ group.add(pipeMesh, roundMesh, squareMesh);
630
+ return {
631
+ root: group,
632
+ pipes,
633
+ drawCalls: () => [pipeMesh, roundMesh, squareMesh].filter((mesh) => mesh.count > 0).length,
634
+ sever(id, share) {
635
+ const index = slotOf.get(id);
636
+ const pipe = index === void 0 ? void 0 : pipes[index];
637
+ if (index === void 0 || pipe === void 0) return;
638
+ const length = Math.hypot(pipe.to[0] - pipe.from[0], pipe.to[1] - pipe.from[1], pipe.to[2] - pipe.from[2]);
639
+ const half = Math.min(0.5, BREAK_GAP / 2 / Math.max(length, 1e-6));
640
+ halves(pipe, index, [Math.max(0, share - half), Math.min(1, share + half)]);
641
+ pipeMesh.instanceMatrix.needsUpdate = true;
642
+ },
643
+ mend(id) {
644
+ const index = slotOf.get(id);
645
+ const pipe = index === void 0 ? void 0 : pipes[index];
646
+ if (index === void 0 || pipe === void 0) return;
647
+ halves(pipe, index, [0.5, 0.5]);
648
+ pipeMesh.instanceMatrix.needsUpdate = true;
649
+ },
650
+ dispose() {
651
+ group.parent?.remove(group);
652
+ for (const mesh of [pipeMesh, roundMesh, squareMesh]) mesh.dispose();
653
+ for (const item of [...geometries, material, openMaterial]) item.dispose();
654
+ }
655
+ };
656
+ }
657
+
658
+ // src/networks/draw-lid.ts
659
+ import { markKitOrigin as markKitOrigin3 } from "@adatechnology/game-contracts";
660
+ import { shapeGeometries as shapeGeometries5 } from "@adatechnology/game-shapes-three";
661
+ import { COVER_PLATE_PART } from "@adatechnology/game-urban/networks";
662
+
663
+ // src/networks/surface-parts.ts
664
+ var IRON = 3882562;
665
+ var IRON_WORN = 5593438;
666
+ var CONCRETE = 10197652;
667
+ var CONCRETE_LID = 11052960;
668
+ var VOID = 723724;
669
+ var HYDRANT_RED = 11545122;
670
+ var FRAME_TOP = 2e-3;
671
+ var LID_TOP = 4e-3;
672
+ var RIB_TOP = 9e-3;
673
+ var CROSS_RIB_TOP = 0.011;
674
+ var THICK = 0.03;
675
+ var flat = (shape, top, size, color) => shape === "box" ? { shape, centre: [0, top - THICK / 2, 0], size: [size[0], THICK, size[1]], color } : { shape, centre: [0, top - THICK / 2, 0], size: [size[0], THICK, size[0]], color };
676
+ var rib = (size, top, at) => ({ shape: "box", centre: [at[0], top - size[1] / 2, at[1]], size, color: IRON_WORN });
677
+ function cover(piece) {
678
+ const [width, , depth] = piece.size;
679
+ const shape = piece.shape === "round" ? "cylinder" : "box";
680
+ const [frame, lid] = piece.shape === "round" ? [(width + 0.12) / 2, width / 2] : [width + 0.12, width];
681
+ const colors = piece.material === "concrete" ? [IRON, CONCRETE_LID] : [IRON, IRON_WORN];
682
+ const parts = [flat(shape, FRAME_TOP, [frame, piece.shape === "round" ? frame : depth + 0.12], colors[0]), flat(shape, LID_TOP, [lid, piece.shape === "round" ? lid : depth], colors[1])];
683
+ if (piece.kind === "inspection_cover") return [...parts, rib([0.14, 6e-3, 0.03], RIB_TOP, [0, 0])];
684
+ if (piece.shape === "round") return [...parts, rib([lid * 1.7, 5e-3, 0.04], RIB_TOP, [0, 0]), rib([0.04, 5e-3, lid * 1.7], CROSS_RIB_TOP, [0, 0])];
685
+ return [...parts, ...[-0.15, 0, 0.15].map((z) => rib([lid * 0.85, 5e-3, 0.03], RIB_TOP, [0, z]))];
686
+ }
687
+ function grate() {
688
+ const bars = [-0.2, -0.1, 0, 0.1, 0.2].map((z) => ({ shape: "box", centre: [0, RIB_TOP - 6e-3, z], size: [0.9, 0.012, 0.025], color: IRON_WORN }));
689
+ const brace = { shape: "box", centre: [0, 55e-4, 0], size: [0.03, 3e-3, 0.5], color: IRON };
690
+ return [
691
+ { shape: "box", centre: [0, FRAME_TOP - THICK / 2, 0], size: [1, THICK, 0.6], color: IRON },
692
+ { shape: "box", centre: [0, 25e-4, 0], size: [0.9, 1e-3, 0.5], color: VOID },
693
+ ...bars,
694
+ brace
695
+ ];
696
+ }
697
+ function hydrant() {
698
+ const part = (y, radius, length, axis, at = [0, 0]) => ({ shape: "cylinder", centre: [at[0], y, at[1]], size: [radius, length, radius], axis, color: HYDRANT_RED });
699
+ return [part(0.02, 0.1, 0.04, "y"), part(0.38, 0.065, 0.68, "y"), part(0.74, 0.085, 0.06, "y"), part(0.55, 0.032, 0.26, "x"), part(0.5, 0.045, 0.14, "z", [0, 0.1])];
700
+ }
701
+ function wingWall(piece) {
702
+ const [width, height, depth] = piece.size;
703
+ return [
704
+ { shape: "box", centre: [0, (height - 0.4) / 2, 0], size: [width, height + 0.4, 0.25], color: CONCRETE },
705
+ ...[-1, 1].map((side) => ({ shape: "box", centre: [side * (width / 2 - 0.135), (height - 0.2 - 0.4) / 2 + 0.01, depth / 2], size: [0.25, height - 0.2 + 0.4 - 0.02, depth], color: CONCRETE })),
706
+ { shape: "box", centre: [0, 0.01 - 0.075, depth / 2], size: [width - 0.6, 0.15, depth - 0.1], color: CONCRETE_LID }
707
+ ];
708
+ }
709
+ function meterBox(piece) {
710
+ const [width, height, depth] = piece.size;
711
+ return [
712
+ { shape: "box", centre: [0, height / 2, 0], size: [width, height, depth], color: CONCRETE },
713
+ { shape: "box", centre: [0, height, 0], size: [width - 0.06, 8e-3, depth - 0.06], color: IRON }
714
+ ];
715
+ }
716
+ function mouth() {
717
+ return [
718
+ { shape: "box", centre: [0, FRAME_TOP - 0.01, 0], size: [0.3, 0.02, 0.2], color: CONCRETE },
719
+ { shape: "box", centre: [0, 25e-4, 0], size: [0.2, 1e-3, 0.08], color: VOID }
720
+ ];
721
+ }
722
+ function partsOf(piece) {
723
+ switch (piece.kind) {
724
+ case "inlet_grate":
725
+ return grate();
726
+ case "hydrant":
727
+ return hydrant();
728
+ case "wing_wall":
729
+ return wingWall(piece);
730
+ case "meter_box":
731
+ return meterBox(piece);
732
+ case "downspout_mouth":
733
+ return mouth();
734
+ default:
735
+ return cover(piece);
736
+ }
737
+ }
738
+
739
+ // src/networks/draw-lid.ts
740
+ var CYLINDER_SEGMENTS2 = 14;
741
+ function drawLid(THREE, piece) {
742
+ const T = shapeGeometries5(THREE);
743
+ const [frame, second, ...over] = partsOf(piece);
744
+ const [lid, ...ribs] = piece.kind === "inlet_grate" ? [frame, ...over] : second === void 0 ? [] : [second, ...over];
745
+ if (lid === void 0) throw new Error(`game-urban-three: "${piece.id}" has no lid to draw`);
746
+ const lift = lid.size[1] / 2 - lid.centre[1];
747
+ const group = markKitOrigin3(new THREE.Group(), { owner: "game-urban-three", kind: "network-lid" });
748
+ group.name = `network:lid:${piece.id}`;
749
+ const geometries = { box: new T.BoxGeometry(1, 1, 1), cylinder: new T.CylinderGeometry(1, 1, 1, CYLINDER_SEGMENTS2) };
750
+ const materials = /* @__PURE__ */ new Map();
751
+ const axisTurn = { x: [0, 0, Math.PI / 2], y: [0, 0, 0], z: [Math.PI / 2, 0, 0] };
752
+ for (const part of [lid, ...ribs]) {
753
+ let material = materials.get(part.color);
754
+ if (material === void 0) materials.set(part.color, material = new THREE.MeshStandardMaterial({ color: part.color, roughness: 0.7, metalness: 0.2 }));
755
+ const mesh = new THREE.Mesh(geometries[part.shape], material);
756
+ mesh.position.set(part.centre[0], part.centre[1] + lift, part.centre[2]);
757
+ mesh.scale.set(part.size[0], part.size[1], part.size[2]);
758
+ const [turnX, turnY, turnZ] = axisTurn[part.axis ?? "y"];
759
+ mesh.rotation.set(turnX, turnY, turnZ);
760
+ mesh.userData.destructionPart = COVER_PLATE_PART;
761
+ mesh.castShadow = true;
762
+ mesh.receiveShadow = true;
763
+ group.add(mesh);
764
+ }
765
+ return {
766
+ root: group,
767
+ dispose() {
768
+ group.parent?.remove(group);
769
+ for (const geometry of Object.values(geometries)) geometry.dispose();
770
+ for (const material of materials.values()) material.dispose();
771
+ }
772
+ };
773
+ }
774
+
775
+ // src/networks/draw-surface.ts
776
+ import { markKitOrigin as markKitOrigin4 } from "@adatechnology/game-contracts";
777
+ import { shapeGeometries as shapeGeometries6 } from "@adatechnology/game-shapes-three";
778
+ import { surfacePiecesOf as surfacePiecesOf2 } from "@adatechnology/game-urban/networks";
779
+ var CYLINDER_SEGMENTS3 = 14;
780
+ function drawSurface(THREE, { networks, pieces, root, options }) {
781
+ const list = pieces ?? surfacePiecesOf2(networks ?? { nodes: [], edges: [] }, options);
782
+ const T = shapeGeometries6(THREE);
783
+ const group = markKitOrigin4(root ?? new THREE.Group(), { owner: "game-urban-three", kind: "network-surface" });
784
+ const boxes = [];
785
+ const cylinders = [];
786
+ const ranges = /* @__PURE__ */ new Map();
787
+ for (const piece of list) {
788
+ const parts = partsOf(piece);
789
+ const range = { box: [boxes.length, 0], cylinder: [cylinders.length, 0] };
790
+ for (const part of parts) (part.shape === "box" ? boxes : cylinders).push({ piece, part });
791
+ range.box[1] = boxes.length - range.box[0];
792
+ range.cylinder[1] = cylinders.length - range.cylinder[0];
793
+ ranges.set(piece.id, range);
794
+ }
795
+ const material = new THREE.MeshStandardMaterial({ color: 16777215, roughness: 0.7, metalness: 0.2 });
796
+ const boxGeometry = new T.BoxGeometry(1, 1, 1);
797
+ const cylinderGeometry = new T.CylinderGeometry(1, 1, 1, CYLINDER_SEGMENTS3);
798
+ const matrix = new THREE.Matrix4();
799
+ const turn = new THREE.Quaternion();
800
+ const spin = new THREE.Quaternion();
801
+ const local = new THREE.Matrix4();
802
+ const color = new THREE.Color();
803
+ const axisTurn = { x: new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 0, 1), Math.PI / 2), y: new THREE.Quaternion(), z: new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(1, 0, 0), Math.PI / 2) };
804
+ const fill2 = (mesh, items, [start, count] = [0, items.length]) => {
805
+ for (let slot = start; slot < start + count; slot++) {
806
+ const { piece, part } = items[slot];
807
+ turn.setFromAxisAngle(new THREE.Vector3(0, 1, 0), piece.ry);
808
+ matrix.compose(new THREE.Vector3(piece.at[0], piece.at[1], piece.at[2]), turn, new THREE.Vector3(1, 1, 1));
809
+ spin.copy(axisTurn[part.axis ?? "y"]);
810
+ local.compose(new THREE.Vector3(...part.centre), spin, new THREE.Vector3(...part.size));
811
+ mesh.setMatrixAt(slot, matrix.multiply(local));
812
+ mesh.setColorAt(slot, color.set(part.color));
813
+ }
814
+ };
815
+ const make = (geometry, items, name) => {
816
+ const mesh = new THREE.InstancedMesh(geometry, material, Math.max(items.length, 1));
817
+ mesh.name = name;
818
+ mesh.count = items.length;
819
+ mesh.receiveShadow = true;
820
+ fill2(mesh, items);
821
+ return mesh;
822
+ };
823
+ const boxMesh = make(boxGeometry, boxes, "network:surface:boxes");
824
+ const cylinderMesh = make(cylinderGeometry, cylinders, "network:surface:cylinders");
825
+ group.add(boxMesh, cylinderMesh);
826
+ const hide = (mesh, [start, count]) => {
827
+ matrix.makeScale(0, 0, 0);
828
+ for (let slot = start; slot < start + count; slot++) mesh.setMatrixAt(slot, matrix);
829
+ mesh.instanceMatrix.needsUpdate = true;
830
+ };
831
+ return {
832
+ root: group,
833
+ pieces: list,
834
+ drawCalls: () => [boxMesh, cylinderMesh].filter((mesh) => mesh.count > 0).length,
835
+ remove(id) {
836
+ const range = ranges.get(id);
837
+ if (range === void 0) return;
838
+ hide(boxMesh, range.box);
839
+ hide(cylinderMesh, range.cylinder);
840
+ },
841
+ restore(id) {
842
+ const range = ranges.get(id);
843
+ if (range === void 0) return;
844
+ fill2(boxMesh, boxes, range.box);
845
+ fill2(cylinderMesh, cylinders, range.cylinder);
846
+ boxMesh.instanceMatrix.needsUpdate = true;
847
+ cylinderMesh.instanceMatrix.needsUpdate = true;
848
+ },
849
+ dispose() {
850
+ group.parent?.remove(group);
851
+ for (const mesh of [boxMesh, cylinderMesh]) mesh.dispose();
852
+ for (const item of [boxGeometry, cylinderGeometry, material]) item.dispose();
853
+ }
854
+ };
855
+ }
856
+
555
857
  // src/draw.ts
556
858
  var DEFAULT_ROUGHNESS = 0.9;
557
859
  var DEFAULT_METALNESS = 0;
@@ -562,17 +864,17 @@ var SIGN_FONT = '700 56px "Arial Narrow", Arial, sans-serif';
562
864
  var SIGN_CANVAS = { width: 512, height: 128 };
563
865
  var PLANE_LAYER_GAP = 2e-3;
564
866
  function createUrbanThree(THREE, options = {}) {
565
- const T = shapeGeometries4(THREE);
867
+ const T = shapeGeometries7(THREE);
566
868
  const geometries = /* @__PURE__ */ new Map();
567
869
  const materials = /* @__PURE__ */ new Map();
568
870
  const disposables = [];
569
- const standard = (color, style, flat = false) => {
871
+ const standard = (color, style, flat2 = false) => {
570
872
  const roughness = style?.roughness ?? DEFAULT_ROUGHNESS;
571
873
  const metalness = style?.metalness ?? DEFAULT_METALNESS;
572
- const key = `s|${color}|${roughness}|${metalness}|${flat ? 1 : 0}`;
874
+ const key = `s|${color}|${roughness}|${metalness}|${flat2 ? 1 : 0}`;
573
875
  let material = materials.get(key);
574
876
  if (!material) {
575
- material = new THREE.MeshStandardMaterial({ color, roughness, metalness, flatShading: flat });
877
+ material = new THREE.MeshStandardMaterial({ color, roughness, metalness, flatShading: flat2 });
576
878
  materials.set(key, material);
577
879
  }
578
880
  return material;
@@ -871,7 +1173,7 @@ function createUrbanThree(THREE, options = {}) {
871
1173
  };
872
1174
  };
873
1175
  function draw(scene, drawOptions = {}) {
874
- const root = markKitOrigin2(drawOptions.root ?? new THREE.Group(), { owner: "game-urban-three", kind: "urban" });
1176
+ const root = markKitOrigin5(drawOptions.root ?? new THREE.Group(), { owner: "game-urban-three", kind: "urban" });
875
1177
  const animators = [];
876
1178
  const lights = [];
877
1179
  animatedLenses = /* @__PURE__ */ new Set();
@@ -909,7 +1211,10 @@ function createUrbanThree(THREE, options = {}) {
909
1211
  };
910
1212
  }
911
1213
  const networks = (data, drawOptions = {}) => drawNetworks(THREE, { networks: data, options: drawOptions, ...options.lights ? { budget: options.lights } : {}, ...options.physicalLights ? { physicalLights: true } : {} });
912
- return { THREE, draw, drawNetworks: networks };
1214
+ const networkSurface = (data, surfaceOptions) => drawSurface(THREE, { networks: data, ...surfaceOptions ? { options: surfaceOptions } : {} });
1215
+ const buriedNetworks = (data, surfaceOptions) => drawBuried(THREE, { networks: data, ...surfaceOptions ? { options: surfaceOptions } : {} });
1216
+ const coverLid = (piece) => drawLid(THREE, piece);
1217
+ return { THREE, draw, drawNetworks: networks, drawNetworkSurface: networkSurface, drawBuriedNetworks: buriedNetworks, drawCoverLid: coverLid };
913
1218
  }
914
1219
 
915
1220
  // src/resolvers.ts
@@ -1311,7 +1616,10 @@ function createUrbanTestModule(options = {}) {
1311
1616
  return { name: id, tags: ["structure"], parts: [{ id: "ground", material: "concrete", shape: { kind: "box", size: [Math.max(size.x, 0.1), Math.max(size.y, 0.1), Math.max(size.z, 0.1)] }, position: [centre.x, centre.y, centre.z], anchored: true }] };
1312
1617
  }
1313
1618
  });
1619
+ let removeBenchCover = null;
1314
1620
  const clearBench = () => {
1621
+ removeBenchCover?.();
1622
+ removeBenchCover = null;
1315
1623
  if (!bench) return;
1316
1624
  bench.drawn.dispose();
1317
1625
  bench = null;
@@ -1333,6 +1641,7 @@ function createUrbanTestModule(options = {}) {
1333
1641
  drawn.root.position.set(benchOrigin[0], FLOOR_Y, benchOrigin[1]);
1334
1642
  host.scene.add(drawn.root);
1335
1643
  bench = { root: drawn.root, drawn, plan: made };
1644
+ if (host.rainCover) removeBenchCover = host.rainCover.add(createFixedFootprintRainCover(b.covers.map((roof) => ({ ...roof, x: roof.x + benchOrigin[0], z: roof.z + benchOrigin[1], top: roof.top + FLOOR_Y }))));
1336
1645
  lightsLeft = b.lights.left;
1337
1646
  host.log(fill(text.log.composed, settings.pattern, settings.seed, countObjects(drawn.root), drawn.lights.length), { pattern: settings.pattern, seed: settings.seed });
1338
1647
  helpersShown = "";
@@ -1401,7 +1710,7 @@ function createUrbanTestModule(options = {}) {
1401
1710
  for (const lamp of entry.drawn.lights) {
1402
1711
  const light = "bulb" in lamp ? { node: lamp.bulb, distance: lamp.part.distance, color: lamp.part.color } : lamp.isLight ? { node: lamp, distance: lamp.distance, color: lamp.color } : null;
1403
1712
  if (!light) continue;
1404
- const reach = new three.Mesh(new (shapeGeometries5(three)).SphereGeometry(Math.min(light.distance || 10, 60), 14, 8), new three.MeshBasicMaterial({ color: light.color ?? 16764006, wireframe: true, transparent: true, opacity: 0.25 }));
1713
+ const reach = new three.Mesh(new (shapeGeometries8(three)).SphereGeometry(Math.min(light.distance || 10, 60), 14, 8), new three.MeshBasicMaterial({ color: light.color ?? 16764006, wireframe: true, transparent: true, opacity: 0.25 }));
1405
1714
  reach.position.copy(light.node.position);
1406
1715
  mark(light.node.parent ?? entry.root, reach);
1407
1716
  }
@@ -1541,4 +1850,4 @@ export {
1541
1850
  createUrbanTestModule,
1542
1851
  loadUrbanTestModule
1543
1852
  };
1544
- //# sourceMappingURL=chunk-JTXGLKOL.js.map
1853
+ //# sourceMappingURL=chunk-IZH7YXT7.js.map