@adatechnology/game-items-three 0.11.4 → 0.11.5

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.
@@ -526,11 +526,11 @@ var GameItemsThree = (() => {
526
526
  }
527
527
  for (let i = 0; i < segments; i++) {
528
528
  for (let j = 0; j < points.length - 1; j++) {
529
- const base = j + i * points.length;
530
- const a = base;
531
- const b = base + points.length;
532
- const c = base + points.length + 1;
533
- const d = base + 1;
529
+ const base2 = j + i * points.length;
530
+ const a = base2;
531
+ const b = base2 + points.length;
532
+ const c = base2 + points.length + 1;
533
+ const d = base2 + 1;
534
534
  indices.push(a, b, d);
535
535
  indices.push(c, d, b);
536
536
  }
@@ -595,13 +595,13 @@ var GameItemsThree = (() => {
595
595
  const uvs = [];
596
596
  const indices = [];
597
597
  const quad = (corners, normal, uv) => {
598
- const base = positions2.length / 3;
598
+ const base2 = positions2.length / 3;
599
599
  for (let k = 0; k < 4; k++) {
600
600
  positions2.push(...corners[k]);
601
601
  normals.push(...normal);
602
602
  uvs.push(...uv[k]);
603
603
  }
604
- indices.push(base, base + 1, base + 2, base, base + 2, base + 3);
604
+ indices.push(base2, base2 + 1, base2 + 2, base2, base2 + 2, base2 + 3);
605
605
  };
606
606
  const fu = (x) => (x + hw) / w;
607
607
  const fv = (y) => (y + hh) / h;
@@ -1520,26 +1520,26 @@ var GameItemsThree = (() => {
1520
1520
  };
1521
1521
  function mergeTransformed(pieces) {
1522
1522
  let total = 0;
1523
- for (const piece2 of pieces) total += piece2.indices ? piece2.indices.length : piece2.positions.length / 3;
1523
+ for (const piece3 of pieces) total += piece3.indices ? piece3.indices.length : piece3.positions.length / 3;
1524
1524
  const positions2 = new Float32Array(total * 3);
1525
1525
  const normals = new Float32Array(total * 3);
1526
1526
  const uvs = new Float32Array(total * 2);
1527
1527
  let at2 = 0;
1528
- for (const piece2 of pieces) {
1529
- const e = piece2.matrix;
1528
+ for (const piece3 of pieces) {
1529
+ const e = piece3.matrix;
1530
1530
  const nm = normalMatrix(e);
1531
- const count = piece2.indices ? piece2.indices.length : piece2.positions.length / 3;
1531
+ const count = piece3.indices ? piece3.indices.length : piece3.positions.length / 3;
1532
1532
  const p = new Float32Array(count * 3);
1533
1533
  const n = new Float32Array(count * 3);
1534
1534
  for (let k = 0; k < count; k++) {
1535
- const i = piece2.indices ? piece2.indices[k] : k;
1535
+ const i = piece3.indices ? piece3.indices[k] : k;
1536
1536
  for (let c = 0; c < 3; c++) {
1537
- p[k * 3 + c] = piece2.positions[i * 3 + c];
1538
- if (piece2.normals) n[k * 3 + c] = piece2.normals[i * 3 + c];
1537
+ p[k * 3 + c] = piece3.positions[i * 3 + c];
1538
+ if (piece3.normals) n[k * 3 + c] = piece3.normals[i * 3 + c];
1539
1539
  }
1540
- if (piece2.uvs) {
1541
- uvs[(at2 + k) * 2] = piece2.uvs[i * 2];
1542
- uvs[(at2 + k) * 2 + 1] = piece2.uvs[i * 2 + 1];
1540
+ if (piece3.uvs) {
1541
+ uvs[(at2 + k) * 2] = piece3.uvs[i * 2];
1542
+ uvs[(at2 + k) * 2 + 1] = piece3.uvs[i * 2 + 1];
1543
1543
  }
1544
1544
  }
1545
1545
  for (let k = 0; k < count; k++) {
@@ -1654,7 +1654,7 @@ var GameItemsThree = (() => {
1654
1654
  var positive = (n) => finite(n) && n > 0;
1655
1655
  var vec3 = (v) => Array.isArray(v) && v.length === 3 && v.every(finite);
1656
1656
  var nonNegative = (n) => n === void 0 || finite(n) && n >= 0;
1657
- var FACES = ["both", "+", "-"];
1657
+ var FACES = ["both", "+", "-", "all"];
1658
1658
  var BONDS = ["running", "stack"];
1659
1659
  var checkStagedFields = (p, label, materials, problems) => {
1660
1660
  const known = (m, what) => {
@@ -1858,9 +1858,9 @@ var GameItemsThree = (() => {
1858
1858
  };
1859
1859
  var UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
1860
1860
  var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
1861
- var deepMerge = (base, patch) => {
1862
- if (!patch) return base;
1863
- const result = { ...base };
1861
+ var deepMerge = (base2, patch) => {
1862
+ if (!patch) return base2;
1863
+ const result = { ...base2 };
1864
1864
  for (const [key2, value] of Object.entries(patch)) {
1865
1865
  if (value === void 0 || UNSAFE_KEYS.has(key2)) continue;
1866
1866
  const current = result[key2];
@@ -2309,8 +2309,8 @@ var GameItemsThree = (() => {
2309
2309
  const materials = [];
2310
2310
  const M = (color2, tag, options = {}) => {
2311
2311
  const material = new T2.MeshStandardMaterial(Object.assign({ color: color2, roughness: 0.78, metalness: 0 }, options));
2312
- const base = new T2.Color(color2);
2313
- const data = { base, baseRgb: channelsOf(color2), tag, rough: material.roughness };
2312
+ const base2 = new T2.Color(color2);
2313
+ const data = { base: base2, baseRgb: channelsOf(color2), tag, rough: material.roughness };
2314
2314
  material.userData = data;
2315
2315
  materials.push(material);
2316
2316
  return material;
@@ -6402,11 +6402,11 @@ var GameItemsThree = (() => {
6402
6402
  var _a;
6403
6403
  if (!isLid(o)) return;
6404
6404
  const mesh2 = o;
6405
- const base = (_a = mesh2.userData).lidBase ?? (_a.lidBase = { y: mesh2.position.y, turn: mesh2.rotation.y });
6405
+ const base2 = (_a = mesh2.userData).lidBase ?? (_a.lidBase = { y: mesh2.position.y, turn: mesh2.rotation.y });
6406
6406
  if (!mesh2.geometry.boundingBox) mesh2.geometry.computeBoundingBox();
6407
6407
  const height = (mesh2.geometry.boundingBox.max.y - mesh2.geometry.boundingBox.min.y) * mesh2.scale.y;
6408
- mesh2.rotation.y = base.turn + state.turned;
6409
- mesh2.position.y = base.y + Math.min(1, Math.max(0, state.lift)) * height * CAP_OFF;
6408
+ mesh2.rotation.y = base2.turn + state.turned;
6409
+ mesh2.position.y = base2.y + Math.min(1, Math.max(0, state.lift)) * height * CAP_OFF;
6410
6410
  });
6411
6411
  return true;
6412
6412
  }
@@ -7673,11 +7673,11 @@ var GameItemsThree = (() => {
7673
7673
  const steel = metal(6251625);
7674
7674
  const dark = metal(4080199);
7675
7675
  const arm = (x, y, angle, z) => mesh2(bx(12.65, 1.2, 1.6), steel, [x, y, z], [0, 0, angle]);
7676
- const arms = [3.8, -3.8].flatMap((z) => [arm(-5.9, 2, 0.3217, z), arm(-5.9, -2, -0.3217, z), arm(5.9, 2, -0.3217, z), arm(5.9, -2, 0.3217, z)]);
7676
+ const arms2 = [3.8, -3.8].flatMap((z) => [arm(-5.9, 2, 0.3217, z), arm(-5.9, -2, -0.3217, z), arm(5.9, 2, -0.3217, z), arm(5.9, -2, 0.3217, z)]);
7677
7677
  return G(
7678
7678
  mesh2(bx(8, 1, 11), dark, [0, -5, 0]),
7679
7679
  mesh2(bx(8, 1, 11), dark, [0, 5, 0]),
7680
- ...arms,
7680
+ ...arms2,
7681
7681
  mesh2(cyl(0.6, 0.6, 30, 8), metal(9277846), [0, 0, 0], [0, 0, Math.PI / 2]),
7682
7682
  mesh2(bx(1.6, 2.4, 3), dark, [-11.8, 0, 0]),
7683
7683
  mesh2(bx(1.6, 2.4, 3), dark, [11.8, 0, 0]),
@@ -7921,12 +7921,12 @@ var GameItemsThree = (() => {
7921
7921
  const rod = (x1, y1, x2, y2, radius) => [cyl(radius, radius, Math.hypot(x2 - x1, y2 - y1), 8), [(x1 + x2) / 2, (y1 + y2) / 2, 0], [0, 0, Math.atan2(-(x2 - x1), y2 - y1)]];
7922
7922
  const frame2 = wood(7031340);
7923
7923
  const band = cloth2(2039583);
7924
- const arms = [-1, 1].map((side) => rod(0, -0.15, side * 0.5675, 0.7, 0.1));
7924
+ const arms2 = [-1, 1].map((side) => rod(0, -0.15, side * 0.5675, 0.7, 0.1));
7925
7925
  const bands = [-1, 1].map((side) => rod(side * 0.5675, 0.7, side * 0.12, 0.25, 0.03));
7926
7926
  return G(
7927
7927
  mesh2(cyl(0.12, 0.1, 0.65, 8), frame2, [0, -0.425, 0]),
7928
7928
  mesh2(cyl(0.126, 0.126, 0.3, 8), cloth2(8007455), [0, -0.5, 0]),
7929
- ...arms.map(([geometry, position, rotation]) => mesh2(geometry, frame2, [...position], [...rotation])),
7929
+ ...arms2.map(([geometry, position, rotation]) => mesh2(geometry, frame2, [...position], [...rotation])),
7930
7930
  ...bands.map(([geometry, position, rotation]) => mesh2(geometry, band, [...position], [...rotation])),
7931
7931
  mesh2(bx(0.26, 0.2, 0.05), cloth2(9067061), [0, 0.2, 0])
7932
7932
  );
@@ -8156,10 +8156,10 @@ var GameItemsThree = (() => {
8156
8156
  const R = Math.PI / 2;
8157
8157
  const pane = glass(12575711, 0.55);
8158
8158
  const deep = glass(8369584, 0.7);
8159
- const base = extrude2([[-0.6, -0.1], [0.45, -0.5], [0.6, 0.2], [-0.1, 0.5]], 0.04, 2e-3);
8159
+ const base2 = extrude2([[-0.6, -0.1], [0.45, -0.5], [0.6, 0.2], [-0.1, 0.5]], 0.04, 2e-3);
8160
8160
  const chip = extrude2([[0, 0], [0.25, 0.05], [0.1, 0.22]], 0.03, 2e-3);
8161
8161
  return G(
8162
- mesh2(base, pane, [0, 0, 0], [R, 0, 0]),
8162
+ mesh2(base2, pane, [0, 0, 0], [R, 0, 0]),
8163
8163
  mesh2(chip, deep, [0.2, 0.03, -0.35], [R, 0, 0.4]),
8164
8164
  mesh2(new T2.ConeGeometry(0.14, 0.46, 3), pane, [-0.2, 0.23, 0.1], [0, 0.3, 0.12]),
8165
8165
  mesh2(new T2.ConeGeometry(0.1, 0.34, 3), deep, [0.25, 0.17, -0.1], [0.15, 0, -0.2]),
@@ -8394,10 +8394,10 @@ var GameItemsThree = (() => {
8394
8394
 
8395
8395
  // src/models/rag.ts
8396
8396
  var rag = ({ mesh: mesh2, bx, G, cloth: cloth2 }) => {
8397
- const base = cloth2(11028282);
8397
+ const base2 = cloth2(11028282);
8398
8398
  const fringe = cloth2(12877167);
8399
8399
  return G(
8400
- mesh2(bx(2, 0.1, 1.8), base, [0, -0.076, 0]),
8400
+ mesh2(bx(2, 0.1, 1.8), base2, [0, -0.076, 0]),
8401
8401
  mesh2(bx(1.7, 0.09, 1.5), cloth2(10108723), [0.1, 0.02, 0], [0, 0.1, 0]),
8402
8402
  mesh2(bx(1.5, 0.036, 1.2), cloth2(11818826), [0, 0.083, 0]),
8403
8403
  mesh2(bx(0.2, 0.02, 1.7), fringe, [1, -0.076, 0]),
@@ -8487,13 +8487,13 @@ var GameItemsThree = (() => {
8487
8487
 
8488
8488
  // src/models/army-camouflage-uniform.ts
8489
8489
  var armyCamouflageUniform = ({ mesh: mesh2, bx, G, cloth: cloth2 }) => {
8490
- const base = cloth2(5857855);
8490
+ const base2 = cloth2(5857855);
8491
8491
  const dark = cloth2(3554600);
8492
8492
  const tan = cloth2(9076565);
8493
8493
  return G(
8494
- mesh2(bx(0.24, 0.08, 0.32), base, [0, 0.04, 0]),
8495
- mesh2(bx(0.08, 0.07, 0.2), base, [-0.16, 0.035, -0.06]),
8496
- mesh2(bx(0.08, 0.07, 0.2), base, [0.16, 0.035, -0.06]),
8494
+ mesh2(bx(0.24, 0.08, 0.32), base2, [0, 0.04, 0]),
8495
+ mesh2(bx(0.08, 0.07, 0.2), base2, [-0.16, 0.035, -0.06]),
8496
+ mesh2(bx(0.08, 0.07, 0.2), base2, [0.16, 0.035, -0.06]),
8497
8497
  mesh2(bx(0.08, 0.074, 0.024), dark, [-0.16, 0.037, 0.052]),
8498
8498
  mesh2(bx(0.08, 0.074, 0.024), dark, [0.16, 0.037, 0.052]),
8499
8499
  mesh2(bx(0.08, 0.01, 0.045), dark, [-0.04, 0.09, -0.135]),
@@ -10643,18 +10643,18 @@ var GameItemsThree = (() => {
10643
10643
  const indexCount = mesh22.geometry.index ? mesh22.geometry.index.count : vertices;
10644
10644
  return { mesh: mesh22, local, vertices, indexCount };
10645
10645
  });
10646
- const totalVertices = pieces.reduce((sum, piece2) => sum + piece2.vertices, 0);
10647
- const totalIndices = pieces.reduce((sum, piece2) => sum + piece2.indexCount, 0);
10646
+ const totalVertices = pieces.reduce((sum, piece3) => sum + piece3.vertices, 0);
10647
+ const totalIndices = pieces.reduce((sum, piece3) => sum + piece3.indexCount, 0);
10648
10648
  const merged2 = new THREE.BufferGeometry();
10649
- const normalMatrices = names.includes("normal") ? pieces.map((piece2) => new THREE.Matrix3().getNormalMatrix(follow ? identity : piece2.local)) : [];
10649
+ const normalMatrices = names.includes("normal") ? pieces.map((piece3) => new THREE.Matrix3().getNormalMatrix(follow ? identity : piece3.local)) : [];
10650
10650
  for (const name of names) {
10651
10651
  const size = first.geometry.attributes[name].itemSize;
10652
10652
  const array = new Float32Array(totalVertices * size);
10653
10653
  let offset = 0;
10654
- for (const [at2, piece2] of pieces.entries()) {
10655
- const matrix = name === "normal" ? normalMatrices[at2] : follow ? identity : piece2.local;
10656
- copyAttribute(name, piece2.mesh.geometry.attributes[name], array, offset, matrix);
10657
- offset += piece2.vertices;
10654
+ for (const [at2, piece3] of pieces.entries()) {
10655
+ const matrix = name === "normal" ? normalMatrices[at2] : follow ? identity : piece3.local;
10656
+ copyAttribute(name, piece3.mesh.geometry.attributes[name], array, offset, matrix);
10657
+ offset += piece3.vertices;
10658
10658
  }
10659
10659
  merged2.setAttribute(name, new THREE.BufferAttribute(array, size));
10660
10660
  }
@@ -10676,30 +10676,30 @@ var GameItemsThree = (() => {
10676
10676
  const sources = [];
10677
10677
  let vertexOffset = 0;
10678
10678
  let indexOffset = 0;
10679
- for (const piece2 of pieces) {
10680
- const index = piece2.mesh.geometry.index;
10679
+ for (const piece3 of pieces) {
10680
+ const index = piece3.mesh.geometry.index;
10681
10681
  if (index) {
10682
10682
  const indices = index.array;
10683
- for (let at2 = 0; at2 < piece2.indexCount; at2++) indexArray2[indexOffset + at2] = indices[at2] + vertexOffset;
10684
- } else for (let at2 = 0; at2 < piece2.indexCount; at2++) indexArray2[indexOffset + at2] = at2 + vertexOffset;
10683
+ for (let at2 = 0; at2 < piece3.indexCount; at2++) indexArray2[indexOffset + at2] = indices[at2] + vertexOffset;
10684
+ } else for (let at2 = 0; at2 < piece3.indexCount; at2++) indexArray2[indexOffset + at2] = at2 + vertexOffset;
10685
10685
  sources.push({
10686
- mesh: piece2.mesh,
10687
- geometry: piece2.mesh.geometry,
10688
- material: piece2.mesh.material,
10689
- version: piece2.mesh.geometry.attributes.position.version,
10690
- local: piece2.local,
10691
- world: piece2.mesh.matrixWorld.clone(),
10692
- mask: piece2.mesh.layers.mask,
10693
- castShadow: piece2.mesh.castShadow,
10686
+ mesh: piece3.mesh,
10687
+ geometry: piece3.mesh.geometry,
10688
+ material: piece3.mesh.material,
10689
+ version: piece3.mesh.geometry.attributes.position.version,
10690
+ local: piece3.local,
10691
+ world: piece3.mesh.matrixWorld.clone(),
10692
+ mask: piece3.mesh.layers.mask,
10693
+ castShadow: piece3.mesh.castShadow,
10694
10694
  batch,
10695
10695
  start: indexOffset,
10696
- count: piece2.indexCount,
10696
+ count: piece3.indexCount,
10697
10697
  released: false
10698
10698
  });
10699
- if (shadowOnly) piece2.mesh.castShadow = false;
10700
- else piece2.mesh.layers.set(BATCHED_LAYER);
10701
- vertexOffset += piece2.vertices;
10702
- indexOffset += piece2.indexCount;
10699
+ if (shadowOnly) piece3.mesh.castShadow = false;
10700
+ else piece3.mesh.layers.set(BATCHED_LAYER);
10701
+ vertexOffset += piece3.vertices;
10702
+ indexOffset += piece3.indexCount;
10703
10703
  }
10704
10704
  return sources;
10705
10705
  }
@@ -11218,7 +11218,7 @@ var GameItemsThree = (() => {
11218
11218
  T("open_door", true, 0.9, 0.15, 2.15, 0, false, "house_state")
11219
11219
  ];
11220
11220
  var DEFS = Object.fromEntries(TYPE_DEFS.map((t) => [t.id, t]));
11221
- var MATERIALS = ["plain", "metal", "wood", "glass", "fabric", "plant", "water", "emissive", "atlas_picture", "atlas_floor"];
11221
+ var MATERIALS = ["plain", "metal", "wood", "glass", "fabric", "foam", "plant", "water", "emissive", "atlas_picture", "atlas_floor"];
11222
11222
  function ceilingBuilders({ kit }) {
11223
11223
  const B = {};
11224
11224
  B.ceiling_light = (M, a) => {
@@ -12440,14 +12440,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
12440
12440
  const uvs = [];
12441
12441
  const indices = [];
12442
12442
  for (const side of [1, -1]) {
12443
- const base = positions2.length / 3;
12443
+ const base2 = positions2.length / 3;
12444
12444
  for (let i = 0; i < 4; i++) {
12445
12445
  positions2.push(f[i * 3], f[i * 3 + 1], f[i * 3 + 2]);
12446
12446
  normals.push(0, 0, side);
12447
12447
  uvs.push(f[i * 3] + 0.5, f[i * 3 + 1]);
12448
12448
  }
12449
- if (side === 1) indices.push(base, base + 2, base + 1, base + 1, base + 2, base + 3);
12450
- else indices.push(base, base + 1, base + 2, base + 1, base + 3, base + 2);
12449
+ if (side === 1) indices.push(base2, base2 + 2, base2 + 1, base2 + 1, base2 + 2, base2 + 3);
12450
+ else indices.push(base2, base2 + 1, base2 + 2, base2 + 1, base2 + 3, base2 + 2);
12451
12451
  }
12452
12452
  return { positions: positions2, normals, uvs, indices };
12453
12453
  })();
@@ -13583,7 +13583,27 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
13583
13583
  var MAX_SPALLS = 64;
13584
13584
  var thinAxisOf = (dims) => dims[0] <= dims[1] && dims[0] <= dims[2] ? 0 : dims[1] <= dims[2] ? 1 : 2;
13585
13585
  var resolveLayer = (def, index, mat) => ({ index, def, mat, energy: mat.penetration * def.thickness * 1e3 });
13586
- var onFace = (layer, face) => layer.def.faces === "both" || layer.def.faces === (face > 0 ? "+" : "-");
13586
+ var faceCode = (thin, axis, sign2) => {
13587
+ const [u] = planeAxes(thin);
13588
+ return (sign2 >= 0 ? 1 : -1) * (axis === thin ? 1 : axis === u ? 2 : 3);
13589
+ };
13590
+ var faceAxis = (thin, face) => {
13591
+ const k = Math.abs(face);
13592
+ return k === 1 ? thin : planeAxes(thin)[k - 2];
13593
+ };
13594
+ var faceOfNormal = (layers, thin, localNormal) => {
13595
+ if (!layers.some((l) => l.def.faces === "all")) return localNormal[thin] >= 0 ? 1 : -1;
13596
+ let axis = thin;
13597
+ for (let k = 0; k < 3; k++) if (Math.abs(localNormal[k]) > Math.abs(localNormal[axis])) axis = k;
13598
+ return faceCode(thin, axis, localNormal[axis]);
13599
+ };
13600
+ var onFace = (layer, face) => {
13601
+ const faces = layer.def.faces;
13602
+ if (faces === "all") return true;
13603
+ if (Math.abs(face) !== 1) return false;
13604
+ return faces === "both" || faces === (face > 0 ? "+" : "-");
13605
+ };
13606
+ var thinSidesOf = (def) => def.faces === "both" || def.faces === "all" ? [1, -1] : [def.faces === "+" ? 1 : -1];
13587
13607
  var isSpalled = (spalls, layer, face, point) => {
13588
13608
  for (const s of spalls ?? []) {
13589
13609
  if (s[0] !== layer || s[1] !== face) continue;
@@ -13603,6 +13623,23 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
13603
13623
  for (const l of layers) if (onFace(l, face)) sum += l.def.thickness;
13604
13624
  return sum;
13605
13625
  };
13626
+ var tornPatchAt = (layers, spalls, face, point, radius) => {
13627
+ for (const l of layers) {
13628
+ if (!onFace(l, face)) continue;
13629
+ if (l.mat.fracture === "tear") {
13630
+ let best = -1;
13631
+ (spalls ?? []).forEach((s, i) => {
13632
+ if (s[0] !== l.index || s[1] !== face) return;
13633
+ const dx = s[2] - point[0], dy = s[3] - point[1], dz = s[4] - point[2];
13634
+ const reach2 = s[5] + radius;
13635
+ if (dx * dx + dy * dy + dz * dz <= reach2 * reach2 && (best < 0 || s[5] > spalls[best][5])) best = i;
13636
+ });
13637
+ if (best >= 0) return { layer: l, spall: best };
13638
+ }
13639
+ if (!isSpalled(spalls, l.index, face, point)) return void 0;
13640
+ }
13641
+ return void 0;
13642
+ };
13606
13643
  var REBAR_COVER = 0.03;
13607
13644
  var COVER = REBAR_COVER;
13608
13645
  var MAX_BARS_PER_DIRECTION = 24;
@@ -14563,8 +14600,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
14563
14600
  beams += cos * cos * q.elasticPa * c.beamFactor * inertia / Math.max(long, 1e-6);
14564
14601
  }
14565
14602
  const k = beams / kc;
14566
- const base = p.min[1] - ground < 0.05;
14567
- const a = base ? (0.5 + k) / (2 + k) : k / (2 + k);
14603
+ const base2 = p.min[1] - ground < 0.05;
14604
+ const a = base2 ? (0.5 + k) / (2 + k) : k / (2 + k);
14568
14605
  const stiffness = a * 12 * (p.elasticPa * c.stiffnessFactor) * (g[i].du ** 3 * g[i].dv / 12) / (h * h);
14569
14606
  for (let j = 0; j < n; j++) ga[j] += stiffness * share(p, j) / bands[j];
14570
14607
  }
@@ -14749,7 +14786,49 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
14749
14786
  elasticGPa: 200,
14750
14787
  absorbed: 0.2
14751
14788
  },
14752
- failureMPa: 250
14789
+ failureMPa: 250,
14790
+ tension: {
14791
+ elasticGPa: 200,
14792
+ ultimateMPa: 400
14793
+ }
14794
+ },
14795
+ {
14796
+ id: "spring_steel",
14797
+ density: 7850,
14798
+ hpPerKg: 900,
14799
+ penetration: 110,
14800
+ penetrationClass: "steel",
14801
+ penetrationScale: 1.3,
14802
+ ductility: 0.95,
14803
+ fracture: "none",
14804
+ damageScale: {
14805
+ slash: 0.1,
14806
+ blunt: 0.8
14807
+ },
14808
+ hitDebris: "sparks",
14809
+ breakDebris: "sparks",
14810
+ ricochetDeg: 20,
14811
+ thermal: {
14812
+ meltC: 1450,
14813
+ meltRate: 0.05,
14814
+ conductivity: 0.5,
14815
+ heatCapacity: 3
14816
+ },
14817
+ visual: {
14818
+ glows: true
14819
+ },
14820
+ tags: [
14821
+ "metal",
14822
+ "conductive",
14823
+ "spring"
14824
+ ],
14825
+ compressive: 2e6,
14826
+ bending: {
14827
+ yieldMPa: 1200,
14828
+ elasticGPa: 200,
14829
+ absorbed: 0.2
14830
+ },
14831
+ failureMPa: 1400
14753
14832
  },
14754
14833
  {
14755
14834
  id: "cast_iron",
@@ -14816,7 +14895,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
14816
14895
  "conductive"
14817
14896
  ],
14818
14897
  compressive: 8e5,
14819
- failureMPa: 90
14898
+ failureMPa: 90,
14899
+ tension: {
14900
+ elasticGPa: 69,
14901
+ ultimateMPa: 170
14902
+ }
14820
14903
  },
14821
14904
  {
14822
14905
  id: "copper",
@@ -14847,7 +14930,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
14847
14930
  "conductive"
14848
14931
  ],
14849
14932
  compressive: 1e6,
14850
- failureMPa: 70
14933
+ failureMPa: 70,
14934
+ tension: {
14935
+ elasticGPa: 117,
14936
+ ultimateMPa: 250
14937
+ }
14851
14938
  },
14852
14939
  {
14853
14940
  id: "wood_soft",
@@ -15388,7 +15475,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
15388
15475
  "flammable"
15389
15476
  ],
15390
15477
  compressive: 500,
15391
- failureMPa: 20
15478
+ failureMPa: 20,
15479
+ hits: {
15480
+ slash: {
15481
+ tear: "strips",
15482
+ tearJoules: 30
15483
+ },
15484
+ blunt: {
15485
+ tear: "strips",
15486
+ tearJoules: 150
15487
+ }
15488
+ }
15392
15489
  },
15393
15490
  {
15394
15491
  id: "foam",
@@ -15396,6 +15493,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
15396
15493
  hpPerKg: 15,
15397
15494
  penetration: 0.5,
15398
15495
  ductility: 0.7,
15496
+ cellular: true,
15399
15497
  fracture: "tear",
15400
15498
  splitForm: "granules",
15401
15499
  fragmentSize: [
@@ -15415,16 +15513,29 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
15415
15513
  burnRate: 0.09,
15416
15514
  conductivity: 0.02,
15417
15515
  heatCapacity: 0.5,
15418
- smoke: "black"
15516
+ smoke: "black",
15517
+ meltC: 200,
15518
+ meltRate: 0.08
15419
15519
  },
15420
15520
  visual: {
15421
- charColor: 855309
15521
+ charColor: 855309,
15522
+ innerColor: 15254346
15422
15523
  },
15423
15524
  tags: [
15424
15525
  "fabric",
15425
15526
  "flammable"
15426
15527
  ],
15427
- compressive: 100
15528
+ compressive: 100,
15529
+ hits: {
15530
+ ballistic: {
15531
+ tear: "lumps",
15532
+ tearJoules: 250
15533
+ },
15534
+ slash: {
15535
+ tear: "lumps",
15536
+ tearJoules: 60
15537
+ }
15538
+ }
15428
15539
  },
15429
15540
  {
15430
15541
  id: "leather",
@@ -16214,19 +16325,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
16214
16325
  };
16215
16326
  var placedPieces = /* @__PURE__ */ new WeakMap();
16216
16327
  var isSamePose = ({ known, position, rotation }) => known.position[0] === position[0] && known.position[1] === position[1] && known.position[2] === position[2] && known.rotation[0] === rotation[0] && known.rotation[1] === rotation[1] && known.rotation[2] === rotation[2] && known.rotation[3] === rotation[3];
16217
- var hostedPieces = (pieces, pose3) => pieces.map((piece2, index) => {
16218
- const known = placedPieces.get(piece2);
16328
+ var hostedPieces = (pieces, pose3) => pieces.map((piece3, index) => {
16329
+ const known = placedPieces.get(piece3);
16219
16330
  const p = pose3.position, q = pose3.rotation;
16220
- const isSamePlace = known !== void 0 && (piece2.key !== void 0 || known.index === index) && isSamePose({ known, position: p, rotation: q });
16331
+ const isSamePlace = known !== void 0 && (piece3.key !== void 0 || known.index === index) && isSamePose({ known, position: p, rotation: q });
16221
16332
  if (known && isSamePlace) return known.solid;
16222
- const solid = placedPiece(piece2, index, pose3);
16223
- placedPieces.set(piece2, { position: [p[0], p[1], p[2]], rotation: [q[0], q[1], q[2], q[3]], index, solid });
16333
+ const solid = placedPiece(piece3, index, pose3);
16334
+ placedPieces.set(piece3, { position: [p[0], p[1], p[2]], rotation: [q[0], q[1], q[2], q[3]], index, solid });
16224
16335
  return solid;
16225
16336
  });
16226
- var placedPiece = (piece2, index, pose3) => {
16227
- const base = { center: toWorld(pose3.position, pose3.rotation, piece2.center), half: piece2.half, rotation: quat.mul(pose3.rotation, piece2.rotation), key: piece2.key ?? `${piece2.id}:${index}` };
16228
- if (!piece2.mesh) return base;
16229
- const source = piece2.mesh.vertices;
16337
+ var placedPiece = (piece3, index, pose3) => {
16338
+ const base2 = { center: toWorld(pose3.position, pose3.rotation, piece3.center), half: piece3.half, rotation: quat.mul(pose3.rotation, piece3.rotation), key: piece3.key ?? `${piece3.id}:${index}` };
16339
+ if (!piece3.mesh) return base2;
16340
+ const source = piece3.mesh.vertices;
16230
16341
  const vertices = new Float32Array(source.length);
16231
16342
  for (let i = 0; i < source.length; i += 3) {
16232
16343
  const world = toWorld(pose3.position, pose3.rotation, [source[i], source[i + 1], source[i + 2]]);
@@ -16234,9 +16345,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
16234
16345
  vertices[i + 1] = world[1];
16235
16346
  vertices[i + 2] = world[2];
16236
16347
  }
16237
- return { ...base, mesh: { vertices, indices: piece2.mesh.indices } };
16348
+ return { ...base2, mesh: { vertices, indices: piece3.mesh.indices } };
16238
16349
  };
16239
16350
  var THIN_SHEET_DISHING = 5e-3;
16351
+ var SHELL_YIELD_SHARE = 0.5;
16352
+ var STEEL_YIELD_MPA = 250;
16240
16353
  var SWEEP_BACK = 0.01;
16241
16354
  function sweepOrigins(box4, d, spacing) {
16242
16355
  const origins = [];
@@ -16295,13 +16408,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
16295
16408
  var MEMBER_CRATER_CALIBRES = 3.4;
16296
16409
  var MEMBER_CUT_LOSS = 0.9;
16297
16410
  var MEMBER_UNIT_LOSS = 0.12;
16411
+ var CHIP_PROBE_DEPTH = 1e-4;
16298
16412
  var JOINT_OPEN_SHARE = 0.6;
16299
16413
  var BLAST_EDGE_WEAR = 0.6;
16300
16414
  var RESIDUAL_CAPACITY = 0.15;
16301
16415
  var SEVER_BAND = 0.1;
16416
+ var SURFACE_SLACK = 0.01;
16417
+ var SURFACE_SAME = 5e-4;
16302
16418
  var SEVER_ASPECT = 3;
16303
16419
  var SEVER_BALLISTIC = 2;
16304
16420
  var TEAR_JOULES = 150;
16421
+ var STRIP_THICKNESS = 15e-4;
16305
16422
  var tears = 0;
16306
16423
  var UNIT_FRAGMENT_FACTOR = 4;
16307
16424
  var BREACH_GRID_CAP = 4096;
@@ -16506,7 +16623,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
16506
16623
  if (typed) for (const fn of typed) fn(e);
16507
16624
  };
16508
16625
  let blow;
16509
- const base = (o, source) => ({
16626
+ const base2 = (o, source) => ({
16510
16627
  object: o.id,
16511
16628
  time,
16512
16629
  ...source === void 0 ? {} : { source },
@@ -17394,7 +17511,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
17394
17511
  w.emitted = { t: time, peak: d.peak, status: st.status };
17395
17512
  const dir = windDirection(o, w.cfg);
17396
17513
  const world2 = rotateVec(o.base.rot, [dir[0], 0, dir[1]]);
17397
- emit({ ...base(o), type: "sway", sway: d.x, peak: d.peak, drift: st.drift, overturn: st.overturn, frequency: st.frequency, direction: world2, status: st.status });
17514
+ emit({ ...base2(o), type: "sway", sway: d.x, peak: d.peak, drift: st.drift, overturn: st.overturn, frequency: st.frequency, direction: world2, status: st.status });
17398
17515
  }
17399
17516
  };
17400
17517
  const isTerrain = (p) => !!p.spec.tags?.includes("terrain");
@@ -17602,7 +17719,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
17602
17719
  const changed = st.status !== e.status || (time - e.t >= 0.5 || e.t === -Infinity) && (Math.abs(st.tilt - e.tilt) > 0.01 || Math.abs(st.settlement - e.s) > 2e-3);
17603
17720
  if (changed) {
17604
17721
  so.emitted = { t: time, s: st.settlement, tilt: st.tilt, status: st.status };
17605
- emit({ ...base(o), type: "settle", settlement: st.settlement, tilt: st.tilt, direction: rotateVec(o.base.rot, st.direction), bearing: st.bearing, status: st.status });
17722
+ emit({ ...base2(o), type: "settle", settlement: st.settlement, tilt: st.tilt, direction: rotateVec(o.base.rot, st.direction), bearing: st.bearing, status: st.status });
17606
17723
  }
17607
17724
  if (st.status === "toppled") topple(o);
17608
17725
  };
@@ -17651,7 +17768,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
17651
17768
  p.st.status = "broken";
17652
17769
  p.st.hp = 0;
17653
17770
  p.st.mass = 0;
17654
- emit({ ...base(o, src), type: "fracture", part: p.spec.id, style: "crumble", fragments, point: c });
17771
+ emit({ ...base2(o, src), type: "fracture", part: p.spec.id, style: "crumble", fragments, point: c });
17655
17772
  debris(o, p, p.mat.breakDebris, c, [0, 1, 0], clamp2(Math.round(Math.cbrt(partVolume(p.spec.shape)) * 30), 3, 20), 2, src);
17656
17773
  setStage(o, p, 3, {}, src);
17657
17774
  partLost(o, p, src);
@@ -17673,7 +17790,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
17673
17790
  markHostedDirty(o, p.spec.id);
17674
17791
  setStage(o, p, 3, {}, src);
17675
17792
  }
17676
- if (whole2.length > 0) emit({ ...base(o, src), type: "collapse", parts: whole2.map((p) => p.spec.id), mass: whole2.reduce((sum, p) => sum + p.st.mass, 0) });
17793
+ if (whole2.length > 0) emit({ ...base2(o, src), type: "collapse", parts: whole2.map((p) => p.spec.id), mass: whole2.reduce((sum, p) => sum + p.st.mass, 0) });
17677
17794
  }
17678
17795
  for (const p of crumbling) crumbleMasonry(o, p, src);
17679
17796
  }
@@ -17994,7 +18111,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
17994
18111
  r.st.subsidence = Math.max(r.st.subsidence ?? 0, drop.reduce((sum, v) => sum + v, 0) / count);
17995
18112
  const middle = [from[0], from[1], from[2]];
17996
18113
  middle[axis] = (stretch[0] + stretch[1]) / 2;
17997
- emit({ ...base(o, src), type: "subside", part: r.spec.id, drop: r.st.subsidence, share: (stretch[1] - stretch[0]) / Math.max(1e-6, box4.max[axis] - box4.min[axis]), point: toWorld(o.st.position, o.st.rotation, middle), status: "opened" });
18114
+ emit({ ...base2(o, src), type: "subside", part: r.spec.id, drop: r.st.subsidence, share: (stretch[1] - stretch[0]) / Math.max(1e-6, box4.max[axis] - box4.min[axis]), point: toWorld(o.st.position, o.st.rotation, middle), status: "opened" });
17998
18115
  let lost = false;
17999
18116
  for (const j of [...o.byPart.get(r.spec.id) ?? []]) {
18000
18117
  settleStructure(o);
@@ -18034,7 +18151,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18034
18151
  if (p.staged) {
18035
18152
  setStage(o, p, 1, {}, src);
18036
18153
  setStage(o, p, 2, { opening: { center: worldCenter, radius: hole.radius }, fragments }, src);
18037
- } else emit({ ...base(o, src), type: "stage", part: p.spec.id, stage: 2, opening: { center: worldCenter, radius: hole.radius }, fragments });
18154
+ } else emit({ ...base2(o, src), type: "stage", part: p.spec.id, stage: 2, opening: { center: worldCenter, radius: hole.radius }, fragments });
18038
18155
  debris(o, p, p.mat.breakDebris, worldCenter, [0, 1, 0], 14, 2, src);
18039
18156
  if (p.spec.reinforcement) exposeRebar(o, p, src);
18040
18157
  };
@@ -18060,8 +18177,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18060
18177
  const width = clamp2(beta * SETTLEMENT_CRACK_OPENING, MIN_CRACK_WIDTH, MAX_CRACK_WIDTH);
18061
18178
  const through = q.dims[q.thin];
18062
18179
  for (let c = 0; c < count; c++) {
18063
- const back = c * SETTLEMENT_CRACK_SPACING;
18064
- const local = [clamp2(at2[0] - toward[0] / reach2 * back, box4.min[0], box4.max[0]), box4.min[1] + height * (0.2 + 0.12 * c), clamp2(at2[2] - toward[2] / reach2 * back, box4.min[2], box4.max[2])];
18180
+ const back2 = c * SETTLEMENT_CRACK_SPACING;
18181
+ const local = [clamp2(at2[0] - toward[0] / reach2 * back2, box4.min[0], box4.max[0]), box4.min[1] + height * (0.2 + 0.12 * c), clamp2(at2[2] - toward[2] / reach2 * back2, box4.min[2], box4.max[2])];
18065
18182
  const face = toLocal(q.pos, q.q, local);
18066
18183
  face[q.thin] = through / 2;
18067
18184
  addCrack(o, q, toWorld(o.st.position, o.st.rotation, toWorld(q.pos, q.q, face)), normal, length, src, { along: along2, step, width, through });
@@ -18183,7 +18300,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18183
18300
  }
18184
18301
  if (bearing.status === "settled" && drop - before < SUBSIDE_MIN && peak() - peakBefore < SUBSIDE_MIN) continue;
18185
18302
  b.p.st.subsidence = drop;
18186
- emit({ ...base(o, src), type: "subside", part: b.p.spec.id, drop, share: fp.share, point: fp.deepest, status: bearing.status });
18303
+ emit({ ...base2(o, src), type: "subside", part: b.p.spec.id, drop, share: fp.share, point: fp.deepest, status: bearing.status });
18187
18304
  }
18188
18305
  for (const { b, fp } of settled) {
18189
18306
  settleStructure(o);
@@ -18298,7 +18415,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18298
18415
  const known = implSolids.get(im);
18299
18416
  if (known && known.spec === spec && known.state === state && im.impl.collidersPending?.() !== true && sameImplPlace(known.key, im)) return known.solids;
18300
18417
  const pieces = im.impl.colliders?.();
18301
- if (pieces && known?.pieces && known.spec === spec && sameImplPlace(known.key, im) && pieces.length === known.pieces.length && pieces.every((piece2, i) => piece2 === known.pieces?.[i])) {
18418
+ if (pieces && known?.pieces && known.spec === spec && sameImplPlace(known.key, im) && pieces.length === known.pieces.length && pieces.every((piece3, i) => piece3 === known.pieces?.[i])) {
18302
18419
  implSolids.set(im, { ...known, state });
18303
18420
  return known.solids;
18304
18421
  }
@@ -18383,6 +18500,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18383
18500
  return fresh.map(([nid]) => nid);
18384
18501
  };
18385
18502
  let rayBroad = null;
18503
+ let surfaceTracer = null;
18386
18504
  let uncovered = [];
18387
18505
  let uncoveredFor = { hook: null, coverage: -1, objects: -1 };
18388
18506
  const metObjects = [];
@@ -18412,7 +18530,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18412
18530
  }
18413
18531
  return rayObjects;
18414
18532
  };
18415
- const raycastInternal = (origin, dir, maxDist, ignore, worldOnly = false, precise = false, skip = {}, scope) => {
18533
+ const raycastInternal = (origin, dir, maxDist, ignore, worldOnly = false, precise = false, skip = {}, scope, drawn = false, passed) => {
18416
18534
  const d = vec.normalize(dir);
18417
18535
  const asked = rayBroad && !scope && rayBroad.begin(origin, d, maxDist) ? rayBroad : null;
18418
18536
  const candidates = asked ? candidatesOf2(asked) : null;
@@ -18440,12 +18558,22 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18440
18558
  if (!r || r.t0 < 0 || r.t0 > maxDist) continue;
18441
18559
  if (p.st.opening && insideOpening(o, p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
18442
18560
  if (p.spec.apertures && throughAperture(p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
18443
- if (p.st.chipped && insideChip(p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
18561
+ if (p.st.chipped && insideChip(p, objLocal(o, vec.madd(origin, d, Math.min(r.t0 + CHIP_PROBE_DEPTH, (r.t0 + r.t1) / 2))))) {
18562
+ passed?.push({ o, p, t: r.t0 });
18563
+ continue;
18564
+ }
18444
18565
  const gap = p.st.chipped?.length ? pastChips(o, p, origin, d, r.t0, r.t1) : null;
18445
18566
  if (gap === "through") continue;
18446
18567
  if (gap) {
18447
18568
  r.t0 = gap.t;
18448
18569
  r.n = gap.n;
18570
+ } else if (drawn && surfaceTracer) {
18571
+ const drawn2 = surfaceTracer({ object: o.id, part: p.spec.id, origin, direction: d, near: Math.max(0, r.t0 - SURFACE_SLACK), far: r.t1 + SURFACE_SLACK });
18572
+ if (drawn2 === null) continue;
18573
+ if (drawn2 && drawn2.distance <= maxDist && Math.abs(drawn2.distance - r.t0) > SURFACE_SAME) {
18574
+ r.t0 = drawn2.distance;
18575
+ r.n = [drawn2.normal[0], drawn2.normal[1], drawn2.normal[2]];
18576
+ }
18449
18577
  }
18450
18578
  if (!best || r.t0 < best.distance) {
18451
18579
  const point = vec.madd(origin, d, r.t0);
@@ -18586,14 +18714,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18586
18714
  arr[ni].radius = Math.max(arr[ni].radius, radius);
18587
18715
  } else arr.push(dent);
18588
18716
  markDamaged(p);
18589
- emit({ ...base(o, src), type: "dent", part: p.spec.id, dent, worldPoint: wp });
18717
+ emit({ ...base2(o, src), type: "dent", part: p.spec.id, dent, worldPoint: wp });
18590
18718
  };
18591
18719
  const addHole = (o, p, wp, wn, diameter, through, exit, src) => {
18592
18720
  const hole = { point: objLocal(o, wp), normal: objLocalDir(o, wn), diameter, through };
18593
18721
  p.st.holes.push(hole);
18594
18722
  if (p.st.holes.length > maxHoles) p.st.holes.shift();
18595
18723
  markDamaged(p);
18596
- emit({ ...base(o, src), type: "hole", part: p.spec.id, hole, worldPoint: wp, ...exit ? { exitPoint: exit } : {}, ...p.spec.powder ? { powder: { ...p.spec.powder } } : {} });
18724
+ emit({ ...base2(o, src), type: "hole", part: p.spec.id, hole, worldPoint: wp, ...exit ? { exitPoint: exit } : {}, ...p.spec.powder ? { powder: { ...p.spec.powder } } : {} });
18597
18725
  setStage(o, p, 1, {}, src);
18598
18726
  return hole;
18599
18727
  };
@@ -18602,13 +18730,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18602
18730
  p.st.cracks.push(crack);
18603
18731
  if (p.st.cracks.length > 16) p.st.cracks.shift();
18604
18732
  markDamaged(p);
18605
- emit({ ...base(o, src), type: "crack", part: p.spec.id, crack, worldPoint: wp });
18733
+ emit({ ...base2(o, src), type: "crack", part: p.spec.id, crack, worldPoint: wp });
18606
18734
  setStage(o, p, 1, {}, src);
18607
18735
  };
18608
- const debris = (o, p, kind, point, normal, count, speed, src, material) => emit({ ...base(o, src), type: "debris", part: p.spec.id, kind, point, normal, count, speed, ...material && material !== p.spec.material ? { material } : {} });
18736
+ const debris = (o, p, kind, point, normal, count, speed, src, material) => emit({ ...base2(o, src), type: "debris", part: p.spec.id, kind, point, normal, count, speed, ...material && material !== p.spec.material ? { material } : {} });
18609
18737
  const holeRate = (hole, pressurized) => (pressurized ? 0.5 : 0.1) * (hole.diameter / 9e-3);
18610
18738
  const detachEvents = (o, opened, by, src) => {
18611
- for (const j of opened) emit({ ...base(o, src), type: "detach", joint: j.spec.id, parts: [j.spec.a, j.spec.b], by, groups: o.st.groups.map((g) => [...g]) });
18739
+ for (const j of opened) emit({ ...base2(o, src), type: "detach", joint: j.spec.id, parts: [j.spec.a, j.spec.b], by, groups: o.st.groups.map((g) => [...g]) });
18612
18740
  };
18613
18741
  const loosened = (o, opened, by, src) => {
18614
18742
  if (runDepth === 0) {
@@ -18687,7 +18815,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18687
18815
  const checkDestroyed = (o, src) => {
18688
18816
  if (!o.st.destroyed && o.parts.length > 0 && o.parts.every(isLost)) {
18689
18817
  o.st.destroyed = true;
18690
- emit({ ...base(o, src), type: "destroyed" });
18818
+ emit({ ...base2(o, src), type: "destroyed" });
18691
18819
  }
18692
18820
  };
18693
18821
  const holeReaches = (host, box4) => {
@@ -18727,7 +18855,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18727
18855
  } else {
18728
18856
  o.hostedHosts = new Set(o.hosted.map((p) => p.spec.hostedIn));
18729
18857
  }
18730
- for (const p of shown) emit({ ...base(o), type: "reveal", part: p.spec.id, host: p.spec.hostedIn });
18858
+ for (const p of shown) emit({ ...base2(o), type: "reveal", part: p.spec.id, host: p.spec.hostedIn });
18731
18859
  if (opened.length > 0) {
18732
18860
  loosened(o, opened, "break");
18733
18861
  collapseCheck(o);
@@ -18853,26 +18981,48 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18853
18981
  const setStage = (o, p, stage, extra = {}, src) => {
18854
18982
  if (!p.staged || (p.st.stage ?? 0) >= stage) return;
18855
18983
  p.st.stage = stage;
18856
- emit({ ...base(o, src), type: "stage", part: p.spec.id, stage, ...extra });
18984
+ emit({ ...base2(o, src), type: "stage", part: p.spec.id, stage, ...extra });
18985
+ };
18986
+ const faceOf = (o, p, worldNormal) => faceOfNormal(p.layers, p.thin, rotateVec(quat.conjugate(partXf(o, p).q), worldNormal));
18987
+ const spallNormal = (o, p, face) => {
18988
+ if (Math.abs(face) === 1) return {};
18989
+ const local = [0, 0, 0];
18990
+ local[faceAxis(p.thin, face)] = face > 0 ? 1 : -1;
18991
+ return { normal: rotateVec(partXf(o, p).q, local) };
18992
+ };
18993
+ const widenTear = (o, p, torn, lp, normal, radius, src) => {
18994
+ const spalls = p.rt.spalls;
18995
+ const s = spalls[torn.spall];
18996
+ const axis = faceAxis(p.thin, s[1]);
18997
+ const faceArea = p.dims.reduce((area3, size, k) => k === axis ? area3 : area3 * size, 1);
18998
+ const reach2 = Math.hypot(lp[0] - s[2], lp[1] - s[3], lp[2] - s[4]);
18999
+ const r = Math.min(Math.sqrt(faceArea / Math.PI), Math.max(Math.sqrt(s[5] * s[5] + radius * radius), reach2));
19000
+ if (r <= s[5]) return;
19001
+ spalls[torn.spall] = [s[0], s[1], s[2], s[3], s[4], r];
19002
+ markDamaged(p);
19003
+ const centre = toWorld(o.st.position, o.st.rotation, [s[2], s[3], s[4]]);
19004
+ emit({ ...base2(o, src), type: "spall", part: p.spec.id, layer: torn.layer.index, point: centre, area: Math.PI * r * r, ...spallNormal(o, p, s[1]) });
19005
+ debris(o, p, torn.layer.mat.hitDebris, toWorld(o.st.position, o.st.rotation, lp), normal, 5, 2, src, torn.layer.mat.id);
18857
19006
  };
18858
- const faceOf = (o, p, worldNormal) => rotateVec(quat.conjugate(partXf(o, p).q), worldNormal)[p.thin] >= 0 ? 1 : -1;
18859
19007
  const spallOuter = (o, p, wp, face, normal, radius, src) => {
18860
19008
  var _a;
18861
19009
  if (p.layers.length === 0) return;
18862
19010
  const lp = objLocal(o, wp);
19011
+ const torn = tornPatchAt(p.layers, p.rt.spalls, face, lp, radius);
19012
+ if (torn) return widenTear(o, p, torn, lp, normal, radius, src);
18863
19013
  const layer = outerLayer(p.layers, p.rt.spalls, face, lp);
18864
19014
  if (!layer) return;
18865
19015
  const spalls = (_a = p.rt).spalls ?? (_a.spalls = []);
18866
19016
  spalls.push([layer.index, face, lp[0], lp[1], lp[2], radius]);
18867
19017
  if (spalls.length > MAX_SPALLS) spalls.shift();
18868
19018
  markDamaged(p);
18869
- emit({ ...base(o, src), type: "spall", part: p.spec.id, layer: layer.index, point: wp, area: Math.PI * radius * radius });
19019
+ emit({ ...base2(o, src), type: "spall", part: p.spec.id, layer: layer.index, point: wp, area: Math.PI * radius * radius, ...spallNormal(o, p, face) });
18870
19020
  debris(o, p, layer.mat.hitDebris, wp, normal, 5, 2, src, layer.mat.id);
18871
19021
  setStage(o, p, 1, {}, src);
18872
19022
  };
18873
19023
  const crater = (o, p, wp, normal, radius, src) => {
18874
19024
  markDamaged(p);
18875
- emit({ ...base(o, src), type: "spall", part: p.spec.id, layer: -1, point: wp, area: Math.PI * radius * radius });
19025
+ emit({ ...base2(o, src), type: "spall", part: p.spec.id, layer: -1, point: wp, area: Math.PI * radius * radius });
18876
19026
  debris(o, p, p.mat.breakDebris, wp, normal, 6, 1.5, src);
18877
19027
  setStage(o, p, 1, {}, src);
18878
19028
  };
@@ -18941,7 +19091,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18941
19091
  if (!layer || cells.length === 0) return [];
18942
19092
  const { c, q } = partXf(o, p);
18943
19093
  const [u, v] = planeAxes(p.thin);
18944
- const faces = layer.def.faces === "both" ? [1, -1] : [layer.def.faces === "+" ? 1 : -1];
19094
+ const faces = thinSidesOf(layer.def);
18945
19095
  const area3 = cells.reduce((sum, cell) => sum + cell.size[u] * cell.size[v], 0) * faces.length;
18946
19096
  const count = Math.min(MAX_PLASTER_FLAKES, Math.ceil(area3 / PLASTER_FLAKE_AREA));
18947
19097
  const out = [];
@@ -19123,6 +19273,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19123
19273
  }
19124
19274
  return cells.some((c) => Math.abs(lp[u] - c.center[u]) <= c.size[u] / 2 && Math.abs(lp[v] - c.center[v]) <= c.size[v] / 2);
19125
19275
  };
19276
+ const alongAt = (along2, at2) => {
19277
+ const point = [0, 0, 0];
19278
+ point[along2] = at2;
19279
+ return point;
19280
+ };
19126
19281
  const wornLocally = (p) => !!p.spec.reinforcement && !!p.spec.units && p.spec.units.mortar === p.spec.material && isMember(p.dims, p.spec.structure?.role) && p.spec.shape.kind === "box";
19127
19282
  const wearMember = (o, p, entry2, d, E, caliber, penMm, src) => {
19128
19283
  var _a, _b, _c;
@@ -19157,7 +19312,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19157
19312
  const wear = (_c = p.rt).cellWear ?? (_c.cellWear = {});
19158
19313
  const cell = grid[hit];
19159
19314
  wear[hit] = (wear[hit] ?? 0) + volume;
19160
- if (wear[hit] >= MEMBER_UNIT_LOSS * cell.size[0] * cell.size[1] * cell.size[2]) knockOutUnits(o, p, entry2, E, [hit], src);
19315
+ if (wear[hit] >= MEMBER_UNIT_LOSS * cell.size[0] * cell.size[1] * cell.size[2]) knockOutUnits(o, p, entry2, E, [hit], src, d);
19161
19316
  return true;
19162
19317
  }
19163
19318
  const out = [];
@@ -19165,8 +19320,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19165
19320
  if (gone[i] === -1) continue;
19166
19321
  if (Math.abs(grid[i].center[along2] - bandCenter) <= height / 2 + 1e-6) out.push(i);
19167
19322
  }
19168
- if (out.length > 0) knockOutUnits(o, p, entry2, E, out, src);
19169
- giveAtCut(o, p, src);
19323
+ worn[band] = 1;
19324
+ if (out.length > 0) knockOutUnits(o, p, entry2, E, out, src, d);
19325
+ giveAtCut(o, p, src, { at: alongAt(along2, bandCenter), d });
19170
19326
  return true;
19171
19327
  };
19172
19328
  const chipUnits = (o, p, kind, wp, hitEnergy, dir, radius, src) => {
@@ -19238,7 +19394,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19238
19394
  p.rt.removed = (p.rt.removed ?? 0) + mass;
19239
19395
  markDamaged(p);
19240
19396
  setStage(o, p, 1, {}, src);
19241
- emit({ ...base(o, src), type: "chip", part: p.spec.id, center, size: [cell.size[0], cell.size[1], cell.size[2]], rotation: q, fragments });
19397
+ emit({ ...base2(o, src), type: "chip", part: p.spec.id, center, size: [cell.size[0], cell.size[1], cell.size[2]], rotation: q, fragments });
19242
19398
  debris(o, p, p.mat.breakDebris, center, vec.scale(dir ?? [0, 1, 0], -1), 6, 2, src);
19243
19399
  }
19244
19400
  markHostedDirty(o, p.spec.id);
@@ -19273,18 +19429,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19273
19429
  const n = clamp2(Math.round(cell.size[u] * cell.size[v] / (bit * bit * 3)), 4, 10) + Math.floor(rnd() * 3);
19274
19430
  const out = [];
19275
19431
  for (let i = 0; i < n; i++) {
19276
- const back = i % 3 === 2;
19432
+ const back2 = i % 3 === 2;
19277
19433
  const lc = [cell.center[0], cell.center[1], cell.center[2]];
19278
19434
  lc[u] += (rnd() - 0.5) * cell.size[u] * 0.7;
19279
19435
  lc[v] += (rnd() - 0.5) * cell.size[v] * 0.7;
19280
- lc[p.thin] += (back ? -exitSign : exitSign) * (p.thickness / 2 + 0.01);
19436
+ lc[p.thin] += (back2 ? -exitSign : exitSign) * (p.thickness / 2 + 0.01);
19281
19437
  const size = [0, 0, 0];
19282
19438
  size[u] = bit * (0.6 + 0.8 * rnd());
19283
19439
  size[v] = bit * (0.5 + 0.7 * rnd());
19284
19440
  size[p.thin] = bit * (0.4 + 0.6 * rnd());
19285
19441
  const spread3 = [(rnd() - 0.5) * 0.9, (rnd() - 0.3) * 0.9, (rnd() - 0.5) * 0.9];
19286
- const k = speed * (back ? 0.4 + 0.4 * rnd() : 0.7 + 0.8 * rnd());
19287
- const vdir = vec.normalize(vec.add(back ? vec.scale(d, -1) : d, spread3));
19442
+ const k = speed * (back2 ? 0.4 + 0.4 * rnd() : 0.7 + 0.8 * rnd());
19443
+ const vdir = vec.normalize(vec.add(back2 ? vec.scale(d, -1) : d, spread3));
19288
19444
  out.push({
19289
19445
  id: `${p.spec.id}#${tag}${i}`,
19290
19446
  part: p.spec.id,
@@ -19301,8 +19457,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19301
19457
  }
19302
19458
  return out;
19303
19459
  };
19304
- const exposeRebar = (o, p, src) => {
19305
- settleStructure(o);
19460
+ const exposeRebar = (o, p, src, bowed = true) => {
19461
+ if (bowed) settleStructure(o);
19306
19462
  const r = p.spec.reinforcement;
19307
19463
  if (!r) return;
19308
19464
  const [u, v] = planeAxes(p.thin);
@@ -19319,14 +19475,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19319
19475
  bars.push(...clipBarsToDisc(all, u, v, [lc[u], lc[v]], op.radius + 0.05));
19320
19476
  }
19321
19477
  }
19322
- const bow2 = clamp2(((p.st.stress ?? 0) - 1) / 0.5, 0, 1);
19478
+ const bow2 = bowed ? clamp2(((p.st.stress ?? 0) - 1) / 0.5, 0, 1) : 0;
19323
19479
  if (bow2 > 0) bars = bars.flatMap((bar2, i) => bendBar(bar2, p.thin, bow2 * BAR_BOW, i));
19324
19480
  const stirrups = memberStirrups(p.dims, void 0, p.spec.structure?.role);
19325
19481
  if (stirrups.length > 0 && bars.length > 0) {
19326
19482
  if (p.st.stripped) bars = [...bars, ...stirrups];
19327
19483
  else for (const box4 of [...p.st.chipped ?? [], ...p.rt.bared ?? []]) bars.push(...clipBarsToVolume(stirrups, box4.center, box4.size));
19328
19484
  }
19329
- emit({ ...base(o, src), type: "expose", part: p.spec.id, bars: worldBars(o, p, bars) });
19485
+ emit({ ...base2(o, src), type: "expose", part: p.spec.id, bars: worldBars(o, p, bars) });
19330
19486
  };
19331
19487
  const openBreach = (o, p, center, total, energy, dir, src) => {
19332
19488
  const [u, v] = planeAxes(p.thin);
@@ -19487,7 +19643,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19487
19643
  for (const i of out) worn[i] = -1;
19488
19644
  return knockOutUnits(o, p, point, energy, out, src);
19489
19645
  };
19490
- const knockOutUnits = (o, p, wp, energy, out, src) => {
19646
+ const knockOutUnits = (o, p, wp, energy, out, src, d) => {
19491
19647
  var _a, _b;
19492
19648
  const [u, v] = planeAxes(p.thin);
19493
19649
  const op = p.st.opening ? toLocal(p.pos, p.q, p.st.opening.center) : null;
@@ -19531,15 +19687,34 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19531
19687
  setStage(o, p, 1, {}, src);
19532
19688
  const center = toWorld(c, q, [(lo[0] + hi[0]) / 2, (lo[1] + hi[1]) / 2, (lo[2] + hi[2]) / 2]);
19533
19689
  const units = cells.map((cell) => ({ center: toWorld(c, q, cell.center), size: [cell.size[0], cell.size[1], cell.size[2]] }));
19534
- emit({ ...base(o, src), type: "chip", part: p.spec.id, center, size: [hi[0] - lo[0], hi[1] - lo[1], hi[2] - lo[2]], rotation: q, fragments, units });
19690
+ emit({ ...base2(o, src), type: "chip", part: p.spec.id, center, size: [hi[0] - lo[0], hi[1] - lo[1], hi[2] - lo[2]], rotation: q, fragments, units });
19535
19691
  debris(o, p, p.mat.breakDebris, center, vec.normalize(vec.sub(center, wp), [0, 1, 0]), 14, 3, src);
19536
- if (p.spec.reinforcement) exposeRebar(o, p, src);
19692
+ const cut = wornLocally(p) && cutBandsGone(o, p, cells, d ?? vec.normalize(vec.sub(partXf(o, p).c, wp), [1, 0, 0]), src);
19693
+ if (p.spec.reinforcement && !cut) exposeRebar(o, p, src);
19537
19694
  if (p.structural && !isLost(p)) {
19538
19695
  solveStructure(o);
19539
19696
  collapseCheck(o, src);
19540
19697
  }
19541
19698
  return true;
19542
19699
  };
19700
+ const cutBandsGone = (o, p, cells, d, src) => {
19701
+ var _a;
19702
+ const along2 = p.dims.indexOf(Math.max(...p.dims));
19703
+ const bands = Math.max(1, Math.round(p.dims[along2] / MEMBER_BAND));
19704
+ const height = p.dims[along2] / bands;
19705
+ const bandOf2 = (at2) => clamp2(Math.floor((at2 + p.dims[along2] / 2) / p.dims[along2] * bands), 0, bands - 1);
19706
+ const grid = gridOf(p);
19707
+ const gone = p.rt.chips ?? {};
19708
+ const worn = (_a = p.rt).bands ?? (_a.bands = {});
19709
+ for (const band of new Set(cells.map((cell) => bandOf2(cell.center[along2])))) {
19710
+ if ((worn[band] ?? 0) >= 1) continue;
19711
+ const center = -p.dims[along2] / 2 + (band + 0.5) * height;
19712
+ if (!grid.every((cell, i) => gone[i] === -1 || Math.abs(cell.center[along2] - center) > height / 2 + 1e-6)) continue;
19713
+ worn[band] = 1;
19714
+ return giveAtCut(o, p, src, { at: alongAt(along2, center), d });
19715
+ }
19716
+ return false;
19717
+ };
19543
19718
  const dropUnsupported = (o, p, src) => {
19544
19719
  var _a, _b;
19545
19720
  if (!p.spec.units || p.spec.units.mortar === p.spec.material || p.st.stripped || isLost(p)) return 0;
@@ -19573,17 +19748,90 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19573
19748
  p.rt.removed = (p.rt.removed ?? 0) + mass;
19574
19749
  markDamaged(p);
19575
19750
  const units = fallen.map((cell) => ({ center: toWorld(c, q, cell.center), size: [cell.size[0], cell.size[1], cell.size[2]] }));
19576
- emit({ ...base(o, src), type: "chip", part: p.spec.id, center, size: [hi[0] - lo[0], hi[1] - lo[1], hi[2] - lo[2]], rotation: q, fragments, units });
19751
+ emit({ ...base2(o, src), type: "chip", part: p.spec.id, center, size: [hi[0] - lo[0], hi[1] - lo[1], hi[2] - lo[2]], rotation: q, fragments, units });
19577
19752
  debris(o, p, p.mat.breakDebris, center, [0, -1, 0], 6, 1, src);
19578
19753
  return loose.length;
19579
19754
  };
19580
- const giveAtCut = (o, p, src) => {
19755
+ const barsMoment = (p) => {
19756
+ const r = p.spec.reinforcement;
19757
+ if (!r) return 0;
19758
+ const left = rebarBars(p.dims, p.thin, r.spacing, p.spec.structure?.role).length - (p.rt.severedBars?.length ?? 0);
19759
+ const along2 = p.dims.indexOf(Math.max(...p.dims));
19760
+ const side = Math.min(...p.dims.filter((_, a) => a !== along2));
19761
+ const fy = (materials.get(r.material)?.bending?.yieldMPa ?? STEEL_YIELD_MPA) * 1e6;
19762
+ return Math.max(0, left) / 2 * Math.PI * (r.diameter / 2) ** 2 * fy * Math.max(0, side - 2 * REBAR_COVER);
19763
+ };
19764
+ const memberSide = (p) => {
19765
+ const along2 = p.dims.indexOf(Math.max(...p.dims));
19766
+ return Math.min(...p.dims.filter((_, a) => a !== along2));
19767
+ };
19768
+ const tubeMoment = (p, share) => {
19769
+ const [a = 0, b = 0] = [...p.dims].sort((x, y) => x - y);
19770
+ const fy = (p.mat.bending?.yieldMPa ?? STEEL_YIELD_MPA) * 1e6;
19771
+ return fy * p.thickness * ((a + b) / 2) ** 2 * Math.max(0, 1 - share) ** 2;
19772
+ };
19773
+ const holdsAbove = (o, p, j) => {
19774
+ if (j.st.open) return false;
19775
+ const other = o.parts[j.ia === o.idx.get(p.spec.id) ? j.ib : j.ia];
19776
+ if (j.bears === "a_on_b") return j.spec.b === p.spec.id;
19777
+ if (j.bears === "b_on_a") return j.spec.a === p.spec.id;
19778
+ return partXf(o, other).c[1] > partXf(o, p).c[1] + 1e-6;
19779
+ };
19780
+ const hingeAcross = (o, p, opened, cut, src) => {
19781
+ var _a;
19782
+ const blow2 = cut.d ? objLocalDir(o, cut.d) : [1, 0, 0];
19783
+ const across2 = vec.normalize([blow2[0], 0, blow2[2]], [1, 0, 0]);
19784
+ const point = vec.madd(vec.add(p.pos, rotateVec(p.q, cut.at)), across2, cut.behind);
19785
+ const toward = vec.scale(across2, -1);
19786
+ const moment = cut.moment;
19787
+ const hinges = (_a = p.rt).hinges ?? (_a.hinges = []);
19788
+ for (const j of opened) {
19789
+ j.st.yields = { point, toward, moment };
19790
+ hinges.push({ joint: j.spec.id, point, toward, moment });
19791
+ }
19792
+ emitYields(o, p, src);
19793
+ };
19794
+ const reyield = (o, p, moment, src) => {
19795
+ for (const h of p.rt.hinges ?? []) h.moment = moment;
19796
+ for (const j of o.byPart.get(p.spec.id) ?? []) if (j.st.yields) j.st.yields.moment = moment;
19797
+ emitYields(o, p, src);
19798
+ };
19799
+ const emitYields = (o, p, src) => {
19800
+ for (const h of p.rt.hinges ?? []) {
19801
+ const point = toWorld(o.st.position, o.st.rotation, h.point);
19802
+ emit({ ...base2(o, src), type: "yield", part: p.spec.id, joint: h.joint, point, toward: rotateVec(o.st.rotation, h.toward), moment: h.moment });
19803
+ }
19804
+ };
19805
+ const severBars = (o, p, origin, d, caliber, src) => {
19806
+ var _a;
19807
+ const r = p.spec.reinforcement;
19808
+ if (!r || isLost(p) || !isMember(p.dims, p.spec.structure?.role)) return;
19809
+ const along2 = p.dims.indexOf(Math.max(...p.dims));
19810
+ const [u, v] = [0, 1, 2].filter((k) => k !== along2);
19811
+ const lo = toLocal(p.pos, p.q, objLocal(o, origin));
19812
+ const ld = rotateVec(quat.conjugate(p.q), objLocalDir(o, d));
19813
+ const across2 = Math.hypot(ld[u], ld[v]);
19814
+ if (across2 < 1e-6) return;
19815
+ const cut = (_a = p.rt).severedBars ?? (_a.severedBars = []);
19816
+ let severed = 0;
19817
+ rebarBars(p.dims, p.thin, r.spacing, p.spec.structure?.role).forEach(([a], i) => {
19818
+ if (cut.includes(i)) return;
19819
+ const du = a[u] - lo[u];
19820
+ const dv = a[v] - lo[v];
19821
+ if (Math.abs(du * ld[v] - dv * ld[u]) / across2 > r.diameter / 2 + caliber / 2e3) return;
19822
+ cut.push(i);
19823
+ severed++;
19824
+ const s = (du * ld[u] + dv * ld[v]) / (across2 * across2);
19825
+ const at2 = vec.madd(origin, d, s * vec.length(d));
19826
+ debris(o, p, "sparks", at2, vec.scale(d, -1), 6, 3, src);
19827
+ });
19828
+ if (severed > 0) reyield(o, p, barsMoment(p), src);
19829
+ };
19830
+ const giveAtCut = (o, p, src, cut) => {
19581
19831
  if (!p.spec.reinforcement || !p.spec.units || !p.st.chipped?.length || sectionLoss(p) <= 0) return false;
19582
19832
  const opened = [];
19583
19833
  for (const j of o.byPart.get(p.spec.id) ?? []) {
19584
- if (j.st.open) continue;
19585
- const onIt = j.bears === "a_on_b" && j.spec.b === p.spec.id || j.bears === "b_on_a" && j.spec.a === p.spec.id;
19586
- if (!onIt) continue;
19834
+ if (!j.bears || !holdsAbove(o, p, j)) continue;
19587
19835
  j.st.open = true;
19588
19836
  j.st.openedBy = "break";
19589
19837
  opened.push(j);
@@ -19591,8 +19839,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19591
19839
  if (opened.length === 0) return false;
19592
19840
  p.st.hp = Math.max(p.st.hp, p.st.maxHp * GIVE_AT_CUT_HP);
19593
19841
  markDamaged(p);
19842
+ if (cut) hingeAcross(o, p, opened, { at: cut.at, d: cut.d, behind: memberSide(p) / 2 - REBAR_COVER, moment: barsMoment(p) }, src);
19594
19843
  loosened(o, opened, "break", src);
19595
- exposeRebar(o, p, src);
19844
+ exposeRebar(o, p, src, !cut);
19596
19845
  collapseCheck(o, src);
19597
19846
  return true;
19598
19847
  };
@@ -19620,7 +19869,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19620
19869
  p.st.status = "broken";
19621
19870
  p.st.hp = 0;
19622
19871
  p.st.mass = 0;
19623
- emit({ ...base(o, src), type: "expose", part: p.spec.id, bars: [] });
19872
+ emit({ ...base2(o, src), type: "expose", part: p.spec.id, bars: [] });
19624
19873
  debris(o, p, "sparks", partXf(o, p).c, [0, 1, 0], 6, 3, src);
19625
19874
  partLost(o, p, src);
19626
19875
  };
@@ -19719,7 +19968,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19719
19968
  p.st.burning = false;
19720
19969
  p.rt.jet = false;
19721
19970
  }
19722
- emit({ ...base(o, src), type: "fracture", part: p.spec.id, style, fragments, point: hitW });
19971
+ emit({ ...base2(o, src), type: "fracture", part: p.spec.id, style, fragments, point: hitW });
19723
19972
  debris(o, p, p.mat.breakDebris, c, [0, 1, 0], clamp2(Math.round(Math.cbrt(partVolume(p.spec.shape)) * 30), 3, 20), 2, src);
19724
19973
  setStage(o, p, 3, {}, src);
19725
19974
  if (reinforcement) {
@@ -19727,7 +19976,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19727
19976
  return;
19728
19977
  }
19729
19978
  if (ex) {
19730
- emit({ ...base(o, src), type: "explode", part: p.spec.id, point: c, energy: ex.energy, radius: ex.radius, ...ex.lethalRadius !== void 0 ? { lethalRadius: ex.lethalRadius } : {}, ...ex.tnt !== void 0 ? { tnt: ex.tnt } : {}, ...ex.effect !== void 0 ? { effect: ex.effect } : {} });
19979
+ emit({ ...base2(o, src), type: "explode", part: p.spec.id, point: c, energy: ex.energy, radius: ex.radius, ...ex.lethalRadius !== void 0 ? { lethalRadius: ex.lethalRadius } : {}, ...ex.tnt !== void 0 ? { tnt: ex.tnt } : {}, ...ex.effect !== void 0 ? { effect: ex.effect } : {} });
19731
19980
  const fuel = burstFuel(p);
19732
19981
  blasts.push({ point: c, energy: ex.energy, radius: ex.radius, ...ex.lethalRadius !== void 0 ? { lethalRadius: ex.lethalRadius } : {}, ...fuel > 0 ? { fuel } : {}, source: src });
19733
19982
  }
@@ -19740,7 +19989,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19740
19989
  p.rt.chainDue = time + delay;
19741
19990
  primed.set(p, o);
19742
19991
  o.active = true;
19743
- emit({ ...base(o, src), type: "primed", part: p.spec.id, point: partXf(o, p).c, trigger, delay });
19992
+ emit({ ...base2(o, src), type: "primed", part: p.spec.id, point: partXf(o, p).c, trigger, delay });
19744
19993
  };
19745
19994
  const CHAIN_TRIGGER_OF = { ballistic: "shot", explosive: "explosion" };
19746
19995
  const severAxis = (p) => {
@@ -19777,7 +20026,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19777
20026
  if (p.st.hp <= 0 && p.mat.fracture === "none" && !p.spec.explodes) p.st.hp = Math.min(prev, 1);
19778
20027
  if (p.st.hp <= 0 && type === "ballistic" && wornLocally(p)) p.st.hp = Math.min(prev, 1);
19779
20028
  const done = prev - p.st.hp;
19780
- if (done > 0) emit({ ...base(o, src), type: "damage", part: p.spec.id, amount: done, hp: Math.max(0, p.st.hp), damageType: type });
20029
+ if (done > 0) emit({ ...base2(o, src), type: "damage", part: p.spec.id, amount: done, hp: Math.max(0, p.st.hp), damageType: type });
19781
20030
  if (p.st.hp <= 0) failPart(o, p, origin, dir, fragEnergy * weight, cap, src);
19782
20031
  else if (chained && (trigger === "explosion" || 1 - p.st.hp / p.st.maxHp >= shotDamageFractionOf(p.spec))) prime(o, p, trigger, src);
19783
20032
  return done;
@@ -19819,27 +20068,29 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19819
20068
  const n = shot ? exit ? clamp2(Math.round(E / joules), 1, 7) : 1 : clamp2(Math.floor(E / joules), 0, 5);
19820
20069
  if (n === 0) return;
19821
20070
  const fibre = tear === "lumps";
20071
+ const strips = tear === "strips";
19822
20072
  const { q } = partXf(o, p);
19823
20073
  const along2 = (p.spec.grain ? AXIS[p.spec.grain] : void 0) ?? [0, 1, 2].sort((a, b) => p.dims[b] - p.dims[a])[0];
19824
20074
  const fragments = [];
19825
20075
  for (let i = 0; i < n; i++) {
19826
- const back = !exit || i % 3 === 2;
20076
+ const back2 = !exit || i % 3 === 2;
19827
20077
  const plies = p.mat.splitForm === "plies";
19828
- const len = scale * (fibre ? 1.2 + 1.2 * rnd() : 3 + 4 * rnd()), w = scale * (0.8 + 0.8 * rnd()), t = scale * (fibre ? 0.7 + 0.6 * rnd() : plies ? 0.15 + 0.15 * rnd() : 0.4 + 0.4 * rnd());
20078
+ const len = scale * (fibre ? 1.2 + 1.2 * rnd() : strips ? 6 + 6 * rnd() : 3 + 4 * rnd()), w = scale * (strips ? 1 + rnd() : 0.8 + 0.8 * rnd());
20079
+ const t = strips ? Math.min(p.thickness, STRIP_THICKNESS) : scale * (fibre ? 0.7 + 0.6 * rnd() : plies ? 0.15 + 0.15 * rnd() : 0.4 + 0.4 * rnd());
19829
20080
  const size = [w, w, w];
19830
20081
  size[along2] = len;
19831
20082
  size[(along2 + 1) % 3] = w;
19832
20083
  size[(along2 + 2) % 3] = t;
19833
20084
  const spread3 = [(rnd() - 0.5) * 0.8, (rnd() - 0.2) * 0.8, (rnd() - 0.5) * 0.8];
19834
- const speed = shot ? back ? 1.5 + 2 * rnd() : 2 + 4 * rnd() : 0.8 + 1.2 * rnd();
19835
- const v = vec.scale(vec.normalize(vec.add(back ? vec.scale(d, -1) : d, spread3)), speed);
20085
+ const speed = shot ? back2 ? 1.5 + 2 * rnd() : 2 + 4 * rnd() : 0.8 + 1.2 * rnd();
20086
+ const v = vec.scale(vec.normalize(vec.add(back2 ? vec.scale(d, -1) : d, spread3)), speed);
19836
20087
  const mass = size[0] * size[1] * size[2] * p.mat.density;
19837
20088
  fragments.push({
19838
20089
  id: `${p.spec.id}#t${tears++}-${i}`,
19839
20090
  part: p.spec.id,
19840
20091
  material: p.spec.material,
19841
- shape: fibre ? "chunk" : "splinter",
19842
- center: back || !exit ? vec.madd(entry2, d, -0.01) : vec.madd(exit, d, 0.01),
20092
+ shape: fibre ? "chunk" : strips ? "scrap" : "splinter",
20093
+ center: back2 || !exit ? vec.madd(entry2, d, -0.01) : vec.madd(exit, d, 0.01),
19843
20094
  size,
19844
20095
  rotation: q,
19845
20096
  velocity: v,
@@ -19849,14 +20100,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19849
20100
  });
19850
20101
  }
19851
20102
  const patch = [scale * 4, scale * 4, scale * 4];
19852
- emit({ ...base(o, src), type: "chip", part: p.spec.id, center: exit ?? entry2, size: patch, rotation: q, fragments, torn: true });
20103
+ emit({ ...base2(o, src), type: "chip", part: p.spec.id, center: exit ?? entry2, size: patch, rotation: q, fragments, torn: true });
19853
20104
  };
19854
20105
  const ballistic = (o, p, entry2, n, d, E, caliber, pathLen, src, round3 = {}) => {
19855
20106
  const mat = p.mat;
19856
- const piece2 = round3.piece;
19857
- const weight = piece2?.weight ?? 1;
20107
+ const piece3 = round3.piece;
20108
+ const weight = piece3?.weight ?? 1;
19858
20109
  const piercing = round3.piercing ?? 1;
19859
- if (p.st.stripped || p.st.opening && insideOpening(o, p, objLocal(o, entry2)) || insideChip(p, objLocal(o, entry2))) {
20110
+ if (p.st.stripped || p.st.opening && insideOpening(o, p, objLocal(o, entry2)) || insideChip(p, objLocal(o, vec.madd(entry2, d, Math.min(CHIP_PROBE_DEPTH, pathLen / 2))))) {
19860
20111
  return { penetrated: true, exitEnergy: E, exitPoint: vec.madd(entry2, d, Math.min(pathLen, p.thickness)), damage: 0 };
19861
20112
  }
19862
20113
  const sin = Math.min(1, Math.abs(vec.dot(d, n)));
@@ -19870,14 +20121,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19870
20121
  const hard = mat.tags?.includes("metal") || mat.tags?.includes("masonry");
19871
20122
  const penMm = penetrationOf(mat, round3.penetration);
19872
20123
  const Ep = penMm !== void 0 ? penMm * mat.penetration : piercing === 1 || !hard ? E : E * piercing;
19873
- const strength = piece2 && mat.strength?.ndrc ? mat.strength.compressiveMPa : void 0;
20124
+ const strength = piece3 && mat.strength?.ndrc ? mat.strength.compressiveMPa : void 0;
19874
20125
  const path = strength === void 0 ? 0 : (p.thickness + layersThickness(p.layers, face) + layersThickness(p.layers, -face)) / slant;
19875
- const penetrated = Ep > thr && (strength === void 0 || !piece2 || concretePerforation({ mass: piece2.mass, caliber: caliber / 1e3, speed: Math.sqrt(2 * E / piece2.mass), compressiveMPa: strength, nose: piece2.nose }).perforation > path);
20126
+ const penetrated = Ep > thr && (strength === void 0 || !piece3 || concretePerforation({ mass: piece3.mass, caliber: caliber / 1e3, speed: Math.sqrt(2 * E / piece3.mass), compressiveMPa: strength, nose: piece3.nose }).perforation > path);
19876
20127
  const scale = (mat.damageScale?.ballistic ?? 1) * (mat.fracture === "shatter" ? fragility(mat.ductility, p.thickness) : 1);
19877
20128
  const id = p.spec.id;
19878
20129
  if (!penetrated && mat.ricochetDeg && angle < mat.ricochetDeg) {
19879
20130
  const r = vec.sub(d, vec.scale(n, 2 * vec.dot(d, n)));
19880
- emit({ ...base(o, src), type: "ricochet", part: id, point: entry2, direction: vec.normalize(r), energy: E * 0.4 });
20131
+ emit({ ...base2(o, src), type: "ricochet", part: id, point: entry2, direction: vec.normalize(r), energy: E * 0.4 });
19881
20132
  debris(o, p, mat.hitDebris, entry2, n, 3, 3, src);
19882
20133
  const dmg2 = applyDamage(o, p, E * DMG_PER_J * scale * 0.2, "ballistic", entry2, d, E * 0.1, 12, src, weight);
19883
20134
  return { penetrated: false, exitEnergy: 0, damage: dmg2 };
@@ -19888,10 +20139,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19888
20139
  const ratio = Ep / Math.max(thr, 1e-6);
19889
20140
  const crackLen = clamp2(0.03 + ratio * 0.2, 0.03, 0.8);
19890
20141
  let exitPoint;
20142
+ let shellShare = 0;
19891
20143
  if (penetrated) {
19892
20144
  const exitDist = p.spec.contains || p.spec.fill !== void 0 && p.spec.fill < 0.5 || p.thickness < pathLen * 0.5 ? pathLen : Math.min(pathLen, effM + layersThickness(p.layers, face) / slant + layersThickness(p.layers, -face) / slant);
19893
20145
  exitPoint = vec.madd(entry2, d, exitDist);
19894
20146
  const hole = addHole(o, p, entry2, n, caliber / 1e3 * (mat.ductility >= 0.3 ? 1 : 1.5), true, exitPoint, src);
20147
+ shellShare = wearsShell(p, hole.diameter * 2);
19895
20148
  if (p.layers.length > 0) spallOuter(o, p, exitPoint, -face, vec.scale(n, -1), Math.max(0.03, caliber / 1e3 * 4), src);
19896
20149
  addBreach(o, p, entry2, Math.PI * (hole.diameter / 2) * (hole.diameter / 2), E, d, src);
19897
20150
  if (mat.ductility >= 0.5 && p.thickness <= THIN_SHEET_DISHING) addDent(o, p, entry2, n, Math.max(caliber * 3 / 1e3, 0.012), clamp2(E * 2e-5, 1e-3, 0.03), src);
@@ -19899,7 +20152,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19899
20152
  if (p.spec.contains && (p.st.liters ?? 0) > 1e-4) {
19900
20153
  o.active = true;
19901
20154
  emit({
19902
- ...base(o, src),
20155
+ ...base2(o, src),
19903
20156
  type: "leak",
19904
20157
  part: id,
19905
20158
  fluid: p.spec.contains.fluid,
@@ -19919,8 +20172,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19919
20172
  debris(o, p, mat.hitDebris, entry2, n, clamp2(Math.round(E / 60) + 2, 2, 14), clamp2(Math.sqrt(E) / 6, 1, 8), src);
19920
20173
  wearJoints(o, p, (penetrated ? thr : E) * 0.02 * weight, void 0, 0, src, true, BULLET_JOINT_SPAN);
19921
20174
  const hollowTear = mat.fracture === "tear" && p.spec.fill !== void 0 && p.spec.fill < 0.5;
19922
- const absorbed = penetrated && (mat.ductility >= 0.5 && mat.fracture !== "tear" || hollowTear) ? Math.min(E, thr) : E;
20175
+ const absorbed = penetrated && (mat.ductility >= 0.5 && mat.fracture !== "tear" || hollowTear || mat.cellular === true) ? Math.min(E, thr) : E;
19923
20176
  const dmg = applyDamage(o, p, absorbed * DMG_PER_J * scale, "ballistic", entry2, d, absorbed * 0.1, 12, src, weight);
20177
+ if (shellShare > 0 && !isLost(p)) yieldShell(o, p, shellShare, entry2, d, src);
19924
20178
  if (!isLost(p)) tearAt(o, p, "ballistic", entry2, penetrated ? exitPoint : void 0, d, E, caliber / 1e3, src);
19925
20179
  if (!wearMember(o, p, entry2, d, E, caliber, penMm, src)) chipUnits(o, p, "ballistic", entry2, penetrated ? Math.min(E, Math.max(thr, E * 0.5)) : E, d, Math.max(0.05, caliber / 1e3 * 8), src);
19926
20180
  return { penetrated, exitEnergy: penetrated ? penMm !== void 0 ? E * (1 - thr / Ep) : E - thr / (hard ? piercing : 1) : 0, exitPoint, damage: dmg };
@@ -19938,13 +20192,37 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19938
20192
  const hinge = plateHinge(p.dims, toLocal(c, q, point), local);
19939
20193
  const toObject = (v) => rotateVec(p.q, v);
19940
20194
  p.st.bendHinge = { point: vec.add(p.pos, toObject(hinge.point)), axis: toObject(hinge.axis), side: toObject(hinge.side) };
19941
- emit({ ...base(o), type: "bend", part: p.spec.id, hinge: p.st.bendHinge, angle: p.st.bend - before, worldPoint: point });
20195
+ emit({ ...base2(o), type: "bend", part: p.spec.id, hinge: p.st.bendHinge, angle: p.st.bend - before, worldPoint: point });
19942
20196
  }
19943
20197
  const axis = severAxis(p);
19944
20198
  if (axis < 0 || snapRatio(p.dims, p.mat.bending, E, local, SEVER_ASPECT) < 1) return 0;
19945
20199
  p.rt.cutAt = clamp2(toLocal(c, q, point)[axis], -p.dims[axis] / 2, p.dims[axis] / 2);
19946
20200
  return Math.max(0, p.st.hp);
19947
20201
  };
20202
+ const wearsShell = (p, width) => {
20203
+ if (p.mat.ductility < 0.5 || p.thickness > THIN_SHEET_DISHING || p.spec.shape.kind !== "box") return 0;
20204
+ const [a = 0, b = 0, c = 0] = [...p.dims].sort((x, y) => x - y);
20205
+ if (c < 2 * b || b > 3 * a) return 0;
20206
+ p.rt.shellCut = (p.rt.shellCut ?? 0) + width;
20207
+ return Math.min(1, p.rt.shellCut / (2 * (a + b)));
20208
+ };
20209
+ const yieldShell = (o, p, share, entry2, d, src) => {
20210
+ if (share < SHELL_YIELD_SHARE) return;
20211
+ if (p.rt.hinges?.length) {
20212
+ reyield(o, p, tubeMoment(p, share), src);
20213
+ return;
20214
+ }
20215
+ const opened = (o.byPart.get(p.spec.id) ?? []).filter((j) => holdsAbove(o, p, j));
20216
+ if (opened.length === 0) return;
20217
+ for (const j of opened) {
20218
+ j.st.open = true;
20219
+ j.st.openedBy = "break";
20220
+ }
20221
+ const along2 = p.dims.indexOf(Math.max(...p.dims));
20222
+ hingeAcross(o, p, opened, { at: alongAt(along2, toLocal(p.pos, p.q, objLocal(o, entry2))[along2]), d, behind: memberSide(p) / 2, moment: tubeMoment(p, share) }, src);
20223
+ loosened(o, opened, "break", src);
20224
+ collapseCheck(o, src);
20225
+ };
19948
20226
  const melee = (o, p, kind, E, point, n, d, contactR, src) => {
19949
20227
  const mat = p.mat;
19950
20228
  const thrMm = mat.penetration * p.thickness * 1e3;
@@ -20035,7 +20313,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20035
20313
  frontQueue.push({ o, p, due: time + dist / blastFrontSpeed, amount, fragEnergy: Ein * 0.3, point, ...src !== void 0 ? { src } : {} });
20036
20314
  return reach2;
20037
20315
  }
20038
- if (Ein > 20 && p.layers.length > 0) spallOuter(o, p, wp, o.st.rotation === objectRotation && p.q === partQuat ? rotateVec(quat.conjugate(q), wn)[p.thin] >= 0 ? 1 : -1 : faceOf(o, p, wn), wn, clamp2(0.05 + Math.sqrt(Ein) * 2e-3, 0.05, 0.4), src);
20316
+ if (Ein > 20 && p.layers.length > 0) spallOuter(o, p, wp, o.st.rotation === objectRotation && p.q === partQuat ? faceOfNormal(p.layers, p.thin, rotateVec(quat.conjugate(q), wn)) : faceOf(o, p, wn), wn, clamp2(0.05 + Math.sqrt(Ein) * 2e-3, 0.05, 0.4), src);
20039
20317
  const breachReach = BREACH_BLAST_REACH * Math.cbrt(Math.max(0, energy) / 1e3);
20040
20318
  const caged2 = Boolean(p.spec.reinforcement && p.spec.units);
20041
20319
  const member = caged2 && (isMember(p.dims, p.spec.structure?.role) || dist > MEMBER_CUT_REACH * breachReach);
@@ -20394,7 +20672,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20394
20672
  for (let i = 0; i < 4 && E > 0; i++) {
20395
20673
  const reach2 = flight ? E > flight.minEnergy ? Math.log(E / flight.minEnergy) / (2 * flight.drag) : 0 : Infinity;
20396
20674
  if (!(reach2 > 0)) break;
20397
- const rh = raycastInternal(org, d, reach2, ignore, false, true);
20675
+ const crossed = [];
20676
+ const rh = raycastInternal(org, d, reach2, ignore, false, true, {}, void 0, true, crossed);
20677
+ for (const c of crossed) if (!rh || c.t < rh.distance) severBars(c.o, c.p, org, d, caliber, source);
20398
20678
  if (!rh) break;
20399
20679
  if (flight) E *= Math.exp(-2 * flight.drag * vec.distance(org, rh.point));
20400
20680
  const im = impls.get(rh.object);
@@ -20591,14 +20871,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20591
20871
  }
20592
20872
  return out;
20593
20873
  }
20594
- const mergeResults = (base2, extra) => {
20595
- const byObject = new Map(base2.map((r) => [r.object, r]));
20874
+ const mergeResults = (base22, extra) => {
20875
+ const byObject = new Map(base22.map((r) => [r.object, r]));
20596
20876
  for (const r of extra) {
20597
20877
  const have = byObject.get(r.object);
20598
20878
  if (!have) {
20599
20879
  const copy = { ...r, events: [...r.events] };
20600
20880
  byObject.set(r.object, copy);
20601
- base2.push(copy);
20881
+ base22.push(copy);
20602
20882
  continue;
20603
20883
  }
20604
20884
  have.damage += r.damage;
@@ -20606,7 +20886,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20606
20886
  have.events.push(...r.events);
20607
20887
  if (!have.part && r.part) have.part = r.part;
20608
20888
  }
20609
- return base2;
20889
+ return base22;
20610
20890
  };
20611
20891
  function* blastSteps(point, energy, radius, src, call, only, lethal) {
20612
20892
  const cfg = blastCfg(call);
@@ -20858,7 +21138,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20858
21138
  p.st.temperature = Math.max(p.st.temperature, th.flameC ?? 800);
20859
21139
  o.active = true;
20860
21140
  markDamaged(p);
20861
- emit({ ...base(o, src), type: "ignite", part: p.spec.id, point: partXf(o, p).c });
21141
+ emit({ ...base2(o, src), type: "ignite", part: p.spec.id, point: partXf(o, p).c });
20862
21142
  };
20863
21143
  const syncMass = (p) => {
20864
21144
  p.st.mass = Math.max(0, p.mass0 * (1 - p.st.melt) - (p.fuel0 - p.st.fuel));
@@ -20884,11 +21164,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20884
21164
  p.st.status = "ashes";
20885
21165
  p.st.hp = 0;
20886
21166
  p.st.mass = p.mass0 * (1 - (th.fuelFraction ?? 0));
20887
- emit({ ...base(o), type: "burnout", part: p.spec.id, point: c });
21167
+ emit({ ...base2(o), type: "burnout", part: p.spec.id, point: c });
20888
21168
  debris(o, p, "ash", c, [0, 1, 0], clamp2(Math.round(Math.cbrt(partVolume(p.spec.shape)) * 30), 3, 20), 1);
20889
21169
  partLost(o, p);
20890
21170
  } else {
20891
- emit({ ...base(o), type: "burnout", part: p.spec.id, point: c });
21171
+ emit({ ...base2(o), type: "burnout", part: p.spec.id, point: c });
20892
21172
  }
20893
21173
  }
20894
21174
  };
@@ -20905,11 +21185,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20905
21185
  p.rt.dripT -= 0.25;
20906
21186
  const b = partWorldAabb(o, p);
20907
21187
  const pt = [b.min[0] + (b.max[0] - b.min[0]) * (0.2 + 0.6 * rnd()), b.min[1], b.min[2] + (b.max[2] - b.min[2]) * (0.2 + 0.6 * rnd())];
20908
- emit({ ...base(o), type: "drip", part: p.spec.id, point: pt, material: p.mat.id });
21188
+ emit({ ...base2(o), type: "drip", part: p.spec.id, point: pt, material: p.mat.id });
20909
21189
  }
20910
21190
  if (p.st.melt - p.rt.meltEmitted >= 0.05 || p.st.melt >= 1) {
20911
21191
  p.rt.meltEmitted = p.st.melt;
20912
- emit({ ...base(o), type: "melt", part: p.spec.id, melt: p.st.melt });
21192
+ emit({ ...base2(o), type: "melt", part: p.spec.id, melt: p.st.melt });
20913
21193
  }
20914
21194
  if (p.st.melt >= 1) {
20915
21195
  p.st.status = "melted";
@@ -20982,7 +21262,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20982
21262
  }
20983
21263
  p.rt.jet = true;
20984
21264
  s.burning = true;
20985
- emit({ ...base(o), type: "ignite", part: p.spec.id, point: partXf(o, p).c });
21265
+ emit({ ...base2(o), type: "ignite", part: p.spec.id, point: partXf(o, p).c });
20986
21266
  }
20987
21267
  }
20988
21268
  }
@@ -20990,7 +21270,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20990
21270
  if (p.rt.jet && (s.liters ?? 0) <= 0) {
20991
21271
  p.rt.jet = false;
20992
21272
  s.burning = false;
20993
- emit({ ...base(o), type: "extinguish", part: p.spec.id });
21273
+ emit({ ...base2(o), type: "extinguish", part: p.spec.id });
20994
21274
  }
20995
21275
  const sc = th.thermalShockC;
20996
21276
  if (sc !== void 0) {
@@ -21024,7 +21304,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21024
21304
  if (stress > 1) {
21025
21305
  if (p.rt.stressT <= 0) {
21026
21306
  p.rt.stressT = 0.5;
21027
- emit({ ...base(o), type: "stress", part: p.spec.id, stress, load: p.st.load ?? 0 });
21307
+ emit({ ...base2(o), type: "stress", part: p.spec.id, stress, load: p.st.load ?? 0 });
21028
21308
  if (p.spec.reinforcement && (p.st.stripped || p.st.chipped?.length || p.st.opening)) exposeRebar(o, p);
21029
21309
  }
21030
21310
  applyDamage(o, p, overloadRate(stress) * p.st.maxHp * dt, "blunt", null, null, 5, 3);
@@ -21338,6 +21618,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21338
21618
  setRayBroadPhase(broadPhase2) {
21339
21619
  rayBroad = broadPhase2;
21340
21620
  },
21621
+ setSurfaceTracer(tracer) {
21622
+ surfaceTracer = tracer;
21623
+ },
21341
21624
  groundLoss(loss) {
21342
21625
  if (!(loss.radius > 0) || !(loss.depth > 0) || !Number.isFinite(loss.x) || !Number.isFinite(loss.z)) return;
21343
21626
  pendingLosses.push({ ...loss });
@@ -21402,7 +21685,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21402
21685
  const step = Math.floor(j.st.progress * 10 + 1e-9);
21403
21686
  if (step > j.step || j.st.progress >= 1) {
21404
21687
  j.step = step;
21405
- emit({ ...base(o), type: "disassemble_progress", joint: j.spec.id, tool: tool2, progress: j.st.progress });
21688
+ emit({ ...base2(o), type: "disassemble_progress", joint: j.spec.id, tool: tool2, progress: j.st.progress });
21406
21689
  }
21407
21690
  if (j.st.progress >= 1) {
21408
21691
  j.st.open = true;
@@ -21488,7 +21771,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21488
21771
  if (p.st.burning) {
21489
21772
  p.st.burning = false;
21490
21773
  p.rt.jet = false;
21491
- emit({ ...base(o), type: "extinguish", part: p.spec.id });
21774
+ emit({ ...base2(o), type: "extinguish", part: p.spec.id });
21492
21775
  }
21493
21776
  p.st.temperature = Math.max(ambient, p.st.temperature - coolC);
21494
21777
  }
@@ -21520,7 +21803,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21520
21803
  if (p.st.holes.length > maxHoles) p.st.holes.shift();
21521
21804
  o.active = true;
21522
21805
  emit({
21523
- ...base(o),
21806
+ ...base2(o),
21524
21807
  type: "leak",
21525
21808
  part: partId,
21526
21809
  fluid: c.fluid,
@@ -21730,7 +22013,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21730
22013
  var defaultSet;
21731
22014
  var defaultAssemblies = () => defaultSet ?? (defaultSet = assembliesOver(ASSEMBLIES));
21732
22015
  var getAssembly = (id) => defaultAssemblies().get(id);
21733
- var faceCount = (layer) => layer.faces === "both" ? 2 : 1;
22016
+ var faceCount = (layer) => layer.faces === "both" || layer.faces === "all" ? 2 : 1;
21734
22017
  var assemblyDepth = (def) => def.depth ?? def.core.thickness + (def.layers ?? []).reduce((sum, l) => sum + l.thickness * faceCount(l), 0);
21735
22018
  var buildAssemblyPart = (def, assemblyId, options) => {
21736
22019
  if (!def) throw new Error(`unknown assembly "${assemblyId}"`);
@@ -21904,8 +22187,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21904
22187
  const id = w.add(onRock(s));
21905
22188
  return new Map(w.state(id).parts.map((p) => [p.id, p.flexure ?? 0]));
21906
22189
  };
21907
- const base = bending(out);
21908
- const factor = new Map(targets.map((p) => [p.id, (base.get(p.id) ?? 0) / safetyOf(p.structure.role)]));
22190
+ const base2 = bending(out);
22191
+ const factor = new Map(targets.map((p) => [p.id, (base2.get(p.id) ?? 0) / safetyOf(p.structure.role)]));
21909
22192
  if (options.redundancy !== void 0) {
21910
22193
  const roles = options.redundancyRoles ?? ["column"];
21911
22194
  for (const lost of out.parts) {
@@ -21949,11 +22232,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21949
22232
  return new Map(w.state(id).parts.map((p) => [p.id, { load: p.load ?? 0, stress: p.stress ?? 0, wind: p.wind ?? 0 }]));
21950
22233
  };
21951
22234
  const out = structuredClone(spec);
21952
- const base = loads(out, options.wind);
22235
+ const base2 = loads(out, options.wind);
21953
22236
  const gamma = options.wind ? resolveWind(options.wind).loadFactor : 0;
21954
22237
  const structural = out.parts.filter((p) => p.structure && p.structure.role !== "none");
21955
22238
  const loadAt = (p) => {
21956
- const b = base.get(p.id);
22239
+ const b = base2.get(p.id);
21957
22240
  return b && b.stress > 0 ? b.load + (b.wind > 0 ? gamma * b.wind / GRAVITY : 0) : void 0;
21958
22241
  };
21959
22242
  const lossesOf = function* () {
@@ -21982,7 +22265,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21982
22265
  if (options.wind) {
21983
22266
  const yieldMPa = resolveFlexure(options.flexure).rebarYieldMPa;
21984
22267
  for (const p of out.parts) {
21985
- const b = base.get(p.id);
22268
+ const b = base2.get(p.id);
21986
22269
  if (!b || b.wind >= 0 || !p.reinforcement || p.shape.kind !== "box") continue;
21987
22270
  const pull = -(b.load + gamma * b.wind / GRAVITY) * GRAVITY;
21988
22271
  if (pull <= 0) continue;
@@ -23035,8 +23318,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23035
23318
  return { parts: context.parts, supports: context.supports };
23036
23319
  }
23037
23320
  function anchorBalconies(context) {
23038
- const base = context.panelsOf.get("slab_base");
23039
- if (!base) return;
23321
+ const base2 = context.panelsOf.get("slab_base");
23322
+ if (!base2) return;
23040
23323
  const decks = context.parts.filter((p) => p.role === "slab" && /^slab_\d+_/.test(p.id) && context.supports.some((s) => s.part === p.id && /^balcony_column_/.test(s.on)));
23041
23324
  for (const deck of decks) {
23042
23325
  const pillars = new Set(context.supports.filter((s) => s.part === deck.id && /^balcony_column_/.test(s.on)).map((s) => s.on));
@@ -23055,7 +23338,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23055
23338
  if (!splits.size) return input;
23056
23339
  const boxes = new Map(input.parts.map((part) => [part.id, part.aabb]));
23057
23340
  const pieceBox = /* @__PURE__ */ new Map();
23058
- for (const split of splits.values()) for (const piece2 of split.pieces) pieceBox.set(piece2.id, piece2.aabb);
23341
+ for (const split of splits.values()) for (const piece3 of split.pieces) pieceBox.set(piece3.id, piece3.aabb);
23059
23342
  const parts2 = input.parts.flatMap((part) => splits.get(part.id)?.pieces ?? [part]);
23060
23343
  const supports = [];
23061
23344
  for (const support of input.supports) {
@@ -23197,9 +23480,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23197
23480
  const spandrel = spandrels[k];
23198
23481
  if (spandrel) internal.push({ part: spandrel.id, on: lintel.id, joint: style.wallJoint });
23199
23482
  });
23200
- const base = [...piers, ...drafts.filter((d) => d.id.includes("_sill_"))].map((d) => d.id);
23483
+ const base2 = [...piers, ...drafts.filter((d) => d.id.includes("_sill_"))].map((d) => d.id);
23201
23484
  const top = [...piers.map((p) => p.id), ...lintels.map((l, k) => spandrels[k]?.id ?? l.id)];
23202
- return { pieces, internal, base, top };
23485
+ return { pieces, internal, base: base2, top };
23203
23486
  }
23204
23487
  var LOG_DIAMETER = 0.26;
23205
23488
  var isWall = (part) => part.id.startsWith("wall_") && part.assembly !== void 0 && (part.role === "wall" || part.role === "partition");
@@ -23261,7 +23544,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23261
23544
  if (capacity === void 0) continue;
23262
23545
  const along2 = (box22) => Math.max(box22[2] - box22[0], box22[3] - box22[1]);
23263
23546
  const length = along2(input.parts.find((part) => part.id === id).aabb);
23264
- for (const piece2 of split.pieces) capacities.set(piece2.id, Math.max(1, capacity * along2(piece2.aabb) / length));
23547
+ for (const piece3 of split.pieces) capacities.set(piece3.id, Math.max(1, capacity * along2(piece3.aabb) / length));
23265
23548
  }
23266
23549
  return { ...next, capacities };
23267
23550
  }
@@ -23485,10 +23768,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23485
23768
  const joints = [...spec.joints ?? []];
23486
23769
  const reinforcement = { material: "steel", spacing: c.rebar.spacing, diameter: c.rebar.diameter };
23487
23770
  const raft2 = parts2.find((p) => p.id === "raft");
23488
- let base = raft2?.id;
23489
- if (!base) {
23490
- base = "core_mat";
23491
- parts2.push({ id: base, material: c.material, shape: box3([W + 1, c.matThickness, L + 1]), position: [cx, -c.matThickness / 2, cz], structure: { role: "foundation" }, anchored: true });
23771
+ let base2 = raft2?.id;
23772
+ if (!base2) {
23773
+ base2 = "core_mat";
23774
+ parts2.push({ id: base2, material: c.material, shape: box3([W + 1, c.matThickness, L + 1]), position: [cx, -c.matThickness / 2, cz], structure: { role: "foundation" }, anchored: true });
23492
23775
  }
23493
23776
  const innerX = x0 + t + c.stairWidth + ti / 2;
23494
23777
  for (let f = 0; f < g.floors; f++) {
@@ -23496,7 +23779,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23496
23779
  const wall = (name, size, pos) => {
23497
23780
  const id = `core_${f}_${name}`;
23498
23781
  parts2.push({ id, material: c.material, shape: box3(size), position: [pos[0], yb + H / 2, pos[1]], structure: { role: "wall" }, reinforcement, tags: ["core"] });
23499
- rests(joints, id, f === 0 ? base : `core_${f - 1}_${name}`, "rebar");
23782
+ rests(joints, id, f === 0 ? base2 : `core_${f - 1}_${name}`, "rebar");
23500
23783
  return id;
23501
23784
  };
23502
23785
  const tube2 = [
@@ -23549,7 +23832,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23549
23832
  mass: 1500,
23550
23833
  tags: ["elevator_car"]
23551
23834
  });
23552
- rests(joints, id, base, "resting", false);
23835
+ rests(joints, id, base2, "resting", false);
23553
23836
  }
23554
23837
  return { ...spec, parts: parts2, joints };
23555
23838
  }
@@ -24272,9 +24555,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24272
24555
  const rule = storageRuleOf(rules, state.storage);
24273
24556
  const thawDays = rules.aging.thawShelfDays[state.storage];
24274
24557
  const isThawing = rule.needsPower === true && !powered && thawDays !== void 0 && state.shelfLife === void 0;
24275
- const base = isThawing ? { ...state, ageDays: 0, shelfLife: thawDays } : state;
24276
- const ageDays = base.ageDays + accruedDays(state.storage, { storedAt: state.storedAt, from: state.since, to: now }, options);
24277
- return { ...base, ageDays, since: Math.max(now, state.since) };
24558
+ const base2 = isThawing ? { ...state, ageDays: 0, shelfLife: thawDays } : state;
24559
+ const ageDays = base2.ageDays + accruedDays(state.storage, { storedAt: state.storedAt, from: state.since, to: now }, options);
24560
+ return { ...base2, ageDays, since: Math.max(now, state.since) };
24278
24561
  };
24279
24562
  var shelfRatio = (item, state) => {
24280
24563
  const shelfLife = state.shelfLife ?? item.shelfLife;
@@ -24305,12 +24588,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24305
24588
  var resolveUse = (item, effects, context = {}, rules = DEFAULT_RULES) => {
24306
24589
  const def = findEffect(item, effects);
24307
24590
  if (!def) return void 0;
24308
- const base = { useId: def.id, effect: def.effect, params: def.params ?? {}, consumes: def.consumes };
24309
- if (def.effect !== "consume_nutrition") return base;
24591
+ const base2 = { useId: def.id, effect: def.effect, params: def.params ?? {}, consumes: def.consumes };
24592
+ if (def.effect !== "consume_nutrition") return base2;
24310
24593
  const nutrition = nutritionOf(item, context, rules);
24311
24594
  const blocked = item.seal && context.seal ? sealBlock(item.seal, context.seal) : void 0;
24312
- if (blocked) return { ...base, consumes: false, nutrition: { ...nutrition, isEdible: false }, blocked };
24313
- return { ...base, consumes: def.consumes && nutrition.isEdible, nutrition };
24595
+ if (blocked) return { ...base2, consumes: false, nutrition: { ...nutrition, isEdible: false }, blocked };
24596
+ return { ...base2, consumes: def.consumes && nutrition.isEdible, nutrition };
24314
24597
  };
24315
24598
  var countOf = (context, id) => context.inventory.get(id) ?? 0;
24316
24599
  var candidatesOf = (input, context) => {
@@ -24447,10 +24730,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24447
24730
  };
24448
24731
  var countFor = (pool, state, footprint, query, rules) => {
24449
24732
  const settings = rules.finds.pool;
24450
- const base = Math.max(settings.min, Math.min(settings.max, Math.round(settings.offset + footprint * settings.perSquareMetre + query.rng() * settings.jitter)));
24451
- if (state === "fortified") return Math.min(pool.length, base + settings.fortifiedExtra);
24733
+ const base2 = Math.max(settings.min, Math.min(settings.max, Math.round(settings.offset + footprint * settings.perSquareMetre + query.rng() * settings.jitter)));
24734
+ if (state === "fortified") return Math.min(pool.length, base2 + settings.fortifiedExtra);
24452
24735
  if (state === "abandoned") return query.rng() < settings.abandonedEmptyChance ? 0 : settings.abandonedKept;
24453
- return base;
24736
+ return base2;
24454
24737
  };
24455
24738
  var rollExplicitPool = (pool, state, query, rules) => {
24456
24739
  const settings = rules.finds.pool;
@@ -43125,9 +43408,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
43125
43408
  var goodsItemUse = createGoodsItemUse();
43126
43409
 
43127
43410
  // ../game-interactables-household/dist/index.js
43128
- var door = (material, joint = "hinge", piece2 = "door") => ({ material, joint, piece: piece2 });
43411
+ var door = (material, joint = "hinge", piece22 = "door") => ({ material, joint, piece: piece22 });
43129
43412
  var drawer = { material: "mdf", joint: "slide", piece: "drawer" };
43130
43413
  var knob = { material: "plastic", joint: "clip", piece: "knob" };
43414
+ var mainLever = { material: "plastic", joint: "clip", piece: "breaker" };
43131
43415
  var tap = { material: "steel", joint: "screw", piece: "handle" };
43132
43416
  var mdfBody = { material: "mdf", joint: "screw" };
43133
43417
  var cabinet = { body: mdfBody, parts: [[/^drawer/, drawer], [/^door/, door("mdf")]] };
@@ -43162,19 +43446,23 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
43162
43446
  wall_socket: { body: { material: "plastic", joint: "screw" }, parts: [] },
43163
43447
  wall_switch: { body: { material: "plastic", joint: "screw" }, parts: [["rocker", { material: "plastic", joint: "clip", piece: "rocker" }]] },
43164
43448
  // a cast concrete pole (NBR 8451: CA-50 bars in the concrete), its segments held by the bars; the meter box, the cross arm and the bracket are bolted to it
43165
- service_entrance: { body: { material: "concrete", joint: "rebar", reinforcement: POLE_CAGE }, parts: [["meter_door", door("steel")]] },
43449
+ service_entrance: { body: { material: "concrete", joint: "rebar", reinforcement: POLE_CAGE }, parts: [["meter_door", door("steel")], ["main_breaker", mainLever]] },
43166
43450
  conduit_run: { body: { material: "plastic", joint: "clip" }, parts: [] },
43167
- service_mast: { body: { material: "steel", joint: "clip" }, parts: [] },
43451
+ // one galvanised pipe bent over the top: its stretches are the same steel (welded, not clipped: the clamps hold it to the wall, not to itself)
43452
+ service_mast: { body: { material: "steel", joint: "weld" }, parts: [] },
43168
43453
  electrical_panel: {
43169
43454
  body: { material: "steel", joint: "screw" },
43170
43455
  parts: [[/^breaker/, { material: "plastic", joint: "clip", piece: "breaker" }], ["door", door("steel")]]
43171
43456
  },
43172
- power_meter: { body: { material: "plastic", joint: "screw" }, parts: [["door", door("plastic")]] },
43457
+ power_meter: { body: { material: "plastic", joint: "screw" }, parts: [["door", door("plastic")], ["main_breaker", mainLever]] },
43173
43458
  tv: { body: { material: "plastic", joint: "screw" }, parts: [["power", { material: "plastic", joint: "clip", piece: "button" }]] },
43174
43459
  microwave: { body: { material: "steel", joint: "screw" }, parts: [["door", door("steel")], ["dial", knob]] },
43175
43460
  washing_machine: { body: { material: "steel", joint: "screw" }, parts: [["dial", knob], ["door", door("tempered_glass")]] },
43176
43461
  sofa: { body: upholstery, parts: [] },
43177
43462
  armchair: { body: upholstery, parts: [] },
43463
+ pouf: { body: upholstery, parts: [] },
43464
+ box_bed: { body: upholstery, parts: [] },
43465
+ upholstered_chair: { body: upholstery, parts: [] },
43178
43466
  dining_chair: { body: { material: "wood_hard", joint: "screw" }, parts: [] },
43179
43467
  bed_double: { body: { material: "wood_soft", joint: "screw" }, parts: [] },
43180
43468
  bed_single: { body: { material: "wood_soft", joint: "screw" }, parts: [] },
@@ -43246,9 +43534,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
43246
43534
  "type.washing_machine": "Washing machine",
43247
43535
  "type.sofa": "Sofa",
43248
43536
  "type.armchair": "Armchair",
43537
+ "type.pouf": "Pouf",
43249
43538
  "type.dining_chair": "Dining chair",
43539
+ "type.upholstered_chair": "Upholstered chair",
43250
43540
  "type.bed_double": "Double bed",
43251
43541
  "type.bed_single": "Single bed",
43542
+ "type.box_bed": "Box bed",
43252
43543
  "type.bench": "Bench",
43253
43544
  "type.blinds": "Blinds",
43254
43545
  "type.curtain": "Curtain",
@@ -43401,6 +43692,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
43401
43692
  "prompt.breaker.off": "Switch on {circuit}",
43402
43693
  "prompt.breaker.off.verb": "Switch on",
43403
43694
  "prompt.breaker.off.object": "{circuit}",
43695
+ "prompt.main_breaker": "Main breaker",
43696
+ "prompt.main_breaker.on": "Switch off the main breaker",
43697
+ "prompt.main_breaker.on.verb": "Switch off",
43698
+ "prompt.main_breaker.on.object": "the main breaker",
43699
+ "prompt.main_breaker.off": "Switch on the main breaker",
43700
+ "prompt.main_breaker.off.verb": "Switch on",
43701
+ "prompt.main_breaker.off.object": "the main breaker",
43404
43702
  "type.bunk_bed": "Bunk bed",
43405
43703
  "type.wood_stove": "Wood stove",
43406
43704
  "type.fireplace": "Fireplace",
@@ -43494,9 +43792,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
43494
43792
  "type.washing_machine": "M\xE1quina de lavar",
43495
43793
  "type.sofa": "Sof\xE1",
43496
43794
  "type.armchair": "Poltrona",
43795
+ "type.pouf": "Pufe",
43497
43796
  "type.dining_chair": "Cadeira",
43797
+ "type.upholstered_chair": "Cadeira estofada",
43498
43798
  "type.bed_double": "Cama de casal",
43499
43799
  "type.bed_single": "Cama de solteiro",
43800
+ "type.box_bed": "Cama box",
43500
43801
  "type.bench": "Banco",
43501
43802
  "type.blinds": "Persiana",
43502
43803
  "type.curtain": "Cortina",
@@ -43649,6 +43950,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
43649
43950
  "prompt.breaker.off": "Ligar {circuit}",
43650
43951
  "prompt.breaker.off.verb": "Ligar",
43651
43952
  "prompt.breaker.off.object": "{circuit}",
43953
+ "prompt.main_breaker": "Disjuntor geral",
43954
+ "prompt.main_breaker.on": "Desligar o disjuntor geral",
43955
+ "prompt.main_breaker.on.verb": "Desligar",
43956
+ "prompt.main_breaker.on.object": "o disjuntor geral",
43957
+ "prompt.main_breaker.off": "Ligar o disjuntor geral",
43958
+ "prompt.main_breaker.off.verb": "Ligar",
43959
+ "prompt.main_breaker.off.object": "o disjuntor geral",
43652
43960
  "type.bunk_bed": "Beliche",
43653
43961
  "type.wood_stove": "Fog\xE3o a lenha",
43654
43962
  "type.fireplace": "Lareira",
@@ -44099,6 +44407,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
44099
44407
  pushable: true,
44100
44408
  massKg: 25
44101
44409
  },
44410
+ {
44411
+ id: "pouf",
44412
+ group: "seating",
44413
+ w: 0.45,
44414
+ d: 0.45,
44415
+ h: 0.42,
44416
+ y: 0,
44417
+ solid: true,
44418
+ pushable: true,
44419
+ massKg: 4
44420
+ },
44102
44421
  {
44103
44422
  id: "dining_chair",
44104
44423
  group: "seating",
@@ -44109,6 +44428,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
44109
44428
  solid: true,
44110
44429
  massKg: 5
44111
44430
  },
44431
+ {
44432
+ id: "upholstered_chair",
44433
+ group: "seating",
44434
+ w: 0.46,
44435
+ d: 0.52,
44436
+ h: 0.92,
44437
+ y: 0,
44438
+ solid: true,
44439
+ massKg: 6
44440
+ },
44112
44441
  {
44113
44442
  id: "bed_double",
44114
44443
  group: "seating",
@@ -44131,6 +44460,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
44131
44460
  pushable: true,
44132
44461
  massKg: 30
44133
44462
  },
44463
+ {
44464
+ id: "box_bed",
44465
+ group: "seating",
44466
+ w: 1.38,
44467
+ d: 1.88,
44468
+ h: 0.72,
44469
+ y: 0,
44470
+ solid: true,
44471
+ pushable: true,
44472
+ massKg: 75
44473
+ },
44134
44474
  {
44135
44475
  id: "bench",
44136
44476
  group: "seating",
@@ -44377,8 +44717,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
44377
44717
  "warn.buildEmpty": "construir devolveu vazio para {id}"
44378
44718
  };
44379
44719
  function createTranslator(locale, table) {
44380
- const base = locale && /^pt/i.test(locale) ? ptBR : en;
44381
- const messages = { ...base, ...table ?? {} };
44720
+ const base2 = locale && /^pt/i.test(locale) ? ptBR : en;
44721
+ const messages = { ...base2, ...table ?? {} };
44382
44722
  return (key2, params) => (messages[key2] ?? key2).replace(/\{(\w+)\}/g, (_m, name) => params && params[name] !== void 0 ? String(params[name]) : `{${name}}`);
44383
44723
  }
44384
44724
  var TYPE_MAP = Object.freeze({
@@ -44871,8 +45211,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
44871
45211
  var r3 = (n) => Math.round(n * 1e3) / 1e3;
44872
45212
  var CYLINDER_VALVE_Y = 0.47;
44873
45213
  var at = (it) => ({ x: it.x ?? 0, z: it.z ?? 0, ry: it.ry ?? 0 });
44874
- function mergeRegistry(base, extra) {
44875
- const out = { ...base };
45214
+ function mergeRegistry(base2, extra) {
45215
+ const out = { ...base2 };
44876
45216
  if (extra) {
44877
45217
  for (const [key2, value] of Object.entries(extra)) {
44878
45218
  if (value == null) delete out[key2];
@@ -46563,7 +46903,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
46563
46903
  rooms: (w, d, op) => {
46564
46904
  const hu0 = r22(w * 0.3), hu1 = r22(w * 0.7), n = floorCount(op, 3), el = !!op.elevator && n > 1;
46565
46905
  const ex = hu0 + (el ? 4.2 : 2.4);
46566
- const base = [
46906
+ const base2 = [
46567
46907
  { id: "sitting_room", type: "living", label: "sitting_room", rect: [0, 0, hu0, 7] },
46568
46908
  { id: "kitchen", type: "kitchen", label: "kitchen", rect: [0, 7, hu0, d - 3.2] },
46569
46909
  { id: "laundry", type: "laundry", label: "laundry", rect: [0, d - 3.2, hu0, d] },
@@ -46574,10 +46914,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
46574
46914
  { id: "bedroom", type: "bedroom", label: "suite", rect: [hu1, 8.2, w, d - 3.3], overrides: { bed: { size: [2.2, 2.35], cats: { bed: 2, bed_king: 3 } }, wardrobe: { cats: { wardrobe: 2, wardrobe_large: 3 }, size: [2.5, 0.75] } } },
46575
46915
  { id: "bathroom", type: "bathroom", label: "bathroom_suite", library: "bathroom_wc", rect: [hu1, d - 3.3, w, d] }
46576
46916
  ];
46577
- if (n > 1) base.push({ id: "stairs", type: "stairs", label: "stairs", rect: [hu0, d - 5, hu0 + 2.4, d], link: [0, 1] });
46578
- if (el) base.push({ id: "elevator", type: "elevator", label: "elevator", rect: [hu0 + 2.4, d - 5, hu0 + 4.2, d] });
46579
- base.push({ id: "office", type: "office", label: "office", rect: [n > 1 ? ex : hu0, d - 5, hu1, d] });
46580
- return base;
46917
+ if (n > 1) base2.push({ id: "stairs", type: "stairs", label: "stairs", rect: [hu0, d - 5, hu0 + 2.4, d], link: [0, 1] });
46918
+ if (el) base2.push({ id: "elevator", type: "elevator", label: "elevator", rect: [hu0 + 2.4, d - 5, hu0 + 4.2, d] });
46919
+ base2.push({ id: "office", type: "office", label: "office", rect: [n > 1 ? ex : hu0, d - 5, hu1, d] });
46920
+ return base2;
46581
46921
  },
46582
46922
  doors: (w, d, op) => {
46583
46923
  const hu0 = r22(w * 0.3), hu1 = r22(w * 0.7), n = floorCount(op, 3), el = !!op.elevator && n > 1;
@@ -46951,7 +47291,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
46951
47291
  }
46952
47292
  var residentialTower = residentialTowerTemplate();
46953
47293
 
46954
- // ../game-floorplan-three/dist/chunk-OGYLJ4F7.js
47294
+ // ../game-floorplan-three/dist/chunk-XI3CKQAV.js
46955
47295
  var __defProp3 = Object.defineProperty;
46956
47296
  var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp3(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
46957
47297
  var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
@@ -46964,6 +47304,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
46964
47304
  "what.door": "the door",
46965
47305
  "what.curtain": "the curtain",
46966
47306
  "what.mailbox": "the mailbox",
47307
+ "what.stallDoor": "the shower door",
46967
47308
  "what.pedestrianGate": "the small gate",
46968
47309
  "what.garageGate": "the garage gate",
46969
47310
  "what.drawer": "drawer",
@@ -46989,6 +47330,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
46989
47330
  "what.door": "a porta",
46990
47331
  "what.curtain": "a cortina",
46991
47332
  "what.mailbox": "a caixa de correio",
47333
+ "what.stallDoor": "a porta do box",
46992
47334
  "what.pedestrianGate": "o port\xE3ozinho",
46993
47335
  "what.garageGate": "o port\xE3o da garagem",
46994
47336
  "what.drawer": "gaveta",
@@ -47024,15 +47366,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
47024
47366
  for (let axis = 0; axis < 3; axis++) {
47025
47367
  const lo = axis, hi = axis + 3;
47026
47368
  if (b[lo] > box4[lo] + EPS3) {
47027
- const piece2 = [...box4];
47028
- piece2[hi] = b[lo];
47029
- out.push(piece2);
47369
+ const piece22 = [...box4];
47370
+ piece22[hi] = b[lo];
47371
+ out.push(piece22);
47030
47372
  box4[lo] = b[lo];
47031
47373
  }
47032
47374
  if (b[hi] < box4[hi] - EPS3) {
47033
- const piece2 = [...box4];
47034
- piece2[lo] = b[hi];
47035
- out.push(piece2);
47375
+ const piece22 = [...box4];
47376
+ piece22[lo] = b[hi];
47377
+ out.push(piece22);
47036
47378
  box4[hi] = b[hi];
47037
47379
  }
47038
47380
  }
@@ -47042,14 +47384,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
47042
47384
  const laid = [];
47043
47385
  for (const solid of solids) {
47044
47386
  let pieces = [solid.box];
47045
- for (const before of laid) pieces = pieces.flatMap((piece2) => subtractBox(piece2, before.box));
47387
+ for (const before of laid) pieces = pieces.flatMap((piece22) => subtractBox(piece22, before.box));
47046
47388
  for (const box4 of pieces) laid.push({ ...solid, box: box4 });
47047
47389
  }
47048
47390
  return laid;
47049
47391
  }
47050
47392
  function outsideBoxes(box4, taken) {
47051
47393
  let pieces = [box4];
47052
- for (const t of taken) pieces = pieces.flatMap((piece2) => subtractBox(piece2, t));
47394
+ for (const t of taken) pieces = pieces.flatMap((piece22) => subtractBox(piece22, t));
47053
47395
  return pieces;
47054
47396
  }
47055
47397
  function installKernelGeometry(K, shared2) {
@@ -47377,7 +47719,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
47377
47719
  nz = -nz;
47378
47720
  [a, b] = [pts[0], pts[1]];
47379
47721
  }
47380
- const [cr, cg, cb] = rgbOf(color2), scale = UV_SCALE[mat] || 1, base = A.nv;
47722
+ const [cr, cg, cb] = rgbOf(color2), scale = UV_SCALE[mat] || 1, base2 = A.nv;
47381
47723
  let e1x = b[0] - a[0], e1y = b[1] - a[1], e1z = b[2] - a[2];
47382
47724
  const l1 = Math.hypot(e1x, e1y, e1z) || 1;
47383
47725
  e1x /= l1;
@@ -47385,7 +47727,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
47385
47727
  e1z /= l1;
47386
47728
  const e2x = ny * e1z - nz * e1y, e2y = nz * e1x - nx * e1z, e2z = nx * e1y - ny * e1x;
47387
47729
  pts.forEach((p, k) => {
47388
- const o = base + k;
47730
+ const o = base2 + k;
47389
47731
  A.p[o * 3] = p[0] - O[0];
47390
47732
  A.p[o * 3 + 1] = p[1] - O[1];
47391
47733
  A.p[o * 3 + 2] = p[2] - O[2];
@@ -47400,9 +47742,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
47400
47742
  A.u[o * 2 + 1] = (dx * e2x + dy * e2y + dz * e2z) / scale;
47401
47743
  });
47402
47744
  for (let k = 1; k < n - 1; k++) {
47403
- A.i[A.ni++] = base;
47404
- A.i[A.ni++] = base + k;
47405
- A.i[A.ni++] = base + k + 1;
47745
+ A.i[A.ni++] = base2;
47746
+ A.i[A.ni++] = base2 + k;
47747
+ A.i[A.ni++] = base2 + k + 1;
47406
47748
  }
47407
47749
  A.nv += n;
47408
47750
  }
@@ -48761,8 +49103,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
48761
49103
  const puts = (f, type, m0, extra) => {
48762
49104
  const ent = T2[type];
48763
49105
  if (!ent) return;
48764
- const com = shared2.ctx.roomById[m0.room], g = "f" + f, base = Y0(f);
48765
- const M = Object.assign({ x: m0.x, z: m0.z, ry: m0.ry || 0, w: m0.w || 0.3, d: m0.d || 0.3, h: m0.h || 0.3, y: 0, base, floor: f, colors: shared2.ctx.colors, seed: m0.id, room: m0.room, typeWith: com ? com.type : null, ceiling: com ? com.ceiling : 2.8, on: shared2.ctx.night, light: shared2.ctx.night, lit: shared2.ctx.night }, extra || {});
49106
+ const com = shared2.ctx.roomById[m0.room], g = "f" + f, base2 = Y0(f);
49107
+ const M = Object.assign({ x: m0.x, z: m0.z, ry: m0.ry || 0, w: m0.w || 0.3, d: m0.d || 0.3, h: m0.h || 0.3, y: 0, base: base2, floor: f, colors: shared2.ctx.colors, seed: m0.id, room: m0.room, typeWith: com ? com.type : null, ceiling: com ? com.ceiling : 2.8, on: shared2.ctx.night, light: shared2.ctx.night, lit: shared2.ctx.night }, extra || {});
48766
49108
  cursor.group = g;
48767
49109
  lightItem({ id: m0.id, room: m0.room }, M, ent, api, g);
48768
49110
  };
@@ -49583,7 +49925,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
49583
49925
  }
49584
49926
  const AC = accFor(mat), m = L.length, [cr, cg, cb] = rgbOf(color2), O = cursor.org;
49585
49927
  AC.ensure(m * 2, (m - 1) * 6);
49586
- const base = AC.nv, w2 = 2 * Math.PI / P;
49928
+ const base2 = AC.nv, w2 = 2 * Math.PI / P;
49587
49929
  const profile = (sv) => {
49588
49930
  const ph = sv * w2, hh = A + A * Math.sin(ph), dh = A * w2 * Math.cos(ph), ql = Math.hypot(dh, 1);
49589
49931
  const per = Math.floor(sv / P), rr = _h2(per * 7 + 3, 11), fil = colonial ? 0.9 + 0.2 * (0.5 + 0.5 * Math.sin(ph + 1.5708)) : 0.95 + 0.1 * (0.5 + 0.5 * Math.sin(ph + 1.5708)), v = 1.5 * fil * (0.94 + 0.1 * rr);
@@ -49599,7 +49941,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
49599
49941
  const sv = L[j], [hh, qx, qy, qz, v] = at2(sv);
49600
49942
  const cj = col[j] || col[j - 1] || col[j + 1] || [0, 0];
49601
49943
  for (let k = 0; k < 2; k++) {
49602
- const t = cj[k], oo = base + j * 2 + k, px = o[0] + sv * ex + t * dx + nx * hh, py = o[1] + sv * ey + t * dy + ny * hh, pz = o[2] + sv * ez + t * dz + nz * hh;
49944
+ const t = cj[k], oo = base2 + j * 2 + k, px = o[0] + sv * ex + t * dx + nx * hh, py = o[1] + sv * ey + t * dy + ny * hh, pz = o[2] + sv * ez + t * dz + nz * hh;
49603
49945
  AC.p[oo * 3] = px - O[0];
49604
49946
  AC.p[oo * 3 + 1] = py - O[1];
49605
49947
  AC.p[oo * 3 + 2] = pz - O[2];
@@ -49615,7 +49957,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
49615
49957
  }
49616
49958
  for (let j = 0; j + 1 < m; j++) {
49617
49959
  if (!col[j] && !col[j + 1]) continue;
49618
- const a0 = base + j * 2, a1 = a0 + 1, b0 = a0 + 2, b1 = a0 + 3;
49960
+ const a0 = base2 + j * 2, a1 = a0 + 1, b0 = a0 + 2, b1 = a0 + 3;
49619
49961
  AC.i[AC.ni++] = a0;
49620
49962
  AC.i[AC.ni++] = b0;
49621
49963
  AC.i[AC.ni++] = a1;
@@ -50315,12 +50657,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50315
50657
  if (x1 - x0 < 1e-4 || y1 - y0 < 1e-4 || z1 - z0 < 1e-4) return;
50316
50658
  for (const [normal, corners] of FACES2) {
50317
50659
  if (openBottom && normal[1] < 0) continue;
50318
- const base = this.positions.length / 3;
50660
+ const base2 = this.positions.length / 3;
50319
50661
  for (const [cx, cy, cz] of corners) {
50320
50662
  this.positions.push(cx ? x1 : x0, cy ? y1 : y0, cz ? z1 : z0);
50321
50663
  this.normals.push(normal[0], normal[1], normal[2]);
50322
50664
  }
50323
- this.indices.push(base, base + 1, base + 2, base, base + 2, base + 3);
50665
+ this.indices.push(base2, base2 + 1, base2 + 2, base2, base2 + 2, base2 + 3);
50324
50666
  }
50325
50667
  }
50326
50668
  /**
@@ -50341,12 +50683,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50341
50683
  const out = [0, 1, 2].reduce((sum, k) => sum + n[k] * ((a[k] + b[k] + c[k] + d[k]) / 4 - centre[k]), 0);
50342
50684
  const ring2 = out >= 0 ? [a, b, c, d] : [a, d, c, b];
50343
50685
  if (out < 0) n = n.map((x) => -x);
50344
- const base = this.positions.length / 3;
50686
+ const base2 = this.positions.length / 3;
50345
50687
  for (const p of ring2) {
50346
50688
  this.positions.push(p[0], p[1], p[2]);
50347
50689
  this.normals.push(n[0], n[1], n[2]);
50348
50690
  }
50349
- this.indices.push(base, base + 1, base + 2, base, base + 2, base + 3);
50691
+ this.indices.push(base2, base2 + 1, base2 + 2, base2, base2 + 2, base2 + 3);
50350
50692
  }
50351
50693
  }
50352
50694
  /** A flat four-cornered face that looks along `normal` (it is wound so). */
@@ -50356,12 +50698,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50356
50698
  const e1 = [b[0] - a[0], b[1] - a[1], b[2] - a[2]], e2 = [d[0] - a[0], d[1] - a[1], d[2] - a[2]];
50357
50699
  const facing = (e1[1] * e2[2] - e1[2] * e2[1]) * normal[0] + (e1[2] * e2[0] - e1[0] * e2[2]) * normal[1] + (e1[0] * e2[1] - e1[1] * e2[0]) * normal[2];
50358
50700
  const ring2 = facing >= 0 ? corners : [corners[0], corners[3], corners[2], corners[1]];
50359
- const base = this.positions.length / 3;
50701
+ const base2 = this.positions.length / 3;
50360
50702
  for (const p of ring2) {
50361
50703
  this.positions.push(p[0], p[1], p[2]);
50362
50704
  this.normals.push(normal[0], normal[1], normal[2]);
50363
50705
  }
50364
- this.indices.push(base, base + 1, base + 2, base, base + 2, base + 3);
50706
+ this.indices.push(base2, base2 + 1, base2 + 2, base2, base2 + 2, base2 + 3);
50365
50707
  }
50366
50708
  /** The mesh of everything added, or null when nothing was. */
50367
50709
  mesh(THREE, material, name) {
@@ -50531,8 +50873,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50531
50873
  var DOOR_HEAD = 2.1;
50532
50874
  function crossesOpening(plan, a, b, y) {
50533
50875
  return plan.openings.some((o) => {
50534
- const base = plan.floors[o.floor]?.y0 ?? 0;
50535
- if (y <= base + (o.y0 ?? 0) || y >= base + (o.y1 ?? DOOR_HEAD)) return false;
50876
+ const base2 = plan.floors[o.floor]?.y0 ?? 0;
50877
+ if (y <= base2 + (o.y0 ?? 0) || y >= base2 + (o.y1 ?? DOOR_HEAD)) return false;
50536
50878
  const [p0, p1, q0, q1] = o.axis === "u" ? [a[1], b[1], a[0], b[0]] : [a[0], b[0], a[1], b[1]];
50537
50879
  const across2 = Math.min(p0, p1) <= o.pos + 0.1 && Math.max(p0, p1) >= o.pos - 0.1;
50538
50880
  return across2 && Math.max(Math.min(q0, q1), o.at - o.width / 2) < Math.min(Math.max(q0, q1), o.at + o.width / 2);
@@ -50752,10 +51094,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50752
51094
  const w = TRENCH.berm.width;
50753
51095
  const heapAt = ox ? [ox > 0 ? x1 + SPOIL_CLEAR : x0 - SPOIL_CLEAR - w, z0, ox > 0 ? x1 + SPOIL_CLEAR + w : x0 - SPOIL_CLEAR, z1] : [x0, oz > 0 ? z1 + SPOIL_CLEAR : z0 - SPOIL_CLEAR - w, x1, oz > 0 ? z1 + SPOIL_CLEAR + w : z0 - SPOIL_CLEAR];
50754
51096
  const onBuilding = [site.footprint, ...site.buildings].some(([bx0, bz0, bx1, bz1]) => heapAt[2] > bx0 - 0.4 && heapAt[0] < bx1 + 0.4 && heapAt[3] > bz0 - 0.4 && heapAt[1] < bz1 + 0.4);
50755
- if (!onBuilding) for (const piece2 of rectMinus(heapAt, [...rects.map((t) => [t[0] - SPOIL_CLEAR, t[1] - SPOIL_CLEAR, t[2] + SPOIL_CLEAR, t[3] + SPOIL_CLEAR]), ...laid])) {
50756
- if (Math.min(piece2[2] - piece2[0], piece2[3] - piece2[1]) < TRENCH.berm.crest * 2) continue;
50757
- addHumps(heap, piece2);
50758
- laid.push(piece2);
51097
+ if (!onBuilding) for (const piece22 of rectMinus(heapAt, [...rects.map((t) => [t[0] - SPOIL_CLEAR, t[1] - SPOIL_CLEAR, t[2] + SPOIL_CLEAR, t[3] + SPOIL_CLEAR]), ...laid])) {
51098
+ if (Math.min(piece22[2] - piece22[0], piece22[3] - piece22[1]) < TRENCH.berm.crest * 2) continue;
51099
+ addHumps(heap, piece22);
51100
+ laid.push(piece22);
50759
51101
  }
50760
51102
  }
50761
51103
  });
@@ -50900,7 +51242,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50900
51242
  function buriedSewerOf(plan) {
50901
51243
  const drains = drainsOf(plan);
50902
51244
  if (!drains.length) return [];
50903
- return sewerLayout(plan, drains).pieces.flatMap((piece2) => piece2.points.slice(1).map((b, i) => ({ a: piece2.points[i], b })));
51245
+ return sewerLayout(plan, drains).pieces.flatMap((piece22) => piece22.points.slice(1).map((b, i) => ({ a: piece22.points[i], b })));
50904
51246
  }
50905
51247
  var FEED = { width: 0.3, bed: 0.05, tape: { over: 0.3, width: 0.1, thickness: 2e-3 }, box: { side: 0.3, floor: 0.1 } };
50906
51248
  function feedLayout(plan) {
@@ -50960,10 +51302,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50960
51302
  const dug = [...layout.trenches, ...rainwater.trenches, ...feeds.trenches, ...boxes.map(pitOf)];
50961
51303
  addSpoil(THREE, group, dug, mats.heap, { solids, footprint: houseFootprint(routingPlanOf(plan)), buildings: (plan.outbuildings ?? []).map((o) => o.aabb) });
50962
51304
  group.userData.excavations = dug.map(excavationOf);
50963
- for (const piece2 of layout.pieces) addPipe(THREE, group, piece2.points, piece2.bore / 2, mats.pipe);
51305
+ for (const piece22 of layout.pieces) addPipe(THREE, group, piece22.points, piece22.bore / 2, mats.pipe);
50964
51306
  const rainGroup = new THREE.Group();
50965
51307
  rainGroup.name = "rain_drains";
50966
- for (const piece2 of rainwater.pieces) addPipe(THREE, rainGroup, piece2.points, piece2.bore / 2, mats.rain);
51308
+ for (const piece22 of rainwater.pieces) addPipe(THREE, rainGroup, piece22.points, piece22.bore / 2, mats.rain);
50967
51309
  group.add(rainGroup);
50968
51310
  addWarningTape(THREE, group, feeds.runs);
50969
51311
  const yard = new THREE.Group();
@@ -51256,11 +51598,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
51256
51598
  });
51257
51599
  }
51258
51600
  function stagedWallRuns(H) {
51259
- const r = shared2.ctx.r, nA = r.floors.length, plan = routingPlanOf(r), tank2 = r.waterTank, base = shared2.ctx.waterTankPos ? shared2.ctx.waterTankPos.y : tank2 ? tank2.y : atticFloor(plan);
51601
+ const r = shared2.ctx.r, nA = r.floors.length, plan = routingPlanOf(r), tank2 = r.waterTank, base2 = shared2.ctx.waterTankPos ? shared2.ctx.waterTankPos.y : tank2 ? tank2.y : atticFloor(plan);
51260
51602
  if (!tank2) return;
51261
51603
  const xyz = (p) => [p[0], p[1], p[2]];
51262
51604
  const out = [tank2.u, tank2.v - (tank2.d || 1.1) / 2 - 0.2], attic = atticFloor(plan) + ATTIC_LIFT.water;
51263
- const outlet = [[tank2.u, base + 0.08, tank2.v - (tank2.d || 1.1) / 2], [out[0], base + 0.08, out[1]], [out[0], attic, out[1]]];
51605
+ const outlet = [[tank2.u, base2 + 0.08, tank2.v - (tank2.d || 1.1) / 2], [out[0], base2 + 0.08, out[1]], [out[0], attic, out[1]]];
51264
51606
  cursor.group = shared2.ctx.waterTankPos && shared2.ctx.waterTankPos.group || "f0";
51265
51607
  cursor.pc = pieceRecord("pipe:run_outlet", "plastic", null, { tags: ["pipe"] });
51266
51608
  for (let i = 0; i + 1 < outlet.length; i++) pipe(outlet[i], outlet[i + 1], 0.032, PIPE_COLOR);
@@ -51415,8 +51757,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
51415
51757
  Object.assign(K, defined);
51416
51758
  }
51417
51759
  var EPS23 = 1e-4;
51418
- function subtractRects(base, holes) {
51419
- let pieces = [base];
51760
+ function subtractRects(base2, holes) {
51761
+ let pieces = [base2];
51420
51762
  for (const h of holes) {
51421
51763
  const next = [];
51422
51764
  for (const r of pieces) {
@@ -51557,8 +51899,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
51557
51899
  const depthOn = (side) => {
51558
51900
  const on = over.filter((c) => c.side === side);
51559
51901
  if (!on.length) return 0;
51560
- const least = Math.min(...on.map((c) => c.back)), back = Math.abs(least - mortar) < CHASE_CLEAR_OF_MORTAR ? mortar - CHASE_CLEAR_OF_MORTAR : least;
51561
- return t / 2 - (back - inset);
51902
+ const least = Math.min(...on.map((c) => c.back)), back2 = Math.abs(least - mortar) < CHASE_CLEAR_OF_MORTAR ? mortar - CHASE_CLEAR_OF_MORTAR : least;
51903
+ return t / 2 - (back2 - inset);
51562
51904
  };
51563
51905
  const low = depthOn(-1), high = depthOn(1);
51564
51906
  box4(batch, p0, q0, p1, q1, t - low - high, (low - high) / 2);
@@ -51698,8 +52040,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
51698
52040
  const along2 = wall.alongU ? r.u : r.v, across2 = (wall.alongU ? r.v : r.u) - core.line;
51699
52041
  if (along2 + r.radius + CHASE_CLEAR2 < wall.a0 || along2 - r.radius - CHASE_CLEAR2 > wall.a1 || r.y1 <= core.y0 || r.y0 >= core.y1) continue;
51700
52042
  if (Math.abs(across2) > wall.thickness / 2 + 1e-6) continue;
51701
- const back = Math.abs(across2) - (r.depth ?? r.radius) - CHASE_CLEAR2;
51702
- out.push({ a0: along2 - r.radius - CHASE_CLEAR2, a1: along2 + r.radius + CHASE_CLEAR2, y0: Math.max(core.y0, r.y0), y1: Math.min(core.y1, r.y1), side: across2 >= 0 ? 1 : -1, back, ...r.box ? { box: true } : {} });
52043
+ const back2 = Math.abs(across2) - (r.depth ?? r.radius) - CHASE_CLEAR2;
52044
+ out.push({ a0: along2 - r.radius - CHASE_CLEAR2, a1: along2 + r.radius + CHASE_CLEAR2, y0: Math.max(core.y0, r.y0), y1: Math.min(core.y1, r.y1), side: across2 >= 0 ? 1 : -1, back: back2, ...r.box ? { box: true } : {} });
51703
52045
  }
51704
52046
  return out;
51705
52047
  }
@@ -52055,8 +52397,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52055
52397
  const alongU = Math.abs(point.frontV) >= Math.abs(point.frontU);
52056
52398
  const intoRoom = Math.sign(alongU ? point.frontV : point.frontU);
52057
52399
  const face = wall.line + intoRoom * (wall.halfThickness - PLASTER_PER_FACE + WALL_BOX_PROUD);
52058
- const back = face - intoRoom * WALL_BOX.deep;
52059
- const [low, high] = face < back ? [face, back] : [back, face];
52400
+ const back2 = face - intoRoom * WALL_BOX.deep;
52401
+ const [low, high] = face < back2 ? [face, back2] : [back2, face];
52060
52402
  const half = WALL_BOX.along / 2;
52061
52403
  return {
52062
52404
  u0: alongU ? point.u - half : low,
@@ -52205,8 +52547,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52205
52547
  const M = en22.meter;
52206
52548
  if (M) {
52207
52549
  const hw = (M.w || 0.35) / 2, hd = (M.d || 0.2) / 2, hh = (M.h || 0.5) / 2, fr = M.side === "front" ? -1 : 1;
52208
- const back = shared2.ctx.visorScene ? 0 : 3e-3;
52209
- if (!(KV && KV.meter)) bx("plain", M.u - hw, M.y - hh, M.v - hd + (fr > 0 ? back : 0), M.u + hw, M.y + hh, M.v + hd - (fr < 0 ? back : 0), 14277597);
52550
+ const back2 = shared2.ctx.visorScene ? 0 : 3e-3;
52551
+ if (!(KV && KV.meter)) bx("plain", M.u - hw, M.y - hh, M.v - hd + (fr > 0 ? back2 : 0), M.u + hw, M.y + hh, M.v + hd - (fr < 0 ? back2 : 0), 14277597);
52210
52552
  const fz = fr < 0 ? [M.v - hd - 0.012, M.v - hd] : [M.v + hd, M.v + hd + 0.012];
52211
52553
  if (!(KV && KV.meter)) {
52212
52554
  bx("glass", M.u - hw * 0.6, M.y - hh * 0.2, fz[0], M.u + hw * 0.6, M.y + hh * 0.6, fz[1], 16777215);
@@ -52385,7 +52727,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52385
52727
  };
52386
52728
  for (const A of ws) for (const [side, sd] of [[A.w.sides[0], -1], [A.w.sides[1], 1]]) {
52387
52729
  if (!sideOf(side, false).exterior) continue;
52388
- const strip = (k, y1, y2, o0, o1, mat, c, piece2, laid = BASEBOARD_TILES) => {
52730
+ const strip = (k, y1, y2, o0, o1, mat, c, piece22, laid = BASEBOARD_TILES) => {
52389
52731
  const ea = junction(A, A.a, sd) > 0 ? A.th / 2 + k : junction(A, A.a, sd) < 0 ? -A.th / 2 : 0, eb = junction(A, A.b, sd) > 0 ? A.th / 2 + k : junction(A, A.b, sd) < 0 ? -A.th / 2 : 0;
52390
52732
  const s0 = A.a - ea, s1 = A.b + eb, f0 = A.L + sd * (A.th / 2 + o0), f1 = A.L + sd * (A.th / 2 + o1), lo = Math.min(f0, f1), hi = Math.max(f0, f1);
52391
52733
  if (s1 - s0 < 1e-3) return;
@@ -52409,7 +52751,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52409
52751
  runs.push([from, s1]);
52410
52752
  runs.forEach(([r0, r1], k2) => {
52411
52753
  if (r1 - r0 < 1e-3) return;
52412
- const id = piece2 && runs.length > 1 ? `${piece2}:${k2}` : piece2;
52754
+ const id = piece22 && runs.length > 1 ? `${piece22}:${k2}` : piece22;
52413
52755
  if (!id) box4(r0, r1);
52414
52756
  else if (shared2.ctx.baseboardBand) tile(id, r0, r1);
52415
52757
  else {
@@ -52497,12 +52839,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52497
52839
  const yA = roofHeightAt(p.u, p.v - hd), yB = roofHeightAt(p.u, p.v + hd), yC = roofHeightAt(p.u, p.v);
52498
52840
  let yc, tilt;
52499
52841
  if (onRack) {
52500
- const base = yC != null ? yC : Y0(fa) + 0.02, angle = (S.tilt || 15) * Math.PI / 180, high = Math.sin(angle) * p.length;
52842
+ const base2 = yC != null ? yC : Y0(fa) + 0.02, angle = (S.tilt || 15) * Math.PI / 180, high = Math.sin(angle) * p.length;
52501
52843
  tilt = sv * Math.atan2(high, d);
52502
- yc = base + 0.25 + high / 2;
52503
- const yLow = base + 0.25, yHigh = yLow + high;
52504
- for (const ex of [-0.8, 0.8]) for (const [vv, yTop] of [[p.v - sv * hd, yLow], [p.v + sv * hd, yHigh]]) bx("metal", p.u + ex * hw - 0.025, base, vv - 0.025, p.u + ex * hw + 0.025, yTop - 0.02, vv + 0.025, 8027780);
52505
- bx("metal", p.u - hw * 0.9, base + 0.01, p.v - sv * hd - 0.02, p.u + hw * 0.9, base + 0.05, p.v - sv * hd + 0.02, 8027780);
52844
+ yc = base2 + 0.25 + high / 2;
52845
+ const yLow = base2 + 0.25, yHigh = yLow + high;
52846
+ for (const ex of [-0.8, 0.8]) for (const [vv, yTop] of [[p.v - sv * hd, yLow], [p.v + sv * hd, yHigh]]) bx("metal", p.u + ex * hw - 0.025, base2, vv - 0.025, p.u + ex * hw + 0.025, yTop - 0.02, vv + 0.025, 8027780);
52847
+ bx("metal", p.u - hw * 0.9, base2 + 0.01, p.v - sv * hd - 0.02, p.u + hw * 0.9, base2 + 0.05, p.v - sv * hd + 0.02, 8027780);
52506
52848
  } else {
52507
52849
  if (yA == null || yB == null || yC == null) continue;
52508
52850
  tilt = Math.atan2(yA - yB, d);
@@ -52604,7 +52946,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52604
52946
  }
52605
52947
  function installFurnitureApi(K, shared2) {
52606
52948
  const { _e, _h2, _q, boxC, cursor, macroGround, polyFace, put } = K;
52607
- const MATERIAL_MAP2 = { plain: "plain", metal: "metal", wood: "wood", glass: "glass", fabric: "fabric", plant: "plant", water: "water", emissive: "emissive", "atlas_picture": "picture", "atlas_floor": "floor", plaster: "plain", matte: "glass", glass_light: "emissive", light: "emissive", ceramic_tile: "plain", parquet: "plain", ceramic: "plain" };
52949
+ const MATERIAL_MAP2 = { plain: "plain", metal: "metal", wood: "wood", glass: "glass", fabric: "fabric", foam: "fabric", plant: "plant", water: "water", emissive: "emissive", "atlas_picture": "picture", "atlas_floor": "floor", plaster: "plain", matte: "glass", glass_light: "emissive", light: "emissive", ceramic_tile: "plain", parquet: "plain", ceramic: "plain" };
52608
52950
  const mm = (k) => MATERIAL_MAP2[k] || "plain";
52609
52951
  const LIGHTS = [];
52610
52952
  function makeApi() {
@@ -53355,7 +53697,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53355
53697
  }
53356
53698
  function installFurnitureTaps(K, shared2) {
53357
53699
  shared2.tapCount = 0;
53358
- function counterTap(K2, x, y, z, reach2, back, meta = {}) {
53700
+ function counterTap(K2, x, y, z, reach2, back2, meta = {}) {
53359
53701
  const cr = 12896460, id = "tap_" + (K2.M.seed || "") + "_" + shared2.tapCount++;
53360
53702
  K2.c("metal", x, y, z, 0.028, 0.012, cr);
53361
53703
  K2.c("metal", x, y + 0.012, z, 0.014, 0.12, cr);
@@ -53382,11 +53724,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53382
53724
  );
53383
53725
  const ya = tip[1] - 0.05;
53384
53726
  K2.part("water_tap", tip[0], ya, tip[2], () => {
53385
- K2.t("water", [tip[0], ya, tip[2]], [tip[0], y - back, tip[2]], 6e-3, 13625588);
53727
+ K2.t("water", [tip[0], ya, tip[2]], [tip[0], y - back2, tip[2]], 6e-3, 13625588);
53386
53728
  }, { id: id + "_a", target: id, hidden: true, fluid: "water" });
53387
53729
  return id;
53388
53730
  }
53389
- function wallTap(K2, x, y, zw, direction, back, meta = {}) {
53731
+ function wallTap(K2, x, y, zw, direction, back2, meta = {}) {
53390
53732
  const cr = 12896460, id = "tap_" + (K2.M.seed || "") + "_" + shared2.tapCount++, s = direction || 1;
53391
53733
  K2.t("metal", [x, y, zw], [x, y, zw + s * 0.025], 0.03, cr);
53392
53734
  K2.t("metal", [x, y, zw + s * 0.02], [x, y, zw + s * 0.1], 0.016, cr);
@@ -53409,19 +53751,24 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53409
53751
  );
53410
53752
  const ya = y - 0.08;
53411
53753
  K2.part("water_tap", x, ya, zw + s * 0.105, () => {
53412
- K2.t("water", [x, ya, zw + s * 0.105], [x, back, zw + s * 0.105], 65e-4, 13625588);
53754
+ K2.t("water", [x, ya, zw + s * 0.105], [x, back2, zw + s * 0.105], 65e-4, 13625588);
53413
53755
  }, { id: id + "_a", target: id, hidden: true, fluid: "water" });
53414
53756
  return id;
53415
53757
  }
53416
53758
  const defined = { counterTap, wallTap };
53417
53759
  Object.assign(K, defined);
53418
53760
  }
53761
+ var SHOWER_DOOR = 0.72;
53762
+ var PANEL_THICKNESS = 0.02;
53763
+ var MIN_PANEL = 0.1;
53419
53764
  function installFurnitureFixtures(K, shared2) {
53765
+ const kernel = K;
53420
53766
  const seedKey = (id) => K.seedKey(id);
53421
53767
  const { FURNITURE, MIRRORS, SEED, arcPoints, cursor, kit2, rngString, sh } = K;
53422
53768
  FURNITURE.box = function(M, A) {
53423
53769
  const K2 = kit2(M, A, 0), w = M.w, d = M.d, cr = 13159632, id = "shower_" + (M.seed || ""), zw = -d / 2, X = w / 2 - 0;
53424
- const R = Math.min(0.32, w * 0.34, d * 0.34), gh = 1.95, gt = 8e-3;
53770
+ const walkIn = !shared2.ctx.visorScene;
53771
+ const R = walkIn ? Math.max(0.1, Math.min(0.32, w * 0.34, d * 0.34, w - 0.042 - SHOWER_DOOR)) : Math.min(0.32, w * 0.34, d * 0.34), gh = 1.95, gt = 8e-3;
53425
53772
  K2.b("plain", 0, 0, 0, w - 0.02, 0.05, d - 0.02, 15132902);
53426
53773
  K2.c("metal", 0, 0.05, 0, 0.045, 6e-3, 11580600);
53427
53774
  if (shared2.ctx.visorScene) K2.c("plain", 0, 0.05, 0, 0.032, 8e-3, 4212812);
@@ -53434,17 +53781,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53434
53781
  gl(px0, -d / 2 + 0.05, px0, pzF - R);
53435
53782
  const arc = arcPoints(px0 - R, pzF - R, R, 0, Math.PI / 2, 6);
53436
53783
  for (let i = 0; i < arc.length - 1; i++) gl(arc[i][0], arc[i][1], arc[i + 1][0], arc[i + 1][1]);
53437
- const fx1 = Math.max(-w / 2 + 0.36, px0 - R - 0.5);
53438
- gl(px0 - R, pzF, fx1, pzF);
53784
+ const front = walkIn ? Math.min(px0 - R, -w / 2 + 0.03 + SHOWER_DOOR) : Math.max(-w / 2 + 0.36, px0 - R - 0.5);
53785
+ const fx1 = walkIn && px0 - R - front < MIN_PANEL ? px0 - R : front, panel = px0 - R - fx1 > 0.01;
53786
+ if (panel) gl(px0 - R, pzF, fx1, pzF);
53439
53787
  const rail = (y, r) => {
53440
53788
  tube2([px0, y, -d / 2 + 0.05], [px0, y, pzF - R], r);
53441
53789
  for (let i = 0; i < arc.length - 1; i++) tube2([arc[i][0], y, arc[i][1]], [arc[i + 1][0], y, arc[i + 1][1]], r);
53442
- tube2([px0 - R, y, pzF], [fx1, y, pzF], r);
53790
+ if (panel) tube2([px0 - R, y, pzF], [fx1, y, pzF], r);
53443
53791
  };
53444
53792
  rail(gh, 0.011);
53445
53793
  rail(0.055, 9e-3);
53446
53794
  for (const [x, z] of [[px0, -d / 2 + 0.05], [fx1, pzF]]) tube2([x, 0.05, z], [x, gh + 5e-3, z], 0.011);
53447
- for (const [x, y, z] of [[px0, gh, -d / 2 + 0.05], [fx1, gh, pzF], [px0 - R, gh, pzF]]) K2.e("metal", x, y, z, 0.013, 0.026, cr);
53795
+ for (const [x, y, z] of [[px0, gh, -d / 2 + 0.05], [fx1, gh, pzF], ...panel ? [[px0 - R, gh, pzF]] : []]) K2.e("metal", x, y, z, 0.013, 0.026, cr);
53448
53796
  const hx = fx1, dw = hx - (-w / 2 + 0.03);
53449
53797
  if (dw > 0.2) K2.part(
53450
53798
  "shower_door",
@@ -53459,6 +53807,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53459
53807
  },
53460
53808
  { id: id + "_door", opens: { type: "swing", axis: [0, 1, 0], angle: -1.7 } }
53461
53809
  );
53810
+ if (walkIn) {
53811
+ const panels = [[px0, -d / 2 + 0.05, px0, pzF - R]];
53812
+ for (let i = 0; i < arc.length - 1; i++) panels.push([arc[i][0], arc[i][1], arc[i + 1][0], arc[i + 1][1]]);
53813
+ if (panel) panels.push([px0 - R, pzF, fx1, pzF]);
53814
+ kernel.walkInSolids(M, { panels, thickness: PANEL_THICKNESS, height: gh, door: dw > 0.2 ? { part: id + "_door", from: [hx, pzF], to: [hx - dw, pzF] } : null });
53815
+ }
53462
53816
  const ax = 0.1, ya = 2.08, z0 = zw + 0.012, Ra = 0.22, n = 6, pa = [];
53463
53817
  for (let i = 0; i <= n; i++) {
53464
53818
  const f = i / n * Math.PI / 2;
@@ -53669,12 +54023,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53669
54023
  var DOOR = { recess: 0.012, thick: 0.02, side: 4e-3, bottom: 0.03 };
53670
54024
  var LOUVRE = { proud: 3e-3, slat: 0.012, pitch: 0.025, count: 4 };
53671
54025
  function gasShelterBoxes({ side, height }) {
53672
- const half = side / 2, back = -half + SHELTER_OFF_WALL;
54026
+ const half = side / 2, back2 = -half + SHELTER_OFF_WALL;
53673
54027
  const boxes = [
53674
- { part: "wall", front: [back, back + WALL], across: [-half, half], y: [0, height] },
53675
- { part: "wall", front: [back + WALL, half], across: [-half, -half + WALL], y: [0, height] },
53676
- { part: "wall", front: [back + WALL, half], across: [half - WALL, half], y: [0, height] },
53677
- { part: "roof", front: [back, half + EAVE2], across: [-half - EAVE2, half + EAVE2], y: [height, height + ROOF] }
54028
+ { part: "wall", front: [back2, back2 + WALL], across: [-half, half], y: [0, height] },
54029
+ { part: "wall", front: [back2 + WALL, half], across: [-half, -half + WALL], y: [0, height] },
54030
+ { part: "wall", front: [back2 + WALL, half], across: [half - WALL, half], y: [0, height] },
54031
+ { part: "roof", front: [back2, half + EAVE2], across: [-half - EAVE2, half + EAVE2], y: [height, height + ROOF] }
53678
54032
  ];
53679
54033
  const doorFace = half - DOOR.recess, doorAcross = [-half + WALL + DOOR.side, half - WALL - DOOR.side];
53680
54034
  boxes.push({ part: "door", front: [doorFace - DOOR.thick, doorFace], across: doorAcross, y: [DOOR.bottom, height - DOOR.bottom] });
@@ -53825,10 +54179,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53825
54179
  if (shelterOf(M)) {
53826
54180
  } else if (M.hose && M.hose.length > 1) {
53827
54181
  const q = M.hose[M.hose.length - 1], dx = q[0] - M.x, dz = q[1] - M.z, lx = dx * c - dz * s, lz = dx * s + dz * c, y1 = Math.max(0.1, q[2] != null ? q[2] : 0.5) - (M.y || 0);
53828
- const P0 = [0.1, H * 0.9 + 0.045, 0], P2 = [lx, y1, lz], len = Math.hypot(lx - P0[0], lz - P0[2]), back = Math.min(0.28, 0.08 + len * 0.06), n = 8, pts = [];
54182
+ const P0 = [0.1, H * 0.9 + 0.045, 0], P2 = [lx, y1, lz], len = Math.hypot(lx - P0[0], lz - P0[2]), back2 = Math.min(0.28, 0.08 + len * 0.06), n = 8, pts = [];
53829
54183
  for (let k = 0; k <= n; k++) {
53830
54184
  const t = k / n, u = 1 - t;
53831
- pts.push([u * P0[0] + t * P2[0], Math.max(0.02, u * P0[1] + t * P2[1] - 4 * t * u * back * (1 + len * 0.05)), u * P0[2] + t * P2[2]]);
54185
+ pts.push([u * P0[0] + t * P2[0], Math.max(0.02, u * P0[1] + t * P2[1] - 4 * t * u * back2 * (1 + len * 0.05)), u * P0[2] + t * P2[2]]);
53832
54186
  }
53833
54187
  for (let k = 0; k < n; k++) K2.t("plain", pts[k], pts[k + 1], 0.011, 12071454);
53834
54188
  K2.c("metal", P2[0], P2[1] - 0.025, P2[2], 0.016, 0.05, brass);
@@ -54019,6 +54373,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54019
54373
  const { THREE, Y0, _col, boxC, colorOf, cursor, decorLights, makeApi, structurePiece, OPEN_AREA, rectsOf: rectsOf2 } = K;
54020
54374
  const buildItem2 = (...a) => K.buildItem(...a);
54021
54375
  const registerCollision = (...a) => K.registerCollision(...a);
54376
+ const kitCollides = (...a) => K.kitCollides(...a);
54022
54377
  const vegItem = (...a) => K.vegItem(...a);
54023
54378
  const SLAB_UNDERSIDE = 0.24;
54024
54379
  function houseItems() {
@@ -54042,8 +54397,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54042
54397
  if (exterior && m.category === "ground_cover" && shared2.ctx.noGroundSurfaces) continue;
54043
54398
  const f = exterior ? -1 : Math.min(m.floor, R.floors.length - 1);
54044
54399
  cursor.group = exterior && !(m.type === "cooking_gas_cylinder" && m.shelter && !shared2.ctx.visorScene) ? "lot" : "f" + Math.max(f, 0);
54045
- const com = m.room != null ? shared2.ctx.roomById[m.room] : void 0, lift = !exterior && f === 0 && shared2.ctx.constructionStages && !shared2.ctx.visorScene && !com?.outbuilding ? FLOOR_OVER_GROUND : 0, base = exterior ? 0 : Y0(f) + lift;
54046
- const M = { visorScene: shared2.ctx.visorScene, x: m.x, z: m.z, ry: m.ry || 0, w: m.w, d: m.d, h: m.h, y: m.y || 0, base, floor: exterior ? -1 : f, palette: shared2.ctx.colors, color: m.category === "ground_cover" ? void 0 : colorOf(m.color) ?? void 0, seed: m.id, room: m.room, typeWith: com ? com.type : null, ceiling: com ? com.ceiling : 2.9, on: shared2.ctx.night, light: shared2.ctx.night, lit: shared2.ctx.night, open: !!m.doorOpen, overhead: m.overhead, assembly: m.assembly, hose: m.hose, shelter: m.shelter, pipe: m.pipe };
54400
+ const com = m.room != null ? shared2.ctx.roomById[m.room] : void 0, lift = !exterior && f === 0 && shared2.ctx.constructionStages && !shared2.ctx.visorScene && !com?.outbuilding ? FLOOR_OVER_GROUND : 0, base2 = exterior ? 0 : Y0(f) + lift;
54401
+ const M = { visorScene: shared2.ctx.visorScene, x: m.x, z: m.z, ry: m.ry || 0, w: m.w, d: m.d, h: m.h, y: m.y || 0, base: base2, floor: exterior ? -1 : f, palette: shared2.ctx.colors, color: m.category === "ground_cover" ? void 0 : colorOf(m.color) ?? void 0, seed: m.id, room: m.room, typeWith: com ? com.type : null, ceiling: com ? com.ceiling : 2.9, on: shared2.ctx.night, light: shared2.ctx.night, lit: shared2.ctx.night, open: !!m.doorOpen, overhead: m.overhead, assembly: m.assembly, hose: m.hose, shelter: m.shelter, pipe: m.pipe };
54047
54402
  if (!exterior && !shared2.ctx.visorScene && f + 1 < R.floors.length && R.rooms.some((room) => room.floor === f + 1 && room.parts.some((r) => r[0] <= m.x && m.x <= r[2] && r[1] <= m.z && m.z <= r[3]))) M.ceiling = Math.min(M.ceiling ?? 2.9, Y0(f + 1) - SLAB_UNDERSIDE - Y0(f));
54048
54403
  if (lift) M.ceiling = (M.ceiling ?? 2.9) - lift;
54049
54404
  if (!exterior && !shared2.ctx.visorScene && f > 0) overRoof(m, M, f);
@@ -54086,13 +54441,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54086
54441
  }
54087
54442
  }
54088
54443
  if (shared2.ctx.iv && shared2.ctx.iv.replace.has(m.id)) {
54089
- registerCollision(m, M);
54444
+ if (!kitCollides(m)) registerCollision(m, M);
54090
54445
  continue;
54091
54446
  }
54092
54447
  const ent = T2[m.type];
54093
54448
  const st0 = cursor.stage;
54094
54449
  if (shared2.ctx.constructionStages && (m.type === "cooking_gas_cylinder" || m.type === "gas_cylinder" || m.type === "water_tank")) cursor.stage = "installations";
54095
- shared2.ctx.restOn = exterior || shared2.ctx.visorScene ? void 0 : base;
54450
+ shared2.ctx.restOn = exterior || shared2.ctx.visorScene ? void 0 : base2;
54096
54451
  if (!shared2.ctx.visorScene) {
54097
54452
  const quarter = Math.round(M.ry / (Math.PI / 2));
54098
54453
  if (Math.abs(M.ry - quarter * Math.PI / 2) < 0.01) M.ry = quarter * Math.PI / 2;
@@ -54209,7 +54564,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54209
54564
  return;
54210
54565
  }
54211
54566
  const lc = cd.place === "raised_slab" && cd.platform, slab = cd.place === "slab" || !!lc, nA = shared2.ctx.r.floors.length, f = Math.max(0, Math.min(nA - 1, cd.floor));
54212
- const base = lc ? cd.platform.topY : cd.y + (shared2.ctx.r.rooms.some((c) => c.id === cd.room && c.type === "terrace") ? 0 : 0.2 + (slab ? 0.03 : 0));
54567
+ const base2 = lc ? cd.platform.topY : cd.y + (shared2.ctx.r.rooms.some((c) => c.id === cd.room && c.type === "terrace") ? 0 : 0.2 + (slab ? 0.03 : 0));
54213
54568
  cursor.group = slab ? "f" + f : "attic_tank";
54214
54569
  const platformLift = !slab && !shared2.ctx.visorScene ? 0.12 : 0;
54215
54570
  if (lc) {
@@ -54228,12 +54583,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54228
54583
  }
54229
54584
  if (!slab) {
54230
54585
  const color2 = shared2.ctx.colors.slab != null ? shared2.ctx.colors.slab : 12170668, yp = Y0(f), hw = cd.w / 2 + 0.1, hd = cd.d / 2 + 0.1;
54231
- const top = base + platformLift;
54586
+ const top = base2 + platformLift;
54232
54587
  boxC("plain", cd.u, top - 0.06, cd.v, hw * 2, 0.12, hd * 2, color2);
54233
- for (const sx of [-1, 1]) for (const sz of [-1, 1]) boxC("plain", cd.u + sx * (hw - 0.07), (yp + base - 0.12) / 2, cd.v + sz * (hd - 0.07), 0.1, base - 0.12 - yp, 0.1, color2);
54588
+ for (const sx of [-1, 1]) for (const sz of [-1, 1]) boxC("plain", cd.u + sx * (hw - 0.07), (yp + base2 - 0.12) / 2, cd.v + sz * (hd - 0.07), 0.1, base2 - 0.12 - yp, 0.1, color2);
54234
54589
  }
54235
- const M = { x: cd.u, z: cd.v, ry: 0, w: cd.w, d: cd.d, h: cd.h + 0.12, y: 0, base: base + platformLift, floor: f, colors: shared2.ctx.colors, seed: "water_tank", room: cd.room, onSlab: true, ceiling: 2.9 };
54236
- shared2.ctx.waterTankPos = { x: cd.u, z: cd.v, y: base + platformLift, group: cursor.group };
54590
+ const M = { x: cd.u, z: cd.v, ry: 0, w: cd.w, d: cd.d, h: cd.h + 0.12, y: 0, base: base2 + platformLift, floor: f, colors: shared2.ctx.colors, seed: "water_tank", room: cd.room, onSlab: true, ceiling: 2.9 };
54591
+ shared2.ctx.waterTankPos = { x: cd.u, z: cd.v, y: base2 + platformLift, group: cursor.group };
54237
54592
  shared2.ctx.types.water_tank.f(M, api);
54238
54593
  }
54239
54594
  function trestleTank(api, cd) {
@@ -54634,8 +54989,29 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54634
54989
  const d1 = objectDistance(o, x, z);
54635
54990
  if (d1 < R && d1 < objectDistance(o, fx, fz) - 1e-6) return true;
54636
54991
  }
54992
+ return collideKit(x, z, fx, fz, floor, R);
54993
+ }
54994
+ function collideKit(x, z, fx, fz, floor, R) {
54995
+ const iv = shared2.ctx.iv, collided = iv && iv.collided;
54996
+ if (!iv || !collided || !collided.size) return false;
54997
+ for (const k of iv.world.colliders()) {
54998
+ const f = collided.get(k.object);
54999
+ if (f === void 0 || (f !== -1 ? f !== floor : floor !== 0)) continue;
55000
+ const o = { f, cx: k.cx, cz: k.cz, c: Math.cos(k.ry), s: Math.sin(k.ry), hw: k.hw, hd: k.hd, type: "kit" };
55001
+ const d1 = objectDistance(o, x, z);
55002
+ if (d1 < R && d1 < objectDistance(o, fx, fz) - 1e-6) return true;
55003
+ }
54637
55004
  return false;
54638
55005
  }
55006
+ function kitCollides(m) {
55007
+ const iv = shared2.ctx.iv;
55008
+ if (!iv) return false;
55009
+ const own = [...iv.entries.values()].filter((e) => e.origin === m.id && (e.spec.colliders?.length ?? 0) > 0);
55010
+ if (!own.length) return false;
55011
+ const collided = iv.collided || (iv.collided = /* @__PURE__ */ new Map());
55012
+ for (const e of own) collided.set(e.id, e.floor);
55013
+ return true;
55014
+ }
54639
55015
  function collideAt(x, z, floor, opt) {
54640
55016
  opt = opt || {};
54641
55017
  const R = opt.radius != null ? opt.radius : 0.24;
@@ -54649,7 +55025,24 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54649
55025
  const de = opt.from || [x + 1e4, z + 1e4];
54650
55026
  return collideObject(x, z, de[0], de[1], floor);
54651
55027
  }
54652
- const defined = { NO_COLLIDE, registerCollision, objectDistance, collideObject, collideAt };
55028
+ function walkInSolids(M, spec) {
55029
+ const objs = shared2.inter?.objs, colliders = shared2.ctx.colliders;
55030
+ if (!objs || !colliders) return;
55031
+ const at2 = objs.findIndex((o) => o.cx === M.x && o.cz === M.z && o.f === M.floor);
55032
+ const kept = at2 >= 0 ? objs.splice(at2, 1)[0] : void 0;
55033
+ const type = kept?.type ?? "walk_in";
55034
+ const half = spec.thickness / 2;
55035
+ for (const [x0, z0, x1, z1] of spec.panels) {
55036
+ const length = Math.hypot(x1 - x0, z1 - z0);
55037
+ if (length < 1e-3) continue;
55038
+ const [cx, cz] = K.localOf(M, (x0 + x1) / 2, (z0 + z1) / 2), turn = (M.ry || 0) + Math.atan2(-(z1 - z0), x1 - x0);
55039
+ objs.push({ f: M.floor, cx, cz, c: Math.cos(turn), s: Math.sin(turn), hw: length / 2, hd: half, h: spec.height, type });
55040
+ }
55041
+ if (!spec.door) return;
55042
+ const [ax, az] = K.localOf(M, spec.door.from[0], spec.door.from[1]), [bx, bz] = K.localOf(M, spec.door.to[0], spec.door.to[1]);
55043
+ colliders.push({ type: "walk_in_door", f: M.floor, x0: Math.min(ax, bx) - half, z0: Math.min(az, bz) - half, x1: Math.max(ax, bx) + half, z1: Math.max(az, bz) + half, piece: spec.door.part, anchor: [(ax + bx) / 2, (M.base || 0) + 1, (az + bz) / 2], off: false });
55044
+ }
55045
+ const defined = { NO_COLLIDE, registerCollision, objectDistance, collideObject, collideAt, walkInSolids, kitCollides };
54653
55046
  Object.assign(K, defined);
54654
55047
  }
54655
55048
  function installInteractionItems(K, shared2) {
@@ -54856,13 +55249,26 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54856
55249
  const g = r.g;
54857
55250
  if (!isFinite(r.x0)) return;
54858
55251
  const sd = (g.axis === "u" ? cz - g.v : cu - g.u) >= 0 ? 1 : -1, name = "ix:gate:" + g.id, ped = g.model === "pedestrian", tilt = g.model === "tilting";
54859
- const base = { parent: "lot", ry: 0, t0: g.open ? 1 : 0, col: cols[i], gate: g };
54860
- const p = ped ? definePiece(name, Object.assign(base, { kind: "gate_swing", pivot: [r.x0, 0, g.v], angle: -sd * 1.65 })) : tilt ? definePiece(name, Object.assign(base, { kind: "gate_tilting", pivot: [(r.x0 + r.x1) / 2, r.y1, g.v], angle: -sd * 1.45 })) : definePiece(name, Object.assign(base, { kind: "gate_sliding", pivot: [r.x0, 0, r.zm], travel: r.dx * g.width }));
55252
+ const base2 = { parent: "lot", ry: 0, t0: g.open ? 1 : 0, col: cols[i], gate: g };
55253
+ const p = ped ? definePiece(name, Object.assign(base2, { kind: "gate_swing", pivot: [r.x0, 0, g.v], angle: -sd * 1.65 })) : tilt ? definePiece(name, Object.assign(base2, { kind: "gate_tilting", pivot: [(r.x0 + r.x1) / 2, r.y1, g.v], angle: -sd * 1.45 })) : definePiece(name, Object.assign(base2, { kind: "gate_sliding", pivot: [r.x0, 0, r.zm], travel: r.dx * g.width }));
54861
55254
  if (p.col) p.col.off = p.target > 0.5;
54862
55255
  const text = () => t(p.target > 0.5 ? "prompt.close" : "prompt.open", { what: t(ped ? "what.pedestrianGate" : "what.garageGate") });
54863
55256
  I().items.push({ type: "gate", id: g.id, floor: -1, anchor: [g.u, 1, g.v + sd * 0.4], range: 2.8, angle: 0.9, pieces: [p], text, action: () => togglePiece(p), noWall: true });
54864
55257
  });
54865
55258
  }
55259
+ function walkInInteractive() {
55260
+ for (const c of shared2.ctx.colliders) {
55261
+ if (c.type !== "walk_in_door" || typeof c.piece !== "string") continue;
55262
+ const g = shared2.ctx.parts && shared2.ctx.parts[c.piece];
55263
+ if (!g) continue;
55264
+ const def = definePiece("ix:walkin:" + c.piece, { kind: "part", pivot: [0, 0, 0], ry: 0, parent: "lot" });
55265
+ def.inner = g;
55266
+ def.col = c;
55267
+ c.off = def.t > 0.5;
55268
+ I().items.push({ type: "walk_in_door", id: c.piece, floor: c.f, anchor: c.anchor, range: 1.6, angle: 1, pieces: [def], text: () => t(def.target > 0.5 ? "prompt.close" : "prompt.open", { what: t("what.stallDoor") }), action: () => togglePiece(def) });
55269
+ applyPiece(def);
55270
+ }
55271
+ }
54866
55272
  function mailboxInteractive() {
54867
55273
  for (const m of house().items) {
54868
55274
  if (m.type !== "mailbox") continue;
@@ -54920,15 +55326,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54920
55326
  else bx("plain", Math.min(f2, f3), yc - 0.032, u - 0.016, Math.max(f2, f3), yc + 0.032, u + 0.016, 16250092);
54921
55327
  cursor.group = g0;
54922
55328
  const pv = alongU ? [u, yc, f2] : [f2, yc, u];
54923
- const piece2 = definePiece("ix:int:" + roomId, { kind: "light_switch", pivot: pv, ry: 0, parent: "f" + f, axis: alongU ? "x" : "z", sgn: alongU ? sd : -sd, t0: lightOn(roomId) ? 1 : 0 });
54924
- piece2.t = piece2.target = lightOn(roomId) ? 1 : 0;
55329
+ const piece22 = definePiece("ix:int:" + roomId, { kind: "light_switch", pivot: pv, ry: 0, parent: "f" + f, axis: alongU ? "x" : "z", sgn: alongU ? sd : -sd, t0: lightOn(roomId) ? 1 : 0 });
55330
+ piece22.t = piece22.target = lightOn(roomId) ? 1 : 0;
54925
55331
  const an = alongU ? [u, yc, face + sd * 0.12] : [face + sd * 0.12, yc, u];
54926
- I().items.push({ type: "light_switch", id: roomId, floor: f, anchor: an, range: 1.5, angle: 0.45, pieces: [piece2], text: () => t(lightOn(roomId) ? "prompt.lightOff" : "prompt.lightOn"), action: () => toggleLight(roomId) });
55332
+ I().items.push({ type: "light_switch", id: roomId, floor: f, anchor: an, range: 1.5, angle: 0.45, pieces: [piece22], text: () => t(lightOn(roomId) ? "prompt.lightOff" : "prompt.lightOn"), action: () => toggleLight(roomId) });
54927
55333
  return true;
54928
55334
  }
54929
55335
  return false;
54930
55336
  }
54931
- const defined = { gatesInteractive, mailboxInteractive, placeSwitches, putSwitch };
55337
+ const defined = { walkInInteractive, gatesInteractive, mailboxInteractive, placeSwitches, putSwitch };
54932
55338
  Object.assign(K, defined);
54933
55339
  }
54934
55340
  function installInteractionDoors(K, shared2) {
@@ -55091,7 +55497,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55091
55497
  const { t, THREE, invalidate, invalidateShadow, cfg, DOC, LIGHT_TYPES, _Y, _q, _v3, accFor, applyLight, cursor, hashString: hashString2, hudMessage, lightBase, pieceRecord, rgbOf, wallBlocks } = K;
55092
55498
  const enter = (...a) => K.enter(...a);
55093
55499
  const roomLightMask = (...a) => K.roomLightMask(...a);
55094
- const IV_MATERIAL = { plain: "plain", metal: "metal", wood: "wood", glass: "glass", fabric: "fabric", plant: "plant", water: "water", emissive: "emissive", atlas_picture: "picture", atlas_floor: "floor" };
55500
+ const IV_MATERIAL = { plain: "plain", metal: "metal", wood: "wood", glass: "glass", fabric: "fabric", foam: "fabric", plant: "plant", water: "water", emissive: "emissive", atlas_picture: "picture", atlas_floor: "floor" };
55095
55501
  const IV_WIRE = { conduit: 13618628, cable: 2762532, drop: 1381653, cord: 1776413, earth: 3111482, hose: 11556124 };
55096
55502
  const IV_DOOR = /^(door|drawer)/;
55097
55503
  const ivGroup = (e) => e.floor < 0 ? "lot" : "f" + Math.min(e.floor, shared2.ctx.r.floors.length - 1);
@@ -55161,7 +55567,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55161
55567
  const entById = new Map(plane2.items.map((e) => [e.id, e]));
55162
55568
  const entByItem = new Map(plane2.items.map((e) => [e.item, e]));
55163
55569
  const mats = shared2.mats;
55164
- IV.mats = { plain: mats.plain, metal: shared2.mats.metal, wood: shared2.mats.wood, glass: shared2.mats.glass, fabric: shared2.mats.fabric, plant: shared2.mats.plant, water: shared2.mats.water, emissive: shared2.mats.emissive, atlas_picture: shared2.mats.picture, atlas_floor: shared2.mats.floor };
55570
+ IV.mats = { plain: mats.plain, metal: shared2.mats.metal, wood: shared2.mats.wood, glass: shared2.mats.glass, fabric: shared2.mats.fabric, foam: shared2.mats.fabric, plant: shared2.mats.plant, water: shared2.mats.water, emissive: shared2.mats.emissive, atlas_picture: shared2.mats.picture, atlas_floor: shared2.mats.floor };
55165
55571
  const ev = (e) => ivEvent(h, e);
55166
55572
  const world = IV.world = A.createWorld(source, { water, seed: r.seed, onEvent: ev });
55167
55573
  const add0 = world.add;
@@ -55272,7 +55678,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55272
55678
  cursor.stage = stage0;
55273
55679
  cursor.pc = pieceBefore;
55274
55680
  }
55275
- const base = new Set(Object.values(IV.mats));
55681
+ const base2 = new Set(Object.values(IV.mats));
55276
55682
  root.traverse((o) => {
55277
55683
  if (!isMesh(o)) return;
55278
55684
  o.userData.iv = ent.id;
@@ -55280,7 +55686,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55280
55686
  if (!o.geometry.boundingSphere) o.geometry.computeBoundingSphere();
55281
55687
  if (o.geometry.boundingSphere.radius < 0.07) o.castShadow = false;
55282
55688
  }
55283
- for (const m of Array.isArray(o.material) ? o.material : [o.material]) if (m && !base.has(m) && m.userData && m.userData.roomLightMask && m.onBeforeCompile === THREE.Material.prototype.onBeforeCompile) {
55689
+ for (const m of Array.isArray(o.material) ? o.material : [o.material]) if (m && !base2.has(m) && m.userData && m.userData.roomLightMask && m.onBeforeCompile === THREE.Material.prototype.onBeforeCompile) {
55284
55690
  m.userData.roomLightMask = false;
55285
55691
  roomLightMask(m);
55286
55692
  }
@@ -55582,6 +55988,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55582
55988
  roomStates: IV.roomStates,
55583
55989
  warnings: IV.warnings,
55584
55990
  water: IV.water,
55991
+ solidColliders: () => {
55992
+ const c = IV.collided;
55993
+ return c && c.size ? w.colliders().flatMap((k) => {
55994
+ const floor = c.get(k.object);
55995
+ return floor === void 0 ? [] : [{ ...k, floor }];
55996
+ }) : [];
55997
+ },
55585
55998
  screens: IV.screens,
55586
55999
  effects: () => IV.efx || null,
55587
56000
  // TV screens (id -> kit screen) and the particle system (smoke), for whoever wants to inspect
@@ -56203,8 +56616,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56203
56616
  return { depth: Math.max(drawn, declared2?.depth ?? 0), width: declared2?.width ?? Math.max(u1 - u0, v1 - v0) };
56204
56617
  }
56205
56618
  function groundJointStrength(part, kind) {
56206
- const base = buriedBase(part);
56207
- return base.depth > 0 ? embedmentStrength(kind, base) : void 0;
56619
+ const base2 = buriedBase(part);
56620
+ return base2.depth > 0 ? embedmentStrength(kind, base2) : void 0;
56208
56621
  }
56209
56622
  var NONE = { panels: [], replaced: [], supports: [] };
56210
56623
  var MEMO = /* @__PURE__ */ new WeakMap();
@@ -56316,7 +56729,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56316
56729
  parts2.push(p);
56317
56730
  byId.set(p.id, p);
56318
56731
  }
56319
- const base = parts2.length, view = shared2.ctx.panelView || panelViewOf(null, false), panelIds = new Set(view.panels.map((e) => e.id));
56732
+ const base2 = parts2.length, view = shared2.ctx.panelView || panelViewOf(null, false), panelIds = new Set(view.panels.map((e) => e.id));
56320
56733
  for (const [id, pc] of shared2.ctx.pieces) {
56321
56734
  if (byId.has(id) || panelIds.has(id) || !meshes.has(id)) continue;
56322
56735
  const b = box32(id);
@@ -56346,7 +56759,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56346
56759
  const floorUnder = (p) => {
56347
56760
  const cx = (p.aabb[0] + p.aabb[2]) / 2, cz = (p.aabb[1] + p.aabb[3]) / 2;
56348
56761
  let best = null;
56349
- for (const q of parts2.slice(0, base)) {
56762
+ for (const q of parts2.slice(0, base2)) {
56350
56763
  if (!isFloor(q, p.y0) || cx < q.aabb[0] - HOLD_TOUCH || cx > q.aabb[2] + HOLD_TOUCH || cz < q.aabb[1] - HOLD_TOUCH || cz > q.aabb[3] + HOLD_TOUCH) continue;
56351
56764
  if (!best || q.y1 > best.y1 || q.y1 === best.y1 && q.id < best.id) best = q;
56352
56765
  }
@@ -56379,7 +56792,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56379
56792
  return { part: p.id, on: "ground", joint, bears: false, extra: true, ...strength !== void 0 ? { strength } : {} };
56380
56793
  };
56381
56794
  const unheld = [];
56382
- for (const p of parts2.slice(base)) {
56795
+ for (const p of parts2.slice(base2)) {
56383
56796
  if (/^sidewalk:/.test(p.id)) {
56384
56797
  supports.push({ part: p.id, on: "ground", joint: "mortar", extra: true });
56385
56798
  continue;
@@ -56407,7 +56820,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56407
56820
  if (!/^(window|window_pane|door|jamb|pipe|water_tank|baseboard)/.test(p.id)) continue;
56408
56821
  const target = /^water_tank/.test(p.id) ? ["slab"] : ["wall", "partition"];
56409
56822
  let m = null, md = 1e9;
56410
- for (const q of parts2.slice(0, base)) {
56823
+ for (const q of parts2.slice(0, base2)) {
56411
56824
  if (!target.includes(q.role) || !inside22(p, q, 0.2)) continue;
56412
56825
  const d = Math.hypot((p.aabb[0] + p.aabb[2] - q.aabb[0] - q.aabb[2]) / 2, (p.aabb[1] + p.aabb[3] - q.aabb[1] - q.aabb[3]) / 2);
56413
56826
  if (d < md) {
@@ -56415,7 +56828,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56415
56828
  m = q;
56416
56829
  }
56417
56830
  }
56418
- if (!m && /^(window|door|jamb)/.test(p.id)) for (const q of parts2.slice(0, base)) {
56831
+ if (!m && /^(window|door|jamb)/.test(p.id)) for (const q of parts2.slice(0, base2)) {
56419
56832
  if (!["wall", "partition", "column", "beam"].includes(q.role) || !touches2(p, q, 0.02)) continue;
56420
56833
  const d = Math.hypot((p.aabb[0] + p.aabb[2] - q.aabb[0] - q.aabb[2]) / 2, (p.y0 + p.y1 - q.y0 - q.y1) / 2, (p.aabb[1] + p.aabb[3] - q.aabb[1] - q.aabb[3]) / 2);
56421
56834
  if (d < md) {
@@ -56553,6 +56966,119 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56553
56966
  if (distance2 <= -depth) return true;
56554
56967
  return distance2 <= -depth * noise3();
56555
56968
  }
56969
+ var JOINT_SHARE = 0.5;
56970
+ var EPSILON22 = 1e-4;
56971
+ function carve(boxes, grid) {
56972
+ const { data, w, h, len, y0, height } = grid;
56973
+ const out = [];
56974
+ for (const box4 of boxes) {
56975
+ const j0 = Math.max(0, Math.floor((box4.y0 - y0) / height * h)), j1 = Math.min(h - 1, Math.ceil((box4.y1 - y0) / height * h) - 1);
56976
+ const i0 = Math.max(0, Math.floor(box4.a / len * w)), i1 = Math.min(w - 1, Math.ceil(box4.b / len * w) - 1);
56977
+ if (j1 < j0 || i1 < i0) {
56978
+ out.push(box4);
56979
+ continue;
56980
+ }
56981
+ for (let j = j0; j <= j1; j++) {
56982
+ const ry0 = Math.max(box4.y0, y0 + j / h * height), ry1 = Math.min(box4.y1, y0 + (j + 1) / h * height);
56983
+ let start = -1;
56984
+ for (let i = i0; i <= i1 + 1; i++) {
56985
+ const solid = i <= i1 && data[j * w + i] <= 127;
56986
+ if (solid && start < 0) start = i;
56987
+ if (!solid && start >= 0) {
56988
+ out.push({ a: Math.max(box4.a, start / w * len), b: Math.min(box4.b, i / w * len), y0: ry0, y1: ry1 });
56989
+ start = -1;
56990
+ }
56991
+ }
56992
+ }
56993
+ }
56994
+ return out;
56995
+ }
56996
+ var groupBy = (items, keyOf) => {
56997
+ const groups = /* @__PURE__ */ new Map();
56998
+ for (const item of items) {
56999
+ const key2 = keyOf(item);
57000
+ const group = groups.get(key2);
57001
+ if (group) group.push(item);
57002
+ else groups.set(key2, [item]);
57003
+ }
57004
+ return [...groups.values()];
57005
+ };
57006
+ function mergeSpans(spans, share = JOINT_SHARE) {
57007
+ const runs = [];
57008
+ const unitLengths = /* @__PURE__ */ new Map();
57009
+ for (const row of groupBy(spans, (s) => `${s.y0.toFixed(4)}:${s.y1.toFixed(4)}`)) {
57010
+ row.sort((p, q) => p.a - q.a);
57011
+ let run = { ...row[0] };
57012
+ let unitLength = run.b - run.a;
57013
+ for (const s of row.slice(1)) {
57014
+ if (s.a - run.b <= share * Math.min(s.b - s.a, unitLength) + EPSILON22) run.b = Math.max(run.b, s.b);
57015
+ else {
57016
+ runs.push(run);
57017
+ unitLengths.set(run, unitLength);
57018
+ run = { ...s };
57019
+ }
57020
+ unitLength = s.b - s.a;
57021
+ }
57022
+ runs.push(run);
57023
+ unitLengths.set(run, unitLength);
57024
+ }
57025
+ const out = [];
57026
+ const open = [];
57027
+ for (const r of [...runs].sort((p, q) => p.y0 - q.y0 || p.a - q.a)) {
57028
+ const height = r.y1 - r.y0;
57029
+ const top = open.find((o) => {
57030
+ const slack = share * Math.min(o.unitLength, r.b - r.a) + EPSILON22;
57031
+ return r.y0 - o.box.y1 >= -EPSILON22 && r.y0 - o.box.y1 <= share * Math.min(o.unitHeight, height) + EPSILON22 && Math.abs(r.a - o.box.a) <= slack && Math.abs(r.b - o.box.b) <= slack;
57032
+ });
57033
+ if (top) {
57034
+ top.box.y1 = r.y1;
57035
+ top.box.a = Math.min(top.box.a, r.a);
57036
+ top.box.b = Math.max(top.box.b, r.b);
57037
+ top.unitHeight = height;
57038
+ } else {
57039
+ const box4 = { ...r };
57040
+ out.push(box4);
57041
+ open.push({ box: box4, unitHeight: height, unitLength: unitLengths.get(r) ?? r.b - r.a });
57042
+ }
57043
+ }
57044
+ return out;
57045
+ }
57046
+ function standingSolids(THREE, house, mesh2, line, parts2) {
57047
+ house.updateWorldMatrix(true, false);
57048
+ mesh2.updateWorldMatrix(true, false);
57049
+ const toMesh = new THREE.Matrix4().copy(mesh2.matrixWorld).invert().multiply(house.matrixWorld);
57050
+ const turn = new THREE.Quaternion();
57051
+ const scale = new THREE.Vector3();
57052
+ toMesh.decompose(new THREE.Vector3(), turn, scale);
57053
+ const point = new THREE.Vector3();
57054
+ const out = [];
57055
+ for (const part of parts2) {
57056
+ const boxes = mergeSpans(part.spans);
57057
+ for (const s of line.open ? mergeSpans(carve(boxes, line.open), 0) : boxes) {
57058
+ const along2 = line.start + (s.a + s.b) / 2;
57059
+ point.set(line.alongU ? along2 : part.mid, (s.y0 + s.y1) / 2, line.alongU ? part.mid : along2).applyMatrix4(toMesh);
57060
+ const length = (s.b - s.a) / 2, up = (s.y1 - s.y0) / 2, across2 = part.thick / 2;
57061
+ out.push({
57062
+ center: [point.x, point.y, point.z],
57063
+ half: [(line.alongU ? length : across2) * scale.x, up * scale.y, (line.alongU ? across2 : length) * scale.z],
57064
+ rotation: [turn.x, turn.y, turn.z, turn.w],
57065
+ kind: "box"
57066
+ });
57067
+ }
57068
+ }
57069
+ return out;
57070
+ }
57071
+ function publishSolids(mesh2, v0, v1, solids) {
57072
+ const u = mesh2.userData;
57073
+ u.drawnSolids = [...(u.drawnSolids ?? []).filter((entry2) => entry2.v0 !== v0), { v0, v1, solids }];
57074
+ u.drawnSolidsVersion = (u.drawnSolidsVersion ?? 0) + 1;
57075
+ }
57076
+ function withdrawSolids(mesh2, v0) {
57077
+ const u = mesh2.userData;
57078
+ if (!u.drawnSolids?.some((entry2) => entry2.v0 === v0)) return;
57079
+ u.drawnSolids = u.drawnSolids.filter((entry2) => entry2.v0 !== v0);
57080
+ u.drawnSolidsVersion = (u.drawnSolidsVersion ?? 0) + 1;
57081
+ }
56556
57082
  function collapseRange(mesh2, v0, v1) {
56557
57083
  const pos = mesh2.geometry.attributes.position;
56558
57084
  const a = pos.array;
@@ -56577,6 +57103,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56577
57103
  markPositionsWritten(mesh2, v0, v0 + saved.length / 3);
56578
57104
  const list2 = mesh2.userData.collapsedRanges;
56579
57105
  if (list2) mesh2.userData.collapsedRanges = list2.filter((r) => r[0] !== v0);
57106
+ withdrawSolids(mesh2, v0);
56580
57107
  }
56581
57108
  function noise2(x, y, cell) {
56582
57109
  const h = (i2, j2) => {
@@ -56900,11 +57427,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56900
57427
  }
56901
57428
  g.computeBoundingBox();
56902
57429
  g.computeBoundingSphere();
56903
- const base = it.mesh.material;
56904
- const material = base.clone();
57430
+ const base2 = it.mesh.material;
57431
+ const material = base2.clone();
56905
57432
  const toHouse = { value: new THREE.Matrix4() };
56906
57433
  material.onBeforeCompile = (sh) => {
56907
- base.onBeforeCompile?.(sh);
57434
+ base2.onBeforeCompile?.(sh);
56908
57435
  sh.uniforms.uToHouse = toHouse;
56909
57436
  sh.uniforms.uMask = { value: mask.texture };
56910
57437
  sh.uniforms.uMaskRect = { value: mask.rect };
@@ -56912,7 +57439,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56912
57439
  sh.vertexShader = sh.vertexShader.replace("void main() {", "uniform mat4 uToHouse;\nvarying vec3 vHousePos;\nvoid main() {").replace("#include <begin_vertex>", "#include <begin_vertex>\nvHousePos = (uToHouse * vec4(transformed, 1.0)).xyz;");
56913
57440
  sh.fragmentShader = sh.fragmentShader.replace("void main() {", "uniform sampler2D uMask;\nuniform vec4 uMaskRect;\nuniform float uMaskAlongX;\nvarying vec3 vHousePos;\nvoid main() {\n vec2 mUv = vec2(((uMaskAlongX > 0.5 ? vHousePos.x : vHousePos.z) - uMaskRect.x) / uMaskRect.z, (vHousePos.y - uMaskRect.y) / uMaskRect.w);\n if (mUv.x >= 0.0 && mUv.x <= 1.0 && mUv.y >= 0.0 && mUv.y <= 1.0 && texture2D(uMask, mUv).r > 0.5) discard;");
56914
57441
  };
56915
- material.customProgramCacheKey = () => "breachMask" + (base.customProgramCacheKey?.() ?? "");
57442
+ material.customProgramCacheKey = () => "breachMask" + (base2.customProgramCacheKey?.() ?? "");
56916
57443
  const mesh2 = new THREE.Mesh(g, material);
56917
57444
  mesh2.name = "breach-shell";
56918
57445
  mesh2.userData.breachMask = mask;
@@ -57027,6 +57554,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57027
57554
  const around = { pillars: pillarSpans(view), gaps: windowGaps(view) };
57028
57555
  for (const id of view.parts) view.kept.set(id, splitUnits(view, id, around).kept);
57029
57556
  view.keptStale = false;
57557
+ publishStanding(view);
57558
+ }
57559
+ function publishStanding(view) {
57560
+ if (!view.saved) return;
57561
+ const { mask } = view;
57562
+ const parts2 = view.parts.map((id) => {
57563
+ const part = structure.byId.get(id);
57564
+ const thick = mask.alongU ? part.aabb[3] - part.aabb[1] : part.aabb[2] - part.aabb[0];
57565
+ const mid = mask.alongU ? (part.aabb[1] + part.aabb[3]) / 2 : (part.aabb[0] + part.aabb[2]) / 2;
57566
+ return { spans: view.kept.get(id) ?? [], thick, mid };
57567
+ });
57568
+ const line = { alongU: mask.alongU, start: mask.start, open: view.core };
57569
+ view.items.forEach((it, k) => publishSolids(it.mesh, it.v0, it.v1, k === 0 ? standingSolids(THREE, house, it.mesh, line, parts2) : []));
57030
57570
  }
57031
57571
  function paint(view) {
57032
57572
  const { mask, core } = view;
@@ -57101,13 +57641,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57101
57641
  const unit = clipToBox({ x: mask.alongU ? centre : mid, y, z: mask.alongU ? mid : centre, sx: mask.alongU ? s : d, sy: dy, sz: mask.alongU ? d : s, colour }, inner);
57102
57642
  if (unit && !discs.some((k) => Math.hypot((mask.alongU ? unit.x : unit.z) - mask.start - k.s, unit.y - k.y) < k.r)) list2.push(unit);
57103
57643
  };
57104
- const base = fragmentMaterial(part.material).color.getHex();
57644
+ const base2 = fragmentMaterial(part.material).color.getHex();
57105
57645
  const n = noise2(centre * 3.1, y * 2.7, 0.07);
57106
57646
  if (units2.mortar === "concrete") {
57107
- at2(len, h, thick - 2 * COVER2, tone(base, 0.9 + 0.04 * n));
57647
+ at2(len, h, thick - 2 * COVER2, tone(base2, 0.9 + 0.04 * n));
57108
57648
  } else {
57109
57649
  at2(len, h, thick - 2 * COVER2 - 0.012, 10327948);
57110
- at2(len - 0.012, h - 0.012, thick - 2 * COVER2, tone(base, 0.8 + 0.35 * n));
57650
+ at2(len - 0.012, h - 0.012, thick - 2 * COVER2, tone(base2, 0.8 + 0.35 * n));
57111
57651
  }
57112
57652
  }
57113
57653
  const lumps = stuckLumps(castGone, mask, view.bounds);
@@ -57131,6 +57671,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57131
57671
  view.gone = holes.length;
57132
57672
  view.pits = pits.length;
57133
57673
  view.flakes = flakes.length;
57674
+ publishStanding(view);
57134
57675
  }
57135
57676
  function chipBox(chip, alongU) {
57136
57677
  house.updateWorldMatrix(true, false);
@@ -57242,6 +57783,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57242
57783
  view.shells = view.items.map((it) => shell(it, view.mask));
57243
57784
  for (const m of view.shells) m.userData.behind = () => view.units;
57244
57785
  view.saved = view.items.map((it) => ({ it, v0: it.v0, data: collapseRange(it.mesh, it.v0, it.v1) }));
57786
+ refreshKept(view);
57245
57787
  }
57246
57788
  function draw(partId, change) {
57247
57789
  if (lod !== 0) return false;
@@ -57292,6 +57834,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57292
57834
  if (shown2) restoreRange(s.it.mesh, s.v0, s.data);
57293
57835
  else s.data = collapseRange(s.it.mesh, s.v0, s.it.v1);
57294
57836
  }
57837
+ if (!shown2) publishStanding(view);
57295
57838
  }
57296
57839
  function flush(budgetMs) {
57297
57840
  if (budgetMs !== void 0 || !cutState.attached) paintCut();
@@ -58258,9 +58801,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58258
58801
  walk(house, void 0);
58259
58802
  return stages;
58260
58803
  }
58261
- function stageOfPiece(piece2, stages) {
58804
+ function stageOfPiece(piece22, stages) {
58262
58805
  let found;
58263
- piece2.root.traverse((o) => {
58806
+ piece22.root.traverse((o) => {
58264
58807
  if (found) return;
58265
58808
  const part = o.userData?.destructionPart;
58266
58809
  if (typeof part === "string") found = stages.get(part);
@@ -58269,20 +58812,20 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58269
58812
  }
58270
58813
  function stageLoosePieces(pieces, stages, level, opts, held) {
58271
58814
  let hidden = 0;
58272
- for (const piece2 of pieces) {
58273
- const stage = stageOfPiece(piece2, stages);
58815
+ for (const piece22 of pieces) {
58816
+ const stage = stageOfPiece(piece22, stages);
58274
58817
  if (!stage) continue;
58275
58818
  const shown2 = stageVisible(stage, level, opts);
58276
- piece2.root.visible = shown2;
58819
+ piece22.root.visible = shown2;
58277
58820
  if (!shown2) {
58278
58821
  hidden++;
58279
- if (!piece2.held) {
58280
- piece2.held = true;
58281
- held.add(piece2);
58822
+ if (!piece22.held) {
58823
+ piece22.held = true;
58824
+ held.add(piece22);
58282
58825
  }
58283
- } else if (held.has(piece2)) {
58284
- piece2.held = false;
58285
- held.delete(piece2);
58826
+ } else if (held.has(piece22)) {
58827
+ piece22.held = false;
58828
+ held.delete(piece22);
58286
58829
  }
58287
58830
  }
58288
58831
  return hidden;
@@ -58664,7 +59207,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58664
59207
  return { u: P.u - Math.sign(P.frontU || 0) * PANEL_RECESS, v: P.v - Math.sign(P.frontV || 0) * PANEL_RECESS, y0: P.y - h / 2 + PANEL_LIFT - BOX_CHASE_CLEAR, y1: P.y + h / 2 + PANEL_LIFT + BOX_CHASE_CLEAR, radius: w / 2, depth: 0 };
58665
59208
  }
58666
59209
  function installBuildBuild(K, shared2) {
58667
- const { THREE, cfg, rectsOf: rectsOf2, invalidateShadow, colliderChanged, VERSION: VERSION2, CARS, EPS: EPS4, LIGHTS, MIRRORS, Y0, animateClotheslines, animateDoors, animateInteractive, applyLeaf, applyOutbuildings, applyPart, applyPiece, assembleInteractive, baseboardAndSidewalk, buildStairs, building, carModel, chooseMirror, closeScene, collideAt, createWater, cursor, doorText, doors, electricalStructure, elevator, floorsAndSlabs, gatesInteractive, houseItems, ivAssemble, ivBuild, ivDispose, ivParts, ivPublish, ivUpdate, lightOn, linkDoorLeaves, mailboxInteractive, newInteractiveState, newMirrorState, outbuildings, paths, perimeter, placeSwitches, roofs, roomAt, solar, targetOf, terrain, toggleDoor, toggleLight, walls, waterPipes, drainPipes, windows, props, TYPES, IVK, VEG, vegMaterials, markGroups, assembleStructure, pieceRecord, createHouseDestruction, newState, enter, tagDamage } = K;
59210
+ const { THREE, cfg, rectsOf: rectsOf2, invalidateShadow, colliderChanged, VERSION: VERSION2, CARS, EPS: EPS4, LIGHTS, MIRRORS, Y0, animateClotheslines, animateDoors, animateInteractive, applyLeaf, applyOutbuildings, applyPart, applyPiece, assembleInteractive, baseboardAndSidewalk, buildStairs, building, carModel, chooseMirror, closeScene, collideAt, createWater, cursor, doorText, doors, electricalStructure, elevator, floorsAndSlabs, gatesInteractive, houseItems, ivAssemble, ivBuild, ivDispose, ivParts, ivPublish, ivUpdate, lightOn, linkDoorLeaves, mailboxInteractive, walkInInteractive, newInteractiveState, newMirrorState, outbuildings, paths, perimeter, placeSwitches, roofs, roomAt, solar, targetOf, terrain, toggleDoor, toggleLight, walls, waterPipes, drainPipes, windows, props, TYPES, IVK, VEG, vegMaterials, markGroups, assembleStructure, pieceRecord, createHouseDestruction, newState, enter, tagDamage } = K;
58668
59211
  function build(r0, options) {
58669
59212
  const opts = options || {};
58670
59213
  const r = withLaidConduits(applyOutbuildings(r0), !!(opts.constructionStages || opts.constructionLevel != null));
@@ -58811,6 +59354,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58811
59354
  assembleInteractive(gs);
58812
59355
  linkDoorLeaves();
58813
59356
  mailboxInteractive();
59357
+ walkInInteractive();
58814
59358
  if (cs) {
58815
59359
  for (const def of shared2.inter.defs.values()) {
58816
59360
  if (def.outer && !def.outer.userData.constructionStage) def.outer.userData.constructionStage = /^gate/.test(def.kind) ? "perimeter" : "furniture";
@@ -59501,7 +60045,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59501
60045
  joinBodies(params, byId);
59502
60046
  }
59503
60047
  function holdHanging({ parts: parts2, joints, boxOf: boxOf3 }, byId) {
59504
- const back = Math.min(...parts2.map((part) => boxOf3(part.id).min[2]));
60048
+ const back2 = Math.min(...parts2.map((part) => boxOf3(part.id).min[2]));
59505
60049
  for (let pass = 0; pass < parts2.length; pass++) {
59506
60050
  const groups = groupsOf(parts2, joints).map((ids) => ids.map((id) => byId.get(id)));
59507
60051
  const held = groups.filter((group) => group.some((part) => part.anchored)).flat();
@@ -59515,8 +60059,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59515
60059
  changed = true;
59516
60060
  continue;
59517
60061
  }
59518
- const againstWall = held.length === 0 || held.some((part) => boxOf3(part.id).min[2] <= back + AGAINST_WALL);
59519
- const onWall = againstWall ? group.filter((part) => !SOFT.has(part.material) && boxOf3(part.id).min[2] <= back + BACK_TOUCH) : [];
60062
+ const againstWall = held.length === 0 || held.some((part) => boxOf3(part.id).min[2] <= back2 + AGAINST_WALL);
60063
+ const onWall = againstWall ? group.filter((part) => !SOFT.has(part.material) && boxOf3(part.id).min[2] <= back2 + BACK_TOUCH) : [];
59520
60064
  if (onWall.length === 0) continue;
59521
60065
  for (const part of onWall) part.anchored = true;
59522
60066
  changed = true;
@@ -59529,6 +60073,230 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59529
60073
  return;
59530
60074
  }
59531
60075
  }
60076
+ var COVER22 = 6e-3;
60077
+ var SPRING = 3e-3;
60078
+ var SPRING_WIDTH = 0.012;
60079
+ var CLOTH_COVER = [{ material: "fabric", thickness: COVER22, faces: "all" }];
60080
+ function piece2(id, key2, material, min, max, color2) {
60081
+ const size = [max[0] - min[0], max[1] - min[1], max[2] - min[2]];
60082
+ const position = [(min[0] + max[0]) / 2, (min[1] + max[1]) / 2, (min[2] + max[2]) / 2];
60083
+ return { id, key: key2, material, shape: { kind: "box", size }, position, rotation: null, color: color2, min, max };
60084
+ }
60085
+ var bothSides = (x0, x1) => [
60086
+ [x0, x1],
60087
+ [-x1, -x0]
60088
+ ];
60089
+ var SIDE_RAIL = 0.03;
60090
+ var SLAT_TOP = 0.297;
60091
+ var SLAT_THICK = 0.027;
60092
+ var SLAT_WIDTH = 0.07;
60093
+ var SLAT_PITCH = 0.12;
60094
+ var SPRING_STRIPS = 5;
60095
+ function bedParts(drawn) {
60096
+ const [frame2, ...otherWood] = drawn.filter((p) => p.key === "wood");
60097
+ const [mattress, ...bedclothes] = drawn.filter((p) => p.key === "fabric");
60098
+ if (!frame2 || !mattress) return [...drawn];
60099
+ const hw = (frame2.max[0] - frame2.min[0]) / 2;
60100
+ const [z0, z1] = [frame2.min[2], frame2.max[2]];
60101
+ const wood = frame2.color;
60102
+ const out = [...otherWood.map((p, k) => ({ ...p, id: k === 0 ? "bed_headboard" : "bed_footboard" }))];
60103
+ bothSides(hw - SIDE_RAIL, hw).forEach(([x0, x1], k) => out.push(piece2(`bed_side_rail_${k}`, "wood", "wood_hard", [x0, 0, z0], [x1, frame2.max[1], z1], wood)));
60104
+ out.push(piece2("bed_centre_rail", "wood", "wood_soft", [-0.03, 0.2, z0], [0.03, SLAT_TOP - SLAT_THICK, z1], wood));
60105
+ const slats = Math.floor((z1 - z0 - 2 * 0.02 - SLAT_WIDTH) / SLAT_PITCH) + 1;
60106
+ for (let k = 0; k < slats; k++) {
60107
+ const z = z0 + 0.02 + k * SLAT_PITCH;
60108
+ out.push(piece2(`bed_slat_${k}`, "wood", "wood_soft", [-hw + SIDE_RAIL, SLAT_TOP - SLAT_THICK, z], [hw - SIDE_RAIL, SLAT_TOP, z + SLAT_WIDTH], wood));
60109
+ }
60110
+ const span = 2 * (hw - SIDE_RAIL);
60111
+ for (let k = 0; k < SPRING_STRIPS; k++) {
60112
+ const x = -hw + SIDE_RAIL + (k + 1) * span / (SPRING_STRIPS + 1);
60113
+ out.push(piece2(`bed_spring_${k}`, "metal", "spring_steel", [x - SPRING_WIDTH / 2, SLAT_TOP, z0], [x + SPRING_WIDTH / 2, SLAT_TOP + SPRING, z1], 4869200));
60114
+ }
60115
+ out.push({ ...mattress, id: "bed_mattress", material: "foam", layers: CLOTH_COVER });
60116
+ return [...out, ...bedclothes];
60117
+ }
60118
+ var RAIL_HEIGHT = 0.08;
60119
+ var POST = 0.05;
60120
+ var BOARD = 0.05;
60121
+ function base(L, c, seats, plinth) {
60122
+ const { hw, hd, armWidth: aT, postX: px } = L;
60123
+ const ix = hw - aT;
60124
+ const railTop = L.support - 6e-3;
60125
+ const railBottom = railTop - RAIL_HEIGHT;
60126
+ const zFrom = L.backFrame + BOARD;
60127
+ const zTo = L.coverFront - L.railDepth;
60128
+ const out = [];
60129
+ const wood = (id, min, max, material = "wood_hard") => out.push(piece2(id, "wood", material, min, max, c.wood));
60130
+ if (plinth) {
60131
+ wood("seat_plinth_front", [-hw, 0, hd - 0.06], [hw, L.postFloor, hd]);
60132
+ wood("seat_plinth_back", [-hw, 0, L.rear], [hw, L.postFloor, L.rear + 0.04]);
60133
+ for (const [k, [x0, x1]] of bothSides(hw - 0.04, hw).entries()) wood(`seat_plinth_side_${k}`, [x0, 0, L.rear + 0.04], [x1, L.postFloor, hd - 0.06]);
60134
+ }
60135
+ const upright = (id, x, z, top) => wood(id, [x - POST / 2, L.postFloor, z - POST / 2], [x + POST / 2, top, z + POST / 2]);
60136
+ for (const [k, sx] of [-1, 1].entries()) {
60137
+ upright(`seat_post_front_${k}`, sx * px, L.postFront, railTop);
60138
+ upright(`seat_post_back_${k}`, sx * px, L.postBack, L.stiles === "posts" ? L.armTop - 0.03 : railTop);
60139
+ }
60140
+ wood("seat_rail_front", [-(px - POST / 2), railBottom, zTo], [px - POST / 2, railTop, L.coverFront]);
60141
+ wood("seat_rail_back", [-(px - POST / 2), railBottom, L.backFrame], [px - POST / 2, railTop, zFrom]);
60142
+ for (const [k, [x0, x1]] of bothSides(hw - aT + COVER22, px - POST / 2).entries()) wood(`seat_rail_side_${k}`, [x0, railBottom, zFrom], [x1, railTop, zTo]);
60143
+ for (const seat of seats) if (seat.seam !== void 0) wood(`seat_divider_${out.length}`, [seat.seam - 0.02, railBottom, zFrom], [seat.seam + 0.02, railTop, zTo]);
60144
+ for (const [k, seat] of seats.entries()) {
60145
+ for (const [j, dx] of [-0.12, 0.12].entries()) {
60146
+ const x = seat.x + dx;
60147
+ out.push(piece2(`seat_spring_${k * 2 + j}`, "metal", "spring_steel", [x - SPRING_WIDTH / 2, railTop, L.backFrame + BOARD / 2], [x + SPRING_WIDTH / 2, railTop + SPRING, L.springEnd], 4869200));
60148
+ }
60149
+ }
60150
+ out.push(piece2("seat_cover_front", "fabric", "fabric", [-ix, L.skirt, L.coverFront], [ix, L.support, L.coverFront + COVER22], c.skirt));
60151
+ if (L.springEnd < L.coverFront - 0.03) out.push(piece2("seat_ledge", "fabric", "fabric", [-ix, railTop, L.springEnd], [ix, L.support, L.coverFront + COVER22], c.skirt));
60152
+ return out;
60153
+ }
60154
+ function back(L, c) {
60155
+ const { hw, armWidth: aT } = L;
60156
+ const ix = hw - aT;
60157
+ const railTop = L.support - 6e-3;
60158
+ const top = L.backTop - COVER22;
60159
+ const zFrame = [L.backFrame, L.backFrame + BOARD];
60160
+ const out = [];
60161
+ if (L.stiles === "rail") {
60162
+ for (const [k, [x0, x1]] of bothSides(ix - POST, ix).entries()) out.push(piece2(`back_stile_${k}`, "wood", "wood_hard", [x0, railTop, zFrame[0]], [x1, top, zFrame[1]], c.wood));
60163
+ out.push(piece2("back_top_rail", "wood", "wood_hard", [-(ix - POST), top - BOARD, zFrame[0]], [ix - POST, top, zFrame[1]], c.wood));
60164
+ }
60165
+ const midX = L.stiles === "rail" ? ix - POST : L.postX - POST / 2;
60166
+ out.push(piece2("back_mid_rail", "wood", "wood_hard", [-midX, 0.5, zFrame[0]], [midX, 0.5 + POST, zFrame[1]], c.wood));
60167
+ if (L.backFrame > L.rear + COVER22 + 0.01) out.push(piece2("back_pad_rear", "fabric", "foam", [-ix, L.skirt, L.rear + COVER22], [ix, top, L.backFrame], c.skirt));
60168
+ out.push(piece2("back_pad", "fabric", "foam", [-ix, L.support, zFrame[1]], [ix, top, L.rear + L.backDepth], c.back));
60169
+ out.push(piece2("back_cover_rear", "fabric", "fabric", [-L.rearHalf, L.skirt, L.rear], [L.rearHalf, L.backTop, L.rear + COVER22], c.skirt));
60170
+ out.push(piece2("back_cover_top", "fabric", "fabric", [-L.rearHalf, top, L.rear + COVER22], [L.rearHalf, L.backTop, L.rear + L.backDepth], c.back));
60171
+ if (L.rearHalf > ix) {
60172
+ for (const [k, [x0, x1]] of bothSides(ix, L.rearHalf).entries()) out.push(piece2(`back_shoulder_${k}`, "fabric", "foam", [x0, L.armTop, L.rear + COVER22], [x1, top, L.rear + L.backDepth], c.back));
60173
+ }
60174
+ return out;
60175
+ }
60176
+ function arms(L, c, boardBack) {
60177
+ const { hw, armWidth: aT, postX: px } = L;
60178
+ const railTop = L.support - 6e-3;
60179
+ const padTop = L.armTop - 0.03;
60180
+ const front = L.armFront;
60181
+ const out = [];
60182
+ const sides = [bothSides(px - POST / 2, px + POST / 2), bothSides(px + POST / 2, hw - COVER22), bothSides(hw - aT + COVER22, px - POST / 2), bothSides(hw - aT + COVER22, hw - COVER22), bothSides(hw - COVER22, hw), bothSides(hw - aT, hw - aT + COVER22)];
60183
+ const [board2, outer, inner, top, coverOuter, coverInner] = sides;
60184
+ for (const k of [0, 1]) {
60185
+ const z0 = L.armBack;
60186
+ out.push(piece2(`arm_board_${k}`, "wood", "wood_hard", [board2[k][0], railTop, boardBack], [board2[k][1], padTop, L.postFront + POST / 2], c.wood));
60187
+ out.push(piece2(`arm_pad_outer_${k}`, "fabric", "foam", [outer[k][0], railTop, z0], [outer[k][1], padTop, front - COVER22], c.arm));
60188
+ out.push(piece2(`arm_pad_inner_${k}`, "fabric", "foam", [inner[k][0], railTop, z0], [inner[k][1], padTop, front - COVER22], c.arm));
60189
+ out.push(piece2(`arm_pad_top_${k}`, "fabric", "foam", [top[k][0], padTop, z0], [top[k][1], L.armTop - COVER22, front - COVER22], c.arm));
60190
+ out.push(piece2(`arm_cover_outer_${k}`, "fabric", "fabric", [coverOuter[k][0], L.armBottom, z0], [coverOuter[k][1], L.armTop, front], c.arm));
60191
+ out.push(piece2(`arm_cover_inner_${k}`, "fabric", "fabric", [coverInner[k][0], L.armBottom, z0], [coverInner[k][1], L.armTop, front], c.arm));
60192
+ out.push(piece2(`arm_cover_top_${k}`, "fabric", "fabric", [top[k][0], L.armTop - COVER22, z0], [top[k][1], L.armTop, front - COVER22], c.arm));
60193
+ out.push(piece2(`arm_cover_front_${k}`, "fabric", "fabric", [top[k][0], L.armBottom, front - COVER22], [top[k][1], L.armTop - COVER22, front], c.arm));
60194
+ if (z0 > L.rear + 0.01) out.push(piece2(`arm_cover_back_${k}`, "fabric", "fabric", [top[k][0], L.armBottom, z0], [top[k][1], L.armTop - COVER22, z0 + COVER22], c.arm));
60195
+ }
60196
+ return out;
60197
+ }
60198
+ function seatStructure(L, c, seats, options) {
60199
+ return [...base(L, c, seats, options.plinth), ...back(L, c), ...arms(L, c, options.boardBack)];
60200
+ }
60201
+ function cushion(block, id) {
60202
+ return { ...block, id, material: "foam", layers: CLOTH_COVER };
60203
+ }
60204
+ var SOFAS = /^sofa_/;
60205
+ var ARMCHAIRS = /^armchair/;
60206
+ var BEDS = /^(double_bed|queen_bed|king_bed|single_bed|mattress)$/;
60207
+ var seatsOf = (cushions) => cushions.map((block, k) => ({ x: block.position[0], ...cushions[k + 1] ? { seam: (block.position[0] + cushions[k + 1].position[0]) / 2 } : {} }));
60208
+ function sofaParts(drawn) {
60209
+ const woods = drawn.filter((p) => p.key === "wood");
60210
+ const cloth2 = drawn.filter((p) => p.key === "fabric");
60211
+ const count = (cloth2.length - 5) / 2;
60212
+ const [skirt, ...rest2] = cloth2;
60213
+ const seatCushions = rest2.slice(0, count);
60214
+ const [back2] = rest2.slice(count, count + 1);
60215
+ const backCushions = rest2.slice(count + 1, 2 * count + 1);
60216
+ const [armLeft, , pillow] = rest2.slice(2 * count + 1);
60217
+ const feet = woods.slice(1);
60218
+ if (!skirt || !back2 || !armLeft || !pillow || feet.length !== 4) return [...drawn];
60219
+ const hd = (armLeft.max[2] - armLeft.min[2]) / 2 + 0.02;
60220
+ const hw = (woods[0].max[0] - woods[0].min[0]) / 2;
60221
+ const frontFoot = Math.max(...feet.map((foot) => foot.position[2]));
60222
+ const backFoot = Math.min(...feet.map((foot) => foot.position[2]));
60223
+ const layout = {
60224
+ hw,
60225
+ hd,
60226
+ rear: -hd,
60227
+ armWidth: armLeft.max[0] - armLeft.min[0],
60228
+ armTop: armLeft.max[1],
60229
+ armBottom: armLeft.min[1],
60230
+ backTop: back2.max[1],
60231
+ backDepth: back2.max[2] - back2.min[2],
60232
+ skirt: skirt.min[1],
60233
+ support: skirt.max[1],
60234
+ postX: Math.abs(feet[0].position[0]),
60235
+ postFront: frontFoot,
60236
+ postBack: backFoot,
60237
+ postFloor: 0,
60238
+ coverFront: skirt.max[2] - COVER22,
60239
+ railDepth: 0.07,
60240
+ springEnd: skirt.max[2] - 0.05,
60241
+ backFrame: backFoot - 0.025,
60242
+ armBack: armLeft.min[2],
60243
+ armFront: armLeft.max[2],
60244
+ rearHalf: hw - (armLeft.max[0] - armLeft.min[0]),
60245
+ stiles: "rail"
60246
+ };
60247
+ const colours = { wood: feet[0].color, skirt: skirt.color, back: back2.color, arm: armLeft.color };
60248
+ const structure = seatStructure(layout, colours, seatsOf(seatCushions), { plinth: false, boardBack: layout.backFrame });
60249
+ const cushions = [...seatCushions.map((block, k) => cushion(block, `seat_cushion_${k}`)), ...backCushions.map((block, k) => cushion(block, `back_cushion_${k}`)), cushion(pillow, "accent_pillow")];
60250
+ return [...structure, ...cushions];
60251
+ }
60252
+ var ARMCHAIR_SUPPORT = 0.28;
60253
+ function armchairParts(drawn) {
60254
+ const plinth = drawn.find((p) => p.key === "wood");
60255
+ const [seat, back2, armLeft] = drawn.filter((p) => p.key === "fabric");
60256
+ if (!plinth || !seat || !back2 || !armLeft) return [...drawn];
60257
+ const [hw, hd] = [(plinth.max[0] - plinth.min[0]) / 2, (plinth.max[2] - plinth.min[2]) / 2];
60258
+ const armWidth = armLeft.max[0] - armLeft.min[0];
60259
+ const rear = back2.min[2];
60260
+ const backFrame = rear + COVER22;
60261
+ const coverFront = hd - 0.04;
60262
+ const layout = {
60263
+ hw,
60264
+ hd,
60265
+ rear,
60266
+ armWidth,
60267
+ armTop: armLeft.max[1],
60268
+ armBottom: armLeft.min[1],
60269
+ backTop: back2.max[1],
60270
+ backDepth: back2.max[2] - rear,
60271
+ skirt: plinth.max[1],
60272
+ support: ARMCHAIR_SUPPORT,
60273
+ postX: hw - 0.07,
60274
+ postFront: hd - 0.065,
60275
+ postBack: backFrame + 0.025,
60276
+ postFloor: plinth.max[1],
60277
+ coverFront,
60278
+ railDepth: 0.05,
60279
+ springEnd: coverFront - 0.02,
60280
+ backFrame,
60281
+ armBack: backFrame,
60282
+ armFront: armLeft.max[2],
60283
+ rearHalf: (back2.max[0] - back2.min[0]) / 2,
60284
+ stiles: "posts"
60285
+ };
60286
+ const colours = { wood: plinth.color, skirt: seat.color, back: back2.color, arm: armLeft.color };
60287
+ const structure = seatStructure(layout, colours, [{ x: 0 }], { plinth: true, boardBack: backFrame + 0.05 });
60288
+ const ix = hw - armWidth;
60289
+ const seatCushion = { ...seat, id: "seat_cushion_0", min: [-(ix - 2e-3), ARMCHAIR_SUPPORT, rear + layout.backDepth], max: [ix - 2e-3, seat.max[1], seat.max[2]] };
60290
+ const size = [seatCushion.max[0] - seatCushion.min[0], seatCushion.max[1] - seatCushion.min[1], seatCushion.max[2] - seatCushion.min[2]];
60291
+ const position = [0, (seatCushion.min[1] + seatCushion.max[1]) / 2, (seatCushion.min[2] + seatCushion.max[2]) / 2];
60292
+ return [...structure, cushion({ ...seatCushion, shape: { kind: "box", size }, position }, "seat_cushion_0")];
60293
+ }
60294
+ function upholster(drawn, type) {
60295
+ const made2 = SOFAS.test(type) ? sofaParts(drawn) : ARMCHAIRS.test(type) ? armchairParts(drawn) : BEDS.test(type) ? bedParts(drawn) : void 0;
60296
+ if (!made2) return false;
60297
+ drawn.splice(0, drawn.length, ...made2);
60298
+ return true;
60299
+ }
59532
60300
  var WOOD_THIN = 0.035;
59533
60301
  var BOARD_TOP_THICK = 0.07;
59534
60302
  var BOARD_TOP_WIDTH = 0.5;
@@ -59755,6 +60523,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59755
60523
  run(A);
59756
60524
  if (!drawn.length) throw new Error(`game-floorplan-three: the builder of "${name}" drew no box or cylinder`);
59757
60525
  hollowCases(drawn, name);
60526
+ upholster(drawn, name);
59758
60527
  const boardsOf = splitTopsIntoBoards(drawn, materialOf, Boolean(opts.carcass));
59759
60528
  const parts2 = drawn.map((p) => {
59760
60529
  const thin = Math.min(...p.shape.kind === "box" ? p.shape.size : p.shape.kind === "cylinder" ? [p.shape.radius * 2, p.shape.height] : [p.shape.radius * 2]);
@@ -59767,6 +60536,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59767
60536
  const fill2 = structureFill(material, p.shape);
59768
60537
  if (fill2 < 1) part.fill = Math.round(fill2 * 1e4) / 1e4;
59769
60538
  if (p.rotation) part.rotation = p.rotation;
60539
+ if (p.layers) part.layers = p.layers;
59770
60540
  if (!LOOSE.has(material) && p.min[1] <= FLOOR_TOUCH2) part.anchored = true;
59771
60541
  if (opts.carcass && LOOSE.has(material)) {
59772
60542
  part.hands = 1;
@@ -59804,7 +60574,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59804
60574
  let top = null;
59805
60575
  for (const p of drawn) {
59806
60576
  const part = parts2.find((x) => x.id === p.id);
59807
- if (part.shape.kind === "sphere" || part.rotation || part.material === "fabric" || LOOSE.has(part.material)) continue;
60577
+ if (part.shape.kind === "sphere" || part.rotation || part.material === "fabric" || part.material === "foam" || LOOSE.has(part.material)) continue;
59808
60578
  const area3 = (p.max[0] - p.min[0]) * (p.max[2] - p.min[2]);
59809
60579
  if (area3 < 0.6 * footprint || p.max[1] < 0.2) continue;
59810
60580
  if (!top || p.max[1] > top.y + 1e-6) top = { part: p.id, y: p.max[1] };
@@ -60075,11 +60845,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
60075
60845
  var textOf = (locale) => TEXT[locale] ?? TEXT.en;
60076
60846
  var fill = (template, vars) => template.replace(/\{(\w+)\}/g, (_, key2) => String(vars[key2] ?? ""));
60077
60847
  var humanize = (id) => id.replace(/_/g, " ").replace(/^./, (c) => c.toUpperCase());
60078
- var stageOf = (catalog, item, base, ageDays, storage, powered) => {
60079
- if (item.shelfLife === void 0 || ageDays <= 0) return base;
60848
+ var stageOf = (catalog, item, base2, ageDays, storage, powered) => {
60849
+ if (item.shelfLife === void 0 || ageDays <= 0) return base2;
60080
60850
  const state = freshness(item, { ageDays: 0, since: 0, storage, storedAt: 0 }, ageDays, { powered, rules: catalog.rules });
60081
60851
  const aged = state === "fresh" ? 0 : state === "stale" ? 1 : 2;
60082
- return Math.max(base, aged);
60852
+ return Math.max(base2, aged);
60083
60853
  };
60084
60854
  var sizeOfModel = (modelSet, id) => {
60085
60855
  const entry2 = modelSet.entry(id);
@@ -60140,9 +60910,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
60140
60910
  name,
60141
60911
  movable: false,
60142
60912
  build: (THREE) => {
60143
- const piece2 = furnitureSpec(THREE, type, { ...size, options: { chairs: false } });
60144
- const root = piece2.build(THREE);
60145
- root.userData.furnitureSpec = { ...piece2.spec, name };
60913
+ const piece3 = furnitureSpec(THREE, type, { ...size, options: { chairs: false } });
60914
+ const root = piece3.build(THREE);
60915
+ root.userData.furnitureSpec = { ...piece3.spec, name };
60146
60916
  decorate?.(root);
60147
60917
  return root;
60148
60918
  },
@@ -60223,11 +60993,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
60223
60993
  build: (THREE) => {
60224
60994
  const T2 = THREE;
60225
60995
  const group = markKitOrigin(new T2.Group(), { owner: "game-items-three", kind: "aid" });
60226
- const base = new T2.Mesh(new T2.CylinderGeometry(STAND.radius, STAND.radius + 0.1, STAND.height - 0.04, 40), new T2.MeshStandardMaterial({ color: 3816772, roughness: 0.8 }));
60227
- base.position.y = (STAND.height - 0.04) / 2;
60996
+ const base2 = new T2.Mesh(new T2.CylinderGeometry(STAND.radius, STAND.radius + 0.1, STAND.height - 0.04, 40), new T2.MeshStandardMaterial({ color: 3816772, roughness: 0.8 }));
60997
+ base2.position.y = (STAND.height - 0.04) / 2;
60228
60998
  const top = new T2.Mesh(new T2.CylinderGeometry(STAND.radius, STAND.radius, 0.04, 40), new T2.MeshStandardMaterial({ color: 13617848, roughness: 0.6 }));
60229
60999
  top.position.y = STAND.height - 0.02;
60230
- group.add(base, top);
61000
+ group.add(base2, top);
60231
61001
  return group;
60232
61002
  }
60233
61003
  });
@@ -60248,9 +61018,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
60248
61018
  mark.position.set(0.03 + (long ? 0.025 : 0.015), cm / 100, 0);
60249
61019
  group.add(mark);
60250
61020
  }
60251
- const base = new T2.Mesh(new T2.BoxGeometry(0.3, 0.03, 0.3), new T2.MeshStandardMaterial({ color: 5593180 }));
60252
- base.position.y = 0.015;
60253
- group.add(base);
61021
+ const base2 = new T2.Mesh(new T2.BoxGeometry(0.3, 0.03, 0.3), new T2.MeshStandardMaterial({ color: 5593180 }));
61022
+ base2.position.y = 0.015;
61023
+ group.add(base2);
60254
61024
  group.userData.height = RULER_HEIGHT;
60255
61025
  return group;
60256
61026
  }