@adatechnology/game-items-three 0.11.4 → 0.11.6

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,14 +16408,18 @@ 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;
16420
+ var SEVER_TRACK = 4;
16304
16421
  var TEAR_JOULES = 150;
16305
- var tears = 0;
16422
+ var STRIP_THICKNESS = 15e-4;
16306
16423
  var UNIT_FRAGMENT_FACTOR = 4;
16307
16424
  var BREACH_GRID_CAP = 4096;
16308
16425
  var MASONRY_CRUMBLE_SPEED = 0.6;
@@ -16473,6 +16590,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
16473
16590
  const rnd = () => rng3.next();
16474
16591
  let time = 0;
16475
16592
  let counter = 0;
16593
+ let tears = 0;
16476
16594
  const objects = /* @__PURE__ */ new Map();
16477
16595
  const slots = /* @__PURE__ */ new Map();
16478
16596
  let slotCounter = 0;
@@ -16506,7 +16624,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
16506
16624
  if (typed) for (const fn of typed) fn(e);
16507
16625
  };
16508
16626
  let blow;
16509
- const base = (o, source) => ({
16627
+ const base2 = (o, source) => ({
16510
16628
  object: o.id,
16511
16629
  time,
16512
16630
  ...source === void 0 ? {} : { source },
@@ -17394,7 +17512,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
17394
17512
  w.emitted = { t: time, peak: d.peak, status: st.status };
17395
17513
  const dir = windDirection(o, w.cfg);
17396
17514
  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 });
17515
+ 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
17516
  }
17399
17517
  };
17400
17518
  const isTerrain = (p) => !!p.spec.tags?.includes("terrain");
@@ -17602,7 +17720,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
17602
17720
  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
17721
  if (changed) {
17604
17722
  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 });
17723
+ 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
17724
  }
17607
17725
  if (st.status === "toppled") topple(o);
17608
17726
  };
@@ -17651,7 +17769,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
17651
17769
  p.st.status = "broken";
17652
17770
  p.st.hp = 0;
17653
17771
  p.st.mass = 0;
17654
- emit({ ...base(o, src), type: "fracture", part: p.spec.id, style: "crumble", fragments, point: c });
17772
+ emit({ ...base2(o, src), type: "fracture", part: p.spec.id, style: "crumble", fragments, point: c });
17655
17773
  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
17774
  setStage(o, p, 3, {}, src);
17657
17775
  partLost(o, p, src);
@@ -17673,7 +17791,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
17673
17791
  markHostedDirty(o, p.spec.id);
17674
17792
  setStage(o, p, 3, {}, src);
17675
17793
  }
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) });
17794
+ 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
17795
  }
17678
17796
  for (const p of crumbling) crumbleMasonry(o, p, src);
17679
17797
  }
@@ -17994,7 +18112,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
17994
18112
  r.st.subsidence = Math.max(r.st.subsidence ?? 0, drop.reduce((sum, v) => sum + v, 0) / count);
17995
18113
  const middle = [from[0], from[1], from[2]];
17996
18114
  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" });
18115
+ 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
18116
  let lost = false;
17999
18117
  for (const j of [...o.byPart.get(r.spec.id) ?? []]) {
18000
18118
  settleStructure(o);
@@ -18034,7 +18152,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18034
18152
  if (p.staged) {
18035
18153
  setStage(o, p, 1, {}, src);
18036
18154
  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 });
18155
+ } else emit({ ...base2(o, src), type: "stage", part: p.spec.id, stage: 2, opening: { center: worldCenter, radius: hole.radius }, fragments });
18038
18156
  debris(o, p, p.mat.breakDebris, worldCenter, [0, 1, 0], 14, 2, src);
18039
18157
  if (p.spec.reinforcement) exposeRebar(o, p, src);
18040
18158
  };
@@ -18060,8 +18178,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18060
18178
  const width = clamp2(beta * SETTLEMENT_CRACK_OPENING, MIN_CRACK_WIDTH, MAX_CRACK_WIDTH);
18061
18179
  const through = q.dims[q.thin];
18062
18180
  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])];
18181
+ const back2 = c * SETTLEMENT_CRACK_SPACING;
18182
+ 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
18183
  const face = toLocal(q.pos, q.q, local);
18066
18184
  face[q.thin] = through / 2;
18067
18185
  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 +18301,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18183
18301
  }
18184
18302
  if (bearing.status === "settled" && drop - before < SUBSIDE_MIN && peak() - peakBefore < SUBSIDE_MIN) continue;
18185
18303
  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 });
18304
+ emit({ ...base2(o, src), type: "subside", part: b.p.spec.id, drop, share: fp.share, point: fp.deepest, status: bearing.status });
18187
18305
  }
18188
18306
  for (const { b, fp } of settled) {
18189
18307
  settleStructure(o);
@@ -18298,7 +18416,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18298
18416
  const known = implSolids.get(im);
18299
18417
  if (known && known.spec === spec && known.state === state && im.impl.collidersPending?.() !== true && sameImplPlace(known.key, im)) return known.solids;
18300
18418
  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])) {
18419
+ 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
18420
  implSolids.set(im, { ...known, state });
18303
18421
  return known.solids;
18304
18422
  }
@@ -18383,6 +18501,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18383
18501
  return fresh.map(([nid]) => nid);
18384
18502
  };
18385
18503
  let rayBroad = null;
18504
+ let surfaceTracer = null;
18386
18505
  let uncovered = [];
18387
18506
  let uncoveredFor = { hook: null, coverage: -1, objects: -1 };
18388
18507
  const metObjects = [];
@@ -18412,7 +18531,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18412
18531
  }
18413
18532
  return rayObjects;
18414
18533
  };
18415
- const raycastInternal = (origin, dir, maxDist, ignore, worldOnly = false, precise = false, skip = {}, scope) => {
18534
+ const raycastInternal = (origin, dir, maxDist, ignore, worldOnly = false, precise = false, skip = {}, scope, drawn = false, passed) => {
18416
18535
  const d = vec.normalize(dir);
18417
18536
  const asked = rayBroad && !scope && rayBroad.begin(origin, d, maxDist) ? rayBroad : null;
18418
18537
  const candidates = asked ? candidatesOf2(asked) : null;
@@ -18440,12 +18559,22 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18440
18559
  if (!r || r.t0 < 0 || r.t0 > maxDist) continue;
18441
18560
  if (p.st.opening && insideOpening(o, p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
18442
18561
  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;
18562
+ if (p.st.chipped && insideChip(p, objLocal(o, vec.madd(origin, d, Math.min(r.t0 + CHIP_PROBE_DEPTH, (r.t0 + r.t1) / 2))))) {
18563
+ passed?.push({ o, p, t: r.t0 });
18564
+ continue;
18565
+ }
18444
18566
  const gap = p.st.chipped?.length ? pastChips(o, p, origin, d, r.t0, r.t1) : null;
18445
18567
  if (gap === "through") continue;
18446
18568
  if (gap) {
18447
18569
  r.t0 = gap.t;
18448
18570
  r.n = gap.n;
18571
+ } else if (drawn && surfaceTracer) {
18572
+ 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 });
18573
+ if (drawn2 === null) continue;
18574
+ if (drawn2 && drawn2.distance <= maxDist && Math.abs(drawn2.distance - r.t0) > SURFACE_SAME) {
18575
+ r.t0 = drawn2.distance;
18576
+ r.n = [drawn2.normal[0], drawn2.normal[1], drawn2.normal[2]];
18577
+ }
18449
18578
  }
18450
18579
  if (!best || r.t0 < best.distance) {
18451
18580
  const point = vec.madd(origin, d, r.t0);
@@ -18586,14 +18715,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18586
18715
  arr[ni].radius = Math.max(arr[ni].radius, radius);
18587
18716
  } else arr.push(dent);
18588
18717
  markDamaged(p);
18589
- emit({ ...base(o, src), type: "dent", part: p.spec.id, dent, worldPoint: wp });
18718
+ emit({ ...base2(o, src), type: "dent", part: p.spec.id, dent, worldPoint: wp });
18590
18719
  };
18591
18720
  const addHole = (o, p, wp, wn, diameter, through, exit, src) => {
18592
18721
  const hole = { point: objLocal(o, wp), normal: objLocalDir(o, wn), diameter, through };
18593
18722
  p.st.holes.push(hole);
18594
18723
  if (p.st.holes.length > maxHoles) p.st.holes.shift();
18595
18724
  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 } } : {} });
18725
+ emit({ ...base2(o, src), type: "hole", part: p.spec.id, hole, worldPoint: wp, ...exit ? { exitPoint: exit } : {}, ...p.spec.powder ? { powder: { ...p.spec.powder } } : {} });
18597
18726
  setStage(o, p, 1, {}, src);
18598
18727
  return hole;
18599
18728
  };
@@ -18602,13 +18731,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18602
18731
  p.st.cracks.push(crack);
18603
18732
  if (p.st.cracks.length > 16) p.st.cracks.shift();
18604
18733
  markDamaged(p);
18605
- emit({ ...base(o, src), type: "crack", part: p.spec.id, crack, worldPoint: wp });
18734
+ emit({ ...base2(o, src), type: "crack", part: p.spec.id, crack, worldPoint: wp });
18606
18735
  setStage(o, p, 1, {}, src);
18607
18736
  };
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 } : {} });
18737
+ 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
18738
  const holeRate = (hole, pressurized) => (pressurized ? 0.5 : 0.1) * (hole.diameter / 9e-3);
18610
18739
  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]) });
18740
+ 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
18741
  };
18613
18742
  const loosened = (o, opened, by, src) => {
18614
18743
  if (runDepth === 0) {
@@ -18687,7 +18816,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18687
18816
  const checkDestroyed = (o, src) => {
18688
18817
  if (!o.st.destroyed && o.parts.length > 0 && o.parts.every(isLost)) {
18689
18818
  o.st.destroyed = true;
18690
- emit({ ...base(o, src), type: "destroyed" });
18819
+ emit({ ...base2(o, src), type: "destroyed" });
18691
18820
  }
18692
18821
  };
18693
18822
  const holeReaches = (host, box4) => {
@@ -18727,7 +18856,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18727
18856
  } else {
18728
18857
  o.hostedHosts = new Set(o.hosted.map((p) => p.spec.hostedIn));
18729
18858
  }
18730
- for (const p of shown) emit({ ...base(o), type: "reveal", part: p.spec.id, host: p.spec.hostedIn });
18859
+ for (const p of shown) emit({ ...base2(o), type: "reveal", part: p.spec.id, host: p.spec.hostedIn });
18731
18860
  if (opened.length > 0) {
18732
18861
  loosened(o, opened, "break");
18733
18862
  collapseCheck(o);
@@ -18853,26 +18982,48 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18853
18982
  const setStage = (o, p, stage, extra = {}, src) => {
18854
18983
  if (!p.staged || (p.st.stage ?? 0) >= stage) return;
18855
18984
  p.st.stage = stage;
18856
- emit({ ...base(o, src), type: "stage", part: p.spec.id, stage, ...extra });
18985
+ emit({ ...base2(o, src), type: "stage", part: p.spec.id, stage, ...extra });
18986
+ };
18987
+ const faceOf = (o, p, worldNormal) => faceOfNormal(p.layers, p.thin, rotateVec(quat.conjugate(partXf(o, p).q), worldNormal));
18988
+ const spallNormal = (o, p, face) => {
18989
+ if (Math.abs(face) === 1) return {};
18990
+ const local = [0, 0, 0];
18991
+ local[faceAxis(p.thin, face)] = face > 0 ? 1 : -1;
18992
+ return { normal: rotateVec(partXf(o, p).q, local) };
18993
+ };
18994
+ const widenTear = (o, p, torn, lp, normal, radius, src) => {
18995
+ const spalls = p.rt.spalls;
18996
+ const s = spalls[torn.spall];
18997
+ const axis = faceAxis(p.thin, s[1]);
18998
+ const faceArea = p.dims.reduce((area3, size, k) => k === axis ? area3 : area3 * size, 1);
18999
+ const reach2 = Math.hypot(lp[0] - s[2], lp[1] - s[3], lp[2] - s[4]);
19000
+ const r = Math.min(Math.sqrt(faceArea / Math.PI), Math.max(Math.sqrt(s[5] * s[5] + radius * radius), reach2));
19001
+ if (r <= s[5]) return;
19002
+ spalls[torn.spall] = [s[0], s[1], s[2], s[3], s[4], r];
19003
+ markDamaged(p);
19004
+ const centre = toWorld(o.st.position, o.st.rotation, [s[2], s[3], s[4]]);
19005
+ 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]) });
19006
+ debris(o, p, torn.layer.mat.hitDebris, toWorld(o.st.position, o.st.rotation, lp), normal, 5, 2, src, torn.layer.mat.id);
18857
19007
  };
18858
- const faceOf = (o, p, worldNormal) => rotateVec(quat.conjugate(partXf(o, p).q), worldNormal)[p.thin] >= 0 ? 1 : -1;
18859
19008
  const spallOuter = (o, p, wp, face, normal, radius, src) => {
18860
19009
  var _a;
18861
19010
  if (p.layers.length === 0) return;
18862
19011
  const lp = objLocal(o, wp);
19012
+ const torn = tornPatchAt(p.layers, p.rt.spalls, face, lp, radius);
19013
+ if (torn) return widenTear(o, p, torn, lp, normal, radius, src);
18863
19014
  const layer = outerLayer(p.layers, p.rt.spalls, face, lp);
18864
19015
  if (!layer) return;
18865
19016
  const spalls = (_a = p.rt).spalls ?? (_a.spalls = []);
18866
19017
  spalls.push([layer.index, face, lp[0], lp[1], lp[2], radius]);
18867
19018
  if (spalls.length > MAX_SPALLS) spalls.shift();
18868
19019
  markDamaged(p);
18869
- emit({ ...base(o, src), type: "spall", part: p.spec.id, layer: layer.index, point: wp, area: Math.PI * radius * radius });
19020
+ 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
19021
  debris(o, p, layer.mat.hitDebris, wp, normal, 5, 2, src, layer.mat.id);
18871
19022
  setStage(o, p, 1, {}, src);
18872
19023
  };
18873
19024
  const crater = (o, p, wp, normal, radius, src) => {
18874
19025
  markDamaged(p);
18875
- emit({ ...base(o, src), type: "spall", part: p.spec.id, layer: -1, point: wp, area: Math.PI * radius * radius });
19026
+ emit({ ...base2(o, src), type: "spall", part: p.spec.id, layer: -1, point: wp, area: Math.PI * radius * radius });
18876
19027
  debris(o, p, p.mat.breakDebris, wp, normal, 6, 1.5, src);
18877
19028
  setStage(o, p, 1, {}, src);
18878
19029
  };
@@ -18941,7 +19092,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18941
19092
  if (!layer || cells.length === 0) return [];
18942
19093
  const { c, q } = partXf(o, p);
18943
19094
  const [u, v] = planeAxes(p.thin);
18944
- const faces = layer.def.faces === "both" ? [1, -1] : [layer.def.faces === "+" ? 1 : -1];
19095
+ const faces = thinSidesOf(layer.def);
18945
19096
  const area3 = cells.reduce((sum, cell) => sum + cell.size[u] * cell.size[v], 0) * faces.length;
18946
19097
  const count = Math.min(MAX_PLASTER_FLAKES, Math.ceil(area3 / PLASTER_FLAKE_AREA));
18947
19098
  const out = [];
@@ -19123,6 +19274,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19123
19274
  }
19124
19275
  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
19276
  };
19277
+ const alongAt = (along2, at2) => {
19278
+ const point = [0, 0, 0];
19279
+ point[along2] = at2;
19280
+ return point;
19281
+ };
19126
19282
  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
19283
  const wearMember = (o, p, entry2, d, E, caliber, penMm, src) => {
19128
19284
  var _a, _b, _c;
@@ -19157,7 +19313,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19157
19313
  const wear = (_c = p.rt).cellWear ?? (_c.cellWear = {});
19158
19314
  const cell = grid[hit];
19159
19315
  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);
19316
+ if (wear[hit] >= MEMBER_UNIT_LOSS * cell.size[0] * cell.size[1] * cell.size[2]) knockOutUnits(o, p, entry2, E, [hit], src, d);
19161
19317
  return true;
19162
19318
  }
19163
19319
  const out = [];
@@ -19165,8 +19321,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19165
19321
  if (gone[i] === -1) continue;
19166
19322
  if (Math.abs(grid[i].center[along2] - bandCenter) <= height / 2 + 1e-6) out.push(i);
19167
19323
  }
19168
- if (out.length > 0) knockOutUnits(o, p, entry2, E, out, src);
19169
- giveAtCut(o, p, src);
19324
+ worn[band] = 1;
19325
+ if (out.length > 0) knockOutUnits(o, p, entry2, E, out, src, d);
19326
+ giveAtCut(o, p, src, { at: alongAt(along2, bandCenter), d });
19170
19327
  return true;
19171
19328
  };
19172
19329
  const chipUnits = (o, p, kind, wp, hitEnergy, dir, radius, src) => {
@@ -19238,7 +19395,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19238
19395
  p.rt.removed = (p.rt.removed ?? 0) + mass;
19239
19396
  markDamaged(p);
19240
19397
  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 });
19398
+ 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
19399
  debris(o, p, p.mat.breakDebris, center, vec.scale(dir ?? [0, 1, 0], -1), 6, 2, src);
19243
19400
  }
19244
19401
  markHostedDirty(o, p.spec.id);
@@ -19273,18 +19430,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19273
19430
  const n = clamp2(Math.round(cell.size[u] * cell.size[v] / (bit * bit * 3)), 4, 10) + Math.floor(rnd() * 3);
19274
19431
  const out = [];
19275
19432
  for (let i = 0; i < n; i++) {
19276
- const back = i % 3 === 2;
19433
+ const back2 = i % 3 === 2;
19277
19434
  const lc = [cell.center[0], cell.center[1], cell.center[2]];
19278
19435
  lc[u] += (rnd() - 0.5) * cell.size[u] * 0.7;
19279
19436
  lc[v] += (rnd() - 0.5) * cell.size[v] * 0.7;
19280
- lc[p.thin] += (back ? -exitSign : exitSign) * (p.thickness / 2 + 0.01);
19437
+ lc[p.thin] += (back2 ? -exitSign : exitSign) * (p.thickness / 2 + 0.01);
19281
19438
  const size = [0, 0, 0];
19282
19439
  size[u] = bit * (0.6 + 0.8 * rnd());
19283
19440
  size[v] = bit * (0.5 + 0.7 * rnd());
19284
19441
  size[p.thin] = bit * (0.4 + 0.6 * rnd());
19285
19442
  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));
19443
+ const k = speed * (back2 ? 0.4 + 0.4 * rnd() : 0.7 + 0.8 * rnd());
19444
+ const vdir = vec.normalize(vec.add(back2 ? vec.scale(d, -1) : d, spread3));
19288
19445
  out.push({
19289
19446
  id: `${p.spec.id}#${tag}${i}`,
19290
19447
  part: p.spec.id,
@@ -19301,8 +19458,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19301
19458
  }
19302
19459
  return out;
19303
19460
  };
19304
- const exposeRebar = (o, p, src) => {
19305
- settleStructure(o);
19461
+ const exposeRebar = (o, p, src, bowed = true) => {
19462
+ if (bowed) settleStructure(o);
19306
19463
  const r = p.spec.reinforcement;
19307
19464
  if (!r) return;
19308
19465
  const [u, v] = planeAxes(p.thin);
@@ -19319,14 +19476,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19319
19476
  bars.push(...clipBarsToDisc(all, u, v, [lc[u], lc[v]], op.radius + 0.05));
19320
19477
  }
19321
19478
  }
19322
- const bow2 = clamp2(((p.st.stress ?? 0) - 1) / 0.5, 0, 1);
19479
+ const bow2 = bowed ? clamp2(((p.st.stress ?? 0) - 1) / 0.5, 0, 1) : 0;
19323
19480
  if (bow2 > 0) bars = bars.flatMap((bar2, i) => bendBar(bar2, p.thin, bow2 * BAR_BOW, i));
19324
19481
  const stirrups = memberStirrups(p.dims, void 0, p.spec.structure?.role);
19325
19482
  if (stirrups.length > 0 && bars.length > 0) {
19326
19483
  if (p.st.stripped) bars = [...bars, ...stirrups];
19327
19484
  else for (const box4 of [...p.st.chipped ?? [], ...p.rt.bared ?? []]) bars.push(...clipBarsToVolume(stirrups, box4.center, box4.size));
19328
19485
  }
19329
- emit({ ...base(o, src), type: "expose", part: p.spec.id, bars: worldBars(o, p, bars) });
19486
+ emit({ ...base2(o, src), type: "expose", part: p.spec.id, bars: worldBars(o, p, bars) });
19330
19487
  };
19331
19488
  const openBreach = (o, p, center, total, energy, dir, src) => {
19332
19489
  const [u, v] = planeAxes(p.thin);
@@ -19487,7 +19644,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19487
19644
  for (const i of out) worn[i] = -1;
19488
19645
  return knockOutUnits(o, p, point, energy, out, src);
19489
19646
  };
19490
- const knockOutUnits = (o, p, wp, energy, out, src) => {
19647
+ const knockOutUnits = (o, p, wp, energy, out, src, d) => {
19491
19648
  var _a, _b;
19492
19649
  const [u, v] = planeAxes(p.thin);
19493
19650
  const op = p.st.opening ? toLocal(p.pos, p.q, p.st.opening.center) : null;
@@ -19531,15 +19688,34 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19531
19688
  setStage(o, p, 1, {}, src);
19532
19689
  const center = toWorld(c, q, [(lo[0] + hi[0]) / 2, (lo[1] + hi[1]) / 2, (lo[2] + hi[2]) / 2]);
19533
19690
  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 });
19691
+ 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
19692
  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);
19693
+ const cut = wornLocally(p) && cutBandsGone(o, p, cells, d ?? vec.normalize(vec.sub(partXf(o, p).c, wp), [1, 0, 0]), src);
19694
+ if (p.spec.reinforcement && !cut) exposeRebar(o, p, src);
19537
19695
  if (p.structural && !isLost(p)) {
19538
19696
  solveStructure(o);
19539
19697
  collapseCheck(o, src);
19540
19698
  }
19541
19699
  return true;
19542
19700
  };
19701
+ const cutBandsGone = (o, p, cells, d, src) => {
19702
+ var _a;
19703
+ const along2 = p.dims.indexOf(Math.max(...p.dims));
19704
+ const bands = Math.max(1, Math.round(p.dims[along2] / MEMBER_BAND));
19705
+ const height = p.dims[along2] / bands;
19706
+ const bandOf2 = (at2) => clamp2(Math.floor((at2 + p.dims[along2] / 2) / p.dims[along2] * bands), 0, bands - 1);
19707
+ const grid = gridOf(p);
19708
+ const gone = p.rt.chips ?? {};
19709
+ const worn = (_a = p.rt).bands ?? (_a.bands = {});
19710
+ for (const band of new Set(cells.map((cell) => bandOf2(cell.center[along2])))) {
19711
+ if ((worn[band] ?? 0) >= 1) continue;
19712
+ const center = -p.dims[along2] / 2 + (band + 0.5) * height;
19713
+ if (!grid.every((cell, i) => gone[i] === -1 || Math.abs(cell.center[along2] - center) > height / 2 + 1e-6)) continue;
19714
+ worn[band] = 1;
19715
+ return giveAtCut(o, p, src, { at: alongAt(along2, center), d });
19716
+ }
19717
+ return false;
19718
+ };
19543
19719
  const dropUnsupported = (o, p, src) => {
19544
19720
  var _a, _b;
19545
19721
  if (!p.spec.units || p.spec.units.mortar === p.spec.material || p.st.stripped || isLost(p)) return 0;
@@ -19573,17 +19749,90 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19573
19749
  p.rt.removed = (p.rt.removed ?? 0) + mass;
19574
19750
  markDamaged(p);
19575
19751
  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 });
19752
+ 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
19753
  debris(o, p, p.mat.breakDebris, center, [0, -1, 0], 6, 1, src);
19578
19754
  return loose.length;
19579
19755
  };
19580
- const giveAtCut = (o, p, src) => {
19756
+ const barsMoment = (p) => {
19757
+ const r = p.spec.reinforcement;
19758
+ if (!r) return 0;
19759
+ const left = rebarBars(p.dims, p.thin, r.spacing, p.spec.structure?.role).length - (p.rt.severedBars?.length ?? 0);
19760
+ const along2 = p.dims.indexOf(Math.max(...p.dims));
19761
+ const side = Math.min(...p.dims.filter((_, a) => a !== along2));
19762
+ const fy = (materials.get(r.material)?.bending?.yieldMPa ?? STEEL_YIELD_MPA) * 1e6;
19763
+ return Math.max(0, left) / 2 * Math.PI * (r.diameter / 2) ** 2 * fy * Math.max(0, side - 2 * REBAR_COVER);
19764
+ };
19765
+ const memberSide = (p) => {
19766
+ const along2 = p.dims.indexOf(Math.max(...p.dims));
19767
+ return Math.min(...p.dims.filter((_, a) => a !== along2));
19768
+ };
19769
+ const tubeMoment = (p, share) => {
19770
+ const [a = 0, b = 0] = [...p.dims].sort((x, y) => x - y);
19771
+ const fy = (p.mat.bending?.yieldMPa ?? STEEL_YIELD_MPA) * 1e6;
19772
+ return fy * p.thickness * ((a + b) / 2) ** 2 * Math.max(0, 1 - share) ** 2;
19773
+ };
19774
+ const holdsAbove = (o, p, j) => {
19775
+ if (j.st.open) return false;
19776
+ const other = o.parts[j.ia === o.idx.get(p.spec.id) ? j.ib : j.ia];
19777
+ if (j.bears === "a_on_b") return j.spec.b === p.spec.id;
19778
+ if (j.bears === "b_on_a") return j.spec.a === p.spec.id;
19779
+ return partXf(o, other).c[1] > partXf(o, p).c[1] + 1e-6;
19780
+ };
19781
+ const hingeAcross = (o, p, opened, cut, src) => {
19782
+ var _a;
19783
+ const blow2 = cut.d ? objLocalDir(o, cut.d) : [1, 0, 0];
19784
+ const across2 = vec.normalize([blow2[0], 0, blow2[2]], [1, 0, 0]);
19785
+ const point = vec.madd(vec.add(p.pos, rotateVec(p.q, cut.at)), across2, cut.behind);
19786
+ const toward = vec.scale(across2, -1);
19787
+ const moment = cut.moment;
19788
+ const hinges = (_a = p.rt).hinges ?? (_a.hinges = []);
19789
+ for (const j of opened) {
19790
+ j.st.yields = { point, toward, moment };
19791
+ hinges.push({ joint: j.spec.id, point, toward, moment });
19792
+ }
19793
+ emitYields(o, p, src);
19794
+ };
19795
+ const reyield = (o, p, moment, src) => {
19796
+ for (const h of p.rt.hinges ?? []) h.moment = moment;
19797
+ for (const j of o.byPart.get(p.spec.id) ?? []) if (j.st.yields) j.st.yields.moment = moment;
19798
+ emitYields(o, p, src);
19799
+ };
19800
+ const emitYields = (o, p, src) => {
19801
+ for (const h of p.rt.hinges ?? []) {
19802
+ const point = toWorld(o.st.position, o.st.rotation, h.point);
19803
+ emit({ ...base2(o, src), type: "yield", part: p.spec.id, joint: h.joint, point, toward: rotateVec(o.st.rotation, h.toward), moment: h.moment });
19804
+ }
19805
+ };
19806
+ const severBars = (o, p, origin, d, caliber, src) => {
19807
+ var _a;
19808
+ const r = p.spec.reinforcement;
19809
+ if (!r || isLost(p) || !isMember(p.dims, p.spec.structure?.role)) return;
19810
+ const along2 = p.dims.indexOf(Math.max(...p.dims));
19811
+ const [u, v] = [0, 1, 2].filter((k) => k !== along2);
19812
+ const lo = toLocal(p.pos, p.q, objLocal(o, origin));
19813
+ const ld = rotateVec(quat.conjugate(p.q), objLocalDir(o, d));
19814
+ const across2 = Math.hypot(ld[u], ld[v]);
19815
+ if (across2 < 1e-6) return;
19816
+ const cut = (_a = p.rt).severedBars ?? (_a.severedBars = []);
19817
+ let severed = 0;
19818
+ rebarBars(p.dims, p.thin, r.spacing, p.spec.structure?.role).forEach(([a], i) => {
19819
+ if (cut.includes(i)) return;
19820
+ const du = a[u] - lo[u];
19821
+ const dv = a[v] - lo[v];
19822
+ if (Math.abs(du * ld[v] - dv * ld[u]) / across2 > r.diameter / 2 + caliber / 2e3) return;
19823
+ cut.push(i);
19824
+ severed++;
19825
+ const s = (du * ld[u] + dv * ld[v]) / (across2 * across2);
19826
+ const at2 = vec.madd(origin, d, s * vec.length(d));
19827
+ debris(o, p, "sparks", at2, vec.scale(d, -1), 6, 3, src);
19828
+ });
19829
+ if (severed > 0) reyield(o, p, barsMoment(p), src);
19830
+ };
19831
+ const giveAtCut = (o, p, src, cut) => {
19581
19832
  if (!p.spec.reinforcement || !p.spec.units || !p.st.chipped?.length || sectionLoss(p) <= 0) return false;
19582
19833
  const opened = [];
19583
19834
  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;
19835
+ if (!j.bears || !holdsAbove(o, p, j)) continue;
19587
19836
  j.st.open = true;
19588
19837
  j.st.openedBy = "break";
19589
19838
  opened.push(j);
@@ -19591,8 +19840,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19591
19840
  if (opened.length === 0) return false;
19592
19841
  p.st.hp = Math.max(p.st.hp, p.st.maxHp * GIVE_AT_CUT_HP);
19593
19842
  markDamaged(p);
19843
+ if (cut) hingeAcross(o, p, opened, { at: cut.at, d: cut.d, behind: memberSide(p) / 2 - REBAR_COVER, moment: barsMoment(p) }, src);
19594
19844
  loosened(o, opened, "break", src);
19595
- exposeRebar(o, p, src);
19845
+ exposeRebar(o, p, src, !cut);
19596
19846
  collapseCheck(o, src);
19597
19847
  return true;
19598
19848
  };
@@ -19620,7 +19870,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19620
19870
  p.st.status = "broken";
19621
19871
  p.st.hp = 0;
19622
19872
  p.st.mass = 0;
19623
- emit({ ...base(o, src), type: "expose", part: p.spec.id, bars: [] });
19873
+ emit({ ...base2(o, src), type: "expose", part: p.spec.id, bars: [] });
19624
19874
  debris(o, p, "sparks", partXf(o, p).c, [0, 1, 0], 6, 3, src);
19625
19875
  partLost(o, p, src);
19626
19876
  };
@@ -19719,7 +19969,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19719
19969
  p.st.burning = false;
19720
19970
  p.rt.jet = false;
19721
19971
  }
19722
- emit({ ...base(o, src), type: "fracture", part: p.spec.id, style, fragments, point: hitW });
19972
+ emit({ ...base2(o, src), type: "fracture", part: p.spec.id, style, fragments, point: hitW });
19723
19973
  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
19974
  setStage(o, p, 3, {}, src);
19725
19975
  if (reinforcement) {
@@ -19727,7 +19977,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19727
19977
  return;
19728
19978
  }
19729
19979
  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 } : {} });
19980
+ 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
19981
  const fuel = burstFuel(p);
19732
19982
  blasts.push({ point: c, energy: ex.energy, radius: ex.radius, ...ex.lethalRadius !== void 0 ? { lethalRadius: ex.lethalRadius } : {}, ...fuel > 0 ? { fuel } : {}, source: src });
19733
19983
  }
@@ -19740,7 +19990,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19740
19990
  p.rt.chainDue = time + delay;
19741
19991
  primed.set(p, o);
19742
19992
  o.active = true;
19743
- emit({ ...base(o, src), type: "primed", part: p.spec.id, point: partXf(o, p).c, trigger, delay });
19993
+ emit({ ...base2(o, src), type: "primed", part: p.spec.id, point: partXf(o, p).c, trigger, delay });
19744
19994
  };
19745
19995
  const CHAIN_TRIGGER_OF = { ballistic: "shot", explosive: "explosion" };
19746
19996
  const severAxis = (p) => {
@@ -19749,13 +19999,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19749
19999
  const order2 = [0, 1, 2].sort((a, b) => d[b] - d[a]);
19750
20000
  return d[order2[0]] >= SEVER_ASPECT * d[order2[1]] && d[order2[0]] >= 3 * SEVER_BAND ? order2[0] : -1;
19751
20001
  };
20002
+ const roundSection = (o, p, d, holeWidth, depth) => {
20003
+ const axis = severAxis(p);
20004
+ if (axis < 0) return 1;
20005
+ const local = rotateVec(quat.conjugate(partXf(o, p).q), d);
20006
+ const [a, b] = [0, 1, 2].filter((k) => k !== axis);
20007
+ const across2 = Math.abs(local[a]) >= Math.abs(local[b]) ? p.dims[b] : p.dims[a];
20008
+ return Math.min(1, SEVER_TRACK * holeWidth / Math.max(across2, 1e-6)) * clamp2(depth, 0, 1);
20009
+ };
19752
20010
  const bandOf = (o, p, axis, origin) => {
19753
20011
  const { c, q } = partXf(o, p);
19754
20012
  const along2 = toLocal(c, q, origin)[axis];
19755
20013
  const L = p.dims[axis];
19756
20014
  return clamp2(Math.floor((along2 + L / 2) / SEVER_BAND), 0, Math.ceil(L / SEVER_BAND) - 1);
19757
20015
  };
19758
- const applyDamage = (o, p, amount, type, origin, dir, fragEnergy, cap, src, weight = 1) => {
20016
+ const applyDamage = (o, p, amount, type, origin, dir, fragEnergy, cap, src, weight = 1, section = 1) => {
19759
20017
  var _a;
19760
20018
  if (isLost(p) || amount <= 0) return 0;
19761
20019
  const prev = p.st.hp;
@@ -19764,7 +20022,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19764
20022
  if (axis >= 0 && p.st.hp > 0) {
19765
20023
  const band = bandOf(o, p, axis, origin);
19766
20024
  const cuts = (_a = p.rt).cuts ?? (_a.cuts = {});
19767
- cuts[band] = (cuts[band] ?? 0) + amount * (type === "ballistic" ? SEVER_BALLISTIC : 1);
20025
+ cuts[band] = (cuts[band] ?? 0) + amount * section * (type === "ballistic" ? SEVER_BALLISTIC : 1);
19768
20026
  if (cuts[band] >= p.st.maxHp * SEVER_BAND / p.dims[axis]) {
19769
20027
  p.rt.cutAt = -p.dims[axis] / 2 + (band + 0.5) * SEVER_BAND;
19770
20028
  p.st.hp = 0;
@@ -19777,7 +20035,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19777
20035
  if (p.st.hp <= 0 && p.mat.fracture === "none" && !p.spec.explodes) p.st.hp = Math.min(prev, 1);
19778
20036
  if (p.st.hp <= 0 && type === "ballistic" && wornLocally(p)) p.st.hp = Math.min(prev, 1);
19779
20037
  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 });
20038
+ 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
20039
  if (p.st.hp <= 0) failPart(o, p, origin, dir, fragEnergy * weight, cap, src);
19782
20040
  else if (chained && (trigger === "explosion" || 1 - p.st.hp / p.st.maxHp >= shotDamageFractionOf(p.spec))) prime(o, p, trigger, src);
19783
20041
  return done;
@@ -19819,27 +20077,29 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19819
20077
  const n = shot ? exit ? clamp2(Math.round(E / joules), 1, 7) : 1 : clamp2(Math.floor(E / joules), 0, 5);
19820
20078
  if (n === 0) return;
19821
20079
  const fibre = tear === "lumps";
20080
+ const strips = tear === "strips";
19822
20081
  const { q } = partXf(o, p);
19823
20082
  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
20083
  const fragments = [];
19825
20084
  for (let i = 0; i < n; i++) {
19826
- const back = !exit || i % 3 === 2;
20085
+ const back2 = !exit || i % 3 === 2;
19827
20086
  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());
20087
+ 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());
20088
+ 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
20089
  const size = [w, w, w];
19830
20090
  size[along2] = len;
19831
20091
  size[(along2 + 1) % 3] = w;
19832
20092
  size[(along2 + 2) % 3] = t;
19833
20093
  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);
20094
+ const speed = shot ? back2 ? 1.5 + 2 * rnd() : 2 + 4 * rnd() : 0.8 + 1.2 * rnd();
20095
+ const v = vec.scale(vec.normalize(vec.add(back2 ? vec.scale(d, -1) : d, spread3)), speed);
19836
20096
  const mass = size[0] * size[1] * size[2] * p.mat.density;
19837
20097
  fragments.push({
19838
20098
  id: `${p.spec.id}#t${tears++}-${i}`,
19839
20099
  part: p.spec.id,
19840
20100
  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),
20101
+ shape: fibre ? "chunk" : strips ? "scrap" : "splinter",
20102
+ center: back2 || !exit ? vec.madd(entry2, d, -0.01) : vec.madd(exit, d, 0.01),
19843
20103
  size,
19844
20104
  rotation: q,
19845
20105
  velocity: v,
@@ -19849,14 +20109,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19849
20109
  });
19850
20110
  }
19851
20111
  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 });
20112
+ emit({ ...base2(o, src), type: "chip", part: p.spec.id, center: exit ?? entry2, size: patch, rotation: q, fragments, torn: true });
19853
20113
  };
19854
20114
  const ballistic = (o, p, entry2, n, d, E, caliber, pathLen, src, round3 = {}) => {
19855
20115
  const mat = p.mat;
19856
- const piece2 = round3.piece;
19857
- const weight = piece2?.weight ?? 1;
20116
+ const piece3 = round3.piece;
20117
+ const weight = piece3?.weight ?? 1;
19858
20118
  const piercing = round3.piercing ?? 1;
19859
- if (p.st.stripped || p.st.opening && insideOpening(o, p, objLocal(o, entry2)) || insideChip(p, objLocal(o, entry2))) {
20119
+ 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
20120
  return { penetrated: true, exitEnergy: E, exitPoint: vec.madd(entry2, d, Math.min(pathLen, p.thickness)), damage: 0 };
19861
20121
  }
19862
20122
  const sin = Math.min(1, Math.abs(vec.dot(d, n)));
@@ -19870,14 +20130,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19870
20130
  const hard = mat.tags?.includes("metal") || mat.tags?.includes("masonry");
19871
20131
  const penMm = penetrationOf(mat, round3.penetration);
19872
20132
  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;
20133
+ const strength = piece3 && mat.strength?.ndrc ? mat.strength.compressiveMPa : void 0;
19874
20134
  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);
20135
+ 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
20136
  const scale = (mat.damageScale?.ballistic ?? 1) * (mat.fracture === "shatter" ? fragility(mat.ductility, p.thickness) : 1);
19877
20137
  const id = p.spec.id;
19878
20138
  if (!penetrated && mat.ricochetDeg && angle < mat.ricochetDeg) {
19879
20139
  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 });
20140
+ emit({ ...base2(o, src), type: "ricochet", part: id, point: entry2, direction: vec.normalize(r), energy: E * 0.4 });
19881
20141
  debris(o, p, mat.hitDebris, entry2, n, 3, 3, src);
19882
20142
  const dmg2 = applyDamage(o, p, E * DMG_PER_J * scale * 0.2, "ballistic", entry2, d, E * 0.1, 12, src, weight);
19883
20143
  return { penetrated: false, exitEnergy: 0, damage: dmg2 };
@@ -19888,10 +20148,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19888
20148
  const ratio = Ep / Math.max(thr, 1e-6);
19889
20149
  const crackLen = clamp2(0.03 + ratio * 0.2, 0.03, 0.8);
19890
20150
  let exitPoint;
20151
+ let shellShare = 0;
20152
+ const holeWidth = caliber / 1e3 * (mat.ductility >= 0.3 ? 1 : 1.5);
19891
20153
  if (penetrated) {
19892
20154
  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
20155
  exitPoint = vec.madd(entry2, d, exitDist);
19894
- const hole = addHole(o, p, entry2, n, caliber / 1e3 * (mat.ductility >= 0.3 ? 1 : 1.5), true, exitPoint, src);
20156
+ const hole = addHole(o, p, entry2, n, holeWidth, true, exitPoint, src);
20157
+ shellShare = wearsShell(p, hole.diameter * 2);
19895
20158
  if (p.layers.length > 0) spallOuter(o, p, exitPoint, -face, vec.scale(n, -1), Math.max(0.03, caliber / 1e3 * 4), src);
19896
20159
  addBreach(o, p, entry2, Math.PI * (hole.diameter / 2) * (hole.diameter / 2), E, d, src);
19897
20160
  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 +20162,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19899
20162
  if (p.spec.contains && (p.st.liters ?? 0) > 1e-4) {
19900
20163
  o.active = true;
19901
20164
  emit({
19902
- ...base(o, src),
20165
+ ...base2(o, src),
19903
20166
  type: "leak",
19904
20167
  part: id,
19905
20168
  fluid: p.spec.contains.fluid,
@@ -19919,8 +20182,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19919
20182
  debris(o, p, mat.hitDebris, entry2, n, clamp2(Math.round(E / 60) + 2, 2, 14), clamp2(Math.sqrt(E) / 6, 1, 8), src);
19920
20183
  wearJoints(o, p, (penetrated ? thr : E) * 0.02 * weight, void 0, 0, src, true, BULLET_JOINT_SPAN);
19921
20184
  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;
19923
- const dmg = applyDamage(o, p, absorbed * DMG_PER_J * scale, "ballistic", entry2, d, absorbed * 0.1, 12, src, weight);
20185
+ const absorbed = penetrated && (mat.ductility >= 0.5 && mat.fracture !== "tear" || hollowTear || mat.cellular === true) ? Math.min(E, thr) : E;
20186
+ const dmg = applyDamage(o, p, absorbed * DMG_PER_J * scale, "ballistic", entry2, d, absorbed * 0.1, 12, src, weight, roundSection(o, p, d, holeWidth, penetrated ? 1 : ratio));
20187
+ if (shellShare > 0 && !isLost(p)) yieldShell(o, p, shellShare, entry2, d, src);
19924
20188
  if (!isLost(p)) tearAt(o, p, "ballistic", entry2, penetrated ? exitPoint : void 0, d, E, caliber / 1e3, src);
19925
20189
  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
20190
  return { penetrated, exitEnergy: penetrated ? penMm !== void 0 ? E * (1 - thr / Ep) : E - thr / (hard ? piercing : 1) : 0, exitPoint, damage: dmg };
@@ -19938,13 +20202,37 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19938
20202
  const hinge = plateHinge(p.dims, toLocal(c, q, point), local);
19939
20203
  const toObject = (v) => rotateVec(p.q, v);
19940
20204
  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 });
20205
+ emit({ ...base2(o), type: "bend", part: p.spec.id, hinge: p.st.bendHinge, angle: p.st.bend - before, worldPoint: point });
19942
20206
  }
19943
20207
  const axis = severAxis(p);
19944
20208
  if (axis < 0 || snapRatio(p.dims, p.mat.bending, E, local, SEVER_ASPECT) < 1) return 0;
19945
20209
  p.rt.cutAt = clamp2(toLocal(c, q, point)[axis], -p.dims[axis] / 2, p.dims[axis] / 2);
19946
20210
  return Math.max(0, p.st.hp);
19947
20211
  };
20212
+ const wearsShell = (p, width) => {
20213
+ if (p.mat.ductility < 0.5 || p.thickness > THIN_SHEET_DISHING || p.spec.shape.kind !== "box") return 0;
20214
+ const [a = 0, b = 0, c = 0] = [...p.dims].sort((x, y) => x - y);
20215
+ if (c < 2 * b || b > 3 * a) return 0;
20216
+ p.rt.shellCut = (p.rt.shellCut ?? 0) + width;
20217
+ return Math.min(1, p.rt.shellCut / (2 * (a + b)));
20218
+ };
20219
+ const yieldShell = (o, p, share, entry2, d, src) => {
20220
+ if (share < SHELL_YIELD_SHARE) return;
20221
+ if (p.rt.hinges?.length) {
20222
+ reyield(o, p, tubeMoment(p, share), src);
20223
+ return;
20224
+ }
20225
+ const opened = (o.byPart.get(p.spec.id) ?? []).filter((j) => holdsAbove(o, p, j));
20226
+ if (opened.length === 0) return;
20227
+ for (const j of opened) {
20228
+ j.st.open = true;
20229
+ j.st.openedBy = "break";
20230
+ }
20231
+ const along2 = p.dims.indexOf(Math.max(...p.dims));
20232
+ 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);
20233
+ loosened(o, opened, "break", src);
20234
+ collapseCheck(o, src);
20235
+ };
19948
20236
  const melee = (o, p, kind, E, point, n, d, contactR, src) => {
19949
20237
  const mat = p.mat;
19950
20238
  const thrMm = mat.penetration * p.thickness * 1e3;
@@ -20035,7 +20323,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20035
20323
  frontQueue.push({ o, p, due: time + dist / blastFrontSpeed, amount, fragEnergy: Ein * 0.3, point, ...src !== void 0 ? { src } : {} });
20036
20324
  return reach2;
20037
20325
  }
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);
20326
+ 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
20327
  const breachReach = BREACH_BLAST_REACH * Math.cbrt(Math.max(0, energy) / 1e3);
20040
20328
  const caged2 = Boolean(p.spec.reinforcement && p.spec.units);
20041
20329
  const member = caged2 && (isMember(p.dims, p.spec.structure?.role) || dist > MEMBER_CUT_REACH * breachReach);
@@ -20394,7 +20682,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20394
20682
  for (let i = 0; i < 4 && E > 0; i++) {
20395
20683
  const reach2 = flight ? E > flight.minEnergy ? Math.log(E / flight.minEnergy) / (2 * flight.drag) : 0 : Infinity;
20396
20684
  if (!(reach2 > 0)) break;
20397
- const rh = raycastInternal(org, d, reach2, ignore, false, true);
20685
+ const crossed = [];
20686
+ const rh = raycastInternal(org, d, reach2, ignore, false, true, {}, void 0, true, crossed);
20687
+ for (const c of crossed) if (!rh || c.t < rh.distance) severBars(c.o, c.p, org, d, caliber, source);
20398
20688
  if (!rh) break;
20399
20689
  if (flight) E *= Math.exp(-2 * flight.drag * vec.distance(org, rh.point));
20400
20690
  const im = impls.get(rh.object);
@@ -20591,14 +20881,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20591
20881
  }
20592
20882
  return out;
20593
20883
  }
20594
- const mergeResults = (base2, extra) => {
20595
- const byObject = new Map(base2.map((r) => [r.object, r]));
20884
+ const mergeResults = (base22, extra) => {
20885
+ const byObject = new Map(base22.map((r) => [r.object, r]));
20596
20886
  for (const r of extra) {
20597
20887
  const have = byObject.get(r.object);
20598
20888
  if (!have) {
20599
20889
  const copy = { ...r, events: [...r.events] };
20600
20890
  byObject.set(r.object, copy);
20601
- base2.push(copy);
20891
+ base22.push(copy);
20602
20892
  continue;
20603
20893
  }
20604
20894
  have.damage += r.damage;
@@ -20606,7 +20896,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20606
20896
  have.events.push(...r.events);
20607
20897
  if (!have.part && r.part) have.part = r.part;
20608
20898
  }
20609
- return base2;
20899
+ return base22;
20610
20900
  };
20611
20901
  function* blastSteps(point, energy, radius, src, call, only, lethal) {
20612
20902
  const cfg = blastCfg(call);
@@ -20858,7 +21148,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20858
21148
  p.st.temperature = Math.max(p.st.temperature, th.flameC ?? 800);
20859
21149
  o.active = true;
20860
21150
  markDamaged(p);
20861
- emit({ ...base(o, src), type: "ignite", part: p.spec.id, point: partXf(o, p).c });
21151
+ emit({ ...base2(o, src), type: "ignite", part: p.spec.id, point: partXf(o, p).c });
20862
21152
  };
20863
21153
  const syncMass = (p) => {
20864
21154
  p.st.mass = Math.max(0, p.mass0 * (1 - p.st.melt) - (p.fuel0 - p.st.fuel));
@@ -20884,11 +21174,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20884
21174
  p.st.status = "ashes";
20885
21175
  p.st.hp = 0;
20886
21176
  p.st.mass = p.mass0 * (1 - (th.fuelFraction ?? 0));
20887
- emit({ ...base(o), type: "burnout", part: p.spec.id, point: c });
21177
+ emit({ ...base2(o), type: "burnout", part: p.spec.id, point: c });
20888
21178
  debris(o, p, "ash", c, [0, 1, 0], clamp2(Math.round(Math.cbrt(partVolume(p.spec.shape)) * 30), 3, 20), 1);
20889
21179
  partLost(o, p);
20890
21180
  } else {
20891
- emit({ ...base(o), type: "burnout", part: p.spec.id, point: c });
21181
+ emit({ ...base2(o), type: "burnout", part: p.spec.id, point: c });
20892
21182
  }
20893
21183
  }
20894
21184
  };
@@ -20905,11 +21195,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20905
21195
  p.rt.dripT -= 0.25;
20906
21196
  const b = partWorldAabb(o, p);
20907
21197
  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 });
21198
+ emit({ ...base2(o), type: "drip", part: p.spec.id, point: pt, material: p.mat.id });
20909
21199
  }
20910
21200
  if (p.st.melt - p.rt.meltEmitted >= 0.05 || p.st.melt >= 1) {
20911
21201
  p.rt.meltEmitted = p.st.melt;
20912
- emit({ ...base(o), type: "melt", part: p.spec.id, melt: p.st.melt });
21202
+ emit({ ...base2(o), type: "melt", part: p.spec.id, melt: p.st.melt });
20913
21203
  }
20914
21204
  if (p.st.melt >= 1) {
20915
21205
  p.st.status = "melted";
@@ -20982,7 +21272,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20982
21272
  }
20983
21273
  p.rt.jet = true;
20984
21274
  s.burning = true;
20985
- emit({ ...base(o), type: "ignite", part: p.spec.id, point: partXf(o, p).c });
21275
+ emit({ ...base2(o), type: "ignite", part: p.spec.id, point: partXf(o, p).c });
20986
21276
  }
20987
21277
  }
20988
21278
  }
@@ -20990,7 +21280,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20990
21280
  if (p.rt.jet && (s.liters ?? 0) <= 0) {
20991
21281
  p.rt.jet = false;
20992
21282
  s.burning = false;
20993
- emit({ ...base(o), type: "extinguish", part: p.spec.id });
21283
+ emit({ ...base2(o), type: "extinguish", part: p.spec.id });
20994
21284
  }
20995
21285
  const sc = th.thermalShockC;
20996
21286
  if (sc !== void 0) {
@@ -21024,7 +21314,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21024
21314
  if (stress > 1) {
21025
21315
  if (p.rt.stressT <= 0) {
21026
21316
  p.rt.stressT = 0.5;
21027
- emit({ ...base(o), type: "stress", part: p.spec.id, stress, load: p.st.load ?? 0 });
21317
+ emit({ ...base2(o), type: "stress", part: p.spec.id, stress, load: p.st.load ?? 0 });
21028
21318
  if (p.spec.reinforcement && (p.st.stripped || p.st.chipped?.length || p.st.opening)) exposeRebar(o, p);
21029
21319
  }
21030
21320
  applyDamage(o, p, overloadRate(stress) * p.st.maxHp * dt, "blunt", null, null, 5, 3);
@@ -21338,6 +21628,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21338
21628
  setRayBroadPhase(broadPhase2) {
21339
21629
  rayBroad = broadPhase2;
21340
21630
  },
21631
+ setSurfaceTracer(tracer) {
21632
+ surfaceTracer = tracer;
21633
+ },
21341
21634
  groundLoss(loss) {
21342
21635
  if (!(loss.radius > 0) || !(loss.depth > 0) || !Number.isFinite(loss.x) || !Number.isFinite(loss.z)) return;
21343
21636
  pendingLosses.push({ ...loss });
@@ -21402,7 +21695,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21402
21695
  const step = Math.floor(j.st.progress * 10 + 1e-9);
21403
21696
  if (step > j.step || j.st.progress >= 1) {
21404
21697
  j.step = step;
21405
- emit({ ...base(o), type: "disassemble_progress", joint: j.spec.id, tool: tool2, progress: j.st.progress });
21698
+ emit({ ...base2(o), type: "disassemble_progress", joint: j.spec.id, tool: tool2, progress: j.st.progress });
21406
21699
  }
21407
21700
  if (j.st.progress >= 1) {
21408
21701
  j.st.open = true;
@@ -21488,7 +21781,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21488
21781
  if (p.st.burning) {
21489
21782
  p.st.burning = false;
21490
21783
  p.rt.jet = false;
21491
- emit({ ...base(o), type: "extinguish", part: p.spec.id });
21784
+ emit({ ...base2(o), type: "extinguish", part: p.spec.id });
21492
21785
  }
21493
21786
  p.st.temperature = Math.max(ambient, p.st.temperature - coolC);
21494
21787
  }
@@ -21520,7 +21813,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21520
21813
  if (p.st.holes.length > maxHoles) p.st.holes.shift();
21521
21814
  o.active = true;
21522
21815
  emit({
21523
- ...base(o),
21816
+ ...base2(o),
21524
21817
  type: "leak",
21525
21818
  part: partId,
21526
21819
  fluid: c.fluid,
@@ -21614,6 +21907,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21614
21907
  time,
21615
21908
  rng: rng3.state(),
21616
21909
  counter,
21910
+ ...tears > 0 ? { tears } : {},
21617
21911
  objects: [...objects.values()].map(serializeObject),
21618
21912
  ...impls.size ? { impls: [...impls.values()].map((im) => ({ id: im.impl.id, position: [...im.position], rotation: [...im.rotation], data: im.impl.serialize?.() })) } : {}
21619
21913
  };
@@ -21638,6 +21932,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21638
21932
  time = snap.time;
21639
21933
  rng3.set(snap.rng);
21640
21934
  counter = snap.counter ?? 0;
21935
+ tears = snap.tears ?? 0;
21641
21936
  for (const e of snap.objects) putObject(e.id, buildFromEntry(e, e.id));
21642
21937
  for (const e of snap.impls ?? []) {
21643
21938
  const im = impls.get(e.id);
@@ -21730,7 +22025,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21730
22025
  var defaultSet;
21731
22026
  var defaultAssemblies = () => defaultSet ?? (defaultSet = assembliesOver(ASSEMBLIES));
21732
22027
  var getAssembly = (id) => defaultAssemblies().get(id);
21733
- var faceCount = (layer) => layer.faces === "both" ? 2 : 1;
22028
+ var faceCount = (layer) => layer.faces === "both" || layer.faces === "all" ? 2 : 1;
21734
22029
  var assemblyDepth = (def) => def.depth ?? def.core.thickness + (def.layers ?? []).reduce((sum, l) => sum + l.thickness * faceCount(l), 0);
21735
22030
  var buildAssemblyPart = (def, assemblyId, options) => {
21736
22031
  if (!def) throw new Error(`unknown assembly "${assemblyId}"`);
@@ -21904,8 +22199,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21904
22199
  const id = w.add(onRock(s));
21905
22200
  return new Map(w.state(id).parts.map((p) => [p.id, p.flexure ?? 0]));
21906
22201
  };
21907
- const base = bending(out);
21908
- const factor = new Map(targets.map((p) => [p.id, (base.get(p.id) ?? 0) / safetyOf(p.structure.role)]));
22202
+ const base2 = bending(out);
22203
+ const factor = new Map(targets.map((p) => [p.id, (base2.get(p.id) ?? 0) / safetyOf(p.structure.role)]));
21909
22204
  if (options.redundancy !== void 0) {
21910
22205
  const roles = options.redundancyRoles ?? ["column"];
21911
22206
  for (const lost of out.parts) {
@@ -21949,11 +22244,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21949
22244
  return new Map(w.state(id).parts.map((p) => [p.id, { load: p.load ?? 0, stress: p.stress ?? 0, wind: p.wind ?? 0 }]));
21950
22245
  };
21951
22246
  const out = structuredClone(spec);
21952
- const base = loads(out, options.wind);
22247
+ const base2 = loads(out, options.wind);
21953
22248
  const gamma = options.wind ? resolveWind(options.wind).loadFactor : 0;
21954
22249
  const structural = out.parts.filter((p) => p.structure && p.structure.role !== "none");
21955
22250
  const loadAt = (p) => {
21956
- const b = base.get(p.id);
22251
+ const b = base2.get(p.id);
21957
22252
  return b && b.stress > 0 ? b.load + (b.wind > 0 ? gamma * b.wind / GRAVITY : 0) : void 0;
21958
22253
  };
21959
22254
  const lossesOf = function* () {
@@ -21982,7 +22277,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21982
22277
  if (options.wind) {
21983
22278
  const yieldMPa = resolveFlexure(options.flexure).rebarYieldMPa;
21984
22279
  for (const p of out.parts) {
21985
- const b = base.get(p.id);
22280
+ const b = base2.get(p.id);
21986
22281
  if (!b || b.wind >= 0 || !p.reinforcement || p.shape.kind !== "box") continue;
21987
22282
  const pull = -(b.load + gamma * b.wind / GRAVITY) * GRAVITY;
21988
22283
  if (pull <= 0) continue;
@@ -23035,8 +23330,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23035
23330
  return { parts: context.parts, supports: context.supports };
23036
23331
  }
23037
23332
  function anchorBalconies(context) {
23038
- const base = context.panelsOf.get("slab_base");
23039
- if (!base) return;
23333
+ const base2 = context.panelsOf.get("slab_base");
23334
+ if (!base2) return;
23040
23335
  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
23336
  for (const deck of decks) {
23042
23337
  const pillars = new Set(context.supports.filter((s) => s.part === deck.id && /^balcony_column_/.test(s.on)).map((s) => s.on));
@@ -23055,7 +23350,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23055
23350
  if (!splits.size) return input;
23056
23351
  const boxes = new Map(input.parts.map((part) => [part.id, part.aabb]));
23057
23352
  const pieceBox = /* @__PURE__ */ new Map();
23058
- for (const split of splits.values()) for (const piece2 of split.pieces) pieceBox.set(piece2.id, piece2.aabb);
23353
+ for (const split of splits.values()) for (const piece3 of split.pieces) pieceBox.set(piece3.id, piece3.aabb);
23059
23354
  const parts2 = input.parts.flatMap((part) => splits.get(part.id)?.pieces ?? [part]);
23060
23355
  const supports = [];
23061
23356
  for (const support of input.supports) {
@@ -23197,9 +23492,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23197
23492
  const spandrel = spandrels[k];
23198
23493
  if (spandrel) internal.push({ part: spandrel.id, on: lintel.id, joint: style.wallJoint });
23199
23494
  });
23200
- const base = [...piers, ...drafts.filter((d) => d.id.includes("_sill_"))].map((d) => d.id);
23495
+ const base2 = [...piers, ...drafts.filter((d) => d.id.includes("_sill_"))].map((d) => d.id);
23201
23496
  const top = [...piers.map((p) => p.id), ...lintels.map((l, k) => spandrels[k]?.id ?? l.id)];
23202
- return { pieces, internal, base, top };
23497
+ return { pieces, internal, base: base2, top };
23203
23498
  }
23204
23499
  var LOG_DIAMETER = 0.26;
23205
23500
  var isWall = (part) => part.id.startsWith("wall_") && part.assembly !== void 0 && (part.role === "wall" || part.role === "partition");
@@ -23261,7 +23556,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23261
23556
  if (capacity === void 0) continue;
23262
23557
  const along2 = (box22) => Math.max(box22[2] - box22[0], box22[3] - box22[1]);
23263
23558
  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));
23559
+ for (const piece3 of split.pieces) capacities.set(piece3.id, Math.max(1, capacity * along2(piece3.aabb) / length));
23265
23560
  }
23266
23561
  return { ...next, capacities };
23267
23562
  }
@@ -23485,10 +23780,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23485
23780
  const joints = [...spec.joints ?? []];
23486
23781
  const reinforcement = { material: "steel", spacing: c.rebar.spacing, diameter: c.rebar.diameter };
23487
23782
  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 });
23783
+ let base2 = raft2?.id;
23784
+ if (!base2) {
23785
+ base2 = "core_mat";
23786
+ 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
23787
  }
23493
23788
  const innerX = x0 + t + c.stairWidth + ti / 2;
23494
23789
  for (let f = 0; f < g.floors; f++) {
@@ -23496,7 +23791,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23496
23791
  const wall = (name, size, pos) => {
23497
23792
  const id = `core_${f}_${name}`;
23498
23793
  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");
23794
+ rests(joints, id, f === 0 ? base2 : `core_${f - 1}_${name}`, "rebar");
23500
23795
  return id;
23501
23796
  };
23502
23797
  const tube2 = [
@@ -23549,7 +23844,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23549
23844
  mass: 1500,
23550
23845
  tags: ["elevator_car"]
23551
23846
  });
23552
- rests(joints, id, base, "resting", false);
23847
+ rests(joints, id, base2, "resting", false);
23553
23848
  }
23554
23849
  return { ...spec, parts: parts2, joints };
23555
23850
  }
@@ -24272,9 +24567,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24272
24567
  const rule = storageRuleOf(rules, state.storage);
24273
24568
  const thawDays = rules.aging.thawShelfDays[state.storage];
24274
24569
  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) };
24570
+ const base2 = isThawing ? { ...state, ageDays: 0, shelfLife: thawDays } : state;
24571
+ const ageDays = base2.ageDays + accruedDays(state.storage, { storedAt: state.storedAt, from: state.since, to: now }, options);
24572
+ return { ...base2, ageDays, since: Math.max(now, state.since) };
24278
24573
  };
24279
24574
  var shelfRatio = (item, state) => {
24280
24575
  const shelfLife = state.shelfLife ?? item.shelfLife;
@@ -24305,12 +24600,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24305
24600
  var resolveUse = (item, effects, context = {}, rules = DEFAULT_RULES) => {
24306
24601
  const def = findEffect(item, effects);
24307
24602
  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;
24603
+ const base2 = { useId: def.id, effect: def.effect, params: def.params ?? {}, consumes: def.consumes };
24604
+ if (def.effect !== "consume_nutrition") return base2;
24310
24605
  const nutrition = nutritionOf(item, context, rules);
24311
24606
  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 };
24607
+ if (blocked) return { ...base2, consumes: false, nutrition: { ...nutrition, isEdible: false }, blocked };
24608
+ return { ...base2, consumes: def.consumes && nutrition.isEdible, nutrition };
24314
24609
  };
24315
24610
  var countOf = (context, id) => context.inventory.get(id) ?? 0;
24316
24611
  var candidatesOf = (input, context) => {
@@ -24447,10 +24742,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24447
24742
  };
24448
24743
  var countFor = (pool, state, footprint, query, rules) => {
24449
24744
  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);
24745
+ const base2 = Math.max(settings.min, Math.min(settings.max, Math.round(settings.offset + footprint * settings.perSquareMetre + query.rng() * settings.jitter)));
24746
+ if (state === "fortified") return Math.min(pool.length, base2 + settings.fortifiedExtra);
24452
24747
  if (state === "abandoned") return query.rng() < settings.abandonedEmptyChance ? 0 : settings.abandonedKept;
24453
- return base;
24748
+ return base2;
24454
24749
  };
24455
24750
  var rollExplicitPool = (pool, state, query, rules) => {
24456
24751
  const settings = rules.finds.pool;
@@ -43125,9 +43420,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
43125
43420
  var goodsItemUse = createGoodsItemUse();
43126
43421
 
43127
43422
  // ../game-interactables-household/dist/index.js
43128
- var door = (material, joint = "hinge", piece2 = "door") => ({ material, joint, piece: piece2 });
43423
+ var door = (material, joint = "hinge", piece22 = "door") => ({ material, joint, piece: piece22 });
43129
43424
  var drawer = { material: "mdf", joint: "slide", piece: "drawer" };
43130
43425
  var knob = { material: "plastic", joint: "clip", piece: "knob" };
43426
+ var mainLever = { material: "plastic", joint: "clip", piece: "breaker" };
43131
43427
  var tap = { material: "steel", joint: "screw", piece: "handle" };
43132
43428
  var mdfBody = { material: "mdf", joint: "screw" };
43133
43429
  var cabinet = { body: mdfBody, parts: [[/^drawer/, drawer], [/^door/, door("mdf")]] };
@@ -43162,19 +43458,23 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
43162
43458
  wall_socket: { body: { material: "plastic", joint: "screw" }, parts: [] },
43163
43459
  wall_switch: { body: { material: "plastic", joint: "screw" }, parts: [["rocker", { material: "plastic", joint: "clip", piece: "rocker" }]] },
43164
43460
  // 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")]] },
43461
+ service_entrance: { body: { material: "concrete", joint: "rebar", reinforcement: POLE_CAGE }, parts: [["meter_door", door("steel")], ["main_breaker", mainLever]] },
43166
43462
  conduit_run: { body: { material: "plastic", joint: "clip" }, parts: [] },
43167
- service_mast: { body: { material: "steel", joint: "clip" }, parts: [] },
43463
+ // 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)
43464
+ service_mast: { body: { material: "steel", joint: "weld" }, parts: [] },
43168
43465
  electrical_panel: {
43169
43466
  body: { material: "steel", joint: "screw" },
43170
43467
  parts: [[/^breaker/, { material: "plastic", joint: "clip", piece: "breaker" }], ["door", door("steel")]]
43171
43468
  },
43172
- power_meter: { body: { material: "plastic", joint: "screw" }, parts: [["door", door("plastic")]] },
43469
+ power_meter: { body: { material: "plastic", joint: "screw" }, parts: [["door", door("plastic")], ["main_breaker", mainLever]] },
43173
43470
  tv: { body: { material: "plastic", joint: "screw" }, parts: [["power", { material: "plastic", joint: "clip", piece: "button" }]] },
43174
43471
  microwave: { body: { material: "steel", joint: "screw" }, parts: [["door", door("steel")], ["dial", knob]] },
43175
43472
  washing_machine: { body: { material: "steel", joint: "screw" }, parts: [["dial", knob], ["door", door("tempered_glass")]] },
43176
43473
  sofa: { body: upholstery, parts: [] },
43177
43474
  armchair: { body: upholstery, parts: [] },
43475
+ pouf: { body: upholstery, parts: [] },
43476
+ box_bed: { body: upholstery, parts: [] },
43477
+ upholstered_chair: { body: upholstery, parts: [] },
43178
43478
  dining_chair: { body: { material: "wood_hard", joint: "screw" }, parts: [] },
43179
43479
  bed_double: { body: { material: "wood_soft", joint: "screw" }, parts: [] },
43180
43480
  bed_single: { body: { material: "wood_soft", joint: "screw" }, parts: [] },
@@ -43246,9 +43546,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
43246
43546
  "type.washing_machine": "Washing machine",
43247
43547
  "type.sofa": "Sofa",
43248
43548
  "type.armchair": "Armchair",
43549
+ "type.pouf": "Pouf",
43249
43550
  "type.dining_chair": "Dining chair",
43551
+ "type.upholstered_chair": "Upholstered chair",
43250
43552
  "type.bed_double": "Double bed",
43251
43553
  "type.bed_single": "Single bed",
43554
+ "type.box_bed": "Box bed",
43252
43555
  "type.bench": "Bench",
43253
43556
  "type.blinds": "Blinds",
43254
43557
  "type.curtain": "Curtain",
@@ -43401,6 +43704,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
43401
43704
  "prompt.breaker.off": "Switch on {circuit}",
43402
43705
  "prompt.breaker.off.verb": "Switch on",
43403
43706
  "prompt.breaker.off.object": "{circuit}",
43707
+ "prompt.main_breaker": "Main breaker",
43708
+ "prompt.main_breaker.on": "Switch off the main breaker",
43709
+ "prompt.main_breaker.on.verb": "Switch off",
43710
+ "prompt.main_breaker.on.object": "the main breaker",
43711
+ "prompt.main_breaker.off": "Switch on the main breaker",
43712
+ "prompt.main_breaker.off.verb": "Switch on",
43713
+ "prompt.main_breaker.off.object": "the main breaker",
43404
43714
  "type.bunk_bed": "Bunk bed",
43405
43715
  "type.wood_stove": "Wood stove",
43406
43716
  "type.fireplace": "Fireplace",
@@ -43494,9 +43804,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
43494
43804
  "type.washing_machine": "M\xE1quina de lavar",
43495
43805
  "type.sofa": "Sof\xE1",
43496
43806
  "type.armchair": "Poltrona",
43807
+ "type.pouf": "Pufe",
43497
43808
  "type.dining_chair": "Cadeira",
43809
+ "type.upholstered_chair": "Cadeira estofada",
43498
43810
  "type.bed_double": "Cama de casal",
43499
43811
  "type.bed_single": "Cama de solteiro",
43812
+ "type.box_bed": "Cama box",
43500
43813
  "type.bench": "Banco",
43501
43814
  "type.blinds": "Persiana",
43502
43815
  "type.curtain": "Cortina",
@@ -43649,6 +43962,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
43649
43962
  "prompt.breaker.off": "Ligar {circuit}",
43650
43963
  "prompt.breaker.off.verb": "Ligar",
43651
43964
  "prompt.breaker.off.object": "{circuit}",
43965
+ "prompt.main_breaker": "Disjuntor geral",
43966
+ "prompt.main_breaker.on": "Desligar o disjuntor geral",
43967
+ "prompt.main_breaker.on.verb": "Desligar",
43968
+ "prompt.main_breaker.on.object": "o disjuntor geral",
43969
+ "prompt.main_breaker.off": "Ligar o disjuntor geral",
43970
+ "prompt.main_breaker.off.verb": "Ligar",
43971
+ "prompt.main_breaker.off.object": "o disjuntor geral",
43652
43972
  "type.bunk_bed": "Beliche",
43653
43973
  "type.wood_stove": "Fog\xE3o a lenha",
43654
43974
  "type.fireplace": "Lareira",
@@ -44099,6 +44419,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
44099
44419
  pushable: true,
44100
44420
  massKg: 25
44101
44421
  },
44422
+ {
44423
+ id: "pouf",
44424
+ group: "seating",
44425
+ w: 0.45,
44426
+ d: 0.45,
44427
+ h: 0.42,
44428
+ y: 0,
44429
+ solid: true,
44430
+ pushable: true,
44431
+ massKg: 4
44432
+ },
44102
44433
  {
44103
44434
  id: "dining_chair",
44104
44435
  group: "seating",
@@ -44109,6 +44440,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
44109
44440
  solid: true,
44110
44441
  massKg: 5
44111
44442
  },
44443
+ {
44444
+ id: "upholstered_chair",
44445
+ group: "seating",
44446
+ w: 0.46,
44447
+ d: 0.52,
44448
+ h: 0.92,
44449
+ y: 0,
44450
+ solid: true,
44451
+ massKg: 6
44452
+ },
44112
44453
  {
44113
44454
  id: "bed_double",
44114
44455
  group: "seating",
@@ -44131,6 +44472,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
44131
44472
  pushable: true,
44132
44473
  massKg: 30
44133
44474
  },
44475
+ {
44476
+ id: "box_bed",
44477
+ group: "seating",
44478
+ w: 1.38,
44479
+ d: 1.88,
44480
+ h: 0.72,
44481
+ y: 0,
44482
+ solid: true,
44483
+ pushable: true,
44484
+ massKg: 75
44485
+ },
44134
44486
  {
44135
44487
  id: "bench",
44136
44488
  group: "seating",
@@ -44377,8 +44729,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
44377
44729
  "warn.buildEmpty": "construir devolveu vazio para {id}"
44378
44730
  };
44379
44731
  function createTranslator(locale, table) {
44380
- const base = locale && /^pt/i.test(locale) ? ptBR : en;
44381
- const messages = { ...base, ...table ?? {} };
44732
+ const base2 = locale && /^pt/i.test(locale) ? ptBR : en;
44733
+ const messages = { ...base2, ...table ?? {} };
44382
44734
  return (key2, params) => (messages[key2] ?? key2).replace(/\{(\w+)\}/g, (_m, name) => params && params[name] !== void 0 ? String(params[name]) : `{${name}}`);
44383
44735
  }
44384
44736
  var TYPE_MAP = Object.freeze({
@@ -44871,8 +45223,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
44871
45223
  var r3 = (n) => Math.round(n * 1e3) / 1e3;
44872
45224
  var CYLINDER_VALVE_Y = 0.47;
44873
45225
  var at = (it) => ({ x: it.x ?? 0, z: it.z ?? 0, ry: it.ry ?? 0 });
44874
- function mergeRegistry(base, extra) {
44875
- const out = { ...base };
45226
+ function mergeRegistry(base2, extra) {
45227
+ const out = { ...base2 };
44876
45228
  if (extra) {
44877
45229
  for (const [key2, value] of Object.entries(extra)) {
44878
45230
  if (value == null) delete out[key2];
@@ -46563,7 +46915,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
46563
46915
  rooms: (w, d, op) => {
46564
46916
  const hu0 = r22(w * 0.3), hu1 = r22(w * 0.7), n = floorCount(op, 3), el = !!op.elevator && n > 1;
46565
46917
  const ex = hu0 + (el ? 4.2 : 2.4);
46566
- const base = [
46918
+ const base2 = [
46567
46919
  { id: "sitting_room", type: "living", label: "sitting_room", rect: [0, 0, hu0, 7] },
46568
46920
  { id: "kitchen", type: "kitchen", label: "kitchen", rect: [0, 7, hu0, d - 3.2] },
46569
46921
  { id: "laundry", type: "laundry", label: "laundry", rect: [0, d - 3.2, hu0, d] },
@@ -46574,10 +46926,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
46574
46926
  { 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
46927
  { id: "bathroom", type: "bathroom", label: "bathroom_suite", library: "bathroom_wc", rect: [hu1, d - 3.3, w, d] }
46576
46928
  ];
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;
46929
+ if (n > 1) base2.push({ id: "stairs", type: "stairs", label: "stairs", rect: [hu0, d - 5, hu0 + 2.4, d], link: [0, 1] });
46930
+ if (el) base2.push({ id: "elevator", type: "elevator", label: "elevator", rect: [hu0 + 2.4, d - 5, hu0 + 4.2, d] });
46931
+ base2.push({ id: "office", type: "office", label: "office", rect: [n > 1 ? ex : hu0, d - 5, hu1, d] });
46932
+ return base2;
46581
46933
  },
46582
46934
  doors: (w, d, op) => {
46583
46935
  const hu0 = r22(w * 0.3), hu1 = r22(w * 0.7), n = floorCount(op, 3), el = !!op.elevator && n > 1;
@@ -46951,7 +47303,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
46951
47303
  }
46952
47304
  var residentialTower = residentialTowerTemplate();
46953
47305
 
46954
- // ../game-floorplan-three/dist/chunk-OGYLJ4F7.js
47306
+ // ../game-floorplan-three/dist/chunk-XI3CKQAV.js
46955
47307
  var __defProp3 = Object.defineProperty;
46956
47308
  var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp3(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
46957
47309
  var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
@@ -46964,6 +47316,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
46964
47316
  "what.door": "the door",
46965
47317
  "what.curtain": "the curtain",
46966
47318
  "what.mailbox": "the mailbox",
47319
+ "what.stallDoor": "the shower door",
46967
47320
  "what.pedestrianGate": "the small gate",
46968
47321
  "what.garageGate": "the garage gate",
46969
47322
  "what.drawer": "drawer",
@@ -46989,6 +47342,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
46989
47342
  "what.door": "a porta",
46990
47343
  "what.curtain": "a cortina",
46991
47344
  "what.mailbox": "a caixa de correio",
47345
+ "what.stallDoor": "a porta do box",
46992
47346
  "what.pedestrianGate": "o port\xE3ozinho",
46993
47347
  "what.garageGate": "o port\xE3o da garagem",
46994
47348
  "what.drawer": "gaveta",
@@ -47024,15 +47378,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
47024
47378
  for (let axis = 0; axis < 3; axis++) {
47025
47379
  const lo = axis, hi = axis + 3;
47026
47380
  if (b[lo] > box4[lo] + EPS3) {
47027
- const piece2 = [...box4];
47028
- piece2[hi] = b[lo];
47029
- out.push(piece2);
47381
+ const piece22 = [...box4];
47382
+ piece22[hi] = b[lo];
47383
+ out.push(piece22);
47030
47384
  box4[lo] = b[lo];
47031
47385
  }
47032
47386
  if (b[hi] < box4[hi] - EPS3) {
47033
- const piece2 = [...box4];
47034
- piece2[lo] = b[hi];
47035
- out.push(piece2);
47387
+ const piece22 = [...box4];
47388
+ piece22[lo] = b[hi];
47389
+ out.push(piece22);
47036
47390
  box4[hi] = b[hi];
47037
47391
  }
47038
47392
  }
@@ -47042,14 +47396,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
47042
47396
  const laid = [];
47043
47397
  for (const solid of solids) {
47044
47398
  let pieces = [solid.box];
47045
- for (const before of laid) pieces = pieces.flatMap((piece2) => subtractBox(piece2, before.box));
47399
+ for (const before of laid) pieces = pieces.flatMap((piece22) => subtractBox(piece22, before.box));
47046
47400
  for (const box4 of pieces) laid.push({ ...solid, box: box4 });
47047
47401
  }
47048
47402
  return laid;
47049
47403
  }
47050
47404
  function outsideBoxes(box4, taken) {
47051
47405
  let pieces = [box4];
47052
- for (const t of taken) pieces = pieces.flatMap((piece2) => subtractBox(piece2, t));
47406
+ for (const t of taken) pieces = pieces.flatMap((piece22) => subtractBox(piece22, t));
47053
47407
  return pieces;
47054
47408
  }
47055
47409
  function installKernelGeometry(K, shared2) {
@@ -47377,7 +47731,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
47377
47731
  nz = -nz;
47378
47732
  [a, b] = [pts[0], pts[1]];
47379
47733
  }
47380
- const [cr, cg, cb] = rgbOf(color2), scale = UV_SCALE[mat] || 1, base = A.nv;
47734
+ const [cr, cg, cb] = rgbOf(color2), scale = UV_SCALE[mat] || 1, base2 = A.nv;
47381
47735
  let e1x = b[0] - a[0], e1y = b[1] - a[1], e1z = b[2] - a[2];
47382
47736
  const l1 = Math.hypot(e1x, e1y, e1z) || 1;
47383
47737
  e1x /= l1;
@@ -47385,7 +47739,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
47385
47739
  e1z /= l1;
47386
47740
  const e2x = ny * e1z - nz * e1y, e2y = nz * e1x - nx * e1z, e2z = nx * e1y - ny * e1x;
47387
47741
  pts.forEach((p, k) => {
47388
- const o = base + k;
47742
+ const o = base2 + k;
47389
47743
  A.p[o * 3] = p[0] - O[0];
47390
47744
  A.p[o * 3 + 1] = p[1] - O[1];
47391
47745
  A.p[o * 3 + 2] = p[2] - O[2];
@@ -47400,9 +47754,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
47400
47754
  A.u[o * 2 + 1] = (dx * e2x + dy * e2y + dz * e2z) / scale;
47401
47755
  });
47402
47756
  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;
47757
+ A.i[A.ni++] = base2;
47758
+ A.i[A.ni++] = base2 + k;
47759
+ A.i[A.ni++] = base2 + k + 1;
47406
47760
  }
47407
47761
  A.nv += n;
47408
47762
  }
@@ -48761,8 +49115,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
48761
49115
  const puts = (f, type, m0, extra) => {
48762
49116
  const ent = T2[type];
48763
49117
  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 || {});
49118
+ const com = shared2.ctx.roomById[m0.room], g = "f" + f, base2 = Y0(f);
49119
+ 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
49120
  cursor.group = g;
48767
49121
  lightItem({ id: m0.id, room: m0.room }, M, ent, api, g);
48768
49122
  };
@@ -49583,7 +49937,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
49583
49937
  }
49584
49938
  const AC = accFor(mat), m = L.length, [cr, cg, cb] = rgbOf(color2), O = cursor.org;
49585
49939
  AC.ensure(m * 2, (m - 1) * 6);
49586
- const base = AC.nv, w2 = 2 * Math.PI / P;
49940
+ const base2 = AC.nv, w2 = 2 * Math.PI / P;
49587
49941
  const profile = (sv) => {
49588
49942
  const ph = sv * w2, hh = A + A * Math.sin(ph), dh = A * w2 * Math.cos(ph), ql = Math.hypot(dh, 1);
49589
49943
  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 +49953,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
49599
49953
  const sv = L[j], [hh, qx, qy, qz, v] = at2(sv);
49600
49954
  const cj = col[j] || col[j - 1] || col[j + 1] || [0, 0];
49601
49955
  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;
49956
+ 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
49957
  AC.p[oo * 3] = px - O[0];
49604
49958
  AC.p[oo * 3 + 1] = py - O[1];
49605
49959
  AC.p[oo * 3 + 2] = pz - O[2];
@@ -49615,7 +49969,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
49615
49969
  }
49616
49970
  for (let j = 0; j + 1 < m; j++) {
49617
49971
  if (!col[j] && !col[j + 1]) continue;
49618
- const a0 = base + j * 2, a1 = a0 + 1, b0 = a0 + 2, b1 = a0 + 3;
49972
+ const a0 = base2 + j * 2, a1 = a0 + 1, b0 = a0 + 2, b1 = a0 + 3;
49619
49973
  AC.i[AC.ni++] = a0;
49620
49974
  AC.i[AC.ni++] = b0;
49621
49975
  AC.i[AC.ni++] = a1;
@@ -50315,12 +50669,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50315
50669
  if (x1 - x0 < 1e-4 || y1 - y0 < 1e-4 || z1 - z0 < 1e-4) return;
50316
50670
  for (const [normal, corners] of FACES2) {
50317
50671
  if (openBottom && normal[1] < 0) continue;
50318
- const base = this.positions.length / 3;
50672
+ const base2 = this.positions.length / 3;
50319
50673
  for (const [cx, cy, cz] of corners) {
50320
50674
  this.positions.push(cx ? x1 : x0, cy ? y1 : y0, cz ? z1 : z0);
50321
50675
  this.normals.push(normal[0], normal[1], normal[2]);
50322
50676
  }
50323
- this.indices.push(base, base + 1, base + 2, base, base + 2, base + 3);
50677
+ this.indices.push(base2, base2 + 1, base2 + 2, base2, base2 + 2, base2 + 3);
50324
50678
  }
50325
50679
  }
50326
50680
  /**
@@ -50341,12 +50695,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50341
50695
  const out = [0, 1, 2].reduce((sum, k) => sum + n[k] * ((a[k] + b[k] + c[k] + d[k]) / 4 - centre[k]), 0);
50342
50696
  const ring2 = out >= 0 ? [a, b, c, d] : [a, d, c, b];
50343
50697
  if (out < 0) n = n.map((x) => -x);
50344
- const base = this.positions.length / 3;
50698
+ const base2 = this.positions.length / 3;
50345
50699
  for (const p of ring2) {
50346
50700
  this.positions.push(p[0], p[1], p[2]);
50347
50701
  this.normals.push(n[0], n[1], n[2]);
50348
50702
  }
50349
- this.indices.push(base, base + 1, base + 2, base, base + 2, base + 3);
50703
+ this.indices.push(base2, base2 + 1, base2 + 2, base2, base2 + 2, base2 + 3);
50350
50704
  }
50351
50705
  }
50352
50706
  /** A flat four-cornered face that looks along `normal` (it is wound so). */
@@ -50356,12 +50710,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50356
50710
  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
50711
  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
50712
  const ring2 = facing >= 0 ? corners : [corners[0], corners[3], corners[2], corners[1]];
50359
- const base = this.positions.length / 3;
50713
+ const base2 = this.positions.length / 3;
50360
50714
  for (const p of ring2) {
50361
50715
  this.positions.push(p[0], p[1], p[2]);
50362
50716
  this.normals.push(normal[0], normal[1], normal[2]);
50363
50717
  }
50364
- this.indices.push(base, base + 1, base + 2, base, base + 2, base + 3);
50718
+ this.indices.push(base2, base2 + 1, base2 + 2, base2, base2 + 2, base2 + 3);
50365
50719
  }
50366
50720
  /** The mesh of everything added, or null when nothing was. */
50367
50721
  mesh(THREE, material, name) {
@@ -50531,8 +50885,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50531
50885
  var DOOR_HEAD = 2.1;
50532
50886
  function crossesOpening(plan, a, b, y) {
50533
50887
  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;
50888
+ const base2 = plan.floors[o.floor]?.y0 ?? 0;
50889
+ if (y <= base2 + (o.y0 ?? 0) || y >= base2 + (o.y1 ?? DOOR_HEAD)) return false;
50536
50890
  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
50891
  const across2 = Math.min(p0, p1) <= o.pos + 0.1 && Math.max(p0, p1) >= o.pos - 0.1;
50538
50892
  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 +51106,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50752
51106
  const w = TRENCH.berm.width;
50753
51107
  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
51108
  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);
51109
+ 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])) {
51110
+ if (Math.min(piece22[2] - piece22[0], piece22[3] - piece22[1]) < TRENCH.berm.crest * 2) continue;
51111
+ addHumps(heap, piece22);
51112
+ laid.push(piece22);
50759
51113
  }
50760
51114
  }
50761
51115
  });
@@ -50900,7 +51254,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50900
51254
  function buriedSewerOf(plan) {
50901
51255
  const drains = drainsOf(plan);
50902
51256
  if (!drains.length) return [];
50903
- return sewerLayout(plan, drains).pieces.flatMap((piece2) => piece2.points.slice(1).map((b, i) => ({ a: piece2.points[i], b })));
51257
+ return sewerLayout(plan, drains).pieces.flatMap((piece22) => piece22.points.slice(1).map((b, i) => ({ a: piece22.points[i], b })));
50904
51258
  }
50905
51259
  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
51260
  function feedLayout(plan) {
@@ -50960,10 +51314,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50960
51314
  const dug = [...layout.trenches, ...rainwater.trenches, ...feeds.trenches, ...boxes.map(pitOf)];
50961
51315
  addSpoil(THREE, group, dug, mats.heap, { solids, footprint: houseFootprint(routingPlanOf(plan)), buildings: (plan.outbuildings ?? []).map((o) => o.aabb) });
50962
51316
  group.userData.excavations = dug.map(excavationOf);
50963
- for (const piece2 of layout.pieces) addPipe(THREE, group, piece2.points, piece2.bore / 2, mats.pipe);
51317
+ for (const piece22 of layout.pieces) addPipe(THREE, group, piece22.points, piece22.bore / 2, mats.pipe);
50964
51318
  const rainGroup = new THREE.Group();
50965
51319
  rainGroup.name = "rain_drains";
50966
- for (const piece2 of rainwater.pieces) addPipe(THREE, rainGroup, piece2.points, piece2.bore / 2, mats.rain);
51320
+ for (const piece22 of rainwater.pieces) addPipe(THREE, rainGroup, piece22.points, piece22.bore / 2, mats.rain);
50967
51321
  group.add(rainGroup);
50968
51322
  addWarningTape(THREE, group, feeds.runs);
50969
51323
  const yard = new THREE.Group();
@@ -51256,11 +51610,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
51256
51610
  });
51257
51611
  }
51258
51612
  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);
51613
+ 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
51614
  if (!tank2) return;
51261
51615
  const xyz = (p) => [p[0], p[1], p[2]];
51262
51616
  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]]];
51617
+ 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
51618
  cursor.group = shared2.ctx.waterTankPos && shared2.ctx.waterTankPos.group || "f0";
51265
51619
  cursor.pc = pieceRecord("pipe:run_outlet", "plastic", null, { tags: ["pipe"] });
51266
51620
  for (let i = 0; i + 1 < outlet.length; i++) pipe(outlet[i], outlet[i + 1], 0.032, PIPE_COLOR);
@@ -51415,8 +51769,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
51415
51769
  Object.assign(K, defined);
51416
51770
  }
51417
51771
  var EPS23 = 1e-4;
51418
- function subtractRects(base, holes) {
51419
- let pieces = [base];
51772
+ function subtractRects(base2, holes) {
51773
+ let pieces = [base2];
51420
51774
  for (const h of holes) {
51421
51775
  const next = [];
51422
51776
  for (const r of pieces) {
@@ -51557,8 +51911,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
51557
51911
  const depthOn = (side) => {
51558
51912
  const on = over.filter((c) => c.side === side);
51559
51913
  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);
51914
+ const least = Math.min(...on.map((c) => c.back)), back2 = Math.abs(least - mortar) < CHASE_CLEAR_OF_MORTAR ? mortar - CHASE_CLEAR_OF_MORTAR : least;
51915
+ return t / 2 - (back2 - inset);
51562
51916
  };
51563
51917
  const low = depthOn(-1), high = depthOn(1);
51564
51918
  box4(batch, p0, q0, p1, q1, t - low - high, (low - high) / 2);
@@ -51698,8 +52052,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
51698
52052
  const along2 = wall.alongU ? r.u : r.v, across2 = (wall.alongU ? r.v : r.u) - core.line;
51699
52053
  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
52054
  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 } : {} });
52055
+ const back2 = Math.abs(across2) - (r.depth ?? r.radius) - CHASE_CLEAR2;
52056
+ 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
52057
  }
51704
52058
  return out;
51705
52059
  }
@@ -52055,8 +52409,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52055
52409
  const alongU = Math.abs(point.frontV) >= Math.abs(point.frontU);
52056
52410
  const intoRoom = Math.sign(alongU ? point.frontV : point.frontU);
52057
52411
  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];
52412
+ const back2 = face - intoRoom * WALL_BOX.deep;
52413
+ const [low, high] = face < back2 ? [face, back2] : [back2, face];
52060
52414
  const half = WALL_BOX.along / 2;
52061
52415
  return {
52062
52416
  u0: alongU ? point.u - half : low,
@@ -52205,8 +52559,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52205
52559
  const M = en22.meter;
52206
52560
  if (M) {
52207
52561
  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);
52562
+ const back2 = shared2.ctx.visorScene ? 0 : 3e-3;
52563
+ 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
52564
  const fz = fr < 0 ? [M.v - hd - 0.012, M.v - hd] : [M.v + hd, M.v + hd + 0.012];
52211
52565
  if (!(KV && KV.meter)) {
52212
52566
  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 +52739,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52385
52739
  };
52386
52740
  for (const A of ws) for (const [side, sd] of [[A.w.sides[0], -1], [A.w.sides[1], 1]]) {
52387
52741
  if (!sideOf(side, false).exterior) continue;
52388
- const strip = (k, y1, y2, o0, o1, mat, c, piece2, laid = BASEBOARD_TILES) => {
52742
+ const strip = (k, y1, y2, o0, o1, mat, c, piece22, laid = BASEBOARD_TILES) => {
52389
52743
  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
52744
  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
52745
  if (s1 - s0 < 1e-3) return;
@@ -52409,7 +52763,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52409
52763
  runs.push([from, s1]);
52410
52764
  runs.forEach(([r0, r1], k2) => {
52411
52765
  if (r1 - r0 < 1e-3) return;
52412
- const id = piece2 && runs.length > 1 ? `${piece2}:${k2}` : piece2;
52766
+ const id = piece22 && runs.length > 1 ? `${piece22}:${k2}` : piece22;
52413
52767
  if (!id) box4(r0, r1);
52414
52768
  else if (shared2.ctx.baseboardBand) tile(id, r0, r1);
52415
52769
  else {
@@ -52497,12 +52851,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52497
52851
  const yA = roofHeightAt(p.u, p.v - hd), yB = roofHeightAt(p.u, p.v + hd), yC = roofHeightAt(p.u, p.v);
52498
52852
  let yc, tilt;
52499
52853
  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;
52854
+ const base2 = yC != null ? yC : Y0(fa) + 0.02, angle = (S.tilt || 15) * Math.PI / 180, high = Math.sin(angle) * p.length;
52501
52855
  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);
52856
+ yc = base2 + 0.25 + high / 2;
52857
+ const yLow = base2 + 0.25, yHigh = yLow + high;
52858
+ 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);
52859
+ 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
52860
  } else {
52507
52861
  if (yA == null || yB == null || yC == null) continue;
52508
52862
  tilt = Math.atan2(yA - yB, d);
@@ -52604,7 +52958,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52604
52958
  }
52605
52959
  function installFurnitureApi(K, shared2) {
52606
52960
  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" };
52961
+ 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
52962
  const mm = (k) => MATERIAL_MAP2[k] || "plain";
52609
52963
  const LIGHTS = [];
52610
52964
  function makeApi() {
@@ -53355,7 +53709,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53355
53709
  }
53356
53710
  function installFurnitureTaps(K, shared2) {
53357
53711
  shared2.tapCount = 0;
53358
- function counterTap(K2, x, y, z, reach2, back, meta = {}) {
53712
+ function counterTap(K2, x, y, z, reach2, back2, meta = {}) {
53359
53713
  const cr = 12896460, id = "tap_" + (K2.M.seed || "") + "_" + shared2.tapCount++;
53360
53714
  K2.c("metal", x, y, z, 0.028, 0.012, cr);
53361
53715
  K2.c("metal", x, y + 0.012, z, 0.014, 0.12, cr);
@@ -53382,11 +53736,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53382
53736
  );
53383
53737
  const ya = tip[1] - 0.05;
53384
53738
  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);
53739
+ K2.t("water", [tip[0], ya, tip[2]], [tip[0], y - back2, tip[2]], 6e-3, 13625588);
53386
53740
  }, { id: id + "_a", target: id, hidden: true, fluid: "water" });
53387
53741
  return id;
53388
53742
  }
53389
- function wallTap(K2, x, y, zw, direction, back, meta = {}) {
53743
+ function wallTap(K2, x, y, zw, direction, back2, meta = {}) {
53390
53744
  const cr = 12896460, id = "tap_" + (K2.M.seed || "") + "_" + shared2.tapCount++, s = direction || 1;
53391
53745
  K2.t("metal", [x, y, zw], [x, y, zw + s * 0.025], 0.03, cr);
53392
53746
  K2.t("metal", [x, y, zw + s * 0.02], [x, y, zw + s * 0.1], 0.016, cr);
@@ -53409,19 +53763,24 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53409
53763
  );
53410
53764
  const ya = y - 0.08;
53411
53765
  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);
53766
+ K2.t("water", [x, ya, zw + s * 0.105], [x, back2, zw + s * 0.105], 65e-4, 13625588);
53413
53767
  }, { id: id + "_a", target: id, hidden: true, fluid: "water" });
53414
53768
  return id;
53415
53769
  }
53416
53770
  const defined = { counterTap, wallTap };
53417
53771
  Object.assign(K, defined);
53418
53772
  }
53773
+ var SHOWER_DOOR = 0.72;
53774
+ var PANEL_THICKNESS = 0.02;
53775
+ var MIN_PANEL = 0.1;
53419
53776
  function installFurnitureFixtures(K, shared2) {
53777
+ const kernel = K;
53420
53778
  const seedKey = (id) => K.seedKey(id);
53421
53779
  const { FURNITURE, MIRRORS, SEED, arcPoints, cursor, kit2, rngString, sh } = K;
53422
53780
  FURNITURE.box = function(M, A) {
53423
53781
  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;
53782
+ const walkIn = !shared2.ctx.visorScene;
53783
+ 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
53784
  K2.b("plain", 0, 0, 0, w - 0.02, 0.05, d - 0.02, 15132902);
53426
53785
  K2.c("metal", 0, 0.05, 0, 0.045, 6e-3, 11580600);
53427
53786
  if (shared2.ctx.visorScene) K2.c("plain", 0, 0.05, 0, 0.032, 8e-3, 4212812);
@@ -53434,17 +53793,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53434
53793
  gl(px0, -d / 2 + 0.05, px0, pzF - R);
53435
53794
  const arc = arcPoints(px0 - R, pzF - R, R, 0, Math.PI / 2, 6);
53436
53795
  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);
53796
+ const front = walkIn ? Math.min(px0 - R, -w / 2 + 0.03 + SHOWER_DOOR) : Math.max(-w / 2 + 0.36, px0 - R - 0.5);
53797
+ const fx1 = walkIn && px0 - R - front < MIN_PANEL ? px0 - R : front, panel = px0 - R - fx1 > 0.01;
53798
+ if (panel) gl(px0 - R, pzF, fx1, pzF);
53439
53799
  const rail = (y, r) => {
53440
53800
  tube2([px0, y, -d / 2 + 0.05], [px0, y, pzF - R], r);
53441
53801
  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);
53802
+ if (panel) tube2([px0 - R, y, pzF], [fx1, y, pzF], r);
53443
53803
  };
53444
53804
  rail(gh, 0.011);
53445
53805
  rail(0.055, 9e-3);
53446
53806
  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);
53807
+ 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
53808
  const hx = fx1, dw = hx - (-w / 2 + 0.03);
53449
53809
  if (dw > 0.2) K2.part(
53450
53810
  "shower_door",
@@ -53459,6 +53819,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53459
53819
  },
53460
53820
  { id: id + "_door", opens: { type: "swing", axis: [0, 1, 0], angle: -1.7 } }
53461
53821
  );
53822
+ if (walkIn) {
53823
+ const panels = [[px0, -d / 2 + 0.05, px0, pzF - R]];
53824
+ 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]]);
53825
+ if (panel) panels.push([px0 - R, pzF, fx1, pzF]);
53826
+ kernel.walkInSolids(M, { panels, thickness: PANEL_THICKNESS, height: gh, door: dw > 0.2 ? { part: id + "_door", from: [hx, pzF], to: [hx - dw, pzF] } : null });
53827
+ }
53462
53828
  const ax = 0.1, ya = 2.08, z0 = zw + 0.012, Ra = 0.22, n = 6, pa = [];
53463
53829
  for (let i = 0; i <= n; i++) {
53464
53830
  const f = i / n * Math.PI / 2;
@@ -53669,12 +54035,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53669
54035
  var DOOR = { recess: 0.012, thick: 0.02, side: 4e-3, bottom: 0.03 };
53670
54036
  var LOUVRE = { proud: 3e-3, slat: 0.012, pitch: 0.025, count: 4 };
53671
54037
  function gasShelterBoxes({ side, height }) {
53672
- const half = side / 2, back = -half + SHELTER_OFF_WALL;
54038
+ const half = side / 2, back2 = -half + SHELTER_OFF_WALL;
53673
54039
  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] }
54040
+ { part: "wall", front: [back2, back2 + WALL], across: [-half, half], y: [0, height] },
54041
+ { part: "wall", front: [back2 + WALL, half], across: [-half, -half + WALL], y: [0, height] },
54042
+ { part: "wall", front: [back2 + WALL, half], across: [half - WALL, half], y: [0, height] },
54043
+ { part: "roof", front: [back2, half + EAVE2], across: [-half - EAVE2, half + EAVE2], y: [height, height + ROOF] }
53678
54044
  ];
53679
54045
  const doorFace = half - DOOR.recess, doorAcross = [-half + WALL + DOOR.side, half - WALL - DOOR.side];
53680
54046
  boxes.push({ part: "door", front: [doorFace - DOOR.thick, doorFace], across: doorAcross, y: [DOOR.bottom, height - DOOR.bottom] });
@@ -53825,10 +54191,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53825
54191
  if (shelterOf(M)) {
53826
54192
  } else if (M.hose && M.hose.length > 1) {
53827
54193
  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 = [];
54194
+ 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
54195
  for (let k = 0; k <= n; k++) {
53830
54196
  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]]);
54197
+ 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
54198
  }
53833
54199
  for (let k = 0; k < n; k++) K2.t("plain", pts[k], pts[k + 1], 0.011, 12071454);
53834
54200
  K2.c("metal", P2[0], P2[1] - 0.025, P2[2], 0.016, 0.05, brass);
@@ -54019,6 +54385,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54019
54385
  const { THREE, Y0, _col, boxC, colorOf, cursor, decorLights, makeApi, structurePiece, OPEN_AREA, rectsOf: rectsOf2 } = K;
54020
54386
  const buildItem2 = (...a) => K.buildItem(...a);
54021
54387
  const registerCollision = (...a) => K.registerCollision(...a);
54388
+ const kitCollides = (...a) => K.kitCollides(...a);
54022
54389
  const vegItem = (...a) => K.vegItem(...a);
54023
54390
  const SLAB_UNDERSIDE = 0.24;
54024
54391
  function houseItems() {
@@ -54042,8 +54409,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54042
54409
  if (exterior && m.category === "ground_cover" && shared2.ctx.noGroundSurfaces) continue;
54043
54410
  const f = exterior ? -1 : Math.min(m.floor, R.floors.length - 1);
54044
54411
  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 };
54412
+ 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;
54413
+ 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
54414
  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
54415
  if (lift) M.ceiling = (M.ceiling ?? 2.9) - lift;
54049
54416
  if (!exterior && !shared2.ctx.visorScene && f > 0) overRoof(m, M, f);
@@ -54086,13 +54453,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54086
54453
  }
54087
54454
  }
54088
54455
  if (shared2.ctx.iv && shared2.ctx.iv.replace.has(m.id)) {
54089
- registerCollision(m, M);
54456
+ if (!kitCollides(m)) registerCollision(m, M);
54090
54457
  continue;
54091
54458
  }
54092
54459
  const ent = T2[m.type];
54093
54460
  const st0 = cursor.stage;
54094
54461
  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;
54462
+ shared2.ctx.restOn = exterior || shared2.ctx.visorScene ? void 0 : base2;
54096
54463
  if (!shared2.ctx.visorScene) {
54097
54464
  const quarter = Math.round(M.ry / (Math.PI / 2));
54098
54465
  if (Math.abs(M.ry - quarter * Math.PI / 2) < 0.01) M.ry = quarter * Math.PI / 2;
@@ -54209,7 +54576,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54209
54576
  return;
54210
54577
  }
54211
54578
  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));
54579
+ 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
54580
  cursor.group = slab ? "f" + f : "attic_tank";
54214
54581
  const platformLift = !slab && !shared2.ctx.visorScene ? 0.12 : 0;
54215
54582
  if (lc) {
@@ -54228,12 +54595,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54228
54595
  }
54229
54596
  if (!slab) {
54230
54597
  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;
54598
+ const top = base2 + platformLift;
54232
54599
  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);
54600
+ 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
54601
  }
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 };
54602
+ 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 };
54603
+ shared2.ctx.waterTankPos = { x: cd.u, z: cd.v, y: base2 + platformLift, group: cursor.group };
54237
54604
  shared2.ctx.types.water_tank.f(M, api);
54238
54605
  }
54239
54606
  function trestleTank(api, cd) {
@@ -54634,8 +55001,29 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54634
55001
  const d1 = objectDistance(o, x, z);
54635
55002
  if (d1 < R && d1 < objectDistance(o, fx, fz) - 1e-6) return true;
54636
55003
  }
55004
+ return collideKit(x, z, fx, fz, floor, R);
55005
+ }
55006
+ function collideKit(x, z, fx, fz, floor, R) {
55007
+ const iv = shared2.ctx.iv, collided = iv && iv.collided;
55008
+ if (!iv || !collided || !collided.size) return false;
55009
+ for (const k of iv.world.colliders()) {
55010
+ const f = collided.get(k.object);
55011
+ if (f === void 0 || (f !== -1 ? f !== floor : floor !== 0)) continue;
55012
+ 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" };
55013
+ const d1 = objectDistance(o, x, z);
55014
+ if (d1 < R && d1 < objectDistance(o, fx, fz) - 1e-6) return true;
55015
+ }
54637
55016
  return false;
54638
55017
  }
55018
+ function kitCollides(m) {
55019
+ const iv = shared2.ctx.iv;
55020
+ if (!iv) return false;
55021
+ const own = [...iv.entries.values()].filter((e) => e.origin === m.id && (e.spec.colliders?.length ?? 0) > 0);
55022
+ if (!own.length) return false;
55023
+ const collided = iv.collided || (iv.collided = /* @__PURE__ */ new Map());
55024
+ for (const e of own) collided.set(e.id, e.floor);
55025
+ return true;
55026
+ }
54639
55027
  function collideAt(x, z, floor, opt) {
54640
55028
  opt = opt || {};
54641
55029
  const R = opt.radius != null ? opt.radius : 0.24;
@@ -54649,7 +55037,24 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54649
55037
  const de = opt.from || [x + 1e4, z + 1e4];
54650
55038
  return collideObject(x, z, de[0], de[1], floor);
54651
55039
  }
54652
- const defined = { NO_COLLIDE, registerCollision, objectDistance, collideObject, collideAt };
55040
+ function walkInSolids(M, spec) {
55041
+ const objs = shared2.inter?.objs, colliders = shared2.ctx.colliders;
55042
+ if (!objs || !colliders) return;
55043
+ const at2 = objs.findIndex((o) => o.cx === M.x && o.cz === M.z && o.f === M.floor);
55044
+ const kept = at2 >= 0 ? objs.splice(at2, 1)[0] : void 0;
55045
+ const type = kept?.type ?? "walk_in";
55046
+ const half = spec.thickness / 2;
55047
+ for (const [x0, z0, x1, z1] of spec.panels) {
55048
+ const length = Math.hypot(x1 - x0, z1 - z0);
55049
+ if (length < 1e-3) continue;
55050
+ const [cx, cz] = K.localOf(M, (x0 + x1) / 2, (z0 + z1) / 2), turn = (M.ry || 0) + Math.atan2(-(z1 - z0), x1 - x0);
55051
+ objs.push({ f: M.floor, cx, cz, c: Math.cos(turn), s: Math.sin(turn), hw: length / 2, hd: half, h: spec.height, type });
55052
+ }
55053
+ if (!spec.door) return;
55054
+ 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]);
55055
+ 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 });
55056
+ }
55057
+ const defined = { NO_COLLIDE, registerCollision, objectDistance, collideObject, collideAt, walkInSolids, kitCollides };
54653
55058
  Object.assign(K, defined);
54654
55059
  }
54655
55060
  function installInteractionItems(K, shared2) {
@@ -54856,13 +55261,26 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54856
55261
  const g = r.g;
54857
55262
  if (!isFinite(r.x0)) return;
54858
55263
  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 }));
55264
+ const base2 = { parent: "lot", ry: 0, t0: g.open ? 1 : 0, col: cols[i], gate: g };
55265
+ 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
55266
  if (p.col) p.col.off = p.target > 0.5;
54862
55267
  const text = () => t(p.target > 0.5 ? "prompt.close" : "prompt.open", { what: t(ped ? "what.pedestrianGate" : "what.garageGate") });
54863
55268
  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
55269
  });
54865
55270
  }
55271
+ function walkInInteractive() {
55272
+ for (const c of shared2.ctx.colliders) {
55273
+ if (c.type !== "walk_in_door" || typeof c.piece !== "string") continue;
55274
+ const g = shared2.ctx.parts && shared2.ctx.parts[c.piece];
55275
+ if (!g) continue;
55276
+ const def = definePiece("ix:walkin:" + c.piece, { kind: "part", pivot: [0, 0, 0], ry: 0, parent: "lot" });
55277
+ def.inner = g;
55278
+ def.col = c;
55279
+ c.off = def.t > 0.5;
55280
+ 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) });
55281
+ applyPiece(def);
55282
+ }
55283
+ }
54866
55284
  function mailboxInteractive() {
54867
55285
  for (const m of house().items) {
54868
55286
  if (m.type !== "mailbox") continue;
@@ -54920,15 +55338,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54920
55338
  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
55339
  cursor.group = g0;
54922
55340
  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;
55341
+ 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 });
55342
+ piece22.t = piece22.target = lightOn(roomId) ? 1 : 0;
54925
55343
  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) });
55344
+ 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
55345
  return true;
54928
55346
  }
54929
55347
  return false;
54930
55348
  }
54931
- const defined = { gatesInteractive, mailboxInteractive, placeSwitches, putSwitch };
55349
+ const defined = { walkInInteractive, gatesInteractive, mailboxInteractive, placeSwitches, putSwitch };
54932
55350
  Object.assign(K, defined);
54933
55351
  }
54934
55352
  function installInteractionDoors(K, shared2) {
@@ -55091,7 +55509,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55091
55509
  const { t, THREE, invalidate, invalidateShadow, cfg, DOC, LIGHT_TYPES, _Y, _q, _v3, accFor, applyLight, cursor, hashString: hashString2, hudMessage, lightBase, pieceRecord, rgbOf, wallBlocks } = K;
55092
55510
  const enter = (...a) => K.enter(...a);
55093
55511
  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" };
55512
+ 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
55513
  const IV_WIRE = { conduit: 13618628, cable: 2762532, drop: 1381653, cord: 1776413, earth: 3111482, hose: 11556124 };
55096
55514
  const IV_DOOR = /^(door|drawer)/;
55097
55515
  const ivGroup = (e) => e.floor < 0 ? "lot" : "f" + Math.min(e.floor, shared2.ctx.r.floors.length - 1);
@@ -55161,7 +55579,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55161
55579
  const entById = new Map(plane2.items.map((e) => [e.id, e]));
55162
55580
  const entByItem = new Map(plane2.items.map((e) => [e.item, e]));
55163
55581
  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 };
55582
+ 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
55583
  const ev = (e) => ivEvent(h, e);
55166
55584
  const world = IV.world = A.createWorld(source, { water, seed: r.seed, onEvent: ev });
55167
55585
  const add0 = world.add;
@@ -55272,7 +55690,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55272
55690
  cursor.stage = stage0;
55273
55691
  cursor.pc = pieceBefore;
55274
55692
  }
55275
- const base = new Set(Object.values(IV.mats));
55693
+ const base2 = new Set(Object.values(IV.mats));
55276
55694
  root.traverse((o) => {
55277
55695
  if (!isMesh(o)) return;
55278
55696
  o.userData.iv = ent.id;
@@ -55280,7 +55698,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55280
55698
  if (!o.geometry.boundingSphere) o.geometry.computeBoundingSphere();
55281
55699
  if (o.geometry.boundingSphere.radius < 0.07) o.castShadow = false;
55282
55700
  }
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) {
55701
+ 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
55702
  m.userData.roomLightMask = false;
55285
55703
  roomLightMask(m);
55286
55704
  }
@@ -55582,6 +56000,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55582
56000
  roomStates: IV.roomStates,
55583
56001
  warnings: IV.warnings,
55584
56002
  water: IV.water,
56003
+ solidColliders: () => {
56004
+ const c = IV.collided;
56005
+ return c && c.size ? w.colliders().flatMap((k) => {
56006
+ const floor = c.get(k.object);
56007
+ return floor === void 0 ? [] : [{ ...k, floor }];
56008
+ }) : [];
56009
+ },
55585
56010
  screens: IV.screens,
55586
56011
  effects: () => IV.efx || null,
55587
56012
  // TV screens (id -> kit screen) and the particle system (smoke), for whoever wants to inspect
@@ -56203,8 +56628,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56203
56628
  return { depth: Math.max(drawn, declared2?.depth ?? 0), width: declared2?.width ?? Math.max(u1 - u0, v1 - v0) };
56204
56629
  }
56205
56630
  function groundJointStrength(part, kind) {
56206
- const base = buriedBase(part);
56207
- return base.depth > 0 ? embedmentStrength(kind, base) : void 0;
56631
+ const base2 = buriedBase(part);
56632
+ return base2.depth > 0 ? embedmentStrength(kind, base2) : void 0;
56208
56633
  }
56209
56634
  var NONE = { panels: [], replaced: [], supports: [] };
56210
56635
  var MEMO = /* @__PURE__ */ new WeakMap();
@@ -56316,7 +56741,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56316
56741
  parts2.push(p);
56317
56742
  byId.set(p.id, p);
56318
56743
  }
56319
- const base = parts2.length, view = shared2.ctx.panelView || panelViewOf(null, false), panelIds = new Set(view.panels.map((e) => e.id));
56744
+ const base2 = parts2.length, view = shared2.ctx.panelView || panelViewOf(null, false), panelIds = new Set(view.panels.map((e) => e.id));
56320
56745
  for (const [id, pc] of shared2.ctx.pieces) {
56321
56746
  if (byId.has(id) || panelIds.has(id) || !meshes.has(id)) continue;
56322
56747
  const b = box32(id);
@@ -56346,7 +56771,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56346
56771
  const floorUnder = (p) => {
56347
56772
  const cx = (p.aabb[0] + p.aabb[2]) / 2, cz = (p.aabb[1] + p.aabb[3]) / 2;
56348
56773
  let best = null;
56349
- for (const q of parts2.slice(0, base)) {
56774
+ for (const q of parts2.slice(0, base2)) {
56350
56775
  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
56776
  if (!best || q.y1 > best.y1 || q.y1 === best.y1 && q.id < best.id) best = q;
56352
56777
  }
@@ -56379,7 +56804,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56379
56804
  return { part: p.id, on: "ground", joint, bears: false, extra: true, ...strength !== void 0 ? { strength } : {} };
56380
56805
  };
56381
56806
  const unheld = [];
56382
- for (const p of parts2.slice(base)) {
56807
+ for (const p of parts2.slice(base2)) {
56383
56808
  if (/^sidewalk:/.test(p.id)) {
56384
56809
  supports.push({ part: p.id, on: "ground", joint: "mortar", extra: true });
56385
56810
  continue;
@@ -56407,7 +56832,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56407
56832
  if (!/^(window|window_pane|door|jamb|pipe|water_tank|baseboard)/.test(p.id)) continue;
56408
56833
  const target = /^water_tank/.test(p.id) ? ["slab"] : ["wall", "partition"];
56409
56834
  let m = null, md = 1e9;
56410
- for (const q of parts2.slice(0, base)) {
56835
+ for (const q of parts2.slice(0, base2)) {
56411
56836
  if (!target.includes(q.role) || !inside22(p, q, 0.2)) continue;
56412
56837
  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
56838
  if (d < md) {
@@ -56415,7 +56840,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56415
56840
  m = q;
56416
56841
  }
56417
56842
  }
56418
- if (!m && /^(window|door|jamb)/.test(p.id)) for (const q of parts2.slice(0, base)) {
56843
+ if (!m && /^(window|door|jamb)/.test(p.id)) for (const q of parts2.slice(0, base2)) {
56419
56844
  if (!["wall", "partition", "column", "beam"].includes(q.role) || !touches2(p, q, 0.02)) continue;
56420
56845
  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
56846
  if (d < md) {
@@ -56553,6 +56978,119 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56553
56978
  if (distance2 <= -depth) return true;
56554
56979
  return distance2 <= -depth * noise3();
56555
56980
  }
56981
+ var JOINT_SHARE = 0.5;
56982
+ var EPSILON22 = 1e-4;
56983
+ function carve(boxes, grid) {
56984
+ const { data, w, h, len, y0, height } = grid;
56985
+ const out = [];
56986
+ for (const box4 of boxes) {
56987
+ 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);
56988
+ const i0 = Math.max(0, Math.floor(box4.a / len * w)), i1 = Math.min(w - 1, Math.ceil(box4.b / len * w) - 1);
56989
+ if (j1 < j0 || i1 < i0) {
56990
+ out.push(box4);
56991
+ continue;
56992
+ }
56993
+ for (let j = j0; j <= j1; j++) {
56994
+ const ry0 = Math.max(box4.y0, y0 + j / h * height), ry1 = Math.min(box4.y1, y0 + (j + 1) / h * height);
56995
+ let start = -1;
56996
+ for (let i = i0; i <= i1 + 1; i++) {
56997
+ const solid = i <= i1 && data[j * w + i] <= 127;
56998
+ if (solid && start < 0) start = i;
56999
+ if (!solid && start >= 0) {
57000
+ out.push({ a: Math.max(box4.a, start / w * len), b: Math.min(box4.b, i / w * len), y0: ry0, y1: ry1 });
57001
+ start = -1;
57002
+ }
57003
+ }
57004
+ }
57005
+ }
57006
+ return out;
57007
+ }
57008
+ var groupBy = (items, keyOf) => {
57009
+ const groups = /* @__PURE__ */ new Map();
57010
+ for (const item of items) {
57011
+ const key2 = keyOf(item);
57012
+ const group = groups.get(key2);
57013
+ if (group) group.push(item);
57014
+ else groups.set(key2, [item]);
57015
+ }
57016
+ return [...groups.values()];
57017
+ };
57018
+ function mergeSpans(spans, share = JOINT_SHARE) {
57019
+ const runs = [];
57020
+ const unitLengths = /* @__PURE__ */ new Map();
57021
+ for (const row of groupBy(spans, (s) => `${s.y0.toFixed(4)}:${s.y1.toFixed(4)}`)) {
57022
+ row.sort((p, q) => p.a - q.a);
57023
+ let run = { ...row[0] };
57024
+ let unitLength = run.b - run.a;
57025
+ for (const s of row.slice(1)) {
57026
+ if (s.a - run.b <= share * Math.min(s.b - s.a, unitLength) + EPSILON22) run.b = Math.max(run.b, s.b);
57027
+ else {
57028
+ runs.push(run);
57029
+ unitLengths.set(run, unitLength);
57030
+ run = { ...s };
57031
+ }
57032
+ unitLength = s.b - s.a;
57033
+ }
57034
+ runs.push(run);
57035
+ unitLengths.set(run, unitLength);
57036
+ }
57037
+ const out = [];
57038
+ const open = [];
57039
+ for (const r of [...runs].sort((p, q) => p.y0 - q.y0 || p.a - q.a)) {
57040
+ const height = r.y1 - r.y0;
57041
+ const top = open.find((o) => {
57042
+ const slack = share * Math.min(o.unitLength, r.b - r.a) + EPSILON22;
57043
+ 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;
57044
+ });
57045
+ if (top) {
57046
+ top.box.y1 = r.y1;
57047
+ top.box.a = Math.min(top.box.a, r.a);
57048
+ top.box.b = Math.max(top.box.b, r.b);
57049
+ top.unitHeight = height;
57050
+ } else {
57051
+ const box4 = { ...r };
57052
+ out.push(box4);
57053
+ open.push({ box: box4, unitHeight: height, unitLength: unitLengths.get(r) ?? r.b - r.a });
57054
+ }
57055
+ }
57056
+ return out;
57057
+ }
57058
+ function standingSolids(THREE, house, mesh2, line, parts2) {
57059
+ house.updateWorldMatrix(true, false);
57060
+ mesh2.updateWorldMatrix(true, false);
57061
+ const toMesh = new THREE.Matrix4().copy(mesh2.matrixWorld).invert().multiply(house.matrixWorld);
57062
+ const turn = new THREE.Quaternion();
57063
+ const scale = new THREE.Vector3();
57064
+ toMesh.decompose(new THREE.Vector3(), turn, scale);
57065
+ const point = new THREE.Vector3();
57066
+ const out = [];
57067
+ for (const part of parts2) {
57068
+ const boxes = mergeSpans(part.spans);
57069
+ for (const s of line.open ? mergeSpans(carve(boxes, line.open), 0) : boxes) {
57070
+ const along2 = line.start + (s.a + s.b) / 2;
57071
+ point.set(line.alongU ? along2 : part.mid, (s.y0 + s.y1) / 2, line.alongU ? part.mid : along2).applyMatrix4(toMesh);
57072
+ const length = (s.b - s.a) / 2, up = (s.y1 - s.y0) / 2, across2 = part.thick / 2;
57073
+ out.push({
57074
+ center: [point.x, point.y, point.z],
57075
+ half: [(line.alongU ? length : across2) * scale.x, up * scale.y, (line.alongU ? across2 : length) * scale.z],
57076
+ rotation: [turn.x, turn.y, turn.z, turn.w],
57077
+ kind: "box"
57078
+ });
57079
+ }
57080
+ }
57081
+ return out;
57082
+ }
57083
+ function publishSolids(mesh2, v0, v1, solids) {
57084
+ const u = mesh2.userData;
57085
+ u.drawnSolids = [...(u.drawnSolids ?? []).filter((entry2) => entry2.v0 !== v0), { v0, v1, solids }];
57086
+ u.drawnSolidsVersion = (u.drawnSolidsVersion ?? 0) + 1;
57087
+ }
57088
+ function withdrawSolids(mesh2, v0) {
57089
+ const u = mesh2.userData;
57090
+ if (!u.drawnSolids?.some((entry2) => entry2.v0 === v0)) return;
57091
+ u.drawnSolids = u.drawnSolids.filter((entry2) => entry2.v0 !== v0);
57092
+ u.drawnSolidsVersion = (u.drawnSolidsVersion ?? 0) + 1;
57093
+ }
56556
57094
  function collapseRange(mesh2, v0, v1) {
56557
57095
  const pos = mesh2.geometry.attributes.position;
56558
57096
  const a = pos.array;
@@ -56577,6 +57115,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56577
57115
  markPositionsWritten(mesh2, v0, v0 + saved.length / 3);
56578
57116
  const list2 = mesh2.userData.collapsedRanges;
56579
57117
  if (list2) mesh2.userData.collapsedRanges = list2.filter((r) => r[0] !== v0);
57118
+ withdrawSolids(mesh2, v0);
56580
57119
  }
56581
57120
  function noise2(x, y, cell) {
56582
57121
  const h = (i2, j2) => {
@@ -56900,11 +57439,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56900
57439
  }
56901
57440
  g.computeBoundingBox();
56902
57441
  g.computeBoundingSphere();
56903
- const base = it.mesh.material;
56904
- const material = base.clone();
57442
+ const base2 = it.mesh.material;
57443
+ const material = base2.clone();
56905
57444
  const toHouse = { value: new THREE.Matrix4() };
56906
57445
  material.onBeforeCompile = (sh) => {
56907
- base.onBeforeCompile?.(sh);
57446
+ base2.onBeforeCompile?.(sh);
56908
57447
  sh.uniforms.uToHouse = toHouse;
56909
57448
  sh.uniforms.uMask = { value: mask.texture };
56910
57449
  sh.uniforms.uMaskRect = { value: mask.rect };
@@ -56912,7 +57451,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56912
57451
  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
57452
  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
57453
  };
56915
- material.customProgramCacheKey = () => "breachMask" + (base.customProgramCacheKey?.() ?? "");
57454
+ material.customProgramCacheKey = () => "breachMask" + (base2.customProgramCacheKey?.() ?? "");
56916
57455
  const mesh2 = new THREE.Mesh(g, material);
56917
57456
  mesh2.name = "breach-shell";
56918
57457
  mesh2.userData.breachMask = mask;
@@ -57027,6 +57566,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57027
57566
  const around = { pillars: pillarSpans(view), gaps: windowGaps(view) };
57028
57567
  for (const id of view.parts) view.kept.set(id, splitUnits(view, id, around).kept);
57029
57568
  view.keptStale = false;
57569
+ publishStanding(view);
57570
+ }
57571
+ function publishStanding(view) {
57572
+ if (!view.saved) return;
57573
+ const { mask } = view;
57574
+ const parts2 = view.parts.map((id) => {
57575
+ const part = structure.byId.get(id);
57576
+ const thick = mask.alongU ? part.aabb[3] - part.aabb[1] : part.aabb[2] - part.aabb[0];
57577
+ const mid = mask.alongU ? (part.aabb[1] + part.aabb[3]) / 2 : (part.aabb[0] + part.aabb[2]) / 2;
57578
+ return { spans: view.kept.get(id) ?? [], thick, mid };
57579
+ });
57580
+ const line = { alongU: mask.alongU, start: mask.start, open: view.core };
57581
+ view.items.forEach((it, k) => publishSolids(it.mesh, it.v0, it.v1, k === 0 ? standingSolids(THREE, house, it.mesh, line, parts2) : []));
57030
57582
  }
57031
57583
  function paint(view) {
57032
57584
  const { mask, core } = view;
@@ -57101,13 +57653,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57101
57653
  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
57654
  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
57655
  };
57104
- const base = fragmentMaterial(part.material).color.getHex();
57656
+ const base2 = fragmentMaterial(part.material).color.getHex();
57105
57657
  const n = noise2(centre * 3.1, y * 2.7, 0.07);
57106
57658
  if (units2.mortar === "concrete") {
57107
- at2(len, h, thick - 2 * COVER2, tone(base, 0.9 + 0.04 * n));
57659
+ at2(len, h, thick - 2 * COVER2, tone(base2, 0.9 + 0.04 * n));
57108
57660
  } else {
57109
57661
  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));
57662
+ at2(len - 0.012, h - 0.012, thick - 2 * COVER2, tone(base2, 0.8 + 0.35 * n));
57111
57663
  }
57112
57664
  }
57113
57665
  const lumps = stuckLumps(castGone, mask, view.bounds);
@@ -57131,6 +57683,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57131
57683
  view.gone = holes.length;
57132
57684
  view.pits = pits.length;
57133
57685
  view.flakes = flakes.length;
57686
+ publishStanding(view);
57134
57687
  }
57135
57688
  function chipBox(chip, alongU) {
57136
57689
  house.updateWorldMatrix(true, false);
@@ -57242,6 +57795,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57242
57795
  view.shells = view.items.map((it) => shell(it, view.mask));
57243
57796
  for (const m of view.shells) m.userData.behind = () => view.units;
57244
57797
  view.saved = view.items.map((it) => ({ it, v0: it.v0, data: collapseRange(it.mesh, it.v0, it.v1) }));
57798
+ refreshKept(view);
57245
57799
  }
57246
57800
  function draw(partId, change) {
57247
57801
  if (lod !== 0) return false;
@@ -57292,6 +57846,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57292
57846
  if (shown2) restoreRange(s.it.mesh, s.v0, s.data);
57293
57847
  else s.data = collapseRange(s.it.mesh, s.v0, s.it.v1);
57294
57848
  }
57849
+ if (!shown2) publishStanding(view);
57295
57850
  }
57296
57851
  function flush(budgetMs) {
57297
57852
  if (budgetMs !== void 0 || !cutState.attached) paintCut();
@@ -58258,9 +58813,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58258
58813
  walk(house, void 0);
58259
58814
  return stages;
58260
58815
  }
58261
- function stageOfPiece(piece2, stages) {
58816
+ function stageOfPiece(piece22, stages) {
58262
58817
  let found;
58263
- piece2.root.traverse((o) => {
58818
+ piece22.root.traverse((o) => {
58264
58819
  if (found) return;
58265
58820
  const part = o.userData?.destructionPart;
58266
58821
  if (typeof part === "string") found = stages.get(part);
@@ -58269,20 +58824,20 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58269
58824
  }
58270
58825
  function stageLoosePieces(pieces, stages, level, opts, held) {
58271
58826
  let hidden = 0;
58272
- for (const piece2 of pieces) {
58273
- const stage = stageOfPiece(piece2, stages);
58827
+ for (const piece22 of pieces) {
58828
+ const stage = stageOfPiece(piece22, stages);
58274
58829
  if (!stage) continue;
58275
58830
  const shown2 = stageVisible(stage, level, opts);
58276
- piece2.root.visible = shown2;
58831
+ piece22.root.visible = shown2;
58277
58832
  if (!shown2) {
58278
58833
  hidden++;
58279
- if (!piece2.held) {
58280
- piece2.held = true;
58281
- held.add(piece2);
58834
+ if (!piece22.held) {
58835
+ piece22.held = true;
58836
+ held.add(piece22);
58282
58837
  }
58283
- } else if (held.has(piece2)) {
58284
- piece2.held = false;
58285
- held.delete(piece2);
58838
+ } else if (held.has(piece22)) {
58839
+ piece22.held = false;
58840
+ held.delete(piece22);
58286
58841
  }
58287
58842
  }
58288
58843
  return hidden;
@@ -58664,7 +59219,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58664
59219
  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
59220
  }
58666
59221
  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;
59222
+ 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
59223
  function build(r0, options) {
58669
59224
  const opts = options || {};
58670
59225
  const r = withLaidConduits(applyOutbuildings(r0), !!(opts.constructionStages || opts.constructionLevel != null));
@@ -58811,6 +59366,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58811
59366
  assembleInteractive(gs);
58812
59367
  linkDoorLeaves();
58813
59368
  mailboxInteractive();
59369
+ walkInInteractive();
58814
59370
  if (cs) {
58815
59371
  for (const def of shared2.inter.defs.values()) {
58816
59372
  if (def.outer && !def.outer.userData.constructionStage) def.outer.userData.constructionStage = /^gate/.test(def.kind) ? "perimeter" : "furniture";
@@ -59501,7 +60057,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59501
60057
  joinBodies(params, byId);
59502
60058
  }
59503
60059
  function holdHanging({ parts: parts2, joints, boxOf: boxOf3 }, byId) {
59504
- const back = Math.min(...parts2.map((part) => boxOf3(part.id).min[2]));
60060
+ const back2 = Math.min(...parts2.map((part) => boxOf3(part.id).min[2]));
59505
60061
  for (let pass = 0; pass < parts2.length; pass++) {
59506
60062
  const groups = groupsOf(parts2, joints).map((ids) => ids.map((id) => byId.get(id)));
59507
60063
  const held = groups.filter((group) => group.some((part) => part.anchored)).flat();
@@ -59515,8 +60071,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59515
60071
  changed = true;
59516
60072
  continue;
59517
60073
  }
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) : [];
60074
+ const againstWall = held.length === 0 || held.some((part) => boxOf3(part.id).min[2] <= back2 + AGAINST_WALL);
60075
+ const onWall = againstWall ? group.filter((part) => !SOFT.has(part.material) && boxOf3(part.id).min[2] <= back2 + BACK_TOUCH) : [];
59520
60076
  if (onWall.length === 0) continue;
59521
60077
  for (const part of onWall) part.anchored = true;
59522
60078
  changed = true;
@@ -59529,6 +60085,230 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59529
60085
  return;
59530
60086
  }
59531
60087
  }
60088
+ var COVER22 = 6e-3;
60089
+ var SPRING = 3e-3;
60090
+ var SPRING_WIDTH = 0.012;
60091
+ var CLOTH_COVER = [{ material: "fabric", thickness: COVER22, faces: "all" }];
60092
+ function piece2(id, key2, material, min, max, color2) {
60093
+ const size = [max[0] - min[0], max[1] - min[1], max[2] - min[2]];
60094
+ const position = [(min[0] + max[0]) / 2, (min[1] + max[1]) / 2, (min[2] + max[2]) / 2];
60095
+ return { id, key: key2, material, shape: { kind: "box", size }, position, rotation: null, color: color2, min, max };
60096
+ }
60097
+ var bothSides = (x0, x1) => [
60098
+ [x0, x1],
60099
+ [-x1, -x0]
60100
+ ];
60101
+ var SIDE_RAIL = 0.03;
60102
+ var SLAT_TOP = 0.297;
60103
+ var SLAT_THICK = 0.027;
60104
+ var SLAT_WIDTH = 0.07;
60105
+ var SLAT_PITCH = 0.12;
60106
+ var SPRING_STRIPS = 5;
60107
+ function bedParts(drawn) {
60108
+ const [frame2, ...otherWood] = drawn.filter((p) => p.key === "wood");
60109
+ const [mattress, ...bedclothes] = drawn.filter((p) => p.key === "fabric");
60110
+ if (!frame2 || !mattress) return [...drawn];
60111
+ const hw = (frame2.max[0] - frame2.min[0]) / 2;
60112
+ const [z0, z1] = [frame2.min[2], frame2.max[2]];
60113
+ const wood = frame2.color;
60114
+ const out = [...otherWood.map((p, k) => ({ ...p, id: k === 0 ? "bed_headboard" : "bed_footboard" }))];
60115
+ 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)));
60116
+ out.push(piece2("bed_centre_rail", "wood", "wood_soft", [-0.03, 0.2, z0], [0.03, SLAT_TOP - SLAT_THICK, z1], wood));
60117
+ const slats = Math.floor((z1 - z0 - 2 * 0.02 - SLAT_WIDTH) / SLAT_PITCH) + 1;
60118
+ for (let k = 0; k < slats; k++) {
60119
+ const z = z0 + 0.02 + k * SLAT_PITCH;
60120
+ 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));
60121
+ }
60122
+ const span = 2 * (hw - SIDE_RAIL);
60123
+ for (let k = 0; k < SPRING_STRIPS; k++) {
60124
+ const x = -hw + SIDE_RAIL + (k + 1) * span / (SPRING_STRIPS + 1);
60125
+ 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));
60126
+ }
60127
+ out.push({ ...mattress, id: "bed_mattress", material: "foam", layers: CLOTH_COVER });
60128
+ return [...out, ...bedclothes];
60129
+ }
60130
+ var RAIL_HEIGHT = 0.08;
60131
+ var POST = 0.05;
60132
+ var BOARD = 0.05;
60133
+ function base(L, c, seats, plinth) {
60134
+ const { hw, hd, armWidth: aT, postX: px } = L;
60135
+ const ix = hw - aT;
60136
+ const railTop = L.support - 6e-3;
60137
+ const railBottom = railTop - RAIL_HEIGHT;
60138
+ const zFrom = L.backFrame + BOARD;
60139
+ const zTo = L.coverFront - L.railDepth;
60140
+ const out = [];
60141
+ const wood = (id, min, max, material = "wood_hard") => out.push(piece2(id, "wood", material, min, max, c.wood));
60142
+ if (plinth) {
60143
+ wood("seat_plinth_front", [-hw, 0, hd - 0.06], [hw, L.postFloor, hd]);
60144
+ wood("seat_plinth_back", [-hw, 0, L.rear], [hw, L.postFloor, L.rear + 0.04]);
60145
+ 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]);
60146
+ }
60147
+ const upright = (id, x, z, top) => wood(id, [x - POST / 2, L.postFloor, z - POST / 2], [x + POST / 2, top, z + POST / 2]);
60148
+ for (const [k, sx] of [-1, 1].entries()) {
60149
+ upright(`seat_post_front_${k}`, sx * px, L.postFront, railTop);
60150
+ upright(`seat_post_back_${k}`, sx * px, L.postBack, L.stiles === "posts" ? L.armTop - 0.03 : railTop);
60151
+ }
60152
+ wood("seat_rail_front", [-(px - POST / 2), railBottom, zTo], [px - POST / 2, railTop, L.coverFront]);
60153
+ wood("seat_rail_back", [-(px - POST / 2), railBottom, L.backFrame], [px - POST / 2, railTop, zFrom]);
60154
+ 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]);
60155
+ 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]);
60156
+ for (const [k, seat] of seats.entries()) {
60157
+ for (const [j, dx] of [-0.12, 0.12].entries()) {
60158
+ const x = seat.x + dx;
60159
+ 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));
60160
+ }
60161
+ }
60162
+ out.push(piece2("seat_cover_front", "fabric", "fabric", [-ix, L.skirt, L.coverFront], [ix, L.support, L.coverFront + COVER22], c.skirt));
60163
+ 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));
60164
+ return out;
60165
+ }
60166
+ function back(L, c) {
60167
+ const { hw, armWidth: aT } = L;
60168
+ const ix = hw - aT;
60169
+ const railTop = L.support - 6e-3;
60170
+ const top = L.backTop - COVER22;
60171
+ const zFrame = [L.backFrame, L.backFrame + BOARD];
60172
+ const out = [];
60173
+ if (L.stiles === "rail") {
60174
+ 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));
60175
+ out.push(piece2("back_top_rail", "wood", "wood_hard", [-(ix - POST), top - BOARD, zFrame[0]], [ix - POST, top, zFrame[1]], c.wood));
60176
+ }
60177
+ const midX = L.stiles === "rail" ? ix - POST : L.postX - POST / 2;
60178
+ out.push(piece2("back_mid_rail", "wood", "wood_hard", [-midX, 0.5, zFrame[0]], [midX, 0.5 + POST, zFrame[1]], c.wood));
60179
+ 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));
60180
+ out.push(piece2("back_pad", "fabric", "foam", [-ix, L.support, zFrame[1]], [ix, top, L.rear + L.backDepth], c.back));
60181
+ out.push(piece2("back_cover_rear", "fabric", "fabric", [-L.rearHalf, L.skirt, L.rear], [L.rearHalf, L.backTop, L.rear + COVER22], c.skirt));
60182
+ out.push(piece2("back_cover_top", "fabric", "fabric", [-L.rearHalf, top, L.rear + COVER22], [L.rearHalf, L.backTop, L.rear + L.backDepth], c.back));
60183
+ if (L.rearHalf > ix) {
60184
+ 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));
60185
+ }
60186
+ return out;
60187
+ }
60188
+ function arms(L, c, boardBack) {
60189
+ const { hw, armWidth: aT, postX: px } = L;
60190
+ const railTop = L.support - 6e-3;
60191
+ const padTop = L.armTop - 0.03;
60192
+ const front = L.armFront;
60193
+ const out = [];
60194
+ 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)];
60195
+ const [board2, outer, inner, top, coverOuter, coverInner] = sides;
60196
+ for (const k of [0, 1]) {
60197
+ const z0 = L.armBack;
60198
+ out.push(piece2(`arm_board_${k}`, "wood", "wood_hard", [board2[k][0], railTop, boardBack], [board2[k][1], padTop, L.postFront + POST / 2], c.wood));
60199
+ out.push(piece2(`arm_pad_outer_${k}`, "fabric", "foam", [outer[k][0], railTop, z0], [outer[k][1], padTop, front - COVER22], c.arm));
60200
+ out.push(piece2(`arm_pad_inner_${k}`, "fabric", "foam", [inner[k][0], railTop, z0], [inner[k][1], padTop, front - COVER22], c.arm));
60201
+ out.push(piece2(`arm_pad_top_${k}`, "fabric", "foam", [top[k][0], padTop, z0], [top[k][1], L.armTop - COVER22, front - COVER22], c.arm));
60202
+ out.push(piece2(`arm_cover_outer_${k}`, "fabric", "fabric", [coverOuter[k][0], L.armBottom, z0], [coverOuter[k][1], L.armTop, front], c.arm));
60203
+ out.push(piece2(`arm_cover_inner_${k}`, "fabric", "fabric", [coverInner[k][0], L.armBottom, z0], [coverInner[k][1], L.armTop, front], c.arm));
60204
+ 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));
60205
+ 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));
60206
+ 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));
60207
+ }
60208
+ return out;
60209
+ }
60210
+ function seatStructure(L, c, seats, options) {
60211
+ return [...base(L, c, seats, options.plinth), ...back(L, c), ...arms(L, c, options.boardBack)];
60212
+ }
60213
+ function cushion(block, id) {
60214
+ return { ...block, id, material: "foam", layers: CLOTH_COVER };
60215
+ }
60216
+ var SOFAS = /^sofa_/;
60217
+ var ARMCHAIRS = /^armchair/;
60218
+ var BEDS = /^(double_bed|queen_bed|king_bed|single_bed|mattress)$/;
60219
+ var seatsOf = (cushions) => cushions.map((block, k) => ({ x: block.position[0], ...cushions[k + 1] ? { seam: (block.position[0] + cushions[k + 1].position[0]) / 2 } : {} }));
60220
+ function sofaParts(drawn) {
60221
+ const woods = drawn.filter((p) => p.key === "wood");
60222
+ const cloth2 = drawn.filter((p) => p.key === "fabric");
60223
+ const count = (cloth2.length - 5) / 2;
60224
+ const [skirt, ...rest2] = cloth2;
60225
+ const seatCushions = rest2.slice(0, count);
60226
+ const [back2] = rest2.slice(count, count + 1);
60227
+ const backCushions = rest2.slice(count + 1, 2 * count + 1);
60228
+ const [armLeft, , pillow] = rest2.slice(2 * count + 1);
60229
+ const feet = woods.slice(1);
60230
+ if (!skirt || !back2 || !armLeft || !pillow || feet.length !== 4) return [...drawn];
60231
+ const hd = (armLeft.max[2] - armLeft.min[2]) / 2 + 0.02;
60232
+ const hw = (woods[0].max[0] - woods[0].min[0]) / 2;
60233
+ const frontFoot = Math.max(...feet.map((foot) => foot.position[2]));
60234
+ const backFoot = Math.min(...feet.map((foot) => foot.position[2]));
60235
+ const layout = {
60236
+ hw,
60237
+ hd,
60238
+ rear: -hd,
60239
+ armWidth: armLeft.max[0] - armLeft.min[0],
60240
+ armTop: armLeft.max[1],
60241
+ armBottom: armLeft.min[1],
60242
+ backTop: back2.max[1],
60243
+ backDepth: back2.max[2] - back2.min[2],
60244
+ skirt: skirt.min[1],
60245
+ support: skirt.max[1],
60246
+ postX: Math.abs(feet[0].position[0]),
60247
+ postFront: frontFoot,
60248
+ postBack: backFoot,
60249
+ postFloor: 0,
60250
+ coverFront: skirt.max[2] - COVER22,
60251
+ railDepth: 0.07,
60252
+ springEnd: skirt.max[2] - 0.05,
60253
+ backFrame: backFoot - 0.025,
60254
+ armBack: armLeft.min[2],
60255
+ armFront: armLeft.max[2],
60256
+ rearHalf: hw - (armLeft.max[0] - armLeft.min[0]),
60257
+ stiles: "rail"
60258
+ };
60259
+ const colours = { wood: feet[0].color, skirt: skirt.color, back: back2.color, arm: armLeft.color };
60260
+ const structure = seatStructure(layout, colours, seatsOf(seatCushions), { plinth: false, boardBack: layout.backFrame });
60261
+ const cushions = [...seatCushions.map((block, k) => cushion(block, `seat_cushion_${k}`)), ...backCushions.map((block, k) => cushion(block, `back_cushion_${k}`)), cushion(pillow, "accent_pillow")];
60262
+ return [...structure, ...cushions];
60263
+ }
60264
+ var ARMCHAIR_SUPPORT = 0.28;
60265
+ function armchairParts(drawn) {
60266
+ const plinth = drawn.find((p) => p.key === "wood");
60267
+ const [seat, back2, armLeft] = drawn.filter((p) => p.key === "fabric");
60268
+ if (!plinth || !seat || !back2 || !armLeft) return [...drawn];
60269
+ const [hw, hd] = [(plinth.max[0] - plinth.min[0]) / 2, (plinth.max[2] - plinth.min[2]) / 2];
60270
+ const armWidth = armLeft.max[0] - armLeft.min[0];
60271
+ const rear = back2.min[2];
60272
+ const backFrame = rear + COVER22;
60273
+ const coverFront = hd - 0.04;
60274
+ const layout = {
60275
+ hw,
60276
+ hd,
60277
+ rear,
60278
+ armWidth,
60279
+ armTop: armLeft.max[1],
60280
+ armBottom: armLeft.min[1],
60281
+ backTop: back2.max[1],
60282
+ backDepth: back2.max[2] - rear,
60283
+ skirt: plinth.max[1],
60284
+ support: ARMCHAIR_SUPPORT,
60285
+ postX: hw - 0.07,
60286
+ postFront: hd - 0.065,
60287
+ postBack: backFrame + 0.025,
60288
+ postFloor: plinth.max[1],
60289
+ coverFront,
60290
+ railDepth: 0.05,
60291
+ springEnd: coverFront - 0.02,
60292
+ backFrame,
60293
+ armBack: backFrame,
60294
+ armFront: armLeft.max[2],
60295
+ rearHalf: (back2.max[0] - back2.min[0]) / 2,
60296
+ stiles: "posts"
60297
+ };
60298
+ const colours = { wood: plinth.color, skirt: seat.color, back: back2.color, arm: armLeft.color };
60299
+ const structure = seatStructure(layout, colours, [{ x: 0 }], { plinth: true, boardBack: backFrame + 0.05 });
60300
+ const ix = hw - armWidth;
60301
+ 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]] };
60302
+ const size = [seatCushion.max[0] - seatCushion.min[0], seatCushion.max[1] - seatCushion.min[1], seatCushion.max[2] - seatCushion.min[2]];
60303
+ const position = [0, (seatCushion.min[1] + seatCushion.max[1]) / 2, (seatCushion.min[2] + seatCushion.max[2]) / 2];
60304
+ return [...structure, cushion({ ...seatCushion, shape: { kind: "box", size }, position }, "seat_cushion_0")];
60305
+ }
60306
+ function upholster(drawn, type) {
60307
+ const made2 = SOFAS.test(type) ? sofaParts(drawn) : ARMCHAIRS.test(type) ? armchairParts(drawn) : BEDS.test(type) ? bedParts(drawn) : void 0;
60308
+ if (!made2) return false;
60309
+ drawn.splice(0, drawn.length, ...made2);
60310
+ return true;
60311
+ }
59532
60312
  var WOOD_THIN = 0.035;
59533
60313
  var BOARD_TOP_THICK = 0.07;
59534
60314
  var BOARD_TOP_WIDTH = 0.5;
@@ -59755,6 +60535,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59755
60535
  run(A);
59756
60536
  if (!drawn.length) throw new Error(`game-floorplan-three: the builder of "${name}" drew no box or cylinder`);
59757
60537
  hollowCases(drawn, name);
60538
+ upholster(drawn, name);
59758
60539
  const boardsOf = splitTopsIntoBoards(drawn, materialOf, Boolean(opts.carcass));
59759
60540
  const parts2 = drawn.map((p) => {
59760
60541
  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 +60548,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59767
60548
  const fill2 = structureFill(material, p.shape);
59768
60549
  if (fill2 < 1) part.fill = Math.round(fill2 * 1e4) / 1e4;
59769
60550
  if (p.rotation) part.rotation = p.rotation;
60551
+ if (p.layers) part.layers = p.layers;
59770
60552
  if (!LOOSE.has(material) && p.min[1] <= FLOOR_TOUCH2) part.anchored = true;
59771
60553
  if (opts.carcass && LOOSE.has(material)) {
59772
60554
  part.hands = 1;
@@ -59804,7 +60586,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59804
60586
  let top = null;
59805
60587
  for (const p of drawn) {
59806
60588
  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;
60589
+ if (part.shape.kind === "sphere" || part.rotation || part.material === "fabric" || part.material === "foam" || LOOSE.has(part.material)) continue;
59808
60590
  const area3 = (p.max[0] - p.min[0]) * (p.max[2] - p.min[2]);
59809
60591
  if (area3 < 0.6 * footprint || p.max[1] < 0.2) continue;
59810
60592
  if (!top || p.max[1] > top.y + 1e-6) top = { part: p.id, y: p.max[1] };
@@ -60075,11 +60857,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
60075
60857
  var textOf = (locale) => TEXT[locale] ?? TEXT.en;
60076
60858
  var fill = (template, vars) => template.replace(/\{(\w+)\}/g, (_, key2) => String(vars[key2] ?? ""));
60077
60859
  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;
60860
+ var stageOf = (catalog, item, base2, ageDays, storage, powered) => {
60861
+ if (item.shelfLife === void 0 || ageDays <= 0) return base2;
60080
60862
  const state = freshness(item, { ageDays: 0, since: 0, storage, storedAt: 0 }, ageDays, { powered, rules: catalog.rules });
60081
60863
  const aged = state === "fresh" ? 0 : state === "stale" ? 1 : 2;
60082
- return Math.max(base, aged);
60864
+ return Math.max(base2, aged);
60083
60865
  };
60084
60866
  var sizeOfModel = (modelSet, id) => {
60085
60867
  const entry2 = modelSet.entry(id);
@@ -60140,9 +60922,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
60140
60922
  name,
60141
60923
  movable: false,
60142
60924
  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 };
60925
+ const piece3 = furnitureSpec(THREE, type, { ...size, options: { chairs: false } });
60926
+ const root = piece3.build(THREE);
60927
+ root.userData.furnitureSpec = { ...piece3.spec, name };
60146
60928
  decorate?.(root);
60147
60929
  return root;
60148
60930
  },
@@ -60223,11 +61005,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
60223
61005
  build: (THREE) => {
60224
61006
  const T2 = THREE;
60225
61007
  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;
61008
+ 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 }));
61009
+ base2.position.y = (STAND.height - 0.04) / 2;
60228
61010
  const top = new T2.Mesh(new T2.CylinderGeometry(STAND.radius, STAND.radius, 0.04, 40), new T2.MeshStandardMaterial({ color: 13617848, roughness: 0.6 }));
60229
61011
  top.position.y = STAND.height - 0.02;
60230
- group.add(base, top);
61012
+ group.add(base2, top);
60231
61013
  return group;
60232
61014
  }
60233
61015
  });
@@ -60248,9 +61030,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
60248
61030
  mark.position.set(0.03 + (long ? 0.025 : 0.015), cm / 100, 0);
60249
61031
  group.add(mark);
60250
61032
  }
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);
61033
+ const base2 = new T2.Mesh(new T2.BoxGeometry(0.3, 0.03, 0.3), new T2.MeshStandardMaterial({ color: 5593180 }));
61034
+ base2.position.y = 0.015;
61035
+ group.add(base2);
60254
61036
  group.userData.height = RULER_HEIGHT;
60255
61037
  return group;
60256
61038
  }