@adatechnology/game-items-three 0.11.3 → 0.11.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -526,11 +526,11 @@ var GameItemsThree = (() => {
526
526
  }
527
527
  for (let i = 0; i < segments; i++) {
528
528
  for (let j = 0; j < points.length - 1; j++) {
529
- const base = j + i * points.length;
530
- const a = base;
531
- const b = base + points.length;
532
- const c = base + points.length + 1;
533
- const d = base + 1;
529
+ const base2 = j + i * points.length;
530
+ const a = base2;
531
+ const b = base2 + points.length;
532
+ const c = base2 + points.length + 1;
533
+ const d = base2 + 1;
534
534
  indices.push(a, b, d);
535
535
  indices.push(c, d, b);
536
536
  }
@@ -595,13 +595,13 @@ var GameItemsThree = (() => {
595
595
  const uvs = [];
596
596
  const indices = [];
597
597
  const quad = (corners, normal, uv) => {
598
- const base = positions2.length / 3;
598
+ const base2 = positions2.length / 3;
599
599
  for (let k = 0; k < 4; k++) {
600
600
  positions2.push(...corners[k]);
601
601
  normals.push(...normal);
602
602
  uvs.push(...uv[k]);
603
603
  }
604
- indices.push(base, base + 1, base + 2, base, base + 2, base + 3);
604
+ indices.push(base2, base2 + 1, base2 + 2, base2, base2 + 2, base2 + 3);
605
605
  };
606
606
  const fu = (x) => (x + hw) / w;
607
607
  const fv = (y) => (y + hh) / h;
@@ -1520,26 +1520,26 @@ var GameItemsThree = (() => {
1520
1520
  };
1521
1521
  function mergeTransformed(pieces) {
1522
1522
  let total = 0;
1523
- for (const piece2 of pieces) total += piece2.indices ? piece2.indices.length : piece2.positions.length / 3;
1523
+ for (const piece3 of pieces) total += piece3.indices ? piece3.indices.length : piece3.positions.length / 3;
1524
1524
  const positions2 = new Float32Array(total * 3);
1525
1525
  const normals = new Float32Array(total * 3);
1526
1526
  const uvs = new Float32Array(total * 2);
1527
1527
  let at2 = 0;
1528
- for (const piece2 of pieces) {
1529
- const e = piece2.matrix;
1528
+ for (const piece3 of pieces) {
1529
+ const e = piece3.matrix;
1530
1530
  const nm = normalMatrix(e);
1531
- const count = piece2.indices ? piece2.indices.length : piece2.positions.length / 3;
1531
+ const count = piece3.indices ? piece3.indices.length : piece3.positions.length / 3;
1532
1532
  const p = new Float32Array(count * 3);
1533
1533
  const n = new Float32Array(count * 3);
1534
1534
  for (let k = 0; k < count; k++) {
1535
- const i = piece2.indices ? piece2.indices[k] : k;
1535
+ const i = piece3.indices ? piece3.indices[k] : k;
1536
1536
  for (let c = 0; c < 3; c++) {
1537
- p[k * 3 + c] = piece2.positions[i * 3 + c];
1538
- if (piece2.normals) n[k * 3 + c] = piece2.normals[i * 3 + c];
1537
+ p[k * 3 + c] = piece3.positions[i * 3 + c];
1538
+ if (piece3.normals) n[k * 3 + c] = piece3.normals[i * 3 + c];
1539
1539
  }
1540
- if (piece2.uvs) {
1541
- uvs[(at2 + k) * 2] = piece2.uvs[i * 2];
1542
- uvs[(at2 + k) * 2 + 1] = piece2.uvs[i * 2 + 1];
1540
+ if (piece3.uvs) {
1541
+ uvs[(at2 + k) * 2] = piece3.uvs[i * 2];
1542
+ uvs[(at2 + k) * 2 + 1] = piece3.uvs[i * 2 + 1];
1543
1543
  }
1544
1544
  }
1545
1545
  for (let k = 0; k < count; k++) {
@@ -1654,7 +1654,7 @@ var GameItemsThree = (() => {
1654
1654
  var positive = (n) => finite(n) && n > 0;
1655
1655
  var vec3 = (v) => Array.isArray(v) && v.length === 3 && v.every(finite);
1656
1656
  var nonNegative = (n) => n === void 0 || finite(n) && n >= 0;
1657
- var FACES = ["both", "+", "-"];
1657
+ var FACES = ["both", "+", "-", "all"];
1658
1658
  var BONDS = ["running", "stack"];
1659
1659
  var checkStagedFields = (p, label, materials, problems) => {
1660
1660
  const known = (m, what) => {
@@ -1858,9 +1858,9 @@ var GameItemsThree = (() => {
1858
1858
  };
1859
1859
  var UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
1860
1860
  var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
1861
- var deepMerge = (base, patch) => {
1862
- if (!patch) return base;
1863
- const result = { ...base };
1861
+ var deepMerge = (base2, patch) => {
1862
+ if (!patch) return base2;
1863
+ const result = { ...base2 };
1864
1864
  for (const [key2, value] of Object.entries(patch)) {
1865
1865
  if (value === void 0 || UNSAFE_KEYS.has(key2)) continue;
1866
1866
  const current = result[key2];
@@ -2309,8 +2309,8 @@ var GameItemsThree = (() => {
2309
2309
  const materials = [];
2310
2310
  const M = (color2, tag, options = {}) => {
2311
2311
  const material = new T2.MeshStandardMaterial(Object.assign({ color: color2, roughness: 0.78, metalness: 0 }, options));
2312
- const base = new T2.Color(color2);
2313
- const data = { base, baseRgb: channelsOf(color2), tag, rough: material.roughness };
2312
+ const base2 = new T2.Color(color2);
2313
+ const data = { base: base2, baseRgb: channelsOf(color2), tag, rough: material.roughness };
2314
2314
  material.userData = data;
2315
2315
  materials.push(material);
2316
2316
  return material;
@@ -6402,11 +6402,11 @@ var GameItemsThree = (() => {
6402
6402
  var _a;
6403
6403
  if (!isLid(o)) return;
6404
6404
  const mesh2 = o;
6405
- const base = (_a = mesh2.userData).lidBase ?? (_a.lidBase = { y: mesh2.position.y, turn: mesh2.rotation.y });
6405
+ const base2 = (_a = mesh2.userData).lidBase ?? (_a.lidBase = { y: mesh2.position.y, turn: mesh2.rotation.y });
6406
6406
  if (!mesh2.geometry.boundingBox) mesh2.geometry.computeBoundingBox();
6407
6407
  const height = (mesh2.geometry.boundingBox.max.y - mesh2.geometry.boundingBox.min.y) * mesh2.scale.y;
6408
- mesh2.rotation.y = base.turn + state.turned;
6409
- mesh2.position.y = base.y + Math.min(1, Math.max(0, state.lift)) * height * CAP_OFF;
6408
+ mesh2.rotation.y = base2.turn + state.turned;
6409
+ mesh2.position.y = base2.y + Math.min(1, Math.max(0, state.lift)) * height * CAP_OFF;
6410
6410
  });
6411
6411
  return true;
6412
6412
  }
@@ -7673,11 +7673,11 @@ var GameItemsThree = (() => {
7673
7673
  const steel = metal(6251625);
7674
7674
  const dark = metal(4080199);
7675
7675
  const arm = (x, y, angle, z) => mesh2(bx(12.65, 1.2, 1.6), steel, [x, y, z], [0, 0, angle]);
7676
- const arms = [3.8, -3.8].flatMap((z) => [arm(-5.9, 2, 0.3217, z), arm(-5.9, -2, -0.3217, z), arm(5.9, 2, -0.3217, z), arm(5.9, -2, 0.3217, z)]);
7676
+ const arms2 = [3.8, -3.8].flatMap((z) => [arm(-5.9, 2, 0.3217, z), arm(-5.9, -2, -0.3217, z), arm(5.9, 2, -0.3217, z), arm(5.9, -2, 0.3217, z)]);
7677
7677
  return G(
7678
7678
  mesh2(bx(8, 1, 11), dark, [0, -5, 0]),
7679
7679
  mesh2(bx(8, 1, 11), dark, [0, 5, 0]),
7680
- ...arms,
7680
+ ...arms2,
7681
7681
  mesh2(cyl(0.6, 0.6, 30, 8), metal(9277846), [0, 0, 0], [0, 0, Math.PI / 2]),
7682
7682
  mesh2(bx(1.6, 2.4, 3), dark, [-11.8, 0, 0]),
7683
7683
  mesh2(bx(1.6, 2.4, 3), dark, [11.8, 0, 0]),
@@ -7921,12 +7921,12 @@ var GameItemsThree = (() => {
7921
7921
  const rod = (x1, y1, x2, y2, radius) => [cyl(radius, radius, Math.hypot(x2 - x1, y2 - y1), 8), [(x1 + x2) / 2, (y1 + y2) / 2, 0], [0, 0, Math.atan2(-(x2 - x1), y2 - y1)]];
7922
7922
  const frame2 = wood(7031340);
7923
7923
  const band = cloth2(2039583);
7924
- const arms = [-1, 1].map((side) => rod(0, -0.15, side * 0.5675, 0.7, 0.1));
7924
+ const arms2 = [-1, 1].map((side) => rod(0, -0.15, side * 0.5675, 0.7, 0.1));
7925
7925
  const bands = [-1, 1].map((side) => rod(side * 0.5675, 0.7, side * 0.12, 0.25, 0.03));
7926
7926
  return G(
7927
7927
  mesh2(cyl(0.12, 0.1, 0.65, 8), frame2, [0, -0.425, 0]),
7928
7928
  mesh2(cyl(0.126, 0.126, 0.3, 8), cloth2(8007455), [0, -0.5, 0]),
7929
- ...arms.map(([geometry, position, rotation]) => mesh2(geometry, frame2, [...position], [...rotation])),
7929
+ ...arms2.map(([geometry, position, rotation]) => mesh2(geometry, frame2, [...position], [...rotation])),
7930
7930
  ...bands.map(([geometry, position, rotation]) => mesh2(geometry, band, [...position], [...rotation])),
7931
7931
  mesh2(bx(0.26, 0.2, 0.05), cloth2(9067061), [0, 0.2, 0])
7932
7932
  );
@@ -8156,10 +8156,10 @@ var GameItemsThree = (() => {
8156
8156
  const R = Math.PI / 2;
8157
8157
  const pane = glass(12575711, 0.55);
8158
8158
  const deep = glass(8369584, 0.7);
8159
- const base = extrude2([[-0.6, -0.1], [0.45, -0.5], [0.6, 0.2], [-0.1, 0.5]], 0.04, 2e-3);
8159
+ const base2 = extrude2([[-0.6, -0.1], [0.45, -0.5], [0.6, 0.2], [-0.1, 0.5]], 0.04, 2e-3);
8160
8160
  const chip = extrude2([[0, 0], [0.25, 0.05], [0.1, 0.22]], 0.03, 2e-3);
8161
8161
  return G(
8162
- mesh2(base, pane, [0, 0, 0], [R, 0, 0]),
8162
+ mesh2(base2, pane, [0, 0, 0], [R, 0, 0]),
8163
8163
  mesh2(chip, deep, [0.2, 0.03, -0.35], [R, 0, 0.4]),
8164
8164
  mesh2(new T2.ConeGeometry(0.14, 0.46, 3), pane, [-0.2, 0.23, 0.1], [0, 0.3, 0.12]),
8165
8165
  mesh2(new T2.ConeGeometry(0.1, 0.34, 3), deep, [0.25, 0.17, -0.1], [0.15, 0, -0.2]),
@@ -8394,10 +8394,10 @@ var GameItemsThree = (() => {
8394
8394
 
8395
8395
  // src/models/rag.ts
8396
8396
  var rag = ({ mesh: mesh2, bx, G, cloth: cloth2 }) => {
8397
- const base = cloth2(11028282);
8397
+ const base2 = cloth2(11028282);
8398
8398
  const fringe = cloth2(12877167);
8399
8399
  return G(
8400
- mesh2(bx(2, 0.1, 1.8), base, [0, -0.076, 0]),
8400
+ mesh2(bx(2, 0.1, 1.8), base2, [0, -0.076, 0]),
8401
8401
  mesh2(bx(1.7, 0.09, 1.5), cloth2(10108723), [0.1, 0.02, 0], [0, 0.1, 0]),
8402
8402
  mesh2(bx(1.5, 0.036, 1.2), cloth2(11818826), [0, 0.083, 0]),
8403
8403
  mesh2(bx(0.2, 0.02, 1.7), fringe, [1, -0.076, 0]),
@@ -8487,13 +8487,13 @@ var GameItemsThree = (() => {
8487
8487
 
8488
8488
  // src/models/army-camouflage-uniform.ts
8489
8489
  var armyCamouflageUniform = ({ mesh: mesh2, bx, G, cloth: cloth2 }) => {
8490
- const base = cloth2(5857855);
8490
+ const base2 = cloth2(5857855);
8491
8491
  const dark = cloth2(3554600);
8492
8492
  const tan = cloth2(9076565);
8493
8493
  return G(
8494
- mesh2(bx(0.24, 0.08, 0.32), base, [0, 0.04, 0]),
8495
- mesh2(bx(0.08, 0.07, 0.2), base, [-0.16, 0.035, -0.06]),
8496
- mesh2(bx(0.08, 0.07, 0.2), base, [0.16, 0.035, -0.06]),
8494
+ mesh2(bx(0.24, 0.08, 0.32), base2, [0, 0.04, 0]),
8495
+ mesh2(bx(0.08, 0.07, 0.2), base2, [-0.16, 0.035, -0.06]),
8496
+ mesh2(bx(0.08, 0.07, 0.2), base2, [0.16, 0.035, -0.06]),
8497
8497
  mesh2(bx(0.08, 0.074, 0.024), dark, [-0.16, 0.037, 0.052]),
8498
8498
  mesh2(bx(0.08, 0.074, 0.024), dark, [0.16, 0.037, 0.052]),
8499
8499
  mesh2(bx(0.08, 0.01, 0.045), dark, [-0.04, 0.09, -0.135]),
@@ -10643,18 +10643,18 @@ var GameItemsThree = (() => {
10643
10643
  const indexCount = mesh22.geometry.index ? mesh22.geometry.index.count : vertices;
10644
10644
  return { mesh: mesh22, local, vertices, indexCount };
10645
10645
  });
10646
- const totalVertices = pieces.reduce((sum, piece2) => sum + piece2.vertices, 0);
10647
- const totalIndices = pieces.reduce((sum, piece2) => sum + piece2.indexCount, 0);
10646
+ const totalVertices = pieces.reduce((sum, piece3) => sum + piece3.vertices, 0);
10647
+ const totalIndices = pieces.reduce((sum, piece3) => sum + piece3.indexCount, 0);
10648
10648
  const merged2 = new THREE.BufferGeometry();
10649
- const normalMatrices = names.includes("normal") ? pieces.map((piece2) => new THREE.Matrix3().getNormalMatrix(follow ? identity : piece2.local)) : [];
10649
+ const normalMatrices = names.includes("normal") ? pieces.map((piece3) => new THREE.Matrix3().getNormalMatrix(follow ? identity : piece3.local)) : [];
10650
10650
  for (const name of names) {
10651
10651
  const size = first.geometry.attributes[name].itemSize;
10652
10652
  const array = new Float32Array(totalVertices * size);
10653
10653
  let offset = 0;
10654
- for (const [at2, piece2] of pieces.entries()) {
10655
- const matrix = name === "normal" ? normalMatrices[at2] : follow ? identity : piece2.local;
10656
- copyAttribute(name, piece2.mesh.geometry.attributes[name], array, offset, matrix);
10657
- offset += piece2.vertices;
10654
+ for (const [at2, piece3] of pieces.entries()) {
10655
+ const matrix = name === "normal" ? normalMatrices[at2] : follow ? identity : piece3.local;
10656
+ copyAttribute(name, piece3.mesh.geometry.attributes[name], array, offset, matrix);
10657
+ offset += piece3.vertices;
10658
10658
  }
10659
10659
  merged2.setAttribute(name, new THREE.BufferAttribute(array, size));
10660
10660
  }
@@ -10676,30 +10676,30 @@ var GameItemsThree = (() => {
10676
10676
  const sources = [];
10677
10677
  let vertexOffset = 0;
10678
10678
  let indexOffset = 0;
10679
- for (const piece2 of pieces) {
10680
- const index = piece2.mesh.geometry.index;
10679
+ for (const piece3 of pieces) {
10680
+ const index = piece3.mesh.geometry.index;
10681
10681
  if (index) {
10682
10682
  const indices = index.array;
10683
- for (let at2 = 0; at2 < piece2.indexCount; at2++) indexArray2[indexOffset + at2] = indices[at2] + vertexOffset;
10684
- } else for (let at2 = 0; at2 < piece2.indexCount; at2++) indexArray2[indexOffset + at2] = at2 + vertexOffset;
10683
+ for (let at2 = 0; at2 < piece3.indexCount; at2++) indexArray2[indexOffset + at2] = indices[at2] + vertexOffset;
10684
+ } else for (let at2 = 0; at2 < piece3.indexCount; at2++) indexArray2[indexOffset + at2] = at2 + vertexOffset;
10685
10685
  sources.push({
10686
- mesh: piece2.mesh,
10687
- geometry: piece2.mesh.geometry,
10688
- material: piece2.mesh.material,
10689
- version: piece2.mesh.geometry.attributes.position.version,
10690
- local: piece2.local,
10691
- world: piece2.mesh.matrixWorld.clone(),
10692
- mask: piece2.mesh.layers.mask,
10693
- castShadow: piece2.mesh.castShadow,
10686
+ mesh: piece3.mesh,
10687
+ geometry: piece3.mesh.geometry,
10688
+ material: piece3.mesh.material,
10689
+ version: piece3.mesh.geometry.attributes.position.version,
10690
+ local: piece3.local,
10691
+ world: piece3.mesh.matrixWorld.clone(),
10692
+ mask: piece3.mesh.layers.mask,
10693
+ castShadow: piece3.mesh.castShadow,
10694
10694
  batch,
10695
10695
  start: indexOffset,
10696
- count: piece2.indexCount,
10696
+ count: piece3.indexCount,
10697
10697
  released: false
10698
10698
  });
10699
- if (shadowOnly) piece2.mesh.castShadow = false;
10700
- else piece2.mesh.layers.set(BATCHED_LAYER);
10701
- vertexOffset += piece2.vertices;
10702
- indexOffset += piece2.indexCount;
10699
+ if (shadowOnly) piece3.mesh.castShadow = false;
10700
+ else piece3.mesh.layers.set(BATCHED_LAYER);
10701
+ vertexOffset += piece3.vertices;
10702
+ indexOffset += piece3.indexCount;
10703
10703
  }
10704
10704
  return sources;
10705
10705
  }
@@ -11218,7 +11218,7 @@ var GameItemsThree = (() => {
11218
11218
  T("open_door", true, 0.9, 0.15, 2.15, 0, false, "house_state")
11219
11219
  ];
11220
11220
  var DEFS = Object.fromEntries(TYPE_DEFS.map((t) => [t.id, t]));
11221
- var MATERIALS = ["plain", "metal", "wood", "glass", "fabric", "plant", "water", "emissive", "atlas_picture", "atlas_floor"];
11221
+ var MATERIALS = ["plain", "metal", "wood", "glass", "fabric", "foam", "plant", "water", "emissive", "atlas_picture", "atlas_floor"];
11222
11222
  function ceilingBuilders({ kit }) {
11223
11223
  const B = {};
11224
11224
  B.ceiling_light = (M, a) => {
@@ -12440,14 +12440,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
12440
12440
  const uvs = [];
12441
12441
  const indices = [];
12442
12442
  for (const side of [1, -1]) {
12443
- const base = positions2.length / 3;
12443
+ const base2 = positions2.length / 3;
12444
12444
  for (let i = 0; i < 4; i++) {
12445
12445
  positions2.push(f[i * 3], f[i * 3 + 1], f[i * 3 + 2]);
12446
12446
  normals.push(0, 0, side);
12447
12447
  uvs.push(f[i * 3] + 0.5, f[i * 3 + 1]);
12448
12448
  }
12449
- if (side === 1) indices.push(base, base + 2, base + 1, base + 1, base + 2, base + 3);
12450
- else indices.push(base, base + 1, base + 2, base + 1, base + 3, base + 2);
12449
+ if (side === 1) indices.push(base2, base2 + 2, base2 + 1, base2 + 1, base2 + 2, base2 + 3);
12450
+ else indices.push(base2, base2 + 1, base2 + 2, base2 + 1, base2 + 3, base2 + 2);
12451
12451
  }
12452
12452
  return { positions: positions2, normals, uvs, indices };
12453
12453
  })();
@@ -13125,33 +13125,6 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
13125
13125
  return out;
13126
13126
  };
13127
13127
  var granules = (inp, box4, count) => bsp(box4, count, [0, 1, 2], inp.rnd).map((b) => ({ center: b.c, size: b.s, q: quat.identity(), shape: "chunk", weight: b.s[0] * b.s[1] * b.s[2] }));
13128
- var SLAB_MIN = 0.03;
13129
- var splitAtHit = (root, hit, axes, count, rnd) => {
13130
- let pieces = [root];
13131
- for (const ax of axes) {
13132
- const half = root.s[ax] / 2;
13133
- if (hit[ax] - -half < SLAB_MIN || half - hit[ax] < SLAB_MIN) continue;
13134
- const next = [];
13135
- for (const b of pieces) {
13136
- const lo = b.c[ax] - b.s[ax] / 2;
13137
- const hi = b.c[ax] + b.s[ax] / 2;
13138
- for (const [from, to] of [[lo, hit[ax]], [hit[ax], hi]]) {
13139
- const c = [b.c[0], b.c[1], b.c[2]];
13140
- const s = [b.s[0], b.s[1], b.s[2]];
13141
- c[ax] = (from + to) / 2;
13142
- s[ax] = to - from;
13143
- next.push({ c, s });
13144
- }
13145
- }
13146
- pieces = next;
13147
- }
13148
- while (pieces.length < count) {
13149
- pieces.sort((a, b) => b.s[axes[0]] * b.s[axes[1]] - a.s[axes[0]] * a.s[axes[1]]);
13150
- const [big, ...rest2] = pieces;
13151
- pieces = [...bsp(big, 2, axes, rnd), ...rest2];
13152
- }
13153
- return pieces;
13154
- };
13155
13128
  var CRUMBS = 6;
13156
13129
  var severAt = (inp, root, at2, gap) => {
13157
13130
  const dims = root.s;
@@ -13199,8 +13172,72 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
13199
13172
  }
13200
13173
  return out;
13201
13174
  };
13175
+ var radialPlates = (inp, root, axes, n, th, cap, fit = false) => {
13176
+ const { rnd, maxFragments } = inp;
13177
+ const { t, u, v } = axes;
13178
+ const dims = root.s;
13179
+ const out = [];
13180
+ const Hu = dims[u] / 2, Hv = dims[v] / 2;
13181
+ const hu = clamp(inp.hit[u] - root.c[u], -Hu * 0.95, Hu * 0.95);
13182
+ const hv = clamp(inp.hit[v] - root.c[v], -Hv * 0.95, Hv * 0.95);
13183
+ const R = Math.max(Math.hypot(Hu + Math.abs(hu), Hv + Math.abs(hv)), 0.02);
13184
+ const sectors = clamp(Math.round(Math.sqrt(n * 1.6)), Math.min(5, n), 10);
13185
+ const rings = Math.max(1, Math.ceil(n / sectors));
13186
+ const radii = [];
13187
+ for (let k = 0; k <= rings; k++) radii.push(R * Math.pow(k / rings, 1.3));
13188
+ for (let j = 0; j < sectors && out.length < maxFragments; j++) {
13189
+ const theta = (j + (rnd() - 0.5) * 0.4) * (Math.PI * 2 / sectors);
13190
+ for (let k = 0; k < rings && out.length < maxFragments; k++) {
13191
+ const rm = (radii[k] + radii[k + 1]) / 2;
13192
+ const cu = hu + rm * Math.cos(theta);
13193
+ const cv = hv + rm * Math.sin(theta);
13194
+ if (Math.abs(cu) > Hu + 0.01 || Math.abs(cv) > Hv + 0.01) continue;
13195
+ const radial = clamp(radii[k + 1] - radii[k], 0.01, cap);
13196
+ const tang = clamp(radii[k + 1] * (Math.PI * 2 / sectors) * 0.9, 0.01, cap);
13197
+ const c = [root.c[0], root.c[1], root.c[2]];
13198
+ c[u] = root.c[u] + clamp(cu, -Hu * 0.98, Hu * 0.98);
13199
+ c[v] = root.c[v] + clamp(cv, -Hv * 0.98, Hv * 0.98);
13200
+ const shrink = fit ? fitInside(radial, tang, theta, Hu, Hv) : 1;
13201
+ if (fit) {
13202
+ const reach2 = reachOf(radial * shrink, tang * shrink, theta);
13203
+ c[u] = root.c[u] + clamp(c[u] - root.c[u], -(Hu - reach2[0]), Hu - reach2[0]);
13204
+ c[v] = root.c[v] + clamp(c[v] - root.c[v], -(Hv - reach2[1]), Hv - reach2[1]);
13205
+ }
13206
+ out.push({ center: c, size: [radial * shrink, tang * shrink, th], q: frame(u, v, t, theta), shape: "shard", weight: radial * tang * shrink * shrink });
13207
+ }
13208
+ }
13209
+ if (out.length === 0) out.push({ center: [root.c[0], root.c[1], root.c[2]], size: [dims[u], dims[v], th], q: frame(u, v, t), shape: "shard", weight: 1 });
13210
+ return out;
13211
+ };
13212
+ var reachOf = (radial, tang, theta) => {
13213
+ const cos = Math.abs(Math.cos(theta)), sin = Math.abs(Math.sin(theta));
13214
+ return [(cos * radial + sin * tang) / 2, (sin * radial + cos * tang) / 2];
13215
+ };
13216
+ var fitInside = (radial, tang, theta, halfU, halfV) => {
13217
+ const [reachU, reachV] = reachOf(radial, tang, theta);
13218
+ return Math.min(halfU / Math.max(reachU, 1e-9), halfV / Math.max(reachV, 1e-9), 1);
13219
+ };
13202
13220
  var STACK_LAYER = 0.012;
13221
+ var SOLID_VOLUME_MIN = 1e-6;
13203
13222
  var planFragments = (inp) => {
13223
+ const solids = inp.solids;
13224
+ if (!solids || solids.length < 2) return planBox(inp);
13225
+ const volumes = solids.map((solid) => Math.max(SOLID_VOLUME_MIN, solid.size[0] * solid.size[1] * solid.size[2]));
13226
+ const total = volumes.reduce((sum, volume) => sum + volume, 0);
13227
+ const out = [];
13228
+ solids.forEach((solid, i) => {
13229
+ const share = Math.max(1, Math.round(inp.maxFragments * volumes[i] / total));
13230
+ const hit = [inp.hit[0] - solid.center[0], inp.hit[1] - solid.center[1], inp.hit[2] - solid.center[2]];
13231
+ const { cut, solids: _all, ...rest2 } = inp;
13232
+ const along2 = cut ? [0, 1, 2].sort((a, b) => solid.size[b] - solid.size[a])[0] : -1;
13233
+ const inside3 = cut && Math.abs(cut.at - solid.center[along2]) < solid.size[along2] / 2 ? { cut: { at: cut.at - solid.center[along2], gap: cut.gap } } : {};
13234
+ for (const f of planBox({ ...rest2, ...inside3, dims: [solid.size[0], solid.size[1], solid.size[2]], hit, maxFragments: share, thickness: Math.min(inp.thickness, Math.min(...solid.size)) })) {
13235
+ out.push({ ...f, center: [f.center[0] + solid.center[0], f.center[1] + solid.center[1], f.center[2] + solid.center[2]] });
13236
+ }
13237
+ });
13238
+ return out;
13239
+ };
13240
+ var planBox = (inp) => {
13204
13241
  const { style, dims, rnd, maxFragments } = inp;
13205
13242
  const [fmin, fmax] = inp.fragmentSize;
13206
13243
  const mean = (fmin + fmax) / 2;
@@ -13213,9 +13250,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
13213
13250
  if (style === "snap") {
13214
13251
  if (inp.cut) return severAt(inp, root, inp.cut.at, inp.cut.gap);
13215
13252
  if (inp.form === "plies") return plyBreak(inp, root, maxFragments);
13216
- const n2 = Math.min(maxFragments, 2 + Math.floor(rnd() * 3));
13217
- const slabs = inp.form === "granules" && dims[t] < Math.min(dims[u], dims[v]) / 4 ? splitAtHit(root, inp.hit, [u, v], n2, rnd) : bsp(root, n2, [0, 1, 2], rnd);
13218
- for (const b of slabs) out.push({ center: b.c, size: b.s, q: idq, shape: "slab", weight: b.s[0] * b.s[1] * b.s[2] });
13253
+ const thinBoard = dims[t] < Math.min(dims[u], dims[v]) / 4;
13254
+ if (thinBoard && inp.form !== "slivers") {
13255
+ const crumbled = inp.form === "granules" ? CRUMBS : 0;
13256
+ const plates = clamp(Math.round(dims[u] * dims[v] / (mean * mean)), 6, Math.max(6, maxFragments - crumbled));
13257
+ for (const f of radialPlates(inp, root, { t, u, v }, plates, dims[t], fmax * 1.5, true)) out.push({ ...f, weight: f.size[0] * f.size[1] * dims[t] });
13258
+ } else {
13259
+ const n2 = Math.min(maxFragments, 2 + Math.floor(rnd() * 3));
13260
+ for (const b of bsp(root, n2, [0, 1, 2], rnd)) out.push({ center: b.c, size: b.s, q: idq, shape: "slab", weight: b.s[0] * b.s[1] * b.s[2] });
13261
+ }
13219
13262
  if (inp.form !== "granules") return out;
13220
13263
  const crumbs = Math.min(CRUMBS, maxFragments - out.length);
13221
13264
  if (crumbs <= 0) return out;
@@ -13238,44 +13281,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
13238
13281
  return out;
13239
13282
  }
13240
13283
  if (style === "tear") {
13284
+ if (inp.form === "granules") return granules(inp, root, clamp(Math.ceil(dims[0] * dims[1] * dims[2] / (mean * mean * mean)), 3, maxFragments));
13241
13285
  const n2 = clamp(Math.round(dims[u] * dims[v] / (mean * mean)), 3, maxFragments);
13242
13286
  const sheet = inp.sheet ?? 0;
13243
13287
  if (sheet > 0 && dims[t] > sheet * 4) return tearStack(inp, root, t, u, v, n2, sheet);
13244
- const th2 = Math.min(inp.thickness, dims[t]);
13288
+ const th = Math.min(inp.thickness, dims[t]);
13245
13289
  for (const b of bsp(root, n2, [u, v], rnd)) {
13246
- out.push({ center: [b.c[0], b.c[1], b.c[2]], size: [b.s[u], b.s[v], th2], q: frame(u, v, t), shape: "scrap", weight: b.s[u] * b.s[v] });
13290
+ out.push({ center: [b.c[0], b.c[1], b.c[2]], size: [b.s[u], b.s[v], th], q: frame(u, v, t), shape: "scrap", weight: b.s[u] * b.s[v] });
13247
13291
  }
13248
13292
  return out;
13249
13293
  }
13250
- const th = Math.min(inp.thickness, dims[t]);
13251
- const Hu = dims[u] / 2, Hv = dims[v] / 2;
13252
- const hu = clamp(inp.hit[u], -Hu * 0.95, Hu * 0.95);
13253
- const hv = clamp(inp.hit[v], -Hv * 0.95, Hv * 0.95);
13254
- const R = Math.max(Math.hypot(Hu + Math.abs(hu), Hv + Math.abs(hv)), 0.02);
13255
13294
  const n = clamp(Math.round(dims[u] * dims[v] / (mean * mean)), 6, maxFragments);
13256
- const sectors = clamp(Math.round(Math.sqrt(n * 1.6)), 5, 10);
13257
- const rings = Math.max(1, Math.ceil(n / sectors));
13258
- const radii = [];
13259
- for (let k = 0; k <= rings; k++) radii.push(R * Math.pow(k / rings, 1.3));
13260
- const cap = fmax * 1.5;
13261
- for (let j = 0; j < sectors && out.length < maxFragments; j++) {
13262
- const theta = (j + (rnd() - 0.5) * 0.4) * (Math.PI * 2 / sectors);
13263
- for (let k = 0; k < rings && out.length < maxFragments; k++) {
13264
- const rm = (radii[k] + radii[k + 1]) / 2;
13265
- const cu = hu + rm * Math.cos(theta);
13266
- const cv = hv + rm * Math.sin(theta);
13267
- if (Math.abs(cu) > Hu + 0.01 || Math.abs(cv) > Hv + 0.01) continue;
13268
- const radial = clamp(radii[k + 1] - radii[k], 0.01, cap);
13269
- const tang = clamp(radii[k + 1] * (Math.PI * 2 / sectors) * 0.9, 0.01, cap);
13270
- const c = [0, 0, 0];
13271
- c[u] = clamp(cu, -Hu * 0.98, Hu * 0.98);
13272
- c[v] = clamp(cv, -Hv * 0.98, Hv * 0.98);
13273
- c[t] = 0;
13274
- out.push({ center: c, size: [radial, tang, th], q: frame(u, v, t, theta), shape: "shard", weight: radial * tang });
13275
- }
13276
- }
13277
- if (out.length === 0) out.push({ center: [0, 0, 0], size: [dims[u], dims[v], th], q: frame(u, v, t), shape: "shard", weight: 1 });
13278
- return out;
13295
+ return radialPlates(inp, root, { t, u, v }, n, Math.min(inp.thickness, dims[t]), fmax * 1.5);
13279
13296
  };
13280
13297
  var planeAxes = (thin) => thin === 1 ? [0, 2] : [thin === 0 ? 2 : 0, 1];
13281
13298
  var unitGrid = (dims, thin, units, cap) => {
@@ -13566,7 +13583,27 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
13566
13583
  var MAX_SPALLS = 64;
13567
13584
  var thinAxisOf = (dims) => dims[0] <= dims[1] && dims[0] <= dims[2] ? 0 : dims[1] <= dims[2] ? 1 : 2;
13568
13585
  var resolveLayer = (def, index, mat) => ({ index, def, mat, energy: mat.penetration * def.thickness * 1e3 });
13569
- 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];
13570
13607
  var isSpalled = (spalls, layer, face, point) => {
13571
13608
  for (const s of spalls ?? []) {
13572
13609
  if (s[0] !== layer || s[1] !== face) continue;
@@ -13586,6 +13623,23 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
13586
13623
  for (const l of layers) if (onFace(l, face)) sum += l.def.thickness;
13587
13624
  return sum;
13588
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
+ };
13589
13643
  var REBAR_COVER = 0.03;
13590
13644
  var COVER = REBAR_COVER;
13591
13645
  var MAX_BARS_PER_DIRECTION = 24;
@@ -14546,8 +14600,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
14546
14600
  beams += cos * cos * q.elasticPa * c.beamFactor * inertia / Math.max(long, 1e-6);
14547
14601
  }
14548
14602
  const k = beams / kc;
14549
- const base = p.min[1] - ground < 0.05;
14550
- 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);
14551
14605
  const stiffness = a * 12 * (p.elasticPa * c.stiffnessFactor) * (g[i].du ** 3 * g[i].dv / 12) / (h * h);
14552
14606
  for (let j = 0; j < n; j++) ga[j] += stiffness * share(p, j) / bands[j];
14553
14607
  }
@@ -14732,7 +14786,49 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
14732
14786
  elasticGPa: 200,
14733
14787
  absorbed: 0.2
14734
14788
  },
14735
- 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
14736
14832
  },
14737
14833
  {
14738
14834
  id: "cast_iron",
@@ -14799,7 +14895,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
14799
14895
  "conductive"
14800
14896
  ],
14801
14897
  compressive: 8e5,
14802
- failureMPa: 90
14898
+ failureMPa: 90,
14899
+ tension: {
14900
+ elasticGPa: 69,
14901
+ ultimateMPa: 170
14902
+ }
14803
14903
  },
14804
14904
  {
14805
14905
  id: "copper",
@@ -14830,7 +14930,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
14830
14930
  "conductive"
14831
14931
  ],
14832
14932
  compressive: 1e6,
14833
- failureMPa: 70
14933
+ failureMPa: 70,
14934
+ tension: {
14935
+ elasticGPa: 117,
14936
+ ultimateMPa: 250
14937
+ }
14834
14938
  },
14835
14939
  {
14836
14940
  id: "wood_soft",
@@ -15371,7 +15475,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
15371
15475
  "flammable"
15372
15476
  ],
15373
15477
  compressive: 500,
15374
- 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
+ }
15375
15489
  },
15376
15490
  {
15377
15491
  id: "foam",
@@ -15379,7 +15493,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
15379
15493
  hpPerKg: 15,
15380
15494
  penetration: 0.5,
15381
15495
  ductility: 0.7,
15496
+ cellular: true,
15382
15497
  fracture: "tear",
15498
+ splitForm: "granules",
15383
15499
  fragmentSize: [
15384
15500
  0.03,
15385
15501
  0.15
@@ -15397,16 +15513,29 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
15397
15513
  burnRate: 0.09,
15398
15514
  conductivity: 0.02,
15399
15515
  heatCapacity: 0.5,
15400
- smoke: "black"
15516
+ smoke: "black",
15517
+ meltC: 200,
15518
+ meltRate: 0.08
15401
15519
  },
15402
15520
  visual: {
15403
- charColor: 855309
15521
+ charColor: 855309,
15522
+ innerColor: 15254346
15404
15523
  },
15405
15524
  tags: [
15406
15525
  "fabric",
15407
15526
  "flammable"
15408
15527
  ],
15409
- 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
+ }
15410
15539
  },
15411
15540
  {
15412
15541
  id: "leather",
@@ -16196,19 +16325,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
16196
16325
  };
16197
16326
  var placedPieces = /* @__PURE__ */ new WeakMap();
16198
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];
16199
- var hostedPieces = (pieces, pose3) => pieces.map((piece2, index) => {
16200
- const known = placedPieces.get(piece2);
16328
+ var hostedPieces = (pieces, pose3) => pieces.map((piece3, index) => {
16329
+ const known = placedPieces.get(piece3);
16201
16330
  const p = pose3.position, q = pose3.rotation;
16202
- 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 });
16203
16332
  if (known && isSamePlace) return known.solid;
16204
- const solid = placedPiece(piece2, index, pose3);
16205
- 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 });
16206
16335
  return solid;
16207
16336
  });
16208
- var placedPiece = (piece2, index, pose3) => {
16209
- 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}` };
16210
- if (!piece2.mesh) return base;
16211
- 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;
16212
16341
  const vertices = new Float32Array(source.length);
16213
16342
  for (let i = 0; i < source.length; i += 3) {
16214
16343
  const world = toWorld(pose3.position, pose3.rotation, [source[i], source[i + 1], source[i + 2]]);
@@ -16216,9 +16345,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
16216
16345
  vertices[i + 1] = world[1];
16217
16346
  vertices[i + 2] = world[2];
16218
16347
  }
16219
- return { ...base, mesh: { vertices, indices: piece2.mesh.indices } };
16348
+ return { ...base2, mesh: { vertices, indices: piece3.mesh.indices } };
16220
16349
  };
16221
16350
  var THIN_SHEET_DISHING = 5e-3;
16351
+ var SHELL_YIELD_SHARE = 0.5;
16352
+ var STEEL_YIELD_MPA = 250;
16222
16353
  var SWEEP_BACK = 0.01;
16223
16354
  function sweepOrigins(box4, d, spacing) {
16224
16355
  const origins = [];
@@ -16277,13 +16408,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
16277
16408
  var MEMBER_CRATER_CALIBRES = 3.4;
16278
16409
  var MEMBER_CUT_LOSS = 0.9;
16279
16410
  var MEMBER_UNIT_LOSS = 0.12;
16411
+ var CHIP_PROBE_DEPTH = 1e-4;
16280
16412
  var JOINT_OPEN_SHARE = 0.6;
16281
16413
  var BLAST_EDGE_WEAR = 0.6;
16282
16414
  var RESIDUAL_CAPACITY = 0.15;
16283
16415
  var SEVER_BAND = 0.1;
16416
+ var SURFACE_SLACK = 0.01;
16417
+ var SURFACE_SAME = 5e-4;
16284
16418
  var SEVER_ASPECT = 3;
16285
16419
  var SEVER_BALLISTIC = 2;
16286
16420
  var TEAR_JOULES = 150;
16421
+ var STRIP_THICKNESS = 15e-4;
16287
16422
  var tears = 0;
16288
16423
  var UNIT_FRAGMENT_FACTOR = 4;
16289
16424
  var BREACH_GRID_CAP = 4096;
@@ -16488,7 +16623,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
16488
16623
  if (typed) for (const fn of typed) fn(e);
16489
16624
  };
16490
16625
  let blow;
16491
- const base = (o, source) => ({
16626
+ const base2 = (o, source) => ({
16492
16627
  object: o.id,
16493
16628
  time,
16494
16629
  ...source === void 0 ? {} : { source },
@@ -17376,7 +17511,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
17376
17511
  w.emitted = { t: time, peak: d.peak, status: st.status };
17377
17512
  const dir = windDirection(o, w.cfg);
17378
17513
  const world2 = rotateVec(o.base.rot, [dir[0], 0, dir[1]]);
17379
- emit({ ...base(o), type: "sway", sway: d.x, peak: d.peak, drift: st.drift, overturn: st.overturn, frequency: st.frequency, direction: world2, status: st.status });
17514
+ emit({ ...base2(o), type: "sway", sway: d.x, peak: d.peak, drift: st.drift, overturn: st.overturn, frequency: st.frequency, direction: world2, status: st.status });
17380
17515
  }
17381
17516
  };
17382
17517
  const isTerrain = (p) => !!p.spec.tags?.includes("terrain");
@@ -17584,7 +17719,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
17584
17719
  const changed = st.status !== e.status || (time - e.t >= 0.5 || e.t === -Infinity) && (Math.abs(st.tilt - e.tilt) > 0.01 || Math.abs(st.settlement - e.s) > 2e-3);
17585
17720
  if (changed) {
17586
17721
  so.emitted = { t: time, s: st.settlement, tilt: st.tilt, status: st.status };
17587
- emit({ ...base(o), type: "settle", settlement: st.settlement, tilt: st.tilt, direction: rotateVec(o.base.rot, st.direction), bearing: st.bearing, status: st.status });
17722
+ emit({ ...base2(o), type: "settle", settlement: st.settlement, tilt: st.tilt, direction: rotateVec(o.base.rot, st.direction), bearing: st.bearing, status: st.status });
17588
17723
  }
17589
17724
  if (st.status === "toppled") topple(o);
17590
17725
  };
@@ -17633,7 +17768,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
17633
17768
  p.st.status = "broken";
17634
17769
  p.st.hp = 0;
17635
17770
  p.st.mass = 0;
17636
- emit({ ...base(o, src), type: "fracture", part: p.spec.id, style: "crumble", fragments, point: c });
17771
+ emit({ ...base2(o, src), type: "fracture", part: p.spec.id, style: "crumble", fragments, point: c });
17637
17772
  debris(o, p, p.mat.breakDebris, c, [0, 1, 0], clamp2(Math.round(Math.cbrt(partVolume(p.spec.shape)) * 30), 3, 20), 2, src);
17638
17773
  setStage(o, p, 3, {}, src);
17639
17774
  partLost(o, p, src);
@@ -17655,7 +17790,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
17655
17790
  markHostedDirty(o, p.spec.id);
17656
17791
  setStage(o, p, 3, {}, src);
17657
17792
  }
17658
- if (whole2.length > 0) emit({ ...base(o, src), type: "collapse", parts: whole2.map((p) => p.spec.id), mass: whole2.reduce((sum, p) => sum + p.st.mass, 0) });
17793
+ if (whole2.length > 0) emit({ ...base2(o, src), type: "collapse", parts: whole2.map((p) => p.spec.id), mass: whole2.reduce((sum, p) => sum + p.st.mass, 0) });
17659
17794
  }
17660
17795
  for (const p of crumbling) crumbleMasonry(o, p, src);
17661
17796
  }
@@ -17976,7 +18111,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
17976
18111
  r.st.subsidence = Math.max(r.st.subsidence ?? 0, drop.reduce((sum, v) => sum + v, 0) / count);
17977
18112
  const middle = [from[0], from[1], from[2]];
17978
18113
  middle[axis] = (stretch[0] + stretch[1]) / 2;
17979
- emit({ ...base(o, src), type: "subside", part: r.spec.id, drop: r.st.subsidence, share: (stretch[1] - stretch[0]) / Math.max(1e-6, box4.max[axis] - box4.min[axis]), point: toWorld(o.st.position, o.st.rotation, middle), status: "opened" });
18114
+ emit({ ...base2(o, src), type: "subside", part: r.spec.id, drop: r.st.subsidence, share: (stretch[1] - stretch[0]) / Math.max(1e-6, box4.max[axis] - box4.min[axis]), point: toWorld(o.st.position, o.st.rotation, middle), status: "opened" });
17980
18115
  let lost = false;
17981
18116
  for (const j of [...o.byPart.get(r.spec.id) ?? []]) {
17982
18117
  settleStructure(o);
@@ -18016,7 +18151,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18016
18151
  if (p.staged) {
18017
18152
  setStage(o, p, 1, {}, src);
18018
18153
  setStage(o, p, 2, { opening: { center: worldCenter, radius: hole.radius }, fragments }, src);
18019
- } else emit({ ...base(o, src), type: "stage", part: p.spec.id, stage: 2, opening: { center: worldCenter, radius: hole.radius }, fragments });
18154
+ } else emit({ ...base2(o, src), type: "stage", part: p.spec.id, stage: 2, opening: { center: worldCenter, radius: hole.radius }, fragments });
18020
18155
  debris(o, p, p.mat.breakDebris, worldCenter, [0, 1, 0], 14, 2, src);
18021
18156
  if (p.spec.reinforcement) exposeRebar(o, p, src);
18022
18157
  };
@@ -18042,8 +18177,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18042
18177
  const width = clamp2(beta * SETTLEMENT_CRACK_OPENING, MIN_CRACK_WIDTH, MAX_CRACK_WIDTH);
18043
18178
  const through = q.dims[q.thin];
18044
18179
  for (let c = 0; c < count; c++) {
18045
- const back = c * SETTLEMENT_CRACK_SPACING;
18046
- const local = [clamp2(at2[0] - toward[0] / reach2 * back, box4.min[0], box4.max[0]), box4.min[1] + height * (0.2 + 0.12 * c), clamp2(at2[2] - toward[2] / reach2 * back, box4.min[2], box4.max[2])];
18180
+ const back2 = c * SETTLEMENT_CRACK_SPACING;
18181
+ const local = [clamp2(at2[0] - toward[0] / reach2 * back2, box4.min[0], box4.max[0]), box4.min[1] + height * (0.2 + 0.12 * c), clamp2(at2[2] - toward[2] / reach2 * back2, box4.min[2], box4.max[2])];
18047
18182
  const face = toLocal(q.pos, q.q, local);
18048
18183
  face[q.thin] = through / 2;
18049
18184
  addCrack(o, q, toWorld(o.st.position, o.st.rotation, toWorld(q.pos, q.q, face)), normal, length, src, { along: along2, step, width, through });
@@ -18165,7 +18300,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18165
18300
  }
18166
18301
  if (bearing.status === "settled" && drop - before < SUBSIDE_MIN && peak() - peakBefore < SUBSIDE_MIN) continue;
18167
18302
  b.p.st.subsidence = drop;
18168
- emit({ ...base(o, src), type: "subside", part: b.p.spec.id, drop, share: fp.share, point: fp.deepest, status: bearing.status });
18303
+ emit({ ...base2(o, src), type: "subside", part: b.p.spec.id, drop, share: fp.share, point: fp.deepest, status: bearing.status });
18169
18304
  }
18170
18305
  for (const { b, fp } of settled) {
18171
18306
  settleStructure(o);
@@ -18280,7 +18415,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18280
18415
  const known = implSolids.get(im);
18281
18416
  if (known && known.spec === spec && known.state === state && im.impl.collidersPending?.() !== true && sameImplPlace(known.key, im)) return known.solids;
18282
18417
  const pieces = im.impl.colliders?.();
18283
- if (pieces && known?.pieces && known.spec === spec && sameImplPlace(known.key, im) && pieces.length === known.pieces.length && pieces.every((piece2, i) => piece2 === known.pieces?.[i])) {
18418
+ if (pieces && known?.pieces && known.spec === spec && sameImplPlace(known.key, im) && pieces.length === known.pieces.length && pieces.every((piece3, i) => piece3 === known.pieces?.[i])) {
18284
18419
  implSolids.set(im, { ...known, state });
18285
18420
  return known.solids;
18286
18421
  }
@@ -18365,6 +18500,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18365
18500
  return fresh.map(([nid]) => nid);
18366
18501
  };
18367
18502
  let rayBroad = null;
18503
+ let surfaceTracer = null;
18368
18504
  let uncovered = [];
18369
18505
  let uncoveredFor = { hook: null, coverage: -1, objects: -1 };
18370
18506
  const metObjects = [];
@@ -18394,7 +18530,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18394
18530
  }
18395
18531
  return rayObjects;
18396
18532
  };
18397
- const raycastInternal = (origin, dir, maxDist, ignore, worldOnly = false, precise = false, skip = {}, scope) => {
18533
+ const raycastInternal = (origin, dir, maxDist, ignore, worldOnly = false, precise = false, skip = {}, scope, drawn = false, passed) => {
18398
18534
  const d = vec.normalize(dir);
18399
18535
  const asked = rayBroad && !scope && rayBroad.begin(origin, d, maxDist) ? rayBroad : null;
18400
18536
  const candidates = asked ? candidatesOf2(asked) : null;
@@ -18422,12 +18558,22 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18422
18558
  if (!r || r.t0 < 0 || r.t0 > maxDist) continue;
18423
18559
  if (p.st.opening && insideOpening(o, p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
18424
18560
  if (p.spec.apertures && throughAperture(p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
18425
- if (p.st.chipped && insideChip(p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
18561
+ if (p.st.chipped && insideChip(p, objLocal(o, vec.madd(origin, d, Math.min(r.t0 + CHIP_PROBE_DEPTH, (r.t0 + r.t1) / 2))))) {
18562
+ passed?.push({ o, p, t: r.t0 });
18563
+ continue;
18564
+ }
18426
18565
  const gap = p.st.chipped?.length ? pastChips(o, p, origin, d, r.t0, r.t1) : null;
18427
18566
  if (gap === "through") continue;
18428
18567
  if (gap) {
18429
18568
  r.t0 = gap.t;
18430
18569
  r.n = gap.n;
18570
+ } else if (drawn && surfaceTracer) {
18571
+ const drawn2 = surfaceTracer({ object: o.id, part: p.spec.id, origin, direction: d, near: Math.max(0, r.t0 - SURFACE_SLACK), far: r.t1 + SURFACE_SLACK });
18572
+ if (drawn2 === null) continue;
18573
+ if (drawn2 && drawn2.distance <= maxDist && Math.abs(drawn2.distance - r.t0) > SURFACE_SAME) {
18574
+ r.t0 = drawn2.distance;
18575
+ r.n = [drawn2.normal[0], drawn2.normal[1], drawn2.normal[2]];
18576
+ }
18431
18577
  }
18432
18578
  if (!best || r.t0 < best.distance) {
18433
18579
  const point = vec.madd(origin, d, r.t0);
@@ -18568,14 +18714,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18568
18714
  arr[ni].radius = Math.max(arr[ni].radius, radius);
18569
18715
  } else arr.push(dent);
18570
18716
  markDamaged(p);
18571
- emit({ ...base(o, src), type: "dent", part: p.spec.id, dent, worldPoint: wp });
18717
+ emit({ ...base2(o, src), type: "dent", part: p.spec.id, dent, worldPoint: wp });
18572
18718
  };
18573
18719
  const addHole = (o, p, wp, wn, diameter, through, exit, src) => {
18574
18720
  const hole = { point: objLocal(o, wp), normal: objLocalDir(o, wn), diameter, through };
18575
18721
  p.st.holes.push(hole);
18576
18722
  if (p.st.holes.length > maxHoles) p.st.holes.shift();
18577
18723
  markDamaged(p);
18578
- emit({ ...base(o, src), type: "hole", part: p.spec.id, hole, worldPoint: wp, ...exit ? { exitPoint: exit } : {}, ...p.spec.powder ? { powder: { ...p.spec.powder } } : {} });
18724
+ emit({ ...base2(o, src), type: "hole", part: p.spec.id, hole, worldPoint: wp, ...exit ? { exitPoint: exit } : {}, ...p.spec.powder ? { powder: { ...p.spec.powder } } : {} });
18579
18725
  setStage(o, p, 1, {}, src);
18580
18726
  return hole;
18581
18727
  };
@@ -18584,13 +18730,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18584
18730
  p.st.cracks.push(crack);
18585
18731
  if (p.st.cracks.length > 16) p.st.cracks.shift();
18586
18732
  markDamaged(p);
18587
- emit({ ...base(o, src), type: "crack", part: p.spec.id, crack, worldPoint: wp });
18733
+ emit({ ...base2(o, src), type: "crack", part: p.spec.id, crack, worldPoint: wp });
18588
18734
  setStage(o, p, 1, {}, src);
18589
18735
  };
18590
- const debris = (o, p, kind, point, normal, count, speed, src, material) => emit({ ...base(o, src), type: "debris", part: p.spec.id, kind, point, normal, count, speed, ...material && material !== p.spec.material ? { material } : {} });
18736
+ const debris = (o, p, kind, point, normal, count, speed, src, material) => emit({ ...base2(o, src), type: "debris", part: p.spec.id, kind, point, normal, count, speed, ...material && material !== p.spec.material ? { material } : {} });
18591
18737
  const holeRate = (hole, pressurized) => (pressurized ? 0.5 : 0.1) * (hole.diameter / 9e-3);
18592
18738
  const detachEvents = (o, opened, by, src) => {
18593
- for (const j of opened) emit({ ...base(o, src), type: "detach", joint: j.spec.id, parts: [j.spec.a, j.spec.b], by, groups: o.st.groups.map((g) => [...g]) });
18739
+ for (const j of opened) emit({ ...base2(o, src), type: "detach", joint: j.spec.id, parts: [j.spec.a, j.spec.b], by, groups: o.st.groups.map((g) => [...g]) });
18594
18740
  };
18595
18741
  const loosened = (o, opened, by, src) => {
18596
18742
  if (runDepth === 0) {
@@ -18669,7 +18815,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18669
18815
  const checkDestroyed = (o, src) => {
18670
18816
  if (!o.st.destroyed && o.parts.length > 0 && o.parts.every(isLost)) {
18671
18817
  o.st.destroyed = true;
18672
- emit({ ...base(o, src), type: "destroyed" });
18818
+ emit({ ...base2(o, src), type: "destroyed" });
18673
18819
  }
18674
18820
  };
18675
18821
  const holeReaches = (host, box4) => {
@@ -18709,7 +18855,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18709
18855
  } else {
18710
18856
  o.hostedHosts = new Set(o.hosted.map((p) => p.spec.hostedIn));
18711
18857
  }
18712
- for (const p of shown) emit({ ...base(o), type: "reveal", part: p.spec.id, host: p.spec.hostedIn });
18858
+ for (const p of shown) emit({ ...base2(o), type: "reveal", part: p.spec.id, host: p.spec.hostedIn });
18713
18859
  if (opened.length > 0) {
18714
18860
  loosened(o, opened, "break");
18715
18861
  collapseCheck(o);
@@ -18835,26 +18981,48 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18835
18981
  const setStage = (o, p, stage, extra = {}, src) => {
18836
18982
  if (!p.staged || (p.st.stage ?? 0) >= stage) return;
18837
18983
  p.st.stage = stage;
18838
- emit({ ...base(o, src), type: "stage", part: p.spec.id, stage, ...extra });
18984
+ emit({ ...base2(o, src), type: "stage", part: p.spec.id, stage, ...extra });
18985
+ };
18986
+ const faceOf = (o, p, worldNormal) => faceOfNormal(p.layers, p.thin, rotateVec(quat.conjugate(partXf(o, p).q), worldNormal));
18987
+ const spallNormal = (o, p, face) => {
18988
+ if (Math.abs(face) === 1) return {};
18989
+ const local = [0, 0, 0];
18990
+ local[faceAxis(p.thin, face)] = face > 0 ? 1 : -1;
18991
+ return { normal: rotateVec(partXf(o, p).q, local) };
18992
+ };
18993
+ const widenTear = (o, p, torn, lp, normal, radius, src) => {
18994
+ const spalls = p.rt.spalls;
18995
+ const s = spalls[torn.spall];
18996
+ const axis = faceAxis(p.thin, s[1]);
18997
+ const faceArea = p.dims.reduce((area3, size, k) => k === axis ? area3 : area3 * size, 1);
18998
+ const reach2 = Math.hypot(lp[0] - s[2], lp[1] - s[3], lp[2] - s[4]);
18999
+ const r = Math.min(Math.sqrt(faceArea / Math.PI), Math.max(Math.sqrt(s[5] * s[5] + radius * radius), reach2));
19000
+ if (r <= s[5]) return;
19001
+ spalls[torn.spall] = [s[0], s[1], s[2], s[3], s[4], r];
19002
+ markDamaged(p);
19003
+ const centre = toWorld(o.st.position, o.st.rotation, [s[2], s[3], s[4]]);
19004
+ emit({ ...base2(o, src), type: "spall", part: p.spec.id, layer: torn.layer.index, point: centre, area: Math.PI * r * r, ...spallNormal(o, p, s[1]) });
19005
+ debris(o, p, torn.layer.mat.hitDebris, toWorld(o.st.position, o.st.rotation, lp), normal, 5, 2, src, torn.layer.mat.id);
18839
19006
  };
18840
- const faceOf = (o, p, worldNormal) => rotateVec(quat.conjugate(partXf(o, p).q), worldNormal)[p.thin] >= 0 ? 1 : -1;
18841
19007
  const spallOuter = (o, p, wp, face, normal, radius, src) => {
18842
19008
  var _a;
18843
19009
  if (p.layers.length === 0) return;
18844
19010
  const lp = objLocal(o, wp);
19011
+ const torn = tornPatchAt(p.layers, p.rt.spalls, face, lp, radius);
19012
+ if (torn) return widenTear(o, p, torn, lp, normal, radius, src);
18845
19013
  const layer = outerLayer(p.layers, p.rt.spalls, face, lp);
18846
19014
  if (!layer) return;
18847
19015
  const spalls = (_a = p.rt).spalls ?? (_a.spalls = []);
18848
19016
  spalls.push([layer.index, face, lp[0], lp[1], lp[2], radius]);
18849
19017
  if (spalls.length > MAX_SPALLS) spalls.shift();
18850
19018
  markDamaged(p);
18851
- emit({ ...base(o, src), type: "spall", part: p.spec.id, layer: layer.index, point: wp, area: Math.PI * radius * radius });
19019
+ emit({ ...base2(o, src), type: "spall", part: p.spec.id, layer: layer.index, point: wp, area: Math.PI * radius * radius, ...spallNormal(o, p, face) });
18852
19020
  debris(o, p, layer.mat.hitDebris, wp, normal, 5, 2, src, layer.mat.id);
18853
19021
  setStage(o, p, 1, {}, src);
18854
19022
  };
18855
19023
  const crater = (o, p, wp, normal, radius, src) => {
18856
19024
  markDamaged(p);
18857
- emit({ ...base(o, src), type: "spall", part: p.spec.id, layer: -1, point: wp, area: Math.PI * radius * radius });
19025
+ emit({ ...base2(o, src), type: "spall", part: p.spec.id, layer: -1, point: wp, area: Math.PI * radius * radius });
18858
19026
  debris(o, p, p.mat.breakDebris, wp, normal, 6, 1.5, src);
18859
19027
  setStage(o, p, 1, {}, src);
18860
19028
  };
@@ -18923,7 +19091,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18923
19091
  if (!layer || cells.length === 0) return [];
18924
19092
  const { c, q } = partXf(o, p);
18925
19093
  const [u, v] = planeAxes(p.thin);
18926
- const faces = layer.def.faces === "both" ? [1, -1] : [layer.def.faces === "+" ? 1 : -1];
19094
+ const faces = thinSidesOf(layer.def);
18927
19095
  const area3 = cells.reduce((sum, cell) => sum + cell.size[u] * cell.size[v], 0) * faces.length;
18928
19096
  const count = Math.min(MAX_PLASTER_FLAKES, Math.ceil(area3 / PLASTER_FLAKE_AREA));
18929
19097
  const out = [];
@@ -19105,6 +19273,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19105
19273
  }
19106
19274
  return cells.some((c) => Math.abs(lp[u] - c.center[u]) <= c.size[u] / 2 && Math.abs(lp[v] - c.center[v]) <= c.size[v] / 2);
19107
19275
  };
19276
+ const alongAt = (along2, at2) => {
19277
+ const point = [0, 0, 0];
19278
+ point[along2] = at2;
19279
+ return point;
19280
+ };
19108
19281
  const wornLocally = (p) => !!p.spec.reinforcement && !!p.spec.units && p.spec.units.mortar === p.spec.material && isMember(p.dims, p.spec.structure?.role) && p.spec.shape.kind === "box";
19109
19282
  const wearMember = (o, p, entry2, d, E, caliber, penMm, src) => {
19110
19283
  var _a, _b, _c;
@@ -19139,7 +19312,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19139
19312
  const wear = (_c = p.rt).cellWear ?? (_c.cellWear = {});
19140
19313
  const cell = grid[hit];
19141
19314
  wear[hit] = (wear[hit] ?? 0) + volume;
19142
- if (wear[hit] >= MEMBER_UNIT_LOSS * cell.size[0] * cell.size[1] * cell.size[2]) knockOutUnits(o, p, entry2, E, [hit], src);
19315
+ if (wear[hit] >= MEMBER_UNIT_LOSS * cell.size[0] * cell.size[1] * cell.size[2]) knockOutUnits(o, p, entry2, E, [hit], src, d);
19143
19316
  return true;
19144
19317
  }
19145
19318
  const out = [];
@@ -19147,8 +19320,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19147
19320
  if (gone[i] === -1) continue;
19148
19321
  if (Math.abs(grid[i].center[along2] - bandCenter) <= height / 2 + 1e-6) out.push(i);
19149
19322
  }
19150
- if (out.length > 0) knockOutUnits(o, p, entry2, E, out, src);
19151
- giveAtCut(o, p, src);
19323
+ worn[band] = 1;
19324
+ if (out.length > 0) knockOutUnits(o, p, entry2, E, out, src, d);
19325
+ giveAtCut(o, p, src, { at: alongAt(along2, bandCenter), d });
19152
19326
  return true;
19153
19327
  };
19154
19328
  const chipUnits = (o, p, kind, wp, hitEnergy, dir, radius, src) => {
@@ -19220,7 +19394,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19220
19394
  p.rt.removed = (p.rt.removed ?? 0) + mass;
19221
19395
  markDamaged(p);
19222
19396
  setStage(o, p, 1, {}, src);
19223
- emit({ ...base(o, src), type: "chip", part: p.spec.id, center, size: [cell.size[0], cell.size[1], cell.size[2]], rotation: q, fragments });
19397
+ emit({ ...base2(o, src), type: "chip", part: p.spec.id, center, size: [cell.size[0], cell.size[1], cell.size[2]], rotation: q, fragments });
19224
19398
  debris(o, p, p.mat.breakDebris, center, vec.scale(dir ?? [0, 1, 0], -1), 6, 2, src);
19225
19399
  }
19226
19400
  markHostedDirty(o, p.spec.id);
@@ -19255,18 +19429,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19255
19429
  const n = clamp2(Math.round(cell.size[u] * cell.size[v] / (bit * bit * 3)), 4, 10) + Math.floor(rnd() * 3);
19256
19430
  const out = [];
19257
19431
  for (let i = 0; i < n; i++) {
19258
- const back = i % 3 === 2;
19432
+ const back2 = i % 3 === 2;
19259
19433
  const lc = [cell.center[0], cell.center[1], cell.center[2]];
19260
19434
  lc[u] += (rnd() - 0.5) * cell.size[u] * 0.7;
19261
19435
  lc[v] += (rnd() - 0.5) * cell.size[v] * 0.7;
19262
- lc[p.thin] += (back ? -exitSign : exitSign) * (p.thickness / 2 + 0.01);
19436
+ lc[p.thin] += (back2 ? -exitSign : exitSign) * (p.thickness / 2 + 0.01);
19263
19437
  const size = [0, 0, 0];
19264
19438
  size[u] = bit * (0.6 + 0.8 * rnd());
19265
19439
  size[v] = bit * (0.5 + 0.7 * rnd());
19266
19440
  size[p.thin] = bit * (0.4 + 0.6 * rnd());
19267
19441
  const spread3 = [(rnd() - 0.5) * 0.9, (rnd() - 0.3) * 0.9, (rnd() - 0.5) * 0.9];
19268
- const k = speed * (back ? 0.4 + 0.4 * rnd() : 0.7 + 0.8 * rnd());
19269
- const vdir = vec.normalize(vec.add(back ? vec.scale(d, -1) : d, spread3));
19442
+ const k = speed * (back2 ? 0.4 + 0.4 * rnd() : 0.7 + 0.8 * rnd());
19443
+ const vdir = vec.normalize(vec.add(back2 ? vec.scale(d, -1) : d, spread3));
19270
19444
  out.push({
19271
19445
  id: `${p.spec.id}#${tag}${i}`,
19272
19446
  part: p.spec.id,
@@ -19283,8 +19457,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19283
19457
  }
19284
19458
  return out;
19285
19459
  };
19286
- const exposeRebar = (o, p, src) => {
19287
- settleStructure(o);
19460
+ const exposeRebar = (o, p, src, bowed = true) => {
19461
+ if (bowed) settleStructure(o);
19288
19462
  const r = p.spec.reinforcement;
19289
19463
  if (!r) return;
19290
19464
  const [u, v] = planeAxes(p.thin);
@@ -19301,14 +19475,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19301
19475
  bars.push(...clipBarsToDisc(all, u, v, [lc[u], lc[v]], op.radius + 0.05));
19302
19476
  }
19303
19477
  }
19304
- const bow2 = clamp2(((p.st.stress ?? 0) - 1) / 0.5, 0, 1);
19478
+ const bow2 = bowed ? clamp2(((p.st.stress ?? 0) - 1) / 0.5, 0, 1) : 0;
19305
19479
  if (bow2 > 0) bars = bars.flatMap((bar2, i) => bendBar(bar2, p.thin, bow2 * BAR_BOW, i));
19306
19480
  const stirrups = memberStirrups(p.dims, void 0, p.spec.structure?.role);
19307
19481
  if (stirrups.length > 0 && bars.length > 0) {
19308
19482
  if (p.st.stripped) bars = [...bars, ...stirrups];
19309
19483
  else for (const box4 of [...p.st.chipped ?? [], ...p.rt.bared ?? []]) bars.push(...clipBarsToVolume(stirrups, box4.center, box4.size));
19310
19484
  }
19311
- emit({ ...base(o, src), type: "expose", part: p.spec.id, bars: worldBars(o, p, bars) });
19485
+ emit({ ...base2(o, src), type: "expose", part: p.spec.id, bars: worldBars(o, p, bars) });
19312
19486
  };
19313
19487
  const openBreach = (o, p, center, total, energy, dir, src) => {
19314
19488
  const [u, v] = planeAxes(p.thin);
@@ -19469,7 +19643,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19469
19643
  for (const i of out) worn[i] = -1;
19470
19644
  return knockOutUnits(o, p, point, energy, out, src);
19471
19645
  };
19472
- const knockOutUnits = (o, p, wp, energy, out, src) => {
19646
+ const knockOutUnits = (o, p, wp, energy, out, src, d) => {
19473
19647
  var _a, _b;
19474
19648
  const [u, v] = planeAxes(p.thin);
19475
19649
  const op = p.st.opening ? toLocal(p.pos, p.q, p.st.opening.center) : null;
@@ -19513,15 +19687,34 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19513
19687
  setStage(o, p, 1, {}, src);
19514
19688
  const center = toWorld(c, q, [(lo[0] + hi[0]) / 2, (lo[1] + hi[1]) / 2, (lo[2] + hi[2]) / 2]);
19515
19689
  const units = cells.map((cell) => ({ center: toWorld(c, q, cell.center), size: [cell.size[0], cell.size[1], cell.size[2]] }));
19516
- emit({ ...base(o, src), type: "chip", part: p.spec.id, center, size: [hi[0] - lo[0], hi[1] - lo[1], hi[2] - lo[2]], rotation: q, fragments, units });
19690
+ emit({ ...base2(o, src), type: "chip", part: p.spec.id, center, size: [hi[0] - lo[0], hi[1] - lo[1], hi[2] - lo[2]], rotation: q, fragments, units });
19517
19691
  debris(o, p, p.mat.breakDebris, center, vec.normalize(vec.sub(center, wp), [0, 1, 0]), 14, 3, src);
19518
- if (p.spec.reinforcement) exposeRebar(o, p, src);
19692
+ const cut = wornLocally(p) && cutBandsGone(o, p, cells, d ?? vec.normalize(vec.sub(partXf(o, p).c, wp), [1, 0, 0]), src);
19693
+ if (p.spec.reinforcement && !cut) exposeRebar(o, p, src);
19519
19694
  if (p.structural && !isLost(p)) {
19520
19695
  solveStructure(o);
19521
19696
  collapseCheck(o, src);
19522
19697
  }
19523
19698
  return true;
19524
19699
  };
19700
+ const cutBandsGone = (o, p, cells, d, src) => {
19701
+ var _a;
19702
+ const along2 = p.dims.indexOf(Math.max(...p.dims));
19703
+ const bands = Math.max(1, Math.round(p.dims[along2] / MEMBER_BAND));
19704
+ const height = p.dims[along2] / bands;
19705
+ const bandOf2 = (at2) => clamp2(Math.floor((at2 + p.dims[along2] / 2) / p.dims[along2] * bands), 0, bands - 1);
19706
+ const grid = gridOf(p);
19707
+ const gone = p.rt.chips ?? {};
19708
+ const worn = (_a = p.rt).bands ?? (_a.bands = {});
19709
+ for (const band of new Set(cells.map((cell) => bandOf2(cell.center[along2])))) {
19710
+ if ((worn[band] ?? 0) >= 1) continue;
19711
+ const center = -p.dims[along2] / 2 + (band + 0.5) * height;
19712
+ if (!grid.every((cell, i) => gone[i] === -1 || Math.abs(cell.center[along2] - center) > height / 2 + 1e-6)) continue;
19713
+ worn[band] = 1;
19714
+ return giveAtCut(o, p, src, { at: alongAt(along2, center), d });
19715
+ }
19716
+ return false;
19717
+ };
19525
19718
  const dropUnsupported = (o, p, src) => {
19526
19719
  var _a, _b;
19527
19720
  if (!p.spec.units || p.spec.units.mortar === p.spec.material || p.st.stripped || isLost(p)) return 0;
@@ -19555,17 +19748,90 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19555
19748
  p.rt.removed = (p.rt.removed ?? 0) + mass;
19556
19749
  markDamaged(p);
19557
19750
  const units = fallen.map((cell) => ({ center: toWorld(c, q, cell.center), size: [cell.size[0], cell.size[1], cell.size[2]] }));
19558
- emit({ ...base(o, src), type: "chip", part: p.spec.id, center, size: [hi[0] - lo[0], hi[1] - lo[1], hi[2] - lo[2]], rotation: q, fragments, units });
19751
+ emit({ ...base2(o, src), type: "chip", part: p.spec.id, center, size: [hi[0] - lo[0], hi[1] - lo[1], hi[2] - lo[2]], rotation: q, fragments, units });
19559
19752
  debris(o, p, p.mat.breakDebris, center, [0, -1, 0], 6, 1, src);
19560
19753
  return loose.length;
19561
19754
  };
19562
- const giveAtCut = (o, p, src) => {
19755
+ const barsMoment = (p) => {
19756
+ const r = p.spec.reinforcement;
19757
+ if (!r) return 0;
19758
+ const left = rebarBars(p.dims, p.thin, r.spacing, p.spec.structure?.role).length - (p.rt.severedBars?.length ?? 0);
19759
+ const along2 = p.dims.indexOf(Math.max(...p.dims));
19760
+ const side = Math.min(...p.dims.filter((_, a) => a !== along2));
19761
+ const fy = (materials.get(r.material)?.bending?.yieldMPa ?? STEEL_YIELD_MPA) * 1e6;
19762
+ return Math.max(0, left) / 2 * Math.PI * (r.diameter / 2) ** 2 * fy * Math.max(0, side - 2 * REBAR_COVER);
19763
+ };
19764
+ const memberSide = (p) => {
19765
+ const along2 = p.dims.indexOf(Math.max(...p.dims));
19766
+ return Math.min(...p.dims.filter((_, a) => a !== along2));
19767
+ };
19768
+ const tubeMoment = (p, share) => {
19769
+ const [a = 0, b = 0] = [...p.dims].sort((x, y) => x - y);
19770
+ const fy = (p.mat.bending?.yieldMPa ?? STEEL_YIELD_MPA) * 1e6;
19771
+ return fy * p.thickness * ((a + b) / 2) ** 2 * Math.max(0, 1 - share) ** 2;
19772
+ };
19773
+ const holdsAbove = (o, p, j) => {
19774
+ if (j.st.open) return false;
19775
+ const other = o.parts[j.ia === o.idx.get(p.spec.id) ? j.ib : j.ia];
19776
+ if (j.bears === "a_on_b") return j.spec.b === p.spec.id;
19777
+ if (j.bears === "b_on_a") return j.spec.a === p.spec.id;
19778
+ return partXf(o, other).c[1] > partXf(o, p).c[1] + 1e-6;
19779
+ };
19780
+ const hingeAcross = (o, p, opened, cut, src) => {
19781
+ var _a;
19782
+ const blow2 = cut.d ? objLocalDir(o, cut.d) : [1, 0, 0];
19783
+ const across2 = vec.normalize([blow2[0], 0, blow2[2]], [1, 0, 0]);
19784
+ const point = vec.madd(vec.add(p.pos, rotateVec(p.q, cut.at)), across2, cut.behind);
19785
+ const toward = vec.scale(across2, -1);
19786
+ const moment = cut.moment;
19787
+ const hinges = (_a = p.rt).hinges ?? (_a.hinges = []);
19788
+ for (const j of opened) {
19789
+ j.st.yields = { point, toward, moment };
19790
+ hinges.push({ joint: j.spec.id, point, toward, moment });
19791
+ }
19792
+ emitYields(o, p, src);
19793
+ };
19794
+ const reyield = (o, p, moment, src) => {
19795
+ for (const h of p.rt.hinges ?? []) h.moment = moment;
19796
+ for (const j of o.byPart.get(p.spec.id) ?? []) if (j.st.yields) j.st.yields.moment = moment;
19797
+ emitYields(o, p, src);
19798
+ };
19799
+ const emitYields = (o, p, src) => {
19800
+ for (const h of p.rt.hinges ?? []) {
19801
+ const point = toWorld(o.st.position, o.st.rotation, h.point);
19802
+ emit({ ...base2(o, src), type: "yield", part: p.spec.id, joint: h.joint, point, toward: rotateVec(o.st.rotation, h.toward), moment: h.moment });
19803
+ }
19804
+ };
19805
+ const severBars = (o, p, origin, d, caliber, src) => {
19806
+ var _a;
19807
+ const r = p.spec.reinforcement;
19808
+ if (!r || isLost(p) || !isMember(p.dims, p.spec.structure?.role)) return;
19809
+ const along2 = p.dims.indexOf(Math.max(...p.dims));
19810
+ const [u, v] = [0, 1, 2].filter((k) => k !== along2);
19811
+ const lo = toLocal(p.pos, p.q, objLocal(o, origin));
19812
+ const ld = rotateVec(quat.conjugate(p.q), objLocalDir(o, d));
19813
+ const across2 = Math.hypot(ld[u], ld[v]);
19814
+ if (across2 < 1e-6) return;
19815
+ const cut = (_a = p.rt).severedBars ?? (_a.severedBars = []);
19816
+ let severed = 0;
19817
+ rebarBars(p.dims, p.thin, r.spacing, p.spec.structure?.role).forEach(([a], i) => {
19818
+ if (cut.includes(i)) return;
19819
+ const du = a[u] - lo[u];
19820
+ const dv = a[v] - lo[v];
19821
+ if (Math.abs(du * ld[v] - dv * ld[u]) / across2 > r.diameter / 2 + caliber / 2e3) return;
19822
+ cut.push(i);
19823
+ severed++;
19824
+ const s = (du * ld[u] + dv * ld[v]) / (across2 * across2);
19825
+ const at2 = vec.madd(origin, d, s * vec.length(d));
19826
+ debris(o, p, "sparks", at2, vec.scale(d, -1), 6, 3, src);
19827
+ });
19828
+ if (severed > 0) reyield(o, p, barsMoment(p), src);
19829
+ };
19830
+ const giveAtCut = (o, p, src, cut) => {
19563
19831
  if (!p.spec.reinforcement || !p.spec.units || !p.st.chipped?.length || sectionLoss(p) <= 0) return false;
19564
19832
  const opened = [];
19565
19833
  for (const j of o.byPart.get(p.spec.id) ?? []) {
19566
- if (j.st.open) continue;
19567
- const onIt = j.bears === "a_on_b" && j.spec.b === p.spec.id || j.bears === "b_on_a" && j.spec.a === p.spec.id;
19568
- if (!onIt) continue;
19834
+ if (!j.bears || !holdsAbove(o, p, j)) continue;
19569
19835
  j.st.open = true;
19570
19836
  j.st.openedBy = "break";
19571
19837
  opened.push(j);
@@ -19573,8 +19839,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19573
19839
  if (opened.length === 0) return false;
19574
19840
  p.st.hp = Math.max(p.st.hp, p.st.maxHp * GIVE_AT_CUT_HP);
19575
19841
  markDamaged(p);
19842
+ if (cut) hingeAcross(o, p, opened, { at: cut.at, d: cut.d, behind: memberSide(p) / 2 - REBAR_COVER, moment: barsMoment(p) }, src);
19576
19843
  loosened(o, opened, "break", src);
19577
- exposeRebar(o, p, src);
19844
+ exposeRebar(o, p, src, !cut);
19578
19845
  collapseCheck(o, src);
19579
19846
  return true;
19580
19847
  };
@@ -19602,7 +19869,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19602
19869
  p.st.status = "broken";
19603
19870
  p.st.hp = 0;
19604
19871
  p.st.mass = 0;
19605
- emit({ ...base(o, src), type: "expose", part: p.spec.id, bars: [] });
19872
+ emit({ ...base2(o, src), type: "expose", part: p.spec.id, bars: [] });
19606
19873
  debris(o, p, "sparks", partXf(o, p).c, [0, 1, 0], 6, 3, src);
19607
19874
  partLost(o, p, src);
19608
19875
  };
@@ -19664,7 +19931,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19664
19931
  rnd: planRnd,
19665
19932
  sheet: p.mat.sheet,
19666
19933
  ...p.mat.splitForm ? { form: p.mat.splitForm } : {},
19667
- ...cutAt2 !== void 0 ? { cut: { at: cutAt2, gap: SEVER_BAND } } : {}
19934
+ ...cutAt2 !== void 0 ? { cut: { at: cutAt2, gap: SEVER_BAND } } : {},
19935
+ ...p.spec.solids ? { solids: p.spec.solids } : {}
19668
19936
  });
19669
19937
  const holes = p.st.holes.length > 0 ? localHolesOf(p) : [];
19670
19938
  const mass = p.st.mass;
@@ -19700,7 +19968,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19700
19968
  p.st.burning = false;
19701
19969
  p.rt.jet = false;
19702
19970
  }
19703
- emit({ ...base(o, src), type: "fracture", part: p.spec.id, style, fragments, point: hitW });
19971
+ emit({ ...base2(o, src), type: "fracture", part: p.spec.id, style, fragments, point: hitW });
19704
19972
  debris(o, p, p.mat.breakDebris, c, [0, 1, 0], clamp2(Math.round(Math.cbrt(partVolume(p.spec.shape)) * 30), 3, 20), 2, src);
19705
19973
  setStage(o, p, 3, {}, src);
19706
19974
  if (reinforcement) {
@@ -19708,7 +19976,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19708
19976
  return;
19709
19977
  }
19710
19978
  if (ex) {
19711
- emit({ ...base(o, src), type: "explode", part: p.spec.id, point: c, energy: ex.energy, radius: ex.radius, ...ex.lethalRadius !== void 0 ? { lethalRadius: ex.lethalRadius } : {}, ...ex.tnt !== void 0 ? { tnt: ex.tnt } : {}, ...ex.effect !== void 0 ? { effect: ex.effect } : {} });
19979
+ emit({ ...base2(o, src), type: "explode", part: p.spec.id, point: c, energy: ex.energy, radius: ex.radius, ...ex.lethalRadius !== void 0 ? { lethalRadius: ex.lethalRadius } : {}, ...ex.tnt !== void 0 ? { tnt: ex.tnt } : {}, ...ex.effect !== void 0 ? { effect: ex.effect } : {} });
19712
19980
  const fuel = burstFuel(p);
19713
19981
  blasts.push({ point: c, energy: ex.energy, radius: ex.radius, ...ex.lethalRadius !== void 0 ? { lethalRadius: ex.lethalRadius } : {}, ...fuel > 0 ? { fuel } : {}, source: src });
19714
19982
  }
@@ -19721,7 +19989,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19721
19989
  p.rt.chainDue = time + delay;
19722
19990
  primed.set(p, o);
19723
19991
  o.active = true;
19724
- emit({ ...base(o, src), type: "primed", part: p.spec.id, point: partXf(o, p).c, trigger, delay });
19992
+ emit({ ...base2(o, src), type: "primed", part: p.spec.id, point: partXf(o, p).c, trigger, delay });
19725
19993
  };
19726
19994
  const CHAIN_TRIGGER_OF = { ballistic: "shot", explosive: "explosion" };
19727
19995
  const severAxis = (p) => {
@@ -19758,7 +20026,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19758
20026
  if (p.st.hp <= 0 && p.mat.fracture === "none" && !p.spec.explodes) p.st.hp = Math.min(prev, 1);
19759
20027
  if (p.st.hp <= 0 && type === "ballistic" && wornLocally(p)) p.st.hp = Math.min(prev, 1);
19760
20028
  const done = prev - p.st.hp;
19761
- if (done > 0) emit({ ...base(o, src), type: "damage", part: p.spec.id, amount: done, hp: Math.max(0, p.st.hp), damageType: type });
20029
+ if (done > 0) emit({ ...base2(o, src), type: "damage", part: p.spec.id, amount: done, hp: Math.max(0, p.st.hp), damageType: type });
19762
20030
  if (p.st.hp <= 0) failPart(o, p, origin, dir, fragEnergy * weight, cap, src);
19763
20031
  else if (chained && (trigger === "explosion" || 1 - p.st.hp / p.st.maxHp >= shotDamageFractionOf(p.spec))) prime(o, p, trigger, src);
19764
20032
  return done;
@@ -19800,27 +20068,29 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19800
20068
  const n = shot ? exit ? clamp2(Math.round(E / joules), 1, 7) : 1 : clamp2(Math.floor(E / joules), 0, 5);
19801
20069
  if (n === 0) return;
19802
20070
  const fibre = tear === "lumps";
20071
+ const strips = tear === "strips";
19803
20072
  const { q } = partXf(o, p);
19804
20073
  const along2 = (p.spec.grain ? AXIS[p.spec.grain] : void 0) ?? [0, 1, 2].sort((a, b) => p.dims[b] - p.dims[a])[0];
19805
20074
  const fragments = [];
19806
20075
  for (let i = 0; i < n; i++) {
19807
- const back = !exit || i % 3 === 2;
20076
+ const back2 = !exit || i % 3 === 2;
19808
20077
  const plies = p.mat.splitForm === "plies";
19809
- const len = scale * (fibre ? 1.2 + 1.2 * rnd() : 3 + 4 * rnd()), w = scale * (0.8 + 0.8 * rnd()), t = scale * (fibre ? 0.7 + 0.6 * rnd() : plies ? 0.15 + 0.15 * rnd() : 0.4 + 0.4 * rnd());
20078
+ const len = scale * (fibre ? 1.2 + 1.2 * rnd() : strips ? 6 + 6 * rnd() : 3 + 4 * rnd()), w = scale * (strips ? 1 + rnd() : 0.8 + 0.8 * rnd());
20079
+ const t = strips ? Math.min(p.thickness, STRIP_THICKNESS) : scale * (fibre ? 0.7 + 0.6 * rnd() : plies ? 0.15 + 0.15 * rnd() : 0.4 + 0.4 * rnd());
19810
20080
  const size = [w, w, w];
19811
20081
  size[along2] = len;
19812
20082
  size[(along2 + 1) % 3] = w;
19813
20083
  size[(along2 + 2) % 3] = t;
19814
20084
  const spread3 = [(rnd() - 0.5) * 0.8, (rnd() - 0.2) * 0.8, (rnd() - 0.5) * 0.8];
19815
- const speed = shot ? back ? 1.5 + 2 * rnd() : 2 + 4 * rnd() : 0.8 + 1.2 * rnd();
19816
- const v = vec.scale(vec.normalize(vec.add(back ? vec.scale(d, -1) : d, spread3)), speed);
20085
+ const speed = shot ? back2 ? 1.5 + 2 * rnd() : 2 + 4 * rnd() : 0.8 + 1.2 * rnd();
20086
+ const v = vec.scale(vec.normalize(vec.add(back2 ? vec.scale(d, -1) : d, spread3)), speed);
19817
20087
  const mass = size[0] * size[1] * size[2] * p.mat.density;
19818
20088
  fragments.push({
19819
20089
  id: `${p.spec.id}#t${tears++}-${i}`,
19820
20090
  part: p.spec.id,
19821
20091
  material: p.spec.material,
19822
- shape: fibre ? "chunk" : "splinter",
19823
- center: back || !exit ? vec.madd(entry2, d, -0.01) : vec.madd(exit, d, 0.01),
20092
+ shape: fibre ? "chunk" : strips ? "scrap" : "splinter",
20093
+ center: back2 || !exit ? vec.madd(entry2, d, -0.01) : vec.madd(exit, d, 0.01),
19824
20094
  size,
19825
20095
  rotation: q,
19826
20096
  velocity: v,
@@ -19830,14 +20100,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19830
20100
  });
19831
20101
  }
19832
20102
  const patch = [scale * 4, scale * 4, scale * 4];
19833
- emit({ ...base(o, src), type: "chip", part: p.spec.id, center: exit ?? entry2, size: patch, rotation: q, fragments, torn: true });
20103
+ emit({ ...base2(o, src), type: "chip", part: p.spec.id, center: exit ?? entry2, size: patch, rotation: q, fragments, torn: true });
19834
20104
  };
19835
20105
  const ballistic = (o, p, entry2, n, d, E, caliber, pathLen, src, round3 = {}) => {
19836
20106
  const mat = p.mat;
19837
- const piece2 = round3.piece;
19838
- const weight = piece2?.weight ?? 1;
20107
+ const piece3 = round3.piece;
20108
+ const weight = piece3?.weight ?? 1;
19839
20109
  const piercing = round3.piercing ?? 1;
19840
- if (p.st.stripped || p.st.opening && insideOpening(o, p, objLocal(o, entry2)) || insideChip(p, objLocal(o, entry2))) {
20110
+ if (p.st.stripped || p.st.opening && insideOpening(o, p, objLocal(o, entry2)) || insideChip(p, objLocal(o, vec.madd(entry2, d, Math.min(CHIP_PROBE_DEPTH, pathLen / 2))))) {
19841
20111
  return { penetrated: true, exitEnergy: E, exitPoint: vec.madd(entry2, d, Math.min(pathLen, p.thickness)), damage: 0 };
19842
20112
  }
19843
20113
  const sin = Math.min(1, Math.abs(vec.dot(d, n)));
@@ -19851,14 +20121,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19851
20121
  const hard = mat.tags?.includes("metal") || mat.tags?.includes("masonry");
19852
20122
  const penMm = penetrationOf(mat, round3.penetration);
19853
20123
  const Ep = penMm !== void 0 ? penMm * mat.penetration : piercing === 1 || !hard ? E : E * piercing;
19854
- const strength = piece2 && mat.strength?.ndrc ? mat.strength.compressiveMPa : void 0;
20124
+ const strength = piece3 && mat.strength?.ndrc ? mat.strength.compressiveMPa : void 0;
19855
20125
  const path = strength === void 0 ? 0 : (p.thickness + layersThickness(p.layers, face) + layersThickness(p.layers, -face)) / slant;
19856
- const penetrated = Ep > thr && (strength === void 0 || !piece2 || concretePerforation({ mass: piece2.mass, caliber: caliber / 1e3, speed: Math.sqrt(2 * E / piece2.mass), compressiveMPa: strength, nose: piece2.nose }).perforation > path);
20126
+ const penetrated = Ep > thr && (strength === void 0 || !piece3 || concretePerforation({ mass: piece3.mass, caliber: caliber / 1e3, speed: Math.sqrt(2 * E / piece3.mass), compressiveMPa: strength, nose: piece3.nose }).perforation > path);
19857
20127
  const scale = (mat.damageScale?.ballistic ?? 1) * (mat.fracture === "shatter" ? fragility(mat.ductility, p.thickness) : 1);
19858
20128
  const id = p.spec.id;
19859
20129
  if (!penetrated && mat.ricochetDeg && angle < mat.ricochetDeg) {
19860
20130
  const r = vec.sub(d, vec.scale(n, 2 * vec.dot(d, n)));
19861
- emit({ ...base(o, src), type: "ricochet", part: id, point: entry2, direction: vec.normalize(r), energy: E * 0.4 });
20131
+ emit({ ...base2(o, src), type: "ricochet", part: id, point: entry2, direction: vec.normalize(r), energy: E * 0.4 });
19862
20132
  debris(o, p, mat.hitDebris, entry2, n, 3, 3, src);
19863
20133
  const dmg2 = applyDamage(o, p, E * DMG_PER_J * scale * 0.2, "ballistic", entry2, d, E * 0.1, 12, src, weight);
19864
20134
  return { penetrated: false, exitEnergy: 0, damage: dmg2 };
@@ -19869,10 +20139,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19869
20139
  const ratio = Ep / Math.max(thr, 1e-6);
19870
20140
  const crackLen = clamp2(0.03 + ratio * 0.2, 0.03, 0.8);
19871
20141
  let exitPoint;
20142
+ let shellShare = 0;
19872
20143
  if (penetrated) {
19873
20144
  const exitDist = p.spec.contains || p.spec.fill !== void 0 && p.spec.fill < 0.5 || p.thickness < pathLen * 0.5 ? pathLen : Math.min(pathLen, effM + layersThickness(p.layers, face) / slant + layersThickness(p.layers, -face) / slant);
19874
20145
  exitPoint = vec.madd(entry2, d, exitDist);
19875
20146
  const hole = addHole(o, p, entry2, n, caliber / 1e3 * (mat.ductility >= 0.3 ? 1 : 1.5), true, exitPoint, src);
20147
+ shellShare = wearsShell(p, hole.diameter * 2);
19876
20148
  if (p.layers.length > 0) spallOuter(o, p, exitPoint, -face, vec.scale(n, -1), Math.max(0.03, caliber / 1e3 * 4), src);
19877
20149
  addBreach(o, p, entry2, Math.PI * (hole.diameter / 2) * (hole.diameter / 2), E, d, src);
19878
20150
  if (mat.ductility >= 0.5 && p.thickness <= THIN_SHEET_DISHING) addDent(o, p, entry2, n, Math.max(caliber * 3 / 1e3, 0.012), clamp2(E * 2e-5, 1e-3, 0.03), src);
@@ -19880,7 +20152,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19880
20152
  if (p.spec.contains && (p.st.liters ?? 0) > 1e-4) {
19881
20153
  o.active = true;
19882
20154
  emit({
19883
- ...base(o, src),
20155
+ ...base2(o, src),
19884
20156
  type: "leak",
19885
20157
  part: id,
19886
20158
  fluid: p.spec.contains.fluid,
@@ -19900,8 +20172,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19900
20172
  debris(o, p, mat.hitDebris, entry2, n, clamp2(Math.round(E / 60) + 2, 2, 14), clamp2(Math.sqrt(E) / 6, 1, 8), src);
19901
20173
  wearJoints(o, p, (penetrated ? thr : E) * 0.02 * weight, void 0, 0, src, true, BULLET_JOINT_SPAN);
19902
20174
  const hollowTear = mat.fracture === "tear" && p.spec.fill !== void 0 && p.spec.fill < 0.5;
19903
- const absorbed = penetrated && (mat.ductility >= 0.5 && mat.fracture !== "tear" || hollowTear) ? Math.min(E, thr) : E;
20175
+ const absorbed = penetrated && (mat.ductility >= 0.5 && mat.fracture !== "tear" || hollowTear || mat.cellular === true) ? Math.min(E, thr) : E;
19904
20176
  const dmg = applyDamage(o, p, absorbed * DMG_PER_J * scale, "ballistic", entry2, d, absorbed * 0.1, 12, src, weight);
20177
+ if (shellShare > 0 && !isLost(p)) yieldShell(o, p, shellShare, entry2, d, src);
19905
20178
  if (!isLost(p)) tearAt(o, p, "ballistic", entry2, penetrated ? exitPoint : void 0, d, E, caliber / 1e3, src);
19906
20179
  if (!wearMember(o, p, entry2, d, E, caliber, penMm, src)) chipUnits(o, p, "ballistic", entry2, penetrated ? Math.min(E, Math.max(thr, E * 0.5)) : E, d, Math.max(0.05, caliber / 1e3 * 8), src);
19907
20180
  return { penetrated, exitEnergy: penetrated ? penMm !== void 0 ? E * (1 - thr / Ep) : E - thr / (hard ? piercing : 1) : 0, exitPoint, damage: dmg };
@@ -19919,13 +20192,37 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19919
20192
  const hinge = plateHinge(p.dims, toLocal(c, q, point), local);
19920
20193
  const toObject = (v) => rotateVec(p.q, v);
19921
20194
  p.st.bendHinge = { point: vec.add(p.pos, toObject(hinge.point)), axis: toObject(hinge.axis), side: toObject(hinge.side) };
19922
- emit({ ...base(o), type: "bend", part: p.spec.id, hinge: p.st.bendHinge, angle: p.st.bend - before, worldPoint: point });
20195
+ emit({ ...base2(o), type: "bend", part: p.spec.id, hinge: p.st.bendHinge, angle: p.st.bend - before, worldPoint: point });
19923
20196
  }
19924
20197
  const axis = severAxis(p);
19925
20198
  if (axis < 0 || snapRatio(p.dims, p.mat.bending, E, local, SEVER_ASPECT) < 1) return 0;
19926
20199
  p.rt.cutAt = clamp2(toLocal(c, q, point)[axis], -p.dims[axis] / 2, p.dims[axis] / 2);
19927
20200
  return Math.max(0, p.st.hp);
19928
20201
  };
20202
+ const wearsShell = (p, width) => {
20203
+ if (p.mat.ductility < 0.5 || p.thickness > THIN_SHEET_DISHING || p.spec.shape.kind !== "box") return 0;
20204
+ const [a = 0, b = 0, c = 0] = [...p.dims].sort((x, y) => x - y);
20205
+ if (c < 2 * b || b > 3 * a) return 0;
20206
+ p.rt.shellCut = (p.rt.shellCut ?? 0) + width;
20207
+ return Math.min(1, p.rt.shellCut / (2 * (a + b)));
20208
+ };
20209
+ const yieldShell = (o, p, share, entry2, d, src) => {
20210
+ if (share < SHELL_YIELD_SHARE) return;
20211
+ if (p.rt.hinges?.length) {
20212
+ reyield(o, p, tubeMoment(p, share), src);
20213
+ return;
20214
+ }
20215
+ const opened = (o.byPart.get(p.spec.id) ?? []).filter((j) => holdsAbove(o, p, j));
20216
+ if (opened.length === 0) return;
20217
+ for (const j of opened) {
20218
+ j.st.open = true;
20219
+ j.st.openedBy = "break";
20220
+ }
20221
+ const along2 = p.dims.indexOf(Math.max(...p.dims));
20222
+ hingeAcross(o, p, opened, { at: alongAt(along2, toLocal(p.pos, p.q, objLocal(o, entry2))[along2]), d, behind: memberSide(p) / 2, moment: tubeMoment(p, share) }, src);
20223
+ loosened(o, opened, "break", src);
20224
+ collapseCheck(o, src);
20225
+ };
19929
20226
  const melee = (o, p, kind, E, point, n, d, contactR, src) => {
19930
20227
  const mat = p.mat;
19931
20228
  const thrMm = mat.penetration * p.thickness * 1e3;
@@ -20016,7 +20313,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20016
20313
  frontQueue.push({ o, p, due: time + dist / blastFrontSpeed, amount, fragEnergy: Ein * 0.3, point, ...src !== void 0 ? { src } : {} });
20017
20314
  return reach2;
20018
20315
  }
20019
- if (Ein > 20 && p.layers.length > 0) spallOuter(o, p, wp, o.st.rotation === objectRotation && p.q === partQuat ? rotateVec(quat.conjugate(q), wn)[p.thin] >= 0 ? 1 : -1 : faceOf(o, p, wn), wn, clamp2(0.05 + Math.sqrt(Ein) * 2e-3, 0.05, 0.4), src);
20316
+ if (Ein > 20 && p.layers.length > 0) spallOuter(o, p, wp, o.st.rotation === objectRotation && p.q === partQuat ? faceOfNormal(p.layers, p.thin, rotateVec(quat.conjugate(q), wn)) : faceOf(o, p, wn), wn, clamp2(0.05 + Math.sqrt(Ein) * 2e-3, 0.05, 0.4), src);
20020
20317
  const breachReach = BREACH_BLAST_REACH * Math.cbrt(Math.max(0, energy) / 1e3);
20021
20318
  const caged2 = Boolean(p.spec.reinforcement && p.spec.units);
20022
20319
  const member = caged2 && (isMember(p.dims, p.spec.structure?.role) || dist > MEMBER_CUT_REACH * breachReach);
@@ -20375,7 +20672,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20375
20672
  for (let i = 0; i < 4 && E > 0; i++) {
20376
20673
  const reach2 = flight ? E > flight.minEnergy ? Math.log(E / flight.minEnergy) / (2 * flight.drag) : 0 : Infinity;
20377
20674
  if (!(reach2 > 0)) break;
20378
- const rh = raycastInternal(org, d, reach2, ignore, false, true);
20675
+ const crossed = [];
20676
+ const rh = raycastInternal(org, d, reach2, ignore, false, true, {}, void 0, true, crossed);
20677
+ for (const c of crossed) if (!rh || c.t < rh.distance) severBars(c.o, c.p, org, d, caliber, source);
20379
20678
  if (!rh) break;
20380
20679
  if (flight) E *= Math.exp(-2 * flight.drag * vec.distance(org, rh.point));
20381
20680
  const im = impls.get(rh.object);
@@ -20572,14 +20871,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20572
20871
  }
20573
20872
  return out;
20574
20873
  }
20575
- const mergeResults = (base2, extra) => {
20576
- const byObject = new Map(base2.map((r) => [r.object, r]));
20874
+ const mergeResults = (base22, extra) => {
20875
+ const byObject = new Map(base22.map((r) => [r.object, r]));
20577
20876
  for (const r of extra) {
20578
20877
  const have = byObject.get(r.object);
20579
20878
  if (!have) {
20580
20879
  const copy = { ...r, events: [...r.events] };
20581
20880
  byObject.set(r.object, copy);
20582
- base2.push(copy);
20881
+ base22.push(copy);
20583
20882
  continue;
20584
20883
  }
20585
20884
  have.damage += r.damage;
@@ -20587,7 +20886,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20587
20886
  have.events.push(...r.events);
20588
20887
  if (!have.part && r.part) have.part = r.part;
20589
20888
  }
20590
- return base2;
20889
+ return base22;
20591
20890
  };
20592
20891
  function* blastSteps(point, energy, radius, src, call, only, lethal) {
20593
20892
  const cfg = blastCfg(call);
@@ -20839,7 +21138,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20839
21138
  p.st.temperature = Math.max(p.st.temperature, th.flameC ?? 800);
20840
21139
  o.active = true;
20841
21140
  markDamaged(p);
20842
- emit({ ...base(o, src), type: "ignite", part: p.spec.id, point: partXf(o, p).c });
21141
+ emit({ ...base2(o, src), type: "ignite", part: p.spec.id, point: partXf(o, p).c });
20843
21142
  };
20844
21143
  const syncMass = (p) => {
20845
21144
  p.st.mass = Math.max(0, p.mass0 * (1 - p.st.melt) - (p.fuel0 - p.st.fuel));
@@ -20865,11 +21164,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20865
21164
  p.st.status = "ashes";
20866
21165
  p.st.hp = 0;
20867
21166
  p.st.mass = p.mass0 * (1 - (th.fuelFraction ?? 0));
20868
- emit({ ...base(o), type: "burnout", part: p.spec.id, point: c });
21167
+ emit({ ...base2(o), type: "burnout", part: p.spec.id, point: c });
20869
21168
  debris(o, p, "ash", c, [0, 1, 0], clamp2(Math.round(Math.cbrt(partVolume(p.spec.shape)) * 30), 3, 20), 1);
20870
21169
  partLost(o, p);
20871
21170
  } else {
20872
- emit({ ...base(o), type: "burnout", part: p.spec.id, point: c });
21171
+ emit({ ...base2(o), type: "burnout", part: p.spec.id, point: c });
20873
21172
  }
20874
21173
  }
20875
21174
  };
@@ -20886,11 +21185,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20886
21185
  p.rt.dripT -= 0.25;
20887
21186
  const b = partWorldAabb(o, p);
20888
21187
  const pt = [b.min[0] + (b.max[0] - b.min[0]) * (0.2 + 0.6 * rnd()), b.min[1], b.min[2] + (b.max[2] - b.min[2]) * (0.2 + 0.6 * rnd())];
20889
- emit({ ...base(o), type: "drip", part: p.spec.id, point: pt, material: p.mat.id });
21188
+ emit({ ...base2(o), type: "drip", part: p.spec.id, point: pt, material: p.mat.id });
20890
21189
  }
20891
21190
  if (p.st.melt - p.rt.meltEmitted >= 0.05 || p.st.melt >= 1) {
20892
21191
  p.rt.meltEmitted = p.st.melt;
20893
- emit({ ...base(o), type: "melt", part: p.spec.id, melt: p.st.melt });
21192
+ emit({ ...base2(o), type: "melt", part: p.spec.id, melt: p.st.melt });
20894
21193
  }
20895
21194
  if (p.st.melt >= 1) {
20896
21195
  p.st.status = "melted";
@@ -20963,7 +21262,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20963
21262
  }
20964
21263
  p.rt.jet = true;
20965
21264
  s.burning = true;
20966
- emit({ ...base(o), type: "ignite", part: p.spec.id, point: partXf(o, p).c });
21265
+ emit({ ...base2(o), type: "ignite", part: p.spec.id, point: partXf(o, p).c });
20967
21266
  }
20968
21267
  }
20969
21268
  }
@@ -20971,7 +21270,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20971
21270
  if (p.rt.jet && (s.liters ?? 0) <= 0) {
20972
21271
  p.rt.jet = false;
20973
21272
  s.burning = false;
20974
- emit({ ...base(o), type: "extinguish", part: p.spec.id });
21273
+ emit({ ...base2(o), type: "extinguish", part: p.spec.id });
20975
21274
  }
20976
21275
  const sc = th.thermalShockC;
20977
21276
  if (sc !== void 0) {
@@ -21005,7 +21304,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21005
21304
  if (stress > 1) {
21006
21305
  if (p.rt.stressT <= 0) {
21007
21306
  p.rt.stressT = 0.5;
21008
- emit({ ...base(o), type: "stress", part: p.spec.id, stress, load: p.st.load ?? 0 });
21307
+ emit({ ...base2(o), type: "stress", part: p.spec.id, stress, load: p.st.load ?? 0 });
21009
21308
  if (p.spec.reinforcement && (p.st.stripped || p.st.chipped?.length || p.st.opening)) exposeRebar(o, p);
21010
21309
  }
21011
21310
  applyDamage(o, p, overloadRate(stress) * p.st.maxHp * dt, "blunt", null, null, 5, 3);
@@ -21319,6 +21618,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21319
21618
  setRayBroadPhase(broadPhase2) {
21320
21619
  rayBroad = broadPhase2;
21321
21620
  },
21621
+ setSurfaceTracer(tracer) {
21622
+ surfaceTracer = tracer;
21623
+ },
21322
21624
  groundLoss(loss) {
21323
21625
  if (!(loss.radius > 0) || !(loss.depth > 0) || !Number.isFinite(loss.x) || !Number.isFinite(loss.z)) return;
21324
21626
  pendingLosses.push({ ...loss });
@@ -21383,7 +21685,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21383
21685
  const step = Math.floor(j.st.progress * 10 + 1e-9);
21384
21686
  if (step > j.step || j.st.progress >= 1) {
21385
21687
  j.step = step;
21386
- emit({ ...base(o), type: "disassemble_progress", joint: j.spec.id, tool: tool2, progress: j.st.progress });
21688
+ emit({ ...base2(o), type: "disassemble_progress", joint: j.spec.id, tool: tool2, progress: j.st.progress });
21387
21689
  }
21388
21690
  if (j.st.progress >= 1) {
21389
21691
  j.st.open = true;
@@ -21469,7 +21771,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21469
21771
  if (p.st.burning) {
21470
21772
  p.st.burning = false;
21471
21773
  p.rt.jet = false;
21472
- emit({ ...base(o), type: "extinguish", part: p.spec.id });
21774
+ emit({ ...base2(o), type: "extinguish", part: p.spec.id });
21473
21775
  }
21474
21776
  p.st.temperature = Math.max(ambient, p.st.temperature - coolC);
21475
21777
  }
@@ -21501,7 +21803,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21501
21803
  if (p.st.holes.length > maxHoles) p.st.holes.shift();
21502
21804
  o.active = true;
21503
21805
  emit({
21504
- ...base(o),
21806
+ ...base2(o),
21505
21807
  type: "leak",
21506
21808
  part: partId,
21507
21809
  fluid: c.fluid,
@@ -21711,7 +22013,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21711
22013
  var defaultSet;
21712
22014
  var defaultAssemblies = () => defaultSet ?? (defaultSet = assembliesOver(ASSEMBLIES));
21713
22015
  var getAssembly = (id) => defaultAssemblies().get(id);
21714
- var faceCount = (layer) => layer.faces === "both" ? 2 : 1;
22016
+ var faceCount = (layer) => layer.faces === "both" || layer.faces === "all" ? 2 : 1;
21715
22017
  var assemblyDepth = (def) => def.depth ?? def.core.thickness + (def.layers ?? []).reduce((sum, l) => sum + l.thickness * faceCount(l), 0);
21716
22018
  var buildAssemblyPart = (def, assemblyId, options) => {
21717
22019
  if (!def) throw new Error(`unknown assembly "${assemblyId}"`);
@@ -21885,8 +22187,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21885
22187
  const id = w.add(onRock(s));
21886
22188
  return new Map(w.state(id).parts.map((p) => [p.id, p.flexure ?? 0]));
21887
22189
  };
21888
- const base = bending(out);
21889
- const factor = new Map(targets.map((p) => [p.id, (base.get(p.id) ?? 0) / safetyOf(p.structure.role)]));
22190
+ const base2 = bending(out);
22191
+ const factor = new Map(targets.map((p) => [p.id, (base2.get(p.id) ?? 0) / safetyOf(p.structure.role)]));
21890
22192
  if (options.redundancy !== void 0) {
21891
22193
  const roles = options.redundancyRoles ?? ["column"];
21892
22194
  for (const lost of out.parts) {
@@ -21930,11 +22232,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21930
22232
  return new Map(w.state(id).parts.map((p) => [p.id, { load: p.load ?? 0, stress: p.stress ?? 0, wind: p.wind ?? 0 }]));
21931
22233
  };
21932
22234
  const out = structuredClone(spec);
21933
- const base = loads(out, options.wind);
22235
+ const base2 = loads(out, options.wind);
21934
22236
  const gamma = options.wind ? resolveWind(options.wind).loadFactor : 0;
21935
22237
  const structural = out.parts.filter((p) => p.structure && p.structure.role !== "none");
21936
22238
  const loadAt = (p) => {
21937
- const b = base.get(p.id);
22239
+ const b = base2.get(p.id);
21938
22240
  return b && b.stress > 0 ? b.load + (b.wind > 0 ? gamma * b.wind / GRAVITY : 0) : void 0;
21939
22241
  };
21940
22242
  const lossesOf = function* () {
@@ -21963,7 +22265,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21963
22265
  if (options.wind) {
21964
22266
  const yieldMPa = resolveFlexure(options.flexure).rebarYieldMPa;
21965
22267
  for (const p of out.parts) {
21966
- const b = base.get(p.id);
22268
+ const b = base2.get(p.id);
21967
22269
  if (!b || b.wind >= 0 || !p.reinforcement || p.shape.kind !== "box") continue;
21968
22270
  const pull = -(b.load + gamma * b.wind / GRAVITY) * GRAVITY;
21969
22271
  if (pull <= 0) continue;
@@ -23016,8 +23318,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23016
23318
  return { parts: context.parts, supports: context.supports };
23017
23319
  }
23018
23320
  function anchorBalconies(context) {
23019
- const base = context.panelsOf.get("slab_base");
23020
- if (!base) return;
23321
+ const base2 = context.panelsOf.get("slab_base");
23322
+ if (!base2) return;
23021
23323
  const decks = context.parts.filter((p) => p.role === "slab" && /^slab_\d+_/.test(p.id) && context.supports.some((s) => s.part === p.id && /^balcony_column_/.test(s.on)));
23022
23324
  for (const deck of decks) {
23023
23325
  const pillars = new Set(context.supports.filter((s) => s.part === deck.id && /^balcony_column_/.test(s.on)).map((s) => s.on));
@@ -23036,7 +23338,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23036
23338
  if (!splits.size) return input;
23037
23339
  const boxes = new Map(input.parts.map((part) => [part.id, part.aabb]));
23038
23340
  const pieceBox = /* @__PURE__ */ new Map();
23039
- for (const split of splits.values()) for (const piece2 of split.pieces) pieceBox.set(piece2.id, piece2.aabb);
23341
+ for (const split of splits.values()) for (const piece3 of split.pieces) pieceBox.set(piece3.id, piece3.aabb);
23040
23342
  const parts2 = input.parts.flatMap((part) => splits.get(part.id)?.pieces ?? [part]);
23041
23343
  const supports = [];
23042
23344
  for (const support of input.supports) {
@@ -23178,9 +23480,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23178
23480
  const spandrel = spandrels[k];
23179
23481
  if (spandrel) internal.push({ part: spandrel.id, on: lintel.id, joint: style.wallJoint });
23180
23482
  });
23181
- const base = [...piers, ...drafts.filter((d) => d.id.includes("_sill_"))].map((d) => d.id);
23483
+ const base2 = [...piers, ...drafts.filter((d) => d.id.includes("_sill_"))].map((d) => d.id);
23182
23484
  const top = [...piers.map((p) => p.id), ...lintels.map((l, k) => spandrels[k]?.id ?? l.id)];
23183
- return { pieces, internal, base, top };
23485
+ return { pieces, internal, base: base2, top };
23184
23486
  }
23185
23487
  var LOG_DIAMETER = 0.26;
23186
23488
  var isWall = (part) => part.id.startsWith("wall_") && part.assembly !== void 0 && (part.role === "wall" || part.role === "partition");
@@ -23242,7 +23544,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23242
23544
  if (capacity === void 0) continue;
23243
23545
  const along2 = (box22) => Math.max(box22[2] - box22[0], box22[3] - box22[1]);
23244
23546
  const length = along2(input.parts.find((part) => part.id === id).aabb);
23245
- for (const piece2 of split.pieces) capacities.set(piece2.id, Math.max(1, capacity * along2(piece2.aabb) / length));
23547
+ for (const piece3 of split.pieces) capacities.set(piece3.id, Math.max(1, capacity * along2(piece3.aabb) / length));
23246
23548
  }
23247
23549
  return { ...next, capacities };
23248
23550
  }
@@ -23466,10 +23768,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23466
23768
  const joints = [...spec.joints ?? []];
23467
23769
  const reinforcement = { material: "steel", spacing: c.rebar.spacing, diameter: c.rebar.diameter };
23468
23770
  const raft2 = parts2.find((p) => p.id === "raft");
23469
- let base = raft2?.id;
23470
- if (!base) {
23471
- base = "core_mat";
23472
- parts2.push({ id: base, material: c.material, shape: box3([W + 1, c.matThickness, L + 1]), position: [cx, -c.matThickness / 2, cz], structure: { role: "foundation" }, anchored: true });
23771
+ let base2 = raft2?.id;
23772
+ if (!base2) {
23773
+ base2 = "core_mat";
23774
+ parts2.push({ id: base2, material: c.material, shape: box3([W + 1, c.matThickness, L + 1]), position: [cx, -c.matThickness / 2, cz], structure: { role: "foundation" }, anchored: true });
23473
23775
  }
23474
23776
  const innerX = x0 + t + c.stairWidth + ti / 2;
23475
23777
  for (let f = 0; f < g.floors; f++) {
@@ -23477,7 +23779,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23477
23779
  const wall = (name, size, pos) => {
23478
23780
  const id = `core_${f}_${name}`;
23479
23781
  parts2.push({ id, material: c.material, shape: box3(size), position: [pos[0], yb + H / 2, pos[1]], structure: { role: "wall" }, reinforcement, tags: ["core"] });
23480
- rests(joints, id, f === 0 ? base : `core_${f - 1}_${name}`, "rebar");
23782
+ rests(joints, id, f === 0 ? base2 : `core_${f - 1}_${name}`, "rebar");
23481
23783
  return id;
23482
23784
  };
23483
23785
  const tube2 = [
@@ -23530,7 +23832,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23530
23832
  mass: 1500,
23531
23833
  tags: ["elevator_car"]
23532
23834
  });
23533
- rests(joints, id, base, "resting", false);
23835
+ rests(joints, id, base2, "resting", false);
23534
23836
  }
23535
23837
  return { ...spec, parts: parts2, joints };
23536
23838
  }
@@ -24253,9 +24555,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24253
24555
  const rule = storageRuleOf(rules, state.storage);
24254
24556
  const thawDays = rules.aging.thawShelfDays[state.storage];
24255
24557
  const isThawing = rule.needsPower === true && !powered && thawDays !== void 0 && state.shelfLife === void 0;
24256
- const base = isThawing ? { ...state, ageDays: 0, shelfLife: thawDays } : state;
24257
- const ageDays = base.ageDays + accruedDays(state.storage, { storedAt: state.storedAt, from: state.since, to: now }, options);
24258
- return { ...base, ageDays, since: Math.max(now, state.since) };
24558
+ const base2 = isThawing ? { ...state, ageDays: 0, shelfLife: thawDays } : state;
24559
+ const ageDays = base2.ageDays + accruedDays(state.storage, { storedAt: state.storedAt, from: state.since, to: now }, options);
24560
+ return { ...base2, ageDays, since: Math.max(now, state.since) };
24259
24561
  };
24260
24562
  var shelfRatio = (item, state) => {
24261
24563
  const shelfLife = state.shelfLife ?? item.shelfLife;
@@ -24286,12 +24588,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24286
24588
  var resolveUse = (item, effects, context = {}, rules = DEFAULT_RULES) => {
24287
24589
  const def = findEffect(item, effects);
24288
24590
  if (!def) return void 0;
24289
- const base = { useId: def.id, effect: def.effect, params: def.params ?? {}, consumes: def.consumes };
24290
- if (def.effect !== "consume_nutrition") return base;
24591
+ const base2 = { useId: def.id, effect: def.effect, params: def.params ?? {}, consumes: def.consumes };
24592
+ if (def.effect !== "consume_nutrition") return base2;
24291
24593
  const nutrition = nutritionOf(item, context, rules);
24292
24594
  const blocked = item.seal && context.seal ? sealBlock(item.seal, context.seal) : void 0;
24293
- if (blocked) return { ...base, consumes: false, nutrition: { ...nutrition, isEdible: false }, blocked };
24294
- return { ...base, consumes: def.consumes && nutrition.isEdible, nutrition };
24595
+ if (blocked) return { ...base2, consumes: false, nutrition: { ...nutrition, isEdible: false }, blocked };
24596
+ return { ...base2, consumes: def.consumes && nutrition.isEdible, nutrition };
24295
24597
  };
24296
24598
  var countOf = (context, id) => context.inventory.get(id) ?? 0;
24297
24599
  var candidatesOf = (input, context) => {
@@ -24428,10 +24730,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24428
24730
  };
24429
24731
  var countFor = (pool, state, footprint, query, rules) => {
24430
24732
  const settings = rules.finds.pool;
24431
- const base = Math.max(settings.min, Math.min(settings.max, Math.round(settings.offset + footprint * settings.perSquareMetre + query.rng() * settings.jitter)));
24432
- if (state === "fortified") return Math.min(pool.length, base + settings.fortifiedExtra);
24733
+ const base2 = Math.max(settings.min, Math.min(settings.max, Math.round(settings.offset + footprint * settings.perSquareMetre + query.rng() * settings.jitter)));
24734
+ if (state === "fortified") return Math.min(pool.length, base2 + settings.fortifiedExtra);
24433
24735
  if (state === "abandoned") return query.rng() < settings.abandonedEmptyChance ? 0 : settings.abandonedKept;
24434
- return base;
24736
+ return base2;
24435
24737
  };
24436
24738
  var rollExplicitPool = (pool, state, query, rules) => {
24437
24739
  const settings = rules.finds.pool;
@@ -43106,9 +43408,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
43106
43408
  var goodsItemUse = createGoodsItemUse();
43107
43409
 
43108
43410
  // ../game-interactables-household/dist/index.js
43109
- var door = (material, joint = "hinge", piece2 = "door") => ({ material, joint, piece: piece2 });
43411
+ var door = (material, joint = "hinge", piece22 = "door") => ({ material, joint, piece: piece22 });
43110
43412
  var drawer = { material: "mdf", joint: "slide", piece: "drawer" };
43111
43413
  var knob = { material: "plastic", joint: "clip", piece: "knob" };
43414
+ var mainLever = { material: "plastic", joint: "clip", piece: "breaker" };
43112
43415
  var tap = { material: "steel", joint: "screw", piece: "handle" };
43113
43416
  var mdfBody = { material: "mdf", joint: "screw" };
43114
43417
  var cabinet = { body: mdfBody, parts: [[/^drawer/, drawer], [/^door/, door("mdf")]] };
@@ -43116,6 +43419,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
43116
43419
  var bin = { body: { material: "plastic", joint: "fused" }, parts: [["lid", door("plastic", "hinge", "lid")]] };
43117
43420
  var upholstery = { material: "fabric", joint: "glue" };
43118
43421
  var POLE_CAGE = { material: "steel", spacing: 0.1, diameter: 0.01 };
43422
+ var BRICKWORK = { size: [0.23, 0.075, 0.11], bond: "running", mortar: "mortar" };
43119
43423
  var DESTRUCTION = {
43120
43424
  fridge: fridgeLike,
43121
43425
  fridge_compact: fridgeLike,
@@ -43142,19 +43446,23 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
43142
43446
  wall_socket: { body: { material: "plastic", joint: "screw" }, parts: [] },
43143
43447
  wall_switch: { body: { material: "plastic", joint: "screw" }, parts: [["rocker", { material: "plastic", joint: "clip", piece: "rocker" }]] },
43144
43448
  // a cast concrete pole (NBR 8451: CA-50 bars in the concrete), its segments held by the bars; the meter box, the cross arm and the bracket are bolted to it
43145
- service_entrance: { body: { material: "concrete", joint: "rebar", reinforcement: POLE_CAGE }, parts: [["meter_door", door("steel")]] },
43449
+ service_entrance: { body: { material: "concrete", joint: "rebar", reinforcement: POLE_CAGE }, parts: [["meter_door", door("steel")], ["main_breaker", mainLever]] },
43146
43450
  conduit_run: { body: { material: "plastic", joint: "clip" }, parts: [] },
43147
- service_mast: { body: { material: "steel", joint: "clip" }, parts: [] },
43451
+ // one galvanised pipe bent over the top: its stretches are the same steel (welded, not clipped: the clamps hold it to the wall, not to itself)
43452
+ service_mast: { body: { material: "steel", joint: "weld" }, parts: [] },
43148
43453
  electrical_panel: {
43149
43454
  body: { material: "steel", joint: "screw" },
43150
43455
  parts: [[/^breaker/, { material: "plastic", joint: "clip", piece: "breaker" }], ["door", door("steel")]]
43151
43456
  },
43152
- power_meter: { body: { material: "plastic", joint: "screw" }, parts: [["door", door("plastic")]] },
43457
+ power_meter: { body: { material: "plastic", joint: "screw" }, parts: [["door", door("plastic")], ["main_breaker", mainLever]] },
43153
43458
  tv: { body: { material: "plastic", joint: "screw" }, parts: [["power", { material: "plastic", joint: "clip", piece: "button" }]] },
43154
43459
  microwave: { body: { material: "steel", joint: "screw" }, parts: [["door", door("steel")], ["dial", knob]] },
43155
43460
  washing_machine: { body: { material: "steel", joint: "screw" }, parts: [["dial", knob], ["door", door("tempered_glass")]] },
43156
43461
  sofa: { body: upholstery, parts: [] },
43157
43462
  armchair: { body: upholstery, parts: [] },
43463
+ pouf: { body: upholstery, parts: [] },
43464
+ box_bed: { body: upholstery, parts: [] },
43465
+ upholstered_chair: { body: upholstery, parts: [] },
43158
43466
  dining_chair: { body: { material: "wood_hard", joint: "screw" }, parts: [] },
43159
43467
  bed_double: { body: { material: "wood_soft", joint: "screw" }, parts: [] },
43160
43468
  bed_single: { body: { material: "wood_soft", joint: "screw" }, parts: [] },
@@ -43171,13 +43479,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
43171
43479
  parts: [["flap", door("steel", "hinge", "flap")], ["flag", { material: "steel", joint: "hinge", piece: "flag" }]]
43172
43480
  },
43173
43481
  dog_house: { body: { material: "plywood", joint: "nail" }, parts: [] },
43174
- bbq: { body: { material: "brick", joint: "mortar" }, parts: [["counter_door", door("steel")]] },
43482
+ bbq: { body: { material: "brick", joint: "mortar", units: BRICKWORK }, parts: [["counter_door", door("steel")]] },
43175
43483
  bunk_bed: { body: { material: "wood_soft", joint: "screw" }, parts: [] },
43176
43484
  wood_stove: {
43177
43485
  body: { material: "cast_iron", joint: "bolt" },
43178
43486
  parts: [["firebox_door", { material: "cast_iron", joint: "hinge", piece: "door" }]]
43179
43487
  },
43180
- fireplace: { body: { material: "brick", joint: "mortar" }, parts: [] },
43488
+ fireplace: { body: { material: "brick", joint: "mortar", units: BRICKWORK }, parts: [] },
43181
43489
  outhouse: {
43182
43490
  body: { material: "wood_soft", joint: "nail" },
43183
43491
  parts: [["door", door("wood_soft", "hinge", "door")], ["seat_lid", door("wood_soft", "hinge", "lid")]]
@@ -43226,9 +43534,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
43226
43534
  "type.washing_machine": "Washing machine",
43227
43535
  "type.sofa": "Sofa",
43228
43536
  "type.armchair": "Armchair",
43537
+ "type.pouf": "Pouf",
43229
43538
  "type.dining_chair": "Dining chair",
43539
+ "type.upholstered_chair": "Upholstered chair",
43230
43540
  "type.bed_double": "Double bed",
43231
43541
  "type.bed_single": "Single bed",
43542
+ "type.box_bed": "Box bed",
43232
43543
  "type.bench": "Bench",
43233
43544
  "type.blinds": "Blinds",
43234
43545
  "type.curtain": "Curtain",
@@ -43381,6 +43692,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
43381
43692
  "prompt.breaker.off": "Switch on {circuit}",
43382
43693
  "prompt.breaker.off.verb": "Switch on",
43383
43694
  "prompt.breaker.off.object": "{circuit}",
43695
+ "prompt.main_breaker": "Main breaker",
43696
+ "prompt.main_breaker.on": "Switch off the main breaker",
43697
+ "prompt.main_breaker.on.verb": "Switch off",
43698
+ "prompt.main_breaker.on.object": "the main breaker",
43699
+ "prompt.main_breaker.off": "Switch on the main breaker",
43700
+ "prompt.main_breaker.off.verb": "Switch on",
43701
+ "prompt.main_breaker.off.object": "the main breaker",
43384
43702
  "type.bunk_bed": "Bunk bed",
43385
43703
  "type.wood_stove": "Wood stove",
43386
43704
  "type.fireplace": "Fireplace",
@@ -43474,9 +43792,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
43474
43792
  "type.washing_machine": "M\xE1quina de lavar",
43475
43793
  "type.sofa": "Sof\xE1",
43476
43794
  "type.armchair": "Poltrona",
43795
+ "type.pouf": "Pufe",
43477
43796
  "type.dining_chair": "Cadeira",
43797
+ "type.upholstered_chair": "Cadeira estofada",
43478
43798
  "type.bed_double": "Cama de casal",
43479
43799
  "type.bed_single": "Cama de solteiro",
43800
+ "type.box_bed": "Cama box",
43480
43801
  "type.bench": "Banco",
43481
43802
  "type.blinds": "Persiana",
43482
43803
  "type.curtain": "Cortina",
@@ -43629,6 +43950,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
43629
43950
  "prompt.breaker.off": "Ligar {circuit}",
43630
43951
  "prompt.breaker.off.verb": "Ligar",
43631
43952
  "prompt.breaker.off.object": "{circuit}",
43953
+ "prompt.main_breaker": "Disjuntor geral",
43954
+ "prompt.main_breaker.on": "Desligar o disjuntor geral",
43955
+ "prompt.main_breaker.on.verb": "Desligar",
43956
+ "prompt.main_breaker.on.object": "o disjuntor geral",
43957
+ "prompt.main_breaker.off": "Ligar o disjuntor geral",
43958
+ "prompt.main_breaker.off.verb": "Ligar",
43959
+ "prompt.main_breaker.off.object": "o disjuntor geral",
43632
43960
  "type.bunk_bed": "Beliche",
43633
43961
  "type.wood_stove": "Fog\xE3o a lenha",
43634
43962
  "type.fireplace": "Lareira",
@@ -44079,6 +44407,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
44079
44407
  pushable: true,
44080
44408
  massKg: 25
44081
44409
  },
44410
+ {
44411
+ id: "pouf",
44412
+ group: "seating",
44413
+ w: 0.45,
44414
+ d: 0.45,
44415
+ h: 0.42,
44416
+ y: 0,
44417
+ solid: true,
44418
+ pushable: true,
44419
+ massKg: 4
44420
+ },
44082
44421
  {
44083
44422
  id: "dining_chair",
44084
44423
  group: "seating",
@@ -44089,6 +44428,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
44089
44428
  solid: true,
44090
44429
  massKg: 5
44091
44430
  },
44431
+ {
44432
+ id: "upholstered_chair",
44433
+ group: "seating",
44434
+ w: 0.46,
44435
+ d: 0.52,
44436
+ h: 0.92,
44437
+ y: 0,
44438
+ solid: true,
44439
+ massKg: 6
44440
+ },
44092
44441
  {
44093
44442
  id: "bed_double",
44094
44443
  group: "seating",
@@ -44111,6 +44460,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
44111
44460
  pushable: true,
44112
44461
  massKg: 30
44113
44462
  },
44463
+ {
44464
+ id: "box_bed",
44465
+ group: "seating",
44466
+ w: 1.38,
44467
+ d: 1.88,
44468
+ h: 0.72,
44469
+ y: 0,
44470
+ solid: true,
44471
+ pushable: true,
44472
+ massKg: 75
44473
+ },
44114
44474
  {
44115
44475
  id: "bench",
44116
44476
  group: "seating",
@@ -44357,8 +44717,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
44357
44717
  "warn.buildEmpty": "construir devolveu vazio para {id}"
44358
44718
  };
44359
44719
  function createTranslator(locale, table) {
44360
- const base = locale && /^pt/i.test(locale) ? ptBR : en;
44361
- const messages = { ...base, ...table ?? {} };
44720
+ const base2 = locale && /^pt/i.test(locale) ? ptBR : en;
44721
+ const messages = { ...base2, ...table ?? {} };
44362
44722
  return (key2, params) => (messages[key2] ?? key2).replace(/\{(\w+)\}/g, (_m, name) => params && params[name] !== void 0 ? String(params[name]) : `{${name}}`);
44363
44723
  }
44364
44724
  var TYPE_MAP = Object.freeze({
@@ -44851,8 +45211,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
44851
45211
  var r3 = (n) => Math.round(n * 1e3) / 1e3;
44852
45212
  var CYLINDER_VALVE_Y = 0.47;
44853
45213
  var at = (it) => ({ x: it.x ?? 0, z: it.z ?? 0, ry: it.ry ?? 0 });
44854
- function mergeRegistry(base, extra) {
44855
- const out = { ...base };
45214
+ function mergeRegistry(base2, extra) {
45215
+ const out = { ...base2 };
44856
45216
  if (extra) {
44857
45217
  for (const [key2, value] of Object.entries(extra)) {
44858
45218
  if (value == null) delete out[key2];
@@ -46543,7 +46903,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
46543
46903
  rooms: (w, d, op) => {
46544
46904
  const hu0 = r22(w * 0.3), hu1 = r22(w * 0.7), n = floorCount(op, 3), el = !!op.elevator && n > 1;
46545
46905
  const ex = hu0 + (el ? 4.2 : 2.4);
46546
- const base = [
46906
+ const base2 = [
46547
46907
  { id: "sitting_room", type: "living", label: "sitting_room", rect: [0, 0, hu0, 7] },
46548
46908
  { id: "kitchen", type: "kitchen", label: "kitchen", rect: [0, 7, hu0, d - 3.2] },
46549
46909
  { id: "laundry", type: "laundry", label: "laundry", rect: [0, d - 3.2, hu0, d] },
@@ -46554,10 +46914,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
46554
46914
  { id: "bedroom", type: "bedroom", label: "suite", rect: [hu1, 8.2, w, d - 3.3], overrides: { bed: { size: [2.2, 2.35], cats: { bed: 2, bed_king: 3 } }, wardrobe: { cats: { wardrobe: 2, wardrobe_large: 3 }, size: [2.5, 0.75] } } },
46555
46915
  { id: "bathroom", type: "bathroom", label: "bathroom_suite", library: "bathroom_wc", rect: [hu1, d - 3.3, w, d] }
46556
46916
  ];
46557
- if (n > 1) base.push({ id: "stairs", type: "stairs", label: "stairs", rect: [hu0, d - 5, hu0 + 2.4, d], link: [0, 1] });
46558
- if (el) base.push({ id: "elevator", type: "elevator", label: "elevator", rect: [hu0 + 2.4, d - 5, hu0 + 4.2, d] });
46559
- base.push({ id: "office", type: "office", label: "office", rect: [n > 1 ? ex : hu0, d - 5, hu1, d] });
46560
- return base;
46917
+ if (n > 1) base2.push({ id: "stairs", type: "stairs", label: "stairs", rect: [hu0, d - 5, hu0 + 2.4, d], link: [0, 1] });
46918
+ if (el) base2.push({ id: "elevator", type: "elevator", label: "elevator", rect: [hu0 + 2.4, d - 5, hu0 + 4.2, d] });
46919
+ base2.push({ id: "office", type: "office", label: "office", rect: [n > 1 ? ex : hu0, d - 5, hu1, d] });
46920
+ return base2;
46561
46921
  },
46562
46922
  doors: (w, d, op) => {
46563
46923
  const hu0 = r22(w * 0.3), hu1 = r22(w * 0.7), n = floorCount(op, 3), el = !!op.elevator && n > 1;
@@ -46931,7 +47291,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
46931
47291
  }
46932
47292
  var residentialTower = residentialTowerTemplate();
46933
47293
 
46934
- // ../game-floorplan-three/dist/chunk-OGYLJ4F7.js
47294
+ // ../game-floorplan-three/dist/chunk-XI3CKQAV.js
46935
47295
  var __defProp3 = Object.defineProperty;
46936
47296
  var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp3(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
46937
47297
  var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
@@ -46944,6 +47304,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
46944
47304
  "what.door": "the door",
46945
47305
  "what.curtain": "the curtain",
46946
47306
  "what.mailbox": "the mailbox",
47307
+ "what.stallDoor": "the shower door",
46947
47308
  "what.pedestrianGate": "the small gate",
46948
47309
  "what.garageGate": "the garage gate",
46949
47310
  "what.drawer": "drawer",
@@ -46969,6 +47330,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
46969
47330
  "what.door": "a porta",
46970
47331
  "what.curtain": "a cortina",
46971
47332
  "what.mailbox": "a caixa de correio",
47333
+ "what.stallDoor": "a porta do box",
46972
47334
  "what.pedestrianGate": "o port\xE3ozinho",
46973
47335
  "what.garageGate": "o port\xE3o da garagem",
46974
47336
  "what.drawer": "gaveta",
@@ -47004,15 +47366,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
47004
47366
  for (let axis = 0; axis < 3; axis++) {
47005
47367
  const lo = axis, hi = axis + 3;
47006
47368
  if (b[lo] > box4[lo] + EPS3) {
47007
- const piece2 = [...box4];
47008
- piece2[hi] = b[lo];
47009
- out.push(piece2);
47369
+ const piece22 = [...box4];
47370
+ piece22[hi] = b[lo];
47371
+ out.push(piece22);
47010
47372
  box4[lo] = b[lo];
47011
47373
  }
47012
47374
  if (b[hi] < box4[hi] - EPS3) {
47013
- const piece2 = [...box4];
47014
- piece2[lo] = b[hi];
47015
- out.push(piece2);
47375
+ const piece22 = [...box4];
47376
+ piece22[lo] = b[hi];
47377
+ out.push(piece22);
47016
47378
  box4[hi] = b[hi];
47017
47379
  }
47018
47380
  }
@@ -47022,14 +47384,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
47022
47384
  const laid = [];
47023
47385
  for (const solid of solids) {
47024
47386
  let pieces = [solid.box];
47025
- for (const before of laid) pieces = pieces.flatMap((piece2) => subtractBox(piece2, before.box));
47387
+ for (const before of laid) pieces = pieces.flatMap((piece22) => subtractBox(piece22, before.box));
47026
47388
  for (const box4 of pieces) laid.push({ ...solid, box: box4 });
47027
47389
  }
47028
47390
  return laid;
47029
47391
  }
47030
47392
  function outsideBoxes(box4, taken) {
47031
47393
  let pieces = [box4];
47032
- for (const t of taken) pieces = pieces.flatMap((piece2) => subtractBox(piece2, t));
47394
+ for (const t of taken) pieces = pieces.flatMap((piece22) => subtractBox(piece22, t));
47033
47395
  return pieces;
47034
47396
  }
47035
47397
  function installKernelGeometry(K, shared2) {
@@ -47357,7 +47719,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
47357
47719
  nz = -nz;
47358
47720
  [a, b] = [pts[0], pts[1]];
47359
47721
  }
47360
- const [cr, cg, cb] = rgbOf(color2), scale = UV_SCALE[mat] || 1, base = A.nv;
47722
+ const [cr, cg, cb] = rgbOf(color2), scale = UV_SCALE[mat] || 1, base2 = A.nv;
47361
47723
  let e1x = b[0] - a[0], e1y = b[1] - a[1], e1z = b[2] - a[2];
47362
47724
  const l1 = Math.hypot(e1x, e1y, e1z) || 1;
47363
47725
  e1x /= l1;
@@ -47365,7 +47727,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
47365
47727
  e1z /= l1;
47366
47728
  const e2x = ny * e1z - nz * e1y, e2y = nz * e1x - nx * e1z, e2z = nx * e1y - ny * e1x;
47367
47729
  pts.forEach((p, k) => {
47368
- const o = base + k;
47730
+ const o = base2 + k;
47369
47731
  A.p[o * 3] = p[0] - O[0];
47370
47732
  A.p[o * 3 + 1] = p[1] - O[1];
47371
47733
  A.p[o * 3 + 2] = p[2] - O[2];
@@ -47380,9 +47742,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
47380
47742
  A.u[o * 2 + 1] = (dx * e2x + dy * e2y + dz * e2z) / scale;
47381
47743
  });
47382
47744
  for (let k = 1; k < n - 1; k++) {
47383
- A.i[A.ni++] = base;
47384
- A.i[A.ni++] = base + k;
47385
- A.i[A.ni++] = base + k + 1;
47745
+ A.i[A.ni++] = base2;
47746
+ A.i[A.ni++] = base2 + k;
47747
+ A.i[A.ni++] = base2 + k + 1;
47386
47748
  }
47387
47749
  A.nv += n;
47388
47750
  }
@@ -48741,8 +49103,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
48741
49103
  const puts = (f, type, m0, extra) => {
48742
49104
  const ent = T2[type];
48743
49105
  if (!ent) return;
48744
- const com = shared2.ctx.roomById[m0.room], g = "f" + f, base = Y0(f);
48745
- const M = Object.assign({ x: m0.x, z: m0.z, ry: m0.ry || 0, w: m0.w || 0.3, d: m0.d || 0.3, h: m0.h || 0.3, y: 0, base, floor: f, colors: shared2.ctx.colors, seed: m0.id, room: m0.room, typeWith: com ? com.type : null, ceiling: com ? com.ceiling : 2.8, on: shared2.ctx.night, light: shared2.ctx.night, lit: shared2.ctx.night }, extra || {});
49106
+ const com = shared2.ctx.roomById[m0.room], g = "f" + f, base2 = Y0(f);
49107
+ const M = Object.assign({ x: m0.x, z: m0.z, ry: m0.ry || 0, w: m0.w || 0.3, d: m0.d || 0.3, h: m0.h || 0.3, y: 0, base: base2, floor: f, colors: shared2.ctx.colors, seed: m0.id, room: m0.room, typeWith: com ? com.type : null, ceiling: com ? com.ceiling : 2.8, on: shared2.ctx.night, light: shared2.ctx.night, lit: shared2.ctx.night }, extra || {});
48746
49108
  cursor.group = g;
48747
49109
  lightItem({ id: m0.id, room: m0.room }, M, ent, api, g);
48748
49110
  };
@@ -49563,7 +49925,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
49563
49925
  }
49564
49926
  const AC = accFor(mat), m = L.length, [cr, cg, cb] = rgbOf(color2), O = cursor.org;
49565
49927
  AC.ensure(m * 2, (m - 1) * 6);
49566
- const base = AC.nv, w2 = 2 * Math.PI / P;
49928
+ const base2 = AC.nv, w2 = 2 * Math.PI / P;
49567
49929
  const profile = (sv) => {
49568
49930
  const ph = sv * w2, hh = A + A * Math.sin(ph), dh = A * w2 * Math.cos(ph), ql = Math.hypot(dh, 1);
49569
49931
  const per = Math.floor(sv / P), rr = _h2(per * 7 + 3, 11), fil = colonial ? 0.9 + 0.2 * (0.5 + 0.5 * Math.sin(ph + 1.5708)) : 0.95 + 0.1 * (0.5 + 0.5 * Math.sin(ph + 1.5708)), v = 1.5 * fil * (0.94 + 0.1 * rr);
@@ -49579,7 +49941,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
49579
49941
  const sv = L[j], [hh, qx, qy, qz, v] = at2(sv);
49580
49942
  const cj = col[j] || col[j - 1] || col[j + 1] || [0, 0];
49581
49943
  for (let k = 0; k < 2; k++) {
49582
- const t = cj[k], oo = base + j * 2 + k, px = o[0] + sv * ex + t * dx + nx * hh, py = o[1] + sv * ey + t * dy + ny * hh, pz = o[2] + sv * ez + t * dz + nz * hh;
49944
+ const t = cj[k], oo = base2 + j * 2 + k, px = o[0] + sv * ex + t * dx + nx * hh, py = o[1] + sv * ey + t * dy + ny * hh, pz = o[2] + sv * ez + t * dz + nz * hh;
49583
49945
  AC.p[oo * 3] = px - O[0];
49584
49946
  AC.p[oo * 3 + 1] = py - O[1];
49585
49947
  AC.p[oo * 3 + 2] = pz - O[2];
@@ -49595,7 +49957,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
49595
49957
  }
49596
49958
  for (let j = 0; j + 1 < m; j++) {
49597
49959
  if (!col[j] && !col[j + 1]) continue;
49598
- const a0 = base + j * 2, a1 = a0 + 1, b0 = a0 + 2, b1 = a0 + 3;
49960
+ const a0 = base2 + j * 2, a1 = a0 + 1, b0 = a0 + 2, b1 = a0 + 3;
49599
49961
  AC.i[AC.ni++] = a0;
49600
49962
  AC.i[AC.ni++] = b0;
49601
49963
  AC.i[AC.ni++] = a1;
@@ -50295,12 +50657,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50295
50657
  if (x1 - x0 < 1e-4 || y1 - y0 < 1e-4 || z1 - z0 < 1e-4) return;
50296
50658
  for (const [normal, corners] of FACES2) {
50297
50659
  if (openBottom && normal[1] < 0) continue;
50298
- const base = this.positions.length / 3;
50660
+ const base2 = this.positions.length / 3;
50299
50661
  for (const [cx, cy, cz] of corners) {
50300
50662
  this.positions.push(cx ? x1 : x0, cy ? y1 : y0, cz ? z1 : z0);
50301
50663
  this.normals.push(normal[0], normal[1], normal[2]);
50302
50664
  }
50303
- this.indices.push(base, base + 1, base + 2, base, base + 2, base + 3);
50665
+ this.indices.push(base2, base2 + 1, base2 + 2, base2, base2 + 2, base2 + 3);
50304
50666
  }
50305
50667
  }
50306
50668
  /**
@@ -50321,12 +50683,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50321
50683
  const out = [0, 1, 2].reduce((sum, k) => sum + n[k] * ((a[k] + b[k] + c[k] + d[k]) / 4 - centre[k]), 0);
50322
50684
  const ring2 = out >= 0 ? [a, b, c, d] : [a, d, c, b];
50323
50685
  if (out < 0) n = n.map((x) => -x);
50324
- const base = this.positions.length / 3;
50686
+ const base2 = this.positions.length / 3;
50325
50687
  for (const p of ring2) {
50326
50688
  this.positions.push(p[0], p[1], p[2]);
50327
50689
  this.normals.push(n[0], n[1], n[2]);
50328
50690
  }
50329
- this.indices.push(base, base + 1, base + 2, base, base + 2, base + 3);
50691
+ this.indices.push(base2, base2 + 1, base2 + 2, base2, base2 + 2, base2 + 3);
50330
50692
  }
50331
50693
  }
50332
50694
  /** A flat four-cornered face that looks along `normal` (it is wound so). */
@@ -50336,12 +50698,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50336
50698
  const e1 = [b[0] - a[0], b[1] - a[1], b[2] - a[2]], e2 = [d[0] - a[0], d[1] - a[1], d[2] - a[2]];
50337
50699
  const facing = (e1[1] * e2[2] - e1[2] * e2[1]) * normal[0] + (e1[2] * e2[0] - e1[0] * e2[2]) * normal[1] + (e1[0] * e2[1] - e1[1] * e2[0]) * normal[2];
50338
50700
  const ring2 = facing >= 0 ? corners : [corners[0], corners[3], corners[2], corners[1]];
50339
- const base = this.positions.length / 3;
50701
+ const base2 = this.positions.length / 3;
50340
50702
  for (const p of ring2) {
50341
50703
  this.positions.push(p[0], p[1], p[2]);
50342
50704
  this.normals.push(normal[0], normal[1], normal[2]);
50343
50705
  }
50344
- this.indices.push(base, base + 1, base + 2, base, base + 2, base + 3);
50706
+ this.indices.push(base2, base2 + 1, base2 + 2, base2, base2 + 2, base2 + 3);
50345
50707
  }
50346
50708
  /** The mesh of everything added, or null when nothing was. */
50347
50709
  mesh(THREE, material, name) {
@@ -50511,8 +50873,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50511
50873
  var DOOR_HEAD = 2.1;
50512
50874
  function crossesOpening(plan, a, b, y) {
50513
50875
  return plan.openings.some((o) => {
50514
- const base = plan.floors[o.floor]?.y0 ?? 0;
50515
- if (y <= base + (o.y0 ?? 0) || y >= base + (o.y1 ?? DOOR_HEAD)) return false;
50876
+ const base2 = plan.floors[o.floor]?.y0 ?? 0;
50877
+ if (y <= base2 + (o.y0 ?? 0) || y >= base2 + (o.y1 ?? DOOR_HEAD)) return false;
50516
50878
  const [p0, p1, q0, q1] = o.axis === "u" ? [a[1], b[1], a[0], b[0]] : [a[0], b[0], a[1], b[1]];
50517
50879
  const across2 = Math.min(p0, p1) <= o.pos + 0.1 && Math.max(p0, p1) >= o.pos - 0.1;
50518
50880
  return across2 && Math.max(Math.min(q0, q1), o.at - o.width / 2) < Math.min(Math.max(q0, q1), o.at + o.width / 2);
@@ -50732,10 +51094,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50732
51094
  const w = TRENCH.berm.width;
50733
51095
  const heapAt = ox ? [ox > 0 ? x1 + SPOIL_CLEAR : x0 - SPOIL_CLEAR - w, z0, ox > 0 ? x1 + SPOIL_CLEAR + w : x0 - SPOIL_CLEAR, z1] : [x0, oz > 0 ? z1 + SPOIL_CLEAR : z0 - SPOIL_CLEAR - w, x1, oz > 0 ? z1 + SPOIL_CLEAR + w : z0 - SPOIL_CLEAR];
50734
51096
  const onBuilding = [site.footprint, ...site.buildings].some(([bx0, bz0, bx1, bz1]) => heapAt[2] > bx0 - 0.4 && heapAt[0] < bx1 + 0.4 && heapAt[3] > bz0 - 0.4 && heapAt[1] < bz1 + 0.4);
50735
- 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])) {
50736
- if (Math.min(piece2[2] - piece2[0], piece2[3] - piece2[1]) < TRENCH.berm.crest * 2) continue;
50737
- addHumps(heap, piece2);
50738
- laid.push(piece2);
51097
+ if (!onBuilding) for (const piece22 of rectMinus(heapAt, [...rects.map((t) => [t[0] - SPOIL_CLEAR, t[1] - SPOIL_CLEAR, t[2] + SPOIL_CLEAR, t[3] + SPOIL_CLEAR]), ...laid])) {
51098
+ if (Math.min(piece22[2] - piece22[0], piece22[3] - piece22[1]) < TRENCH.berm.crest * 2) continue;
51099
+ addHumps(heap, piece22);
51100
+ laid.push(piece22);
50739
51101
  }
50740
51102
  }
50741
51103
  });
@@ -50880,7 +51242,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50880
51242
  function buriedSewerOf(plan) {
50881
51243
  const drains = drainsOf(plan);
50882
51244
  if (!drains.length) return [];
50883
- return sewerLayout(plan, drains).pieces.flatMap((piece2) => piece2.points.slice(1).map((b, i) => ({ a: piece2.points[i], b })));
51245
+ return sewerLayout(plan, drains).pieces.flatMap((piece22) => piece22.points.slice(1).map((b, i) => ({ a: piece22.points[i], b })));
50884
51246
  }
50885
51247
  var FEED = { width: 0.3, bed: 0.05, tape: { over: 0.3, width: 0.1, thickness: 2e-3 }, box: { side: 0.3, floor: 0.1 } };
50886
51248
  function feedLayout(plan) {
@@ -50940,10 +51302,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50940
51302
  const dug = [...layout.trenches, ...rainwater.trenches, ...feeds.trenches, ...boxes.map(pitOf)];
50941
51303
  addSpoil(THREE, group, dug, mats.heap, { solids, footprint: houseFootprint(routingPlanOf(plan)), buildings: (plan.outbuildings ?? []).map((o) => o.aabb) });
50942
51304
  group.userData.excavations = dug.map(excavationOf);
50943
- for (const piece2 of layout.pieces) addPipe(THREE, group, piece2.points, piece2.bore / 2, mats.pipe);
51305
+ for (const piece22 of layout.pieces) addPipe(THREE, group, piece22.points, piece22.bore / 2, mats.pipe);
50944
51306
  const rainGroup = new THREE.Group();
50945
51307
  rainGroup.name = "rain_drains";
50946
- for (const piece2 of rainwater.pieces) addPipe(THREE, rainGroup, piece2.points, piece2.bore / 2, mats.rain);
51308
+ for (const piece22 of rainwater.pieces) addPipe(THREE, rainGroup, piece22.points, piece22.bore / 2, mats.rain);
50947
51309
  group.add(rainGroup);
50948
51310
  addWarningTape(THREE, group, feeds.runs);
50949
51311
  const yard = new THREE.Group();
@@ -51236,11 +51598,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
51236
51598
  });
51237
51599
  }
51238
51600
  function stagedWallRuns(H) {
51239
- const r = shared2.ctx.r, nA = r.floors.length, plan = routingPlanOf(r), tank2 = r.waterTank, base = shared2.ctx.waterTankPos ? shared2.ctx.waterTankPos.y : tank2 ? tank2.y : atticFloor(plan);
51601
+ const r = shared2.ctx.r, nA = r.floors.length, plan = routingPlanOf(r), tank2 = r.waterTank, base2 = shared2.ctx.waterTankPos ? shared2.ctx.waterTankPos.y : tank2 ? tank2.y : atticFloor(plan);
51240
51602
  if (!tank2) return;
51241
51603
  const xyz = (p) => [p[0], p[1], p[2]];
51242
51604
  const out = [tank2.u, tank2.v - (tank2.d || 1.1) / 2 - 0.2], attic = atticFloor(plan) + ATTIC_LIFT.water;
51243
- const outlet = [[tank2.u, base + 0.08, tank2.v - (tank2.d || 1.1) / 2], [out[0], base + 0.08, out[1]], [out[0], attic, out[1]]];
51605
+ const outlet = [[tank2.u, base2 + 0.08, tank2.v - (tank2.d || 1.1) / 2], [out[0], base2 + 0.08, out[1]], [out[0], attic, out[1]]];
51244
51606
  cursor.group = shared2.ctx.waterTankPos && shared2.ctx.waterTankPos.group || "f0";
51245
51607
  cursor.pc = pieceRecord("pipe:run_outlet", "plastic", null, { tags: ["pipe"] });
51246
51608
  for (let i = 0; i + 1 < outlet.length; i++) pipe(outlet[i], outlet[i + 1], 0.032, PIPE_COLOR);
@@ -51395,8 +51757,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
51395
51757
  Object.assign(K, defined);
51396
51758
  }
51397
51759
  var EPS23 = 1e-4;
51398
- function subtractRects(base, holes) {
51399
- let pieces = [base];
51760
+ function subtractRects(base2, holes) {
51761
+ let pieces = [base2];
51400
51762
  for (const h of holes) {
51401
51763
  const next = [];
51402
51764
  for (const r of pieces) {
@@ -51537,8 +51899,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
51537
51899
  const depthOn = (side) => {
51538
51900
  const on = over.filter((c) => c.side === side);
51539
51901
  if (!on.length) return 0;
51540
- const least = Math.min(...on.map((c) => c.back)), back = Math.abs(least - mortar) < CHASE_CLEAR_OF_MORTAR ? mortar - CHASE_CLEAR_OF_MORTAR : least;
51541
- return t / 2 - (back - inset);
51902
+ const least = Math.min(...on.map((c) => c.back)), back2 = Math.abs(least - mortar) < CHASE_CLEAR_OF_MORTAR ? mortar - CHASE_CLEAR_OF_MORTAR : least;
51903
+ return t / 2 - (back2 - inset);
51542
51904
  };
51543
51905
  const low = depthOn(-1), high = depthOn(1);
51544
51906
  box4(batch, p0, q0, p1, q1, t - low - high, (low - high) / 2);
@@ -51678,8 +52040,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
51678
52040
  const along2 = wall.alongU ? r.u : r.v, across2 = (wall.alongU ? r.v : r.u) - core.line;
51679
52041
  if (along2 + r.radius + CHASE_CLEAR2 < wall.a0 || along2 - r.radius - CHASE_CLEAR2 > wall.a1 || r.y1 <= core.y0 || r.y0 >= core.y1) continue;
51680
52042
  if (Math.abs(across2) > wall.thickness / 2 + 1e-6) continue;
51681
- const back = Math.abs(across2) - (r.depth ?? r.radius) - CHASE_CLEAR2;
51682
- out.push({ a0: along2 - r.radius - CHASE_CLEAR2, a1: along2 + r.radius + CHASE_CLEAR2, y0: Math.max(core.y0, r.y0), y1: Math.min(core.y1, r.y1), side: across2 >= 0 ? 1 : -1, back, ...r.box ? { box: true } : {} });
52043
+ const back2 = Math.abs(across2) - (r.depth ?? r.radius) - CHASE_CLEAR2;
52044
+ out.push({ a0: along2 - r.radius - CHASE_CLEAR2, a1: along2 + r.radius + CHASE_CLEAR2, y0: Math.max(core.y0, r.y0), y1: Math.min(core.y1, r.y1), side: across2 >= 0 ? 1 : -1, back: back2, ...r.box ? { box: true } : {} });
51683
52045
  }
51684
52046
  return out;
51685
52047
  }
@@ -52035,8 +52397,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52035
52397
  const alongU = Math.abs(point.frontV) >= Math.abs(point.frontU);
52036
52398
  const intoRoom = Math.sign(alongU ? point.frontV : point.frontU);
52037
52399
  const face = wall.line + intoRoom * (wall.halfThickness - PLASTER_PER_FACE + WALL_BOX_PROUD);
52038
- const back = face - intoRoom * WALL_BOX.deep;
52039
- const [low, high] = face < back ? [face, back] : [back, face];
52400
+ const back2 = face - intoRoom * WALL_BOX.deep;
52401
+ const [low, high] = face < back2 ? [face, back2] : [back2, face];
52040
52402
  const half = WALL_BOX.along / 2;
52041
52403
  return {
52042
52404
  u0: alongU ? point.u - half : low,
@@ -52185,8 +52547,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52185
52547
  const M = en22.meter;
52186
52548
  if (M) {
52187
52549
  const hw = (M.w || 0.35) / 2, hd = (M.d || 0.2) / 2, hh = (M.h || 0.5) / 2, fr = M.side === "front" ? -1 : 1;
52188
- const back = shared2.ctx.visorScene ? 0 : 3e-3;
52189
- if (!(KV && KV.meter)) bx("plain", M.u - hw, M.y - hh, M.v - hd + (fr > 0 ? back : 0), M.u + hw, M.y + hh, M.v + hd - (fr < 0 ? back : 0), 14277597);
52550
+ const back2 = shared2.ctx.visorScene ? 0 : 3e-3;
52551
+ if (!(KV && KV.meter)) bx("plain", M.u - hw, M.y - hh, M.v - hd + (fr > 0 ? back2 : 0), M.u + hw, M.y + hh, M.v + hd - (fr < 0 ? back2 : 0), 14277597);
52190
52552
  const fz = fr < 0 ? [M.v - hd - 0.012, M.v - hd] : [M.v + hd, M.v + hd + 0.012];
52191
52553
  if (!(KV && KV.meter)) {
52192
52554
  bx("glass", M.u - hw * 0.6, M.y - hh * 0.2, fz[0], M.u + hw * 0.6, M.y + hh * 0.6, fz[1], 16777215);
@@ -52365,7 +52727,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52365
52727
  };
52366
52728
  for (const A of ws) for (const [side, sd] of [[A.w.sides[0], -1], [A.w.sides[1], 1]]) {
52367
52729
  if (!sideOf(side, false).exterior) continue;
52368
- const strip = (k, y1, y2, o0, o1, mat, c, piece2, laid = BASEBOARD_TILES) => {
52730
+ const strip = (k, y1, y2, o0, o1, mat, c, piece22, laid = BASEBOARD_TILES) => {
52369
52731
  const ea = junction(A, A.a, sd) > 0 ? A.th / 2 + k : junction(A, A.a, sd) < 0 ? -A.th / 2 : 0, eb = junction(A, A.b, sd) > 0 ? A.th / 2 + k : junction(A, A.b, sd) < 0 ? -A.th / 2 : 0;
52370
52732
  const s0 = A.a - ea, s1 = A.b + eb, f0 = A.L + sd * (A.th / 2 + o0), f1 = A.L + sd * (A.th / 2 + o1), lo = Math.min(f0, f1), hi = Math.max(f0, f1);
52371
52733
  if (s1 - s0 < 1e-3) return;
@@ -52389,7 +52751,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52389
52751
  runs.push([from, s1]);
52390
52752
  runs.forEach(([r0, r1], k2) => {
52391
52753
  if (r1 - r0 < 1e-3) return;
52392
- const id = piece2 && runs.length > 1 ? `${piece2}:${k2}` : piece2;
52754
+ const id = piece22 && runs.length > 1 ? `${piece22}:${k2}` : piece22;
52393
52755
  if (!id) box4(r0, r1);
52394
52756
  else if (shared2.ctx.baseboardBand) tile(id, r0, r1);
52395
52757
  else {
@@ -52477,12 +52839,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52477
52839
  const yA = roofHeightAt(p.u, p.v - hd), yB = roofHeightAt(p.u, p.v + hd), yC = roofHeightAt(p.u, p.v);
52478
52840
  let yc, tilt;
52479
52841
  if (onRack) {
52480
- const base = yC != null ? yC : Y0(fa) + 0.02, angle = (S.tilt || 15) * Math.PI / 180, high = Math.sin(angle) * p.length;
52842
+ const base2 = yC != null ? yC : Y0(fa) + 0.02, angle = (S.tilt || 15) * Math.PI / 180, high = Math.sin(angle) * p.length;
52481
52843
  tilt = sv * Math.atan2(high, d);
52482
- yc = base + 0.25 + high / 2;
52483
- const yLow = base + 0.25, yHigh = yLow + high;
52484
- 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);
52485
- bx("metal", p.u - hw * 0.9, base + 0.01, p.v - sv * hd - 0.02, p.u + hw * 0.9, base + 0.05, p.v - sv * hd + 0.02, 8027780);
52844
+ yc = base2 + 0.25 + high / 2;
52845
+ const yLow = base2 + 0.25, yHigh = yLow + high;
52846
+ for (const ex of [-0.8, 0.8]) for (const [vv, yTop] of [[p.v - sv * hd, yLow], [p.v + sv * hd, yHigh]]) bx("metal", p.u + ex * hw - 0.025, base2, vv - 0.025, p.u + ex * hw + 0.025, yTop - 0.02, vv + 0.025, 8027780);
52847
+ bx("metal", p.u - hw * 0.9, base2 + 0.01, p.v - sv * hd - 0.02, p.u + hw * 0.9, base2 + 0.05, p.v - sv * hd + 0.02, 8027780);
52486
52848
  } else {
52487
52849
  if (yA == null || yB == null || yC == null) continue;
52488
52850
  tilt = Math.atan2(yA - yB, d);
@@ -52584,7 +52946,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52584
52946
  }
52585
52947
  function installFurnitureApi(K, shared2) {
52586
52948
  const { _e, _h2, _q, boxC, cursor, macroGround, polyFace, put } = K;
52587
- const MATERIAL_MAP2 = { plain: "plain", metal: "metal", wood: "wood", glass: "glass", fabric: "fabric", plant: "plant", water: "water", emissive: "emissive", "atlas_picture": "picture", "atlas_floor": "floor", plaster: "plain", matte: "glass", glass_light: "emissive", light: "emissive", ceramic_tile: "plain", parquet: "plain", ceramic: "plain" };
52949
+ const MATERIAL_MAP2 = { plain: "plain", metal: "metal", wood: "wood", glass: "glass", fabric: "fabric", foam: "fabric", plant: "plant", water: "water", emissive: "emissive", "atlas_picture": "picture", "atlas_floor": "floor", plaster: "plain", matte: "glass", glass_light: "emissive", light: "emissive", ceramic_tile: "plain", parquet: "plain", ceramic: "plain" };
52588
52950
  const mm = (k) => MATERIAL_MAP2[k] || "plain";
52589
52951
  const LIGHTS = [];
52590
52952
  function makeApi() {
@@ -53335,7 +53697,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53335
53697
  }
53336
53698
  function installFurnitureTaps(K, shared2) {
53337
53699
  shared2.tapCount = 0;
53338
- function counterTap(K2, x, y, z, reach2, back, meta = {}) {
53700
+ function counterTap(K2, x, y, z, reach2, back2, meta = {}) {
53339
53701
  const cr = 12896460, id = "tap_" + (K2.M.seed || "") + "_" + shared2.tapCount++;
53340
53702
  K2.c("metal", x, y, z, 0.028, 0.012, cr);
53341
53703
  K2.c("metal", x, y + 0.012, z, 0.014, 0.12, cr);
@@ -53362,11 +53724,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53362
53724
  );
53363
53725
  const ya = tip[1] - 0.05;
53364
53726
  K2.part("water_tap", tip[0], ya, tip[2], () => {
53365
- K2.t("water", [tip[0], ya, tip[2]], [tip[0], y - back, tip[2]], 6e-3, 13625588);
53727
+ K2.t("water", [tip[0], ya, tip[2]], [tip[0], y - back2, tip[2]], 6e-3, 13625588);
53366
53728
  }, { id: id + "_a", target: id, hidden: true, fluid: "water" });
53367
53729
  return id;
53368
53730
  }
53369
- function wallTap(K2, x, y, zw, direction, back, meta = {}) {
53731
+ function wallTap(K2, x, y, zw, direction, back2, meta = {}) {
53370
53732
  const cr = 12896460, id = "tap_" + (K2.M.seed || "") + "_" + shared2.tapCount++, s = direction || 1;
53371
53733
  K2.t("metal", [x, y, zw], [x, y, zw + s * 0.025], 0.03, cr);
53372
53734
  K2.t("metal", [x, y, zw + s * 0.02], [x, y, zw + s * 0.1], 0.016, cr);
@@ -53389,19 +53751,24 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53389
53751
  );
53390
53752
  const ya = y - 0.08;
53391
53753
  K2.part("water_tap", x, ya, zw + s * 0.105, () => {
53392
- K2.t("water", [x, ya, zw + s * 0.105], [x, back, zw + s * 0.105], 65e-4, 13625588);
53754
+ K2.t("water", [x, ya, zw + s * 0.105], [x, back2, zw + s * 0.105], 65e-4, 13625588);
53393
53755
  }, { id: id + "_a", target: id, hidden: true, fluid: "water" });
53394
53756
  return id;
53395
53757
  }
53396
53758
  const defined = { counterTap, wallTap };
53397
53759
  Object.assign(K, defined);
53398
53760
  }
53761
+ var SHOWER_DOOR = 0.72;
53762
+ var PANEL_THICKNESS = 0.02;
53763
+ var MIN_PANEL = 0.1;
53399
53764
  function installFurnitureFixtures(K, shared2) {
53765
+ const kernel = K;
53400
53766
  const seedKey = (id) => K.seedKey(id);
53401
53767
  const { FURNITURE, MIRRORS, SEED, arcPoints, cursor, kit2, rngString, sh } = K;
53402
53768
  FURNITURE.box = function(M, A) {
53403
53769
  const K2 = kit2(M, A, 0), w = M.w, d = M.d, cr = 13159632, id = "shower_" + (M.seed || ""), zw = -d / 2, X = w / 2 - 0;
53404
- const R = Math.min(0.32, w * 0.34, d * 0.34), gh = 1.95, gt = 8e-3;
53770
+ const walkIn = !shared2.ctx.visorScene;
53771
+ const R = walkIn ? Math.max(0.1, Math.min(0.32, w * 0.34, d * 0.34, w - 0.042 - SHOWER_DOOR)) : Math.min(0.32, w * 0.34, d * 0.34), gh = 1.95, gt = 8e-3;
53405
53772
  K2.b("plain", 0, 0, 0, w - 0.02, 0.05, d - 0.02, 15132902);
53406
53773
  K2.c("metal", 0, 0.05, 0, 0.045, 6e-3, 11580600);
53407
53774
  if (shared2.ctx.visorScene) K2.c("plain", 0, 0.05, 0, 0.032, 8e-3, 4212812);
@@ -53414,17 +53781,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53414
53781
  gl(px0, -d / 2 + 0.05, px0, pzF - R);
53415
53782
  const arc = arcPoints(px0 - R, pzF - R, R, 0, Math.PI / 2, 6);
53416
53783
  for (let i = 0; i < arc.length - 1; i++) gl(arc[i][0], arc[i][1], arc[i + 1][0], arc[i + 1][1]);
53417
- const fx1 = Math.max(-w / 2 + 0.36, px0 - R - 0.5);
53418
- gl(px0 - R, pzF, fx1, pzF);
53784
+ const front = walkIn ? Math.min(px0 - R, -w / 2 + 0.03 + SHOWER_DOOR) : Math.max(-w / 2 + 0.36, px0 - R - 0.5);
53785
+ const fx1 = walkIn && px0 - R - front < MIN_PANEL ? px0 - R : front, panel = px0 - R - fx1 > 0.01;
53786
+ if (panel) gl(px0 - R, pzF, fx1, pzF);
53419
53787
  const rail = (y, r) => {
53420
53788
  tube2([px0, y, -d / 2 + 0.05], [px0, y, pzF - R], r);
53421
53789
  for (let i = 0; i < arc.length - 1; i++) tube2([arc[i][0], y, arc[i][1]], [arc[i + 1][0], y, arc[i + 1][1]], r);
53422
- tube2([px0 - R, y, pzF], [fx1, y, pzF], r);
53790
+ if (panel) tube2([px0 - R, y, pzF], [fx1, y, pzF], r);
53423
53791
  };
53424
53792
  rail(gh, 0.011);
53425
53793
  rail(0.055, 9e-3);
53426
53794
  for (const [x, z] of [[px0, -d / 2 + 0.05], [fx1, pzF]]) tube2([x, 0.05, z], [x, gh + 5e-3, z], 0.011);
53427
- for (const [x, y, z] of [[px0, gh, -d / 2 + 0.05], [fx1, gh, pzF], [px0 - R, gh, pzF]]) K2.e("metal", x, y, z, 0.013, 0.026, cr);
53795
+ for (const [x, y, z] of [[px0, gh, -d / 2 + 0.05], [fx1, gh, pzF], ...panel ? [[px0 - R, gh, pzF]] : []]) K2.e("metal", x, y, z, 0.013, 0.026, cr);
53428
53796
  const hx = fx1, dw = hx - (-w / 2 + 0.03);
53429
53797
  if (dw > 0.2) K2.part(
53430
53798
  "shower_door",
@@ -53439,6 +53807,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53439
53807
  },
53440
53808
  { id: id + "_door", opens: { type: "swing", axis: [0, 1, 0], angle: -1.7 } }
53441
53809
  );
53810
+ if (walkIn) {
53811
+ const panels = [[px0, -d / 2 + 0.05, px0, pzF - R]];
53812
+ for (let i = 0; i < arc.length - 1; i++) panels.push([arc[i][0], arc[i][1], arc[i + 1][0], arc[i + 1][1]]);
53813
+ if (panel) panels.push([px0 - R, pzF, fx1, pzF]);
53814
+ kernel.walkInSolids(M, { panels, thickness: PANEL_THICKNESS, height: gh, door: dw > 0.2 ? { part: id + "_door", from: [hx, pzF], to: [hx - dw, pzF] } : null });
53815
+ }
53442
53816
  const ax = 0.1, ya = 2.08, z0 = zw + 0.012, Ra = 0.22, n = 6, pa = [];
53443
53817
  for (let i = 0; i <= n; i++) {
53444
53818
  const f = i / n * Math.PI / 2;
@@ -53649,12 +54023,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53649
54023
  var DOOR = { recess: 0.012, thick: 0.02, side: 4e-3, bottom: 0.03 };
53650
54024
  var LOUVRE = { proud: 3e-3, slat: 0.012, pitch: 0.025, count: 4 };
53651
54025
  function gasShelterBoxes({ side, height }) {
53652
- const half = side / 2, back = -half + SHELTER_OFF_WALL;
54026
+ const half = side / 2, back2 = -half + SHELTER_OFF_WALL;
53653
54027
  const boxes = [
53654
- { part: "wall", front: [back, back + WALL], across: [-half, half], y: [0, height] },
53655
- { part: "wall", front: [back + WALL, half], across: [-half, -half + WALL], y: [0, height] },
53656
- { part: "wall", front: [back + WALL, half], across: [half - WALL, half], y: [0, height] },
53657
- { part: "roof", front: [back, half + EAVE2], across: [-half - EAVE2, half + EAVE2], y: [height, height + ROOF] }
54028
+ { part: "wall", front: [back2, back2 + WALL], across: [-half, half], y: [0, height] },
54029
+ { part: "wall", front: [back2 + WALL, half], across: [-half, -half + WALL], y: [0, height] },
54030
+ { part: "wall", front: [back2 + WALL, half], across: [half - WALL, half], y: [0, height] },
54031
+ { part: "roof", front: [back2, half + EAVE2], across: [-half - EAVE2, half + EAVE2], y: [height, height + ROOF] }
53658
54032
  ];
53659
54033
  const doorFace = half - DOOR.recess, doorAcross = [-half + WALL + DOOR.side, half - WALL - DOOR.side];
53660
54034
  boxes.push({ part: "door", front: [doorFace - DOOR.thick, doorFace], across: doorAcross, y: [DOOR.bottom, height - DOOR.bottom] });
@@ -53805,10 +54179,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53805
54179
  if (shelterOf(M)) {
53806
54180
  } else if (M.hose && M.hose.length > 1) {
53807
54181
  const q = M.hose[M.hose.length - 1], dx = q[0] - M.x, dz = q[1] - M.z, lx = dx * c - dz * s, lz = dx * s + dz * c, y1 = Math.max(0.1, q[2] != null ? q[2] : 0.5) - (M.y || 0);
53808
- const P0 = [0.1, H * 0.9 + 0.045, 0], P2 = [lx, y1, lz], len = Math.hypot(lx - P0[0], lz - P0[2]), back = Math.min(0.28, 0.08 + len * 0.06), n = 8, pts = [];
54182
+ const P0 = [0.1, H * 0.9 + 0.045, 0], P2 = [lx, y1, lz], len = Math.hypot(lx - P0[0], lz - P0[2]), back2 = Math.min(0.28, 0.08 + len * 0.06), n = 8, pts = [];
53809
54183
  for (let k = 0; k <= n; k++) {
53810
54184
  const t = k / n, u = 1 - t;
53811
- pts.push([u * P0[0] + t * P2[0], Math.max(0.02, u * P0[1] + t * P2[1] - 4 * t * u * back * (1 + len * 0.05)), u * P0[2] + t * P2[2]]);
54185
+ pts.push([u * P0[0] + t * P2[0], Math.max(0.02, u * P0[1] + t * P2[1] - 4 * t * u * back2 * (1 + len * 0.05)), u * P0[2] + t * P2[2]]);
53812
54186
  }
53813
54187
  for (let k = 0; k < n; k++) K2.t("plain", pts[k], pts[k + 1], 0.011, 12071454);
53814
54188
  K2.c("metal", P2[0], P2[1] - 0.025, P2[2], 0.016, 0.05, brass);
@@ -53999,6 +54373,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53999
54373
  const { THREE, Y0, _col, boxC, colorOf, cursor, decorLights, makeApi, structurePiece, OPEN_AREA, rectsOf: rectsOf2 } = K;
54000
54374
  const buildItem2 = (...a) => K.buildItem(...a);
54001
54375
  const registerCollision = (...a) => K.registerCollision(...a);
54376
+ const kitCollides = (...a) => K.kitCollides(...a);
54002
54377
  const vegItem = (...a) => K.vegItem(...a);
54003
54378
  const SLAB_UNDERSIDE = 0.24;
54004
54379
  function houseItems() {
@@ -54022,8 +54397,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54022
54397
  if (exterior && m.category === "ground_cover" && shared2.ctx.noGroundSurfaces) continue;
54023
54398
  const f = exterior ? -1 : Math.min(m.floor, R.floors.length - 1);
54024
54399
  cursor.group = exterior && !(m.type === "cooking_gas_cylinder" && m.shelter && !shared2.ctx.visorScene) ? "lot" : "f" + Math.max(f, 0);
54025
- 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;
54026
- const M = { visorScene: shared2.ctx.visorScene, x: m.x, z: m.z, ry: m.ry || 0, w: m.w, d: m.d, h: m.h, y: m.y || 0, base, floor: exterior ? -1 : f, palette: shared2.ctx.colors, color: m.category === "ground_cover" ? void 0 : colorOf(m.color) ?? void 0, seed: m.id, room: m.room, typeWith: com ? com.type : null, ceiling: com ? com.ceiling : 2.9, on: shared2.ctx.night, light: shared2.ctx.night, lit: shared2.ctx.night, open: !!m.doorOpen, overhead: m.overhead, assembly: m.assembly, hose: m.hose, shelter: m.shelter, pipe: m.pipe };
54400
+ const com = m.room != null ? shared2.ctx.roomById[m.room] : void 0, lift = !exterior && f === 0 && shared2.ctx.constructionStages && !shared2.ctx.visorScene && !com?.outbuilding ? FLOOR_OVER_GROUND : 0, base2 = exterior ? 0 : Y0(f) + lift;
54401
+ const M = { visorScene: shared2.ctx.visorScene, x: m.x, z: m.z, ry: m.ry || 0, w: m.w, d: m.d, h: m.h, y: m.y || 0, base: base2, floor: exterior ? -1 : f, palette: shared2.ctx.colors, color: m.category === "ground_cover" ? void 0 : colorOf(m.color) ?? void 0, seed: m.id, room: m.room, typeWith: com ? com.type : null, ceiling: com ? com.ceiling : 2.9, on: shared2.ctx.night, light: shared2.ctx.night, lit: shared2.ctx.night, open: !!m.doorOpen, overhead: m.overhead, assembly: m.assembly, hose: m.hose, shelter: m.shelter, pipe: m.pipe };
54027
54402
  if (!exterior && !shared2.ctx.visorScene && f + 1 < R.floors.length && R.rooms.some((room) => room.floor === f + 1 && room.parts.some((r) => r[0] <= m.x && m.x <= r[2] && r[1] <= m.z && m.z <= r[3]))) M.ceiling = Math.min(M.ceiling ?? 2.9, Y0(f + 1) - SLAB_UNDERSIDE - Y0(f));
54028
54403
  if (lift) M.ceiling = (M.ceiling ?? 2.9) - lift;
54029
54404
  if (!exterior && !shared2.ctx.visorScene && f > 0) overRoof(m, M, f);
@@ -54066,13 +54441,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54066
54441
  }
54067
54442
  }
54068
54443
  if (shared2.ctx.iv && shared2.ctx.iv.replace.has(m.id)) {
54069
- registerCollision(m, M);
54444
+ if (!kitCollides(m)) registerCollision(m, M);
54070
54445
  continue;
54071
54446
  }
54072
54447
  const ent = T2[m.type];
54073
54448
  const st0 = cursor.stage;
54074
54449
  if (shared2.ctx.constructionStages && (m.type === "cooking_gas_cylinder" || m.type === "gas_cylinder" || m.type === "water_tank")) cursor.stage = "installations";
54075
- shared2.ctx.restOn = exterior || shared2.ctx.visorScene ? void 0 : base;
54450
+ shared2.ctx.restOn = exterior || shared2.ctx.visorScene ? void 0 : base2;
54076
54451
  if (!shared2.ctx.visorScene) {
54077
54452
  const quarter = Math.round(M.ry / (Math.PI / 2));
54078
54453
  if (Math.abs(M.ry - quarter * Math.PI / 2) < 0.01) M.ry = quarter * Math.PI / 2;
@@ -54189,7 +54564,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54189
54564
  return;
54190
54565
  }
54191
54566
  const lc = cd.place === "raised_slab" && cd.platform, slab = cd.place === "slab" || !!lc, nA = shared2.ctx.r.floors.length, f = Math.max(0, Math.min(nA - 1, cd.floor));
54192
- const base = lc ? cd.platform.topY : cd.y + (shared2.ctx.r.rooms.some((c) => c.id === cd.room && c.type === "terrace") ? 0 : 0.2 + (slab ? 0.03 : 0));
54567
+ const base2 = lc ? cd.platform.topY : cd.y + (shared2.ctx.r.rooms.some((c) => c.id === cd.room && c.type === "terrace") ? 0 : 0.2 + (slab ? 0.03 : 0));
54193
54568
  cursor.group = slab ? "f" + f : "attic_tank";
54194
54569
  const platformLift = !slab && !shared2.ctx.visorScene ? 0.12 : 0;
54195
54570
  if (lc) {
@@ -54208,12 +54583,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54208
54583
  }
54209
54584
  if (!slab) {
54210
54585
  const color2 = shared2.ctx.colors.slab != null ? shared2.ctx.colors.slab : 12170668, yp = Y0(f), hw = cd.w / 2 + 0.1, hd = cd.d / 2 + 0.1;
54211
- const top = base + platformLift;
54586
+ const top = base2 + platformLift;
54212
54587
  boxC("plain", cd.u, top - 0.06, cd.v, hw * 2, 0.12, hd * 2, color2);
54213
- for (const sx of [-1, 1]) for (const sz of [-1, 1]) boxC("plain", cd.u + sx * (hw - 0.07), (yp + base - 0.12) / 2, cd.v + sz * (hd - 0.07), 0.1, base - 0.12 - yp, 0.1, color2);
54588
+ for (const sx of [-1, 1]) for (const sz of [-1, 1]) boxC("plain", cd.u + sx * (hw - 0.07), (yp + base2 - 0.12) / 2, cd.v + sz * (hd - 0.07), 0.1, base2 - 0.12 - yp, 0.1, color2);
54214
54589
  }
54215
- 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 };
54216
- shared2.ctx.waterTankPos = { x: cd.u, z: cd.v, y: base + platformLift, group: cursor.group };
54590
+ const M = { x: cd.u, z: cd.v, ry: 0, w: cd.w, d: cd.d, h: cd.h + 0.12, y: 0, base: base2 + platformLift, floor: f, colors: shared2.ctx.colors, seed: "water_tank", room: cd.room, onSlab: true, ceiling: 2.9 };
54591
+ shared2.ctx.waterTankPos = { x: cd.u, z: cd.v, y: base2 + platformLift, group: cursor.group };
54217
54592
  shared2.ctx.types.water_tank.f(M, api);
54218
54593
  }
54219
54594
  function trestleTank(api, cd) {
@@ -54614,8 +54989,29 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54614
54989
  const d1 = objectDistance(o, x, z);
54615
54990
  if (d1 < R && d1 < objectDistance(o, fx, fz) - 1e-6) return true;
54616
54991
  }
54992
+ return collideKit(x, z, fx, fz, floor, R);
54993
+ }
54994
+ function collideKit(x, z, fx, fz, floor, R) {
54995
+ const iv = shared2.ctx.iv, collided = iv && iv.collided;
54996
+ if (!iv || !collided || !collided.size) return false;
54997
+ for (const k of iv.world.colliders()) {
54998
+ const f = collided.get(k.object);
54999
+ if (f === void 0 || (f !== -1 ? f !== floor : floor !== 0)) continue;
55000
+ const o = { f, cx: k.cx, cz: k.cz, c: Math.cos(k.ry), s: Math.sin(k.ry), hw: k.hw, hd: k.hd, type: "kit" };
55001
+ const d1 = objectDistance(o, x, z);
55002
+ if (d1 < R && d1 < objectDistance(o, fx, fz) - 1e-6) return true;
55003
+ }
54617
55004
  return false;
54618
55005
  }
55006
+ function kitCollides(m) {
55007
+ const iv = shared2.ctx.iv;
55008
+ if (!iv) return false;
55009
+ const own = [...iv.entries.values()].filter((e) => e.origin === m.id && (e.spec.colliders?.length ?? 0) > 0);
55010
+ if (!own.length) return false;
55011
+ const collided = iv.collided || (iv.collided = /* @__PURE__ */ new Map());
55012
+ for (const e of own) collided.set(e.id, e.floor);
55013
+ return true;
55014
+ }
54619
55015
  function collideAt(x, z, floor, opt) {
54620
55016
  opt = opt || {};
54621
55017
  const R = opt.radius != null ? opt.radius : 0.24;
@@ -54629,7 +55025,24 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54629
55025
  const de = opt.from || [x + 1e4, z + 1e4];
54630
55026
  return collideObject(x, z, de[0], de[1], floor);
54631
55027
  }
54632
- const defined = { NO_COLLIDE, registerCollision, objectDistance, collideObject, collideAt };
55028
+ function walkInSolids(M, spec) {
55029
+ const objs = shared2.inter?.objs, colliders = shared2.ctx.colliders;
55030
+ if (!objs || !colliders) return;
55031
+ const at2 = objs.findIndex((o) => o.cx === M.x && o.cz === M.z && o.f === M.floor);
55032
+ const kept = at2 >= 0 ? objs.splice(at2, 1)[0] : void 0;
55033
+ const type = kept?.type ?? "walk_in";
55034
+ const half = spec.thickness / 2;
55035
+ for (const [x0, z0, x1, z1] of spec.panels) {
55036
+ const length = Math.hypot(x1 - x0, z1 - z0);
55037
+ if (length < 1e-3) continue;
55038
+ const [cx, cz] = K.localOf(M, (x0 + x1) / 2, (z0 + z1) / 2), turn = (M.ry || 0) + Math.atan2(-(z1 - z0), x1 - x0);
55039
+ objs.push({ f: M.floor, cx, cz, c: Math.cos(turn), s: Math.sin(turn), hw: length / 2, hd: half, h: spec.height, type });
55040
+ }
55041
+ if (!spec.door) return;
55042
+ const [ax, az] = K.localOf(M, spec.door.from[0], spec.door.from[1]), [bx, bz] = K.localOf(M, spec.door.to[0], spec.door.to[1]);
55043
+ colliders.push({ type: "walk_in_door", f: M.floor, x0: Math.min(ax, bx) - half, z0: Math.min(az, bz) - half, x1: Math.max(ax, bx) + half, z1: Math.max(az, bz) + half, piece: spec.door.part, anchor: [(ax + bx) / 2, (M.base || 0) + 1, (az + bz) / 2], off: false });
55044
+ }
55045
+ const defined = { NO_COLLIDE, registerCollision, objectDistance, collideObject, collideAt, walkInSolids, kitCollides };
54633
55046
  Object.assign(K, defined);
54634
55047
  }
54635
55048
  function installInteractionItems(K, shared2) {
@@ -54836,13 +55249,26 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54836
55249
  const g = r.g;
54837
55250
  if (!isFinite(r.x0)) return;
54838
55251
  const sd = (g.axis === "u" ? cz - g.v : cu - g.u) >= 0 ? 1 : -1, name = "ix:gate:" + g.id, ped = g.model === "pedestrian", tilt = g.model === "tilting";
54839
- const base = { parent: "lot", ry: 0, t0: g.open ? 1 : 0, col: cols[i], gate: g };
54840
- const p = ped ? definePiece(name, Object.assign(base, { kind: "gate_swing", pivot: [r.x0, 0, g.v], angle: -sd * 1.65 })) : tilt ? definePiece(name, Object.assign(base, { kind: "gate_tilting", pivot: [(r.x0 + r.x1) / 2, r.y1, g.v], angle: -sd * 1.45 })) : definePiece(name, Object.assign(base, { kind: "gate_sliding", pivot: [r.x0, 0, r.zm], travel: r.dx * g.width }));
55252
+ const base2 = { parent: "lot", ry: 0, t0: g.open ? 1 : 0, col: cols[i], gate: g };
55253
+ const p = ped ? definePiece(name, Object.assign(base2, { kind: "gate_swing", pivot: [r.x0, 0, g.v], angle: -sd * 1.65 })) : tilt ? definePiece(name, Object.assign(base2, { kind: "gate_tilting", pivot: [(r.x0 + r.x1) / 2, r.y1, g.v], angle: -sd * 1.45 })) : definePiece(name, Object.assign(base2, { kind: "gate_sliding", pivot: [r.x0, 0, r.zm], travel: r.dx * g.width }));
54841
55254
  if (p.col) p.col.off = p.target > 0.5;
54842
55255
  const text = () => t(p.target > 0.5 ? "prompt.close" : "prompt.open", { what: t(ped ? "what.pedestrianGate" : "what.garageGate") });
54843
55256
  I().items.push({ type: "gate", id: g.id, floor: -1, anchor: [g.u, 1, g.v + sd * 0.4], range: 2.8, angle: 0.9, pieces: [p], text, action: () => togglePiece(p), noWall: true });
54844
55257
  });
54845
55258
  }
55259
+ function walkInInteractive() {
55260
+ for (const c of shared2.ctx.colliders) {
55261
+ if (c.type !== "walk_in_door" || typeof c.piece !== "string") continue;
55262
+ const g = shared2.ctx.parts && shared2.ctx.parts[c.piece];
55263
+ if (!g) continue;
55264
+ const def = definePiece("ix:walkin:" + c.piece, { kind: "part", pivot: [0, 0, 0], ry: 0, parent: "lot" });
55265
+ def.inner = g;
55266
+ def.col = c;
55267
+ c.off = def.t > 0.5;
55268
+ I().items.push({ type: "walk_in_door", id: c.piece, floor: c.f, anchor: c.anchor, range: 1.6, angle: 1, pieces: [def], text: () => t(def.target > 0.5 ? "prompt.close" : "prompt.open", { what: t("what.stallDoor") }), action: () => togglePiece(def) });
55269
+ applyPiece(def);
55270
+ }
55271
+ }
54846
55272
  function mailboxInteractive() {
54847
55273
  for (const m of house().items) {
54848
55274
  if (m.type !== "mailbox") continue;
@@ -54900,15 +55326,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54900
55326
  else bx("plain", Math.min(f2, f3), yc - 0.032, u - 0.016, Math.max(f2, f3), yc + 0.032, u + 0.016, 16250092);
54901
55327
  cursor.group = g0;
54902
55328
  const pv = alongU ? [u, yc, f2] : [f2, yc, u];
54903
- 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 });
54904
- piece2.t = piece2.target = lightOn(roomId) ? 1 : 0;
55329
+ const piece22 = definePiece("ix:int:" + roomId, { kind: "light_switch", pivot: pv, ry: 0, parent: "f" + f, axis: alongU ? "x" : "z", sgn: alongU ? sd : -sd, t0: lightOn(roomId) ? 1 : 0 });
55330
+ piece22.t = piece22.target = lightOn(roomId) ? 1 : 0;
54905
55331
  const an = alongU ? [u, yc, face + sd * 0.12] : [face + sd * 0.12, yc, u];
54906
- I().items.push({ type: "light_switch", id: roomId, floor: f, anchor: an, range: 1.5, angle: 0.45, pieces: [piece2], text: () => t(lightOn(roomId) ? "prompt.lightOff" : "prompt.lightOn"), action: () => toggleLight(roomId) });
55332
+ I().items.push({ type: "light_switch", id: roomId, floor: f, anchor: an, range: 1.5, angle: 0.45, pieces: [piece22], text: () => t(lightOn(roomId) ? "prompt.lightOff" : "prompt.lightOn"), action: () => toggleLight(roomId) });
54907
55333
  return true;
54908
55334
  }
54909
55335
  return false;
54910
55336
  }
54911
- const defined = { gatesInteractive, mailboxInteractive, placeSwitches, putSwitch };
55337
+ const defined = { walkInInteractive, gatesInteractive, mailboxInteractive, placeSwitches, putSwitch };
54912
55338
  Object.assign(K, defined);
54913
55339
  }
54914
55340
  function installInteractionDoors(K, shared2) {
@@ -55071,7 +55497,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55071
55497
  const { t, THREE, invalidate, invalidateShadow, cfg, DOC, LIGHT_TYPES, _Y, _q, _v3, accFor, applyLight, cursor, hashString: hashString2, hudMessage, lightBase, pieceRecord, rgbOf, wallBlocks } = K;
55072
55498
  const enter = (...a) => K.enter(...a);
55073
55499
  const roomLightMask = (...a) => K.roomLightMask(...a);
55074
- const IV_MATERIAL = { plain: "plain", metal: "metal", wood: "wood", glass: "glass", fabric: "fabric", plant: "plant", water: "water", emissive: "emissive", atlas_picture: "picture", atlas_floor: "floor" };
55500
+ const IV_MATERIAL = { plain: "plain", metal: "metal", wood: "wood", glass: "glass", fabric: "fabric", foam: "fabric", plant: "plant", water: "water", emissive: "emissive", atlas_picture: "picture", atlas_floor: "floor" };
55075
55501
  const IV_WIRE = { conduit: 13618628, cable: 2762532, drop: 1381653, cord: 1776413, earth: 3111482, hose: 11556124 };
55076
55502
  const IV_DOOR = /^(door|drawer)/;
55077
55503
  const ivGroup = (e) => e.floor < 0 ? "lot" : "f" + Math.min(e.floor, shared2.ctx.r.floors.length - 1);
@@ -55141,7 +55567,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55141
55567
  const entById = new Map(plane2.items.map((e) => [e.id, e]));
55142
55568
  const entByItem = new Map(plane2.items.map((e) => [e.item, e]));
55143
55569
  const mats = shared2.mats;
55144
- IV.mats = { plain: mats.plain, metal: shared2.mats.metal, wood: shared2.mats.wood, glass: shared2.mats.glass, fabric: shared2.mats.fabric, plant: shared2.mats.plant, water: shared2.mats.water, emissive: shared2.mats.emissive, atlas_picture: shared2.mats.picture, atlas_floor: shared2.mats.floor };
55570
+ IV.mats = { plain: mats.plain, metal: shared2.mats.metal, wood: shared2.mats.wood, glass: shared2.mats.glass, fabric: shared2.mats.fabric, foam: shared2.mats.fabric, plant: shared2.mats.plant, water: shared2.mats.water, emissive: shared2.mats.emissive, atlas_picture: shared2.mats.picture, atlas_floor: shared2.mats.floor };
55145
55571
  const ev = (e) => ivEvent(h, e);
55146
55572
  const world = IV.world = A.createWorld(source, { water, seed: r.seed, onEvent: ev });
55147
55573
  const add0 = world.add;
@@ -55252,7 +55678,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55252
55678
  cursor.stage = stage0;
55253
55679
  cursor.pc = pieceBefore;
55254
55680
  }
55255
- const base = new Set(Object.values(IV.mats));
55681
+ const base2 = new Set(Object.values(IV.mats));
55256
55682
  root.traverse((o) => {
55257
55683
  if (!isMesh(o)) return;
55258
55684
  o.userData.iv = ent.id;
@@ -55260,7 +55686,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55260
55686
  if (!o.geometry.boundingSphere) o.geometry.computeBoundingSphere();
55261
55687
  if (o.geometry.boundingSphere.radius < 0.07) o.castShadow = false;
55262
55688
  }
55263
- for (const m of Array.isArray(o.material) ? o.material : [o.material]) if (m && !base.has(m) && m.userData && m.userData.roomLightMask && m.onBeforeCompile === THREE.Material.prototype.onBeforeCompile) {
55689
+ for (const m of Array.isArray(o.material) ? o.material : [o.material]) if (m && !base2.has(m) && m.userData && m.userData.roomLightMask && m.onBeforeCompile === THREE.Material.prototype.onBeforeCompile) {
55264
55690
  m.userData.roomLightMask = false;
55265
55691
  roomLightMask(m);
55266
55692
  }
@@ -55562,6 +55988,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55562
55988
  roomStates: IV.roomStates,
55563
55989
  warnings: IV.warnings,
55564
55990
  water: IV.water,
55991
+ solidColliders: () => {
55992
+ const c = IV.collided;
55993
+ return c && c.size ? w.colliders().flatMap((k) => {
55994
+ const floor = c.get(k.object);
55995
+ return floor === void 0 ? [] : [{ ...k, floor }];
55996
+ }) : [];
55997
+ },
55565
55998
  screens: IV.screens,
55566
55999
  effects: () => IV.efx || null,
55567
56000
  // TV screens (id -> kit screen) and the particle system (smoke), for whoever wants to inspect
@@ -56183,8 +56616,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56183
56616
  return { depth: Math.max(drawn, declared2?.depth ?? 0), width: declared2?.width ?? Math.max(u1 - u0, v1 - v0) };
56184
56617
  }
56185
56618
  function groundJointStrength(part, kind) {
56186
- const base = buriedBase(part);
56187
- return base.depth > 0 ? embedmentStrength(kind, base) : void 0;
56619
+ const base2 = buriedBase(part);
56620
+ return base2.depth > 0 ? embedmentStrength(kind, base2) : void 0;
56188
56621
  }
56189
56622
  var NONE = { panels: [], replaced: [], supports: [] };
56190
56623
  var MEMO = /* @__PURE__ */ new WeakMap();
@@ -56296,7 +56729,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56296
56729
  parts2.push(p);
56297
56730
  byId.set(p.id, p);
56298
56731
  }
56299
- const base = parts2.length, view = shared2.ctx.panelView || panelViewOf(null, false), panelIds = new Set(view.panels.map((e) => e.id));
56732
+ const base2 = parts2.length, view = shared2.ctx.panelView || panelViewOf(null, false), panelIds = new Set(view.panels.map((e) => e.id));
56300
56733
  for (const [id, pc] of shared2.ctx.pieces) {
56301
56734
  if (byId.has(id) || panelIds.has(id) || !meshes.has(id)) continue;
56302
56735
  const b = box32(id);
@@ -56326,7 +56759,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56326
56759
  const floorUnder = (p) => {
56327
56760
  const cx = (p.aabb[0] + p.aabb[2]) / 2, cz = (p.aabb[1] + p.aabb[3]) / 2;
56328
56761
  let best = null;
56329
- for (const q of parts2.slice(0, base)) {
56762
+ for (const q of parts2.slice(0, base2)) {
56330
56763
  if (!isFloor(q, p.y0) || cx < q.aabb[0] - HOLD_TOUCH || cx > q.aabb[2] + HOLD_TOUCH || cz < q.aabb[1] - HOLD_TOUCH || cz > q.aabb[3] + HOLD_TOUCH) continue;
56331
56764
  if (!best || q.y1 > best.y1 || q.y1 === best.y1 && q.id < best.id) best = q;
56332
56765
  }
@@ -56359,7 +56792,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56359
56792
  return { part: p.id, on: "ground", joint, bears: false, extra: true, ...strength !== void 0 ? { strength } : {} };
56360
56793
  };
56361
56794
  const unheld = [];
56362
- for (const p of parts2.slice(base)) {
56795
+ for (const p of parts2.slice(base2)) {
56363
56796
  if (/^sidewalk:/.test(p.id)) {
56364
56797
  supports.push({ part: p.id, on: "ground", joint: "mortar", extra: true });
56365
56798
  continue;
@@ -56387,7 +56820,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56387
56820
  if (!/^(window|window_pane|door|jamb|pipe|water_tank|baseboard)/.test(p.id)) continue;
56388
56821
  const target = /^water_tank/.test(p.id) ? ["slab"] : ["wall", "partition"];
56389
56822
  let m = null, md = 1e9;
56390
- for (const q of parts2.slice(0, base)) {
56823
+ for (const q of parts2.slice(0, base2)) {
56391
56824
  if (!target.includes(q.role) || !inside22(p, q, 0.2)) continue;
56392
56825
  const d = Math.hypot((p.aabb[0] + p.aabb[2] - q.aabb[0] - q.aabb[2]) / 2, (p.aabb[1] + p.aabb[3] - q.aabb[1] - q.aabb[3]) / 2);
56393
56826
  if (d < md) {
@@ -56395,7 +56828,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56395
56828
  m = q;
56396
56829
  }
56397
56830
  }
56398
- if (!m && /^(window|door|jamb)/.test(p.id)) for (const q of parts2.slice(0, base)) {
56831
+ if (!m && /^(window|door|jamb)/.test(p.id)) for (const q of parts2.slice(0, base2)) {
56399
56832
  if (!["wall", "partition", "column", "beam"].includes(q.role) || !touches2(p, q, 0.02)) continue;
56400
56833
  const d = Math.hypot((p.aabb[0] + p.aabb[2] - q.aabb[0] - q.aabb[2]) / 2, (p.y0 + p.y1 - q.y0 - q.y1) / 2, (p.aabb[1] + p.aabb[3] - q.aabb[1] - q.aabb[3]) / 2);
56401
56834
  if (d < md) {
@@ -56533,6 +56966,119 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56533
56966
  if (distance2 <= -depth) return true;
56534
56967
  return distance2 <= -depth * noise3();
56535
56968
  }
56969
+ var JOINT_SHARE = 0.5;
56970
+ var EPSILON22 = 1e-4;
56971
+ function carve(boxes, grid) {
56972
+ const { data, w, h, len, y0, height } = grid;
56973
+ const out = [];
56974
+ for (const box4 of boxes) {
56975
+ const j0 = Math.max(0, Math.floor((box4.y0 - y0) / height * h)), j1 = Math.min(h - 1, Math.ceil((box4.y1 - y0) / height * h) - 1);
56976
+ const i0 = Math.max(0, Math.floor(box4.a / len * w)), i1 = Math.min(w - 1, Math.ceil(box4.b / len * w) - 1);
56977
+ if (j1 < j0 || i1 < i0) {
56978
+ out.push(box4);
56979
+ continue;
56980
+ }
56981
+ for (let j = j0; j <= j1; j++) {
56982
+ const ry0 = Math.max(box4.y0, y0 + j / h * height), ry1 = Math.min(box4.y1, y0 + (j + 1) / h * height);
56983
+ let start = -1;
56984
+ for (let i = i0; i <= i1 + 1; i++) {
56985
+ const solid = i <= i1 && data[j * w + i] <= 127;
56986
+ if (solid && start < 0) start = i;
56987
+ if (!solid && start >= 0) {
56988
+ out.push({ a: Math.max(box4.a, start / w * len), b: Math.min(box4.b, i / w * len), y0: ry0, y1: ry1 });
56989
+ start = -1;
56990
+ }
56991
+ }
56992
+ }
56993
+ }
56994
+ return out;
56995
+ }
56996
+ var groupBy = (items, keyOf) => {
56997
+ const groups = /* @__PURE__ */ new Map();
56998
+ for (const item of items) {
56999
+ const key2 = keyOf(item);
57000
+ const group = groups.get(key2);
57001
+ if (group) group.push(item);
57002
+ else groups.set(key2, [item]);
57003
+ }
57004
+ return [...groups.values()];
57005
+ };
57006
+ function mergeSpans(spans, share = JOINT_SHARE) {
57007
+ const runs = [];
57008
+ const unitLengths = /* @__PURE__ */ new Map();
57009
+ for (const row of groupBy(spans, (s) => `${s.y0.toFixed(4)}:${s.y1.toFixed(4)}`)) {
57010
+ row.sort((p, q) => p.a - q.a);
57011
+ let run = { ...row[0] };
57012
+ let unitLength = run.b - run.a;
57013
+ for (const s of row.slice(1)) {
57014
+ if (s.a - run.b <= share * Math.min(s.b - s.a, unitLength) + EPSILON22) run.b = Math.max(run.b, s.b);
57015
+ else {
57016
+ runs.push(run);
57017
+ unitLengths.set(run, unitLength);
57018
+ run = { ...s };
57019
+ }
57020
+ unitLength = s.b - s.a;
57021
+ }
57022
+ runs.push(run);
57023
+ unitLengths.set(run, unitLength);
57024
+ }
57025
+ const out = [];
57026
+ const open = [];
57027
+ for (const r of [...runs].sort((p, q) => p.y0 - q.y0 || p.a - q.a)) {
57028
+ const height = r.y1 - r.y0;
57029
+ const top = open.find((o) => {
57030
+ const slack = share * Math.min(o.unitLength, r.b - r.a) + EPSILON22;
57031
+ return r.y0 - o.box.y1 >= -EPSILON22 && r.y0 - o.box.y1 <= share * Math.min(o.unitHeight, height) + EPSILON22 && Math.abs(r.a - o.box.a) <= slack && Math.abs(r.b - o.box.b) <= slack;
57032
+ });
57033
+ if (top) {
57034
+ top.box.y1 = r.y1;
57035
+ top.box.a = Math.min(top.box.a, r.a);
57036
+ top.box.b = Math.max(top.box.b, r.b);
57037
+ top.unitHeight = height;
57038
+ } else {
57039
+ const box4 = { ...r };
57040
+ out.push(box4);
57041
+ open.push({ box: box4, unitHeight: height, unitLength: unitLengths.get(r) ?? r.b - r.a });
57042
+ }
57043
+ }
57044
+ return out;
57045
+ }
57046
+ function standingSolids(THREE, house, mesh2, line, parts2) {
57047
+ house.updateWorldMatrix(true, false);
57048
+ mesh2.updateWorldMatrix(true, false);
57049
+ const toMesh = new THREE.Matrix4().copy(mesh2.matrixWorld).invert().multiply(house.matrixWorld);
57050
+ const turn = new THREE.Quaternion();
57051
+ const scale = new THREE.Vector3();
57052
+ toMesh.decompose(new THREE.Vector3(), turn, scale);
57053
+ const point = new THREE.Vector3();
57054
+ const out = [];
57055
+ for (const part of parts2) {
57056
+ const boxes = mergeSpans(part.spans);
57057
+ for (const s of line.open ? mergeSpans(carve(boxes, line.open), 0) : boxes) {
57058
+ const along2 = line.start + (s.a + s.b) / 2;
57059
+ point.set(line.alongU ? along2 : part.mid, (s.y0 + s.y1) / 2, line.alongU ? part.mid : along2).applyMatrix4(toMesh);
57060
+ const length = (s.b - s.a) / 2, up = (s.y1 - s.y0) / 2, across2 = part.thick / 2;
57061
+ out.push({
57062
+ center: [point.x, point.y, point.z],
57063
+ half: [(line.alongU ? length : across2) * scale.x, up * scale.y, (line.alongU ? across2 : length) * scale.z],
57064
+ rotation: [turn.x, turn.y, turn.z, turn.w],
57065
+ kind: "box"
57066
+ });
57067
+ }
57068
+ }
57069
+ return out;
57070
+ }
57071
+ function publishSolids(mesh2, v0, v1, solids) {
57072
+ const u = mesh2.userData;
57073
+ u.drawnSolids = [...(u.drawnSolids ?? []).filter((entry2) => entry2.v0 !== v0), { v0, v1, solids }];
57074
+ u.drawnSolidsVersion = (u.drawnSolidsVersion ?? 0) + 1;
57075
+ }
57076
+ function withdrawSolids(mesh2, v0) {
57077
+ const u = mesh2.userData;
57078
+ if (!u.drawnSolids?.some((entry2) => entry2.v0 === v0)) return;
57079
+ u.drawnSolids = u.drawnSolids.filter((entry2) => entry2.v0 !== v0);
57080
+ u.drawnSolidsVersion = (u.drawnSolidsVersion ?? 0) + 1;
57081
+ }
56536
57082
  function collapseRange(mesh2, v0, v1) {
56537
57083
  const pos = mesh2.geometry.attributes.position;
56538
57084
  const a = pos.array;
@@ -56557,6 +57103,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56557
57103
  markPositionsWritten(mesh2, v0, v0 + saved.length / 3);
56558
57104
  const list2 = mesh2.userData.collapsedRanges;
56559
57105
  if (list2) mesh2.userData.collapsedRanges = list2.filter((r) => r[0] !== v0);
57106
+ withdrawSolids(mesh2, v0);
56560
57107
  }
56561
57108
  function noise2(x, y, cell) {
56562
57109
  const h = (i2, j2) => {
@@ -56880,11 +57427,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56880
57427
  }
56881
57428
  g.computeBoundingBox();
56882
57429
  g.computeBoundingSphere();
56883
- const base = it.mesh.material;
56884
- const material = base.clone();
57430
+ const base2 = it.mesh.material;
57431
+ const material = base2.clone();
56885
57432
  const toHouse = { value: new THREE.Matrix4() };
56886
57433
  material.onBeforeCompile = (sh) => {
56887
- base.onBeforeCompile?.(sh);
57434
+ base2.onBeforeCompile?.(sh);
56888
57435
  sh.uniforms.uToHouse = toHouse;
56889
57436
  sh.uniforms.uMask = { value: mask.texture };
56890
57437
  sh.uniforms.uMaskRect = { value: mask.rect };
@@ -56892,7 +57439,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56892
57439
  sh.vertexShader = sh.vertexShader.replace("void main() {", "uniform mat4 uToHouse;\nvarying vec3 vHousePos;\nvoid main() {").replace("#include <begin_vertex>", "#include <begin_vertex>\nvHousePos = (uToHouse * vec4(transformed, 1.0)).xyz;");
56893
57440
  sh.fragmentShader = sh.fragmentShader.replace("void main() {", "uniform sampler2D uMask;\nuniform vec4 uMaskRect;\nuniform float uMaskAlongX;\nvarying vec3 vHousePos;\nvoid main() {\n vec2 mUv = vec2(((uMaskAlongX > 0.5 ? vHousePos.x : vHousePos.z) - uMaskRect.x) / uMaskRect.z, (vHousePos.y - uMaskRect.y) / uMaskRect.w);\n if (mUv.x >= 0.0 && mUv.x <= 1.0 && mUv.y >= 0.0 && mUv.y <= 1.0 && texture2D(uMask, mUv).r > 0.5) discard;");
56894
57441
  };
56895
- material.customProgramCacheKey = () => "breachMask" + (base.customProgramCacheKey?.() ?? "");
57442
+ material.customProgramCacheKey = () => "breachMask" + (base2.customProgramCacheKey?.() ?? "");
56896
57443
  const mesh2 = new THREE.Mesh(g, material);
56897
57444
  mesh2.name = "breach-shell";
56898
57445
  mesh2.userData.breachMask = mask;
@@ -57007,6 +57554,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57007
57554
  const around = { pillars: pillarSpans(view), gaps: windowGaps(view) };
57008
57555
  for (const id of view.parts) view.kept.set(id, splitUnits(view, id, around).kept);
57009
57556
  view.keptStale = false;
57557
+ publishStanding(view);
57558
+ }
57559
+ function publishStanding(view) {
57560
+ if (!view.saved) return;
57561
+ const { mask } = view;
57562
+ const parts2 = view.parts.map((id) => {
57563
+ const part = structure.byId.get(id);
57564
+ const thick = mask.alongU ? part.aabb[3] - part.aabb[1] : part.aabb[2] - part.aabb[0];
57565
+ const mid = mask.alongU ? (part.aabb[1] + part.aabb[3]) / 2 : (part.aabb[0] + part.aabb[2]) / 2;
57566
+ return { spans: view.kept.get(id) ?? [], thick, mid };
57567
+ });
57568
+ const line = { alongU: mask.alongU, start: mask.start, open: view.core };
57569
+ view.items.forEach((it, k) => publishSolids(it.mesh, it.v0, it.v1, k === 0 ? standingSolids(THREE, house, it.mesh, line, parts2) : []));
57010
57570
  }
57011
57571
  function paint(view) {
57012
57572
  const { mask, core } = view;
@@ -57081,13 +57641,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57081
57641
  const unit = clipToBox({ x: mask.alongU ? centre : mid, y, z: mask.alongU ? mid : centre, sx: mask.alongU ? s : d, sy: dy, sz: mask.alongU ? d : s, colour }, inner);
57082
57642
  if (unit && !discs.some((k) => Math.hypot((mask.alongU ? unit.x : unit.z) - mask.start - k.s, unit.y - k.y) < k.r)) list2.push(unit);
57083
57643
  };
57084
- const base = fragmentMaterial(part.material).color.getHex();
57644
+ const base2 = fragmentMaterial(part.material).color.getHex();
57085
57645
  const n = noise2(centre * 3.1, y * 2.7, 0.07);
57086
57646
  if (units2.mortar === "concrete") {
57087
- at2(len, h, thick - 2 * COVER2, tone(base, 0.9 + 0.04 * n));
57647
+ at2(len, h, thick - 2 * COVER2, tone(base2, 0.9 + 0.04 * n));
57088
57648
  } else {
57089
57649
  at2(len, h, thick - 2 * COVER2 - 0.012, 10327948);
57090
- at2(len - 0.012, h - 0.012, thick - 2 * COVER2, tone(base, 0.8 + 0.35 * n));
57650
+ at2(len - 0.012, h - 0.012, thick - 2 * COVER2, tone(base2, 0.8 + 0.35 * n));
57091
57651
  }
57092
57652
  }
57093
57653
  const lumps = stuckLumps(castGone, mask, view.bounds);
@@ -57111,6 +57671,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57111
57671
  view.gone = holes.length;
57112
57672
  view.pits = pits.length;
57113
57673
  view.flakes = flakes.length;
57674
+ publishStanding(view);
57114
57675
  }
57115
57676
  function chipBox(chip, alongU) {
57116
57677
  house.updateWorldMatrix(true, false);
@@ -57222,6 +57783,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57222
57783
  view.shells = view.items.map((it) => shell(it, view.mask));
57223
57784
  for (const m of view.shells) m.userData.behind = () => view.units;
57224
57785
  view.saved = view.items.map((it) => ({ it, v0: it.v0, data: collapseRange(it.mesh, it.v0, it.v1) }));
57786
+ refreshKept(view);
57225
57787
  }
57226
57788
  function draw(partId, change) {
57227
57789
  if (lod !== 0) return false;
@@ -57272,6 +57834,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57272
57834
  if (shown2) restoreRange(s.it.mesh, s.v0, s.data);
57273
57835
  else s.data = collapseRange(s.it.mesh, s.v0, s.it.v1);
57274
57836
  }
57837
+ if (!shown2) publishStanding(view);
57275
57838
  }
57276
57839
  function flush(budgetMs) {
57277
57840
  if (budgetMs !== void 0 || !cutState.attached) paintCut();
@@ -58238,9 +58801,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58238
58801
  walk(house, void 0);
58239
58802
  return stages;
58240
58803
  }
58241
- function stageOfPiece(piece2, stages) {
58804
+ function stageOfPiece(piece22, stages) {
58242
58805
  let found;
58243
- piece2.root.traverse((o) => {
58806
+ piece22.root.traverse((o) => {
58244
58807
  if (found) return;
58245
58808
  const part = o.userData?.destructionPart;
58246
58809
  if (typeof part === "string") found = stages.get(part);
@@ -58249,20 +58812,20 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58249
58812
  }
58250
58813
  function stageLoosePieces(pieces, stages, level, opts, held) {
58251
58814
  let hidden = 0;
58252
- for (const piece2 of pieces) {
58253
- const stage = stageOfPiece(piece2, stages);
58815
+ for (const piece22 of pieces) {
58816
+ const stage = stageOfPiece(piece22, stages);
58254
58817
  if (!stage) continue;
58255
58818
  const shown2 = stageVisible(stage, level, opts);
58256
- piece2.root.visible = shown2;
58819
+ piece22.root.visible = shown2;
58257
58820
  if (!shown2) {
58258
58821
  hidden++;
58259
- if (!piece2.held) {
58260
- piece2.held = true;
58261
- held.add(piece2);
58822
+ if (!piece22.held) {
58823
+ piece22.held = true;
58824
+ held.add(piece22);
58262
58825
  }
58263
- } else if (held.has(piece2)) {
58264
- piece2.held = false;
58265
- held.delete(piece2);
58826
+ } else if (held.has(piece22)) {
58827
+ piece22.held = false;
58828
+ held.delete(piece22);
58266
58829
  }
58267
58830
  }
58268
58831
  return hidden;
@@ -58644,7 +59207,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58644
59207
  return { u: P.u - Math.sign(P.frontU || 0) * PANEL_RECESS, v: P.v - Math.sign(P.frontV || 0) * PANEL_RECESS, y0: P.y - h / 2 + PANEL_LIFT - BOX_CHASE_CLEAR, y1: P.y + h / 2 + PANEL_LIFT + BOX_CHASE_CLEAR, radius: w / 2, depth: 0 };
58645
59208
  }
58646
59209
  function installBuildBuild(K, shared2) {
58647
- const { THREE, cfg, rectsOf: rectsOf2, invalidateShadow, colliderChanged, VERSION: VERSION2, CARS, EPS: EPS4, LIGHTS, MIRRORS, Y0, animateClotheslines, animateDoors, animateInteractive, applyLeaf, applyOutbuildings, applyPart, applyPiece, assembleInteractive, baseboardAndSidewalk, buildStairs, building, carModel, chooseMirror, closeScene, collideAt, createWater, cursor, doorText, doors, electricalStructure, elevator, floorsAndSlabs, gatesInteractive, houseItems, ivAssemble, ivBuild, ivDispose, ivParts, ivPublish, ivUpdate, lightOn, linkDoorLeaves, mailboxInteractive, newInteractiveState, newMirrorState, outbuildings, paths, perimeter, placeSwitches, roofs, roomAt, solar, targetOf, terrain, toggleDoor, toggleLight, walls, waterPipes, drainPipes, windows, props, TYPES, IVK, VEG, vegMaterials, markGroups, assembleStructure, pieceRecord, createHouseDestruction, newState, enter, tagDamage } = K;
59210
+ const { THREE, cfg, rectsOf: rectsOf2, invalidateShadow, colliderChanged, VERSION: VERSION2, CARS, EPS: EPS4, LIGHTS, MIRRORS, Y0, animateClotheslines, animateDoors, animateInteractive, applyLeaf, applyOutbuildings, applyPart, applyPiece, assembleInteractive, baseboardAndSidewalk, buildStairs, building, carModel, chooseMirror, closeScene, collideAt, createWater, cursor, doorText, doors, electricalStructure, elevator, floorsAndSlabs, gatesInteractive, houseItems, ivAssemble, ivBuild, ivDispose, ivParts, ivPublish, ivUpdate, lightOn, linkDoorLeaves, mailboxInteractive, walkInInteractive, newInteractiveState, newMirrorState, outbuildings, paths, perimeter, placeSwitches, roofs, roomAt, solar, targetOf, terrain, toggleDoor, toggleLight, walls, waterPipes, drainPipes, windows, props, TYPES, IVK, VEG, vegMaterials, markGroups, assembleStructure, pieceRecord, createHouseDestruction, newState, enter, tagDamage } = K;
58648
59211
  function build(r0, options) {
58649
59212
  const opts = options || {};
58650
59213
  const r = withLaidConduits(applyOutbuildings(r0), !!(opts.constructionStages || opts.constructionLevel != null));
@@ -58791,6 +59354,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58791
59354
  assembleInteractive(gs);
58792
59355
  linkDoorLeaves();
58793
59356
  mailboxInteractive();
59357
+ walkInInteractive();
58794
59358
  if (cs) {
58795
59359
  for (const def of shared2.inter.defs.values()) {
58796
59360
  if (def.outer && !def.outer.userData.constructionStage) def.outer.userData.constructionStage = /^gate/.test(def.kind) ? "perimeter" : "furniture";
@@ -59481,7 +60045,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59481
60045
  joinBodies(params, byId);
59482
60046
  }
59483
60047
  function holdHanging({ parts: parts2, joints, boxOf: boxOf3 }, byId) {
59484
- const back = Math.min(...parts2.map((part) => boxOf3(part.id).min[2]));
60048
+ const back2 = Math.min(...parts2.map((part) => boxOf3(part.id).min[2]));
59485
60049
  for (let pass = 0; pass < parts2.length; pass++) {
59486
60050
  const groups = groupsOf(parts2, joints).map((ids) => ids.map((id) => byId.get(id)));
59487
60051
  const held = groups.filter((group) => group.some((part) => part.anchored)).flat();
@@ -59495,8 +60059,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59495
60059
  changed = true;
59496
60060
  continue;
59497
60061
  }
59498
- const againstWall = held.length === 0 || held.some((part) => boxOf3(part.id).min[2] <= back + AGAINST_WALL);
59499
- const onWall = againstWall ? group.filter((part) => !SOFT.has(part.material) && boxOf3(part.id).min[2] <= back + BACK_TOUCH) : [];
60062
+ const againstWall = held.length === 0 || held.some((part) => boxOf3(part.id).min[2] <= back2 + AGAINST_WALL);
60063
+ const onWall = againstWall ? group.filter((part) => !SOFT.has(part.material) && boxOf3(part.id).min[2] <= back2 + BACK_TOUCH) : [];
59500
60064
  if (onWall.length === 0) continue;
59501
60065
  for (const part of onWall) part.anchored = true;
59502
60066
  changed = true;
@@ -59509,6 +60073,230 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59509
60073
  return;
59510
60074
  }
59511
60075
  }
60076
+ var COVER22 = 6e-3;
60077
+ var SPRING = 3e-3;
60078
+ var SPRING_WIDTH = 0.012;
60079
+ var CLOTH_COVER = [{ material: "fabric", thickness: COVER22, faces: "all" }];
60080
+ function piece2(id, key2, material, min, max, color2) {
60081
+ const size = [max[0] - min[0], max[1] - min[1], max[2] - min[2]];
60082
+ const position = [(min[0] + max[0]) / 2, (min[1] + max[1]) / 2, (min[2] + max[2]) / 2];
60083
+ return { id, key: key2, material, shape: { kind: "box", size }, position, rotation: null, color: color2, min, max };
60084
+ }
60085
+ var bothSides = (x0, x1) => [
60086
+ [x0, x1],
60087
+ [-x1, -x0]
60088
+ ];
60089
+ var SIDE_RAIL = 0.03;
60090
+ var SLAT_TOP = 0.297;
60091
+ var SLAT_THICK = 0.027;
60092
+ var SLAT_WIDTH = 0.07;
60093
+ var SLAT_PITCH = 0.12;
60094
+ var SPRING_STRIPS = 5;
60095
+ function bedParts(drawn) {
60096
+ const [frame2, ...otherWood] = drawn.filter((p) => p.key === "wood");
60097
+ const [mattress, ...bedclothes] = drawn.filter((p) => p.key === "fabric");
60098
+ if (!frame2 || !mattress) return [...drawn];
60099
+ const hw = (frame2.max[0] - frame2.min[0]) / 2;
60100
+ const [z0, z1] = [frame2.min[2], frame2.max[2]];
60101
+ const wood = frame2.color;
60102
+ const out = [...otherWood.map((p, k) => ({ ...p, id: k === 0 ? "bed_headboard" : "bed_footboard" }))];
60103
+ bothSides(hw - SIDE_RAIL, hw).forEach(([x0, x1], k) => out.push(piece2(`bed_side_rail_${k}`, "wood", "wood_hard", [x0, 0, z0], [x1, frame2.max[1], z1], wood)));
60104
+ out.push(piece2("bed_centre_rail", "wood", "wood_soft", [-0.03, 0.2, z0], [0.03, SLAT_TOP - SLAT_THICK, z1], wood));
60105
+ const slats = Math.floor((z1 - z0 - 2 * 0.02 - SLAT_WIDTH) / SLAT_PITCH) + 1;
60106
+ for (let k = 0; k < slats; k++) {
60107
+ const z = z0 + 0.02 + k * SLAT_PITCH;
60108
+ out.push(piece2(`bed_slat_${k}`, "wood", "wood_soft", [-hw + SIDE_RAIL, SLAT_TOP - SLAT_THICK, z], [hw - SIDE_RAIL, SLAT_TOP, z + SLAT_WIDTH], wood));
60109
+ }
60110
+ const span = 2 * (hw - SIDE_RAIL);
60111
+ for (let k = 0; k < SPRING_STRIPS; k++) {
60112
+ const x = -hw + SIDE_RAIL + (k + 1) * span / (SPRING_STRIPS + 1);
60113
+ out.push(piece2(`bed_spring_${k}`, "metal", "spring_steel", [x - SPRING_WIDTH / 2, SLAT_TOP, z0], [x + SPRING_WIDTH / 2, SLAT_TOP + SPRING, z1], 4869200));
60114
+ }
60115
+ out.push({ ...mattress, id: "bed_mattress", material: "foam", layers: CLOTH_COVER });
60116
+ return [...out, ...bedclothes];
60117
+ }
60118
+ var RAIL_HEIGHT = 0.08;
60119
+ var POST = 0.05;
60120
+ var BOARD = 0.05;
60121
+ function base(L, c, seats, plinth) {
60122
+ const { hw, hd, armWidth: aT, postX: px } = L;
60123
+ const ix = hw - aT;
60124
+ const railTop = L.support - 6e-3;
60125
+ const railBottom = railTop - RAIL_HEIGHT;
60126
+ const zFrom = L.backFrame + BOARD;
60127
+ const zTo = L.coverFront - L.railDepth;
60128
+ const out = [];
60129
+ const wood = (id, min, max, material = "wood_hard") => out.push(piece2(id, "wood", material, min, max, c.wood));
60130
+ if (plinth) {
60131
+ wood("seat_plinth_front", [-hw, 0, hd - 0.06], [hw, L.postFloor, hd]);
60132
+ wood("seat_plinth_back", [-hw, 0, L.rear], [hw, L.postFloor, L.rear + 0.04]);
60133
+ for (const [k, [x0, x1]] of bothSides(hw - 0.04, hw).entries()) wood(`seat_plinth_side_${k}`, [x0, 0, L.rear + 0.04], [x1, L.postFloor, hd - 0.06]);
60134
+ }
60135
+ const upright = (id, x, z, top) => wood(id, [x - POST / 2, L.postFloor, z - POST / 2], [x + POST / 2, top, z + POST / 2]);
60136
+ for (const [k, sx] of [-1, 1].entries()) {
60137
+ upright(`seat_post_front_${k}`, sx * px, L.postFront, railTop);
60138
+ upright(`seat_post_back_${k}`, sx * px, L.postBack, L.stiles === "posts" ? L.armTop - 0.03 : railTop);
60139
+ }
60140
+ wood("seat_rail_front", [-(px - POST / 2), railBottom, zTo], [px - POST / 2, railTop, L.coverFront]);
60141
+ wood("seat_rail_back", [-(px - POST / 2), railBottom, L.backFrame], [px - POST / 2, railTop, zFrom]);
60142
+ for (const [k, [x0, x1]] of bothSides(hw - aT + COVER22, px - POST / 2).entries()) wood(`seat_rail_side_${k}`, [x0, railBottom, zFrom], [x1, railTop, zTo]);
60143
+ for (const seat of seats) if (seat.seam !== void 0) wood(`seat_divider_${out.length}`, [seat.seam - 0.02, railBottom, zFrom], [seat.seam + 0.02, railTop, zTo]);
60144
+ for (const [k, seat] of seats.entries()) {
60145
+ for (const [j, dx] of [-0.12, 0.12].entries()) {
60146
+ const x = seat.x + dx;
60147
+ out.push(piece2(`seat_spring_${k * 2 + j}`, "metal", "spring_steel", [x - SPRING_WIDTH / 2, railTop, L.backFrame + BOARD / 2], [x + SPRING_WIDTH / 2, railTop + SPRING, L.springEnd], 4869200));
60148
+ }
60149
+ }
60150
+ out.push(piece2("seat_cover_front", "fabric", "fabric", [-ix, L.skirt, L.coverFront], [ix, L.support, L.coverFront + COVER22], c.skirt));
60151
+ if (L.springEnd < L.coverFront - 0.03) out.push(piece2("seat_ledge", "fabric", "fabric", [-ix, railTop, L.springEnd], [ix, L.support, L.coverFront + COVER22], c.skirt));
60152
+ return out;
60153
+ }
60154
+ function back(L, c) {
60155
+ const { hw, armWidth: aT } = L;
60156
+ const ix = hw - aT;
60157
+ const railTop = L.support - 6e-3;
60158
+ const top = L.backTop - COVER22;
60159
+ const zFrame = [L.backFrame, L.backFrame + BOARD];
60160
+ const out = [];
60161
+ if (L.stiles === "rail") {
60162
+ for (const [k, [x0, x1]] of bothSides(ix - POST, ix).entries()) out.push(piece2(`back_stile_${k}`, "wood", "wood_hard", [x0, railTop, zFrame[0]], [x1, top, zFrame[1]], c.wood));
60163
+ out.push(piece2("back_top_rail", "wood", "wood_hard", [-(ix - POST), top - BOARD, zFrame[0]], [ix - POST, top, zFrame[1]], c.wood));
60164
+ }
60165
+ const midX = L.stiles === "rail" ? ix - POST : L.postX - POST / 2;
60166
+ out.push(piece2("back_mid_rail", "wood", "wood_hard", [-midX, 0.5, zFrame[0]], [midX, 0.5 + POST, zFrame[1]], c.wood));
60167
+ if (L.backFrame > L.rear + COVER22 + 0.01) out.push(piece2("back_pad_rear", "fabric", "foam", [-ix, L.skirt, L.rear + COVER22], [ix, top, L.backFrame], c.skirt));
60168
+ out.push(piece2("back_pad", "fabric", "foam", [-ix, L.support, zFrame[1]], [ix, top, L.rear + L.backDepth], c.back));
60169
+ out.push(piece2("back_cover_rear", "fabric", "fabric", [-L.rearHalf, L.skirt, L.rear], [L.rearHalf, L.backTop, L.rear + COVER22], c.skirt));
60170
+ out.push(piece2("back_cover_top", "fabric", "fabric", [-L.rearHalf, top, L.rear + COVER22], [L.rearHalf, L.backTop, L.rear + L.backDepth], c.back));
60171
+ if (L.rearHalf > ix) {
60172
+ for (const [k, [x0, x1]] of bothSides(ix, L.rearHalf).entries()) out.push(piece2(`back_shoulder_${k}`, "fabric", "foam", [x0, L.armTop, L.rear + COVER22], [x1, top, L.rear + L.backDepth], c.back));
60173
+ }
60174
+ return out;
60175
+ }
60176
+ function arms(L, c, boardBack) {
60177
+ const { hw, armWidth: aT, postX: px } = L;
60178
+ const railTop = L.support - 6e-3;
60179
+ const padTop = L.armTop - 0.03;
60180
+ const front = L.armFront;
60181
+ const out = [];
60182
+ const sides = [bothSides(px - POST / 2, px + POST / 2), bothSides(px + POST / 2, hw - COVER22), bothSides(hw - aT + COVER22, px - POST / 2), bothSides(hw - aT + COVER22, hw - COVER22), bothSides(hw - COVER22, hw), bothSides(hw - aT, hw - aT + COVER22)];
60183
+ const [board2, outer, inner, top, coverOuter, coverInner] = sides;
60184
+ for (const k of [0, 1]) {
60185
+ const z0 = L.armBack;
60186
+ out.push(piece2(`arm_board_${k}`, "wood", "wood_hard", [board2[k][0], railTop, boardBack], [board2[k][1], padTop, L.postFront + POST / 2], c.wood));
60187
+ out.push(piece2(`arm_pad_outer_${k}`, "fabric", "foam", [outer[k][0], railTop, z0], [outer[k][1], padTop, front - COVER22], c.arm));
60188
+ out.push(piece2(`arm_pad_inner_${k}`, "fabric", "foam", [inner[k][0], railTop, z0], [inner[k][1], padTop, front - COVER22], c.arm));
60189
+ out.push(piece2(`arm_pad_top_${k}`, "fabric", "foam", [top[k][0], padTop, z0], [top[k][1], L.armTop - COVER22, front - COVER22], c.arm));
60190
+ out.push(piece2(`arm_cover_outer_${k}`, "fabric", "fabric", [coverOuter[k][0], L.armBottom, z0], [coverOuter[k][1], L.armTop, front], c.arm));
60191
+ out.push(piece2(`arm_cover_inner_${k}`, "fabric", "fabric", [coverInner[k][0], L.armBottom, z0], [coverInner[k][1], L.armTop, front], c.arm));
60192
+ out.push(piece2(`arm_cover_top_${k}`, "fabric", "fabric", [top[k][0], L.armTop - COVER22, z0], [top[k][1], L.armTop, front - COVER22], c.arm));
60193
+ out.push(piece2(`arm_cover_front_${k}`, "fabric", "fabric", [top[k][0], L.armBottom, front - COVER22], [top[k][1], L.armTop - COVER22, front], c.arm));
60194
+ if (z0 > L.rear + 0.01) out.push(piece2(`arm_cover_back_${k}`, "fabric", "fabric", [top[k][0], L.armBottom, z0], [top[k][1], L.armTop - COVER22, z0 + COVER22], c.arm));
60195
+ }
60196
+ return out;
60197
+ }
60198
+ function seatStructure(L, c, seats, options) {
60199
+ return [...base(L, c, seats, options.plinth), ...back(L, c), ...arms(L, c, options.boardBack)];
60200
+ }
60201
+ function cushion(block, id) {
60202
+ return { ...block, id, material: "foam", layers: CLOTH_COVER };
60203
+ }
60204
+ var SOFAS = /^sofa_/;
60205
+ var ARMCHAIRS = /^armchair/;
60206
+ var BEDS = /^(double_bed|queen_bed|king_bed|single_bed|mattress)$/;
60207
+ var seatsOf = (cushions) => cushions.map((block, k) => ({ x: block.position[0], ...cushions[k + 1] ? { seam: (block.position[0] + cushions[k + 1].position[0]) / 2 } : {} }));
60208
+ function sofaParts(drawn) {
60209
+ const woods = drawn.filter((p) => p.key === "wood");
60210
+ const cloth2 = drawn.filter((p) => p.key === "fabric");
60211
+ const count = (cloth2.length - 5) / 2;
60212
+ const [skirt, ...rest2] = cloth2;
60213
+ const seatCushions = rest2.slice(0, count);
60214
+ const [back2] = rest2.slice(count, count + 1);
60215
+ const backCushions = rest2.slice(count + 1, 2 * count + 1);
60216
+ const [armLeft, , pillow] = rest2.slice(2 * count + 1);
60217
+ const feet = woods.slice(1);
60218
+ if (!skirt || !back2 || !armLeft || !pillow || feet.length !== 4) return [...drawn];
60219
+ const hd = (armLeft.max[2] - armLeft.min[2]) / 2 + 0.02;
60220
+ const hw = (woods[0].max[0] - woods[0].min[0]) / 2;
60221
+ const frontFoot = Math.max(...feet.map((foot) => foot.position[2]));
60222
+ const backFoot = Math.min(...feet.map((foot) => foot.position[2]));
60223
+ const layout = {
60224
+ hw,
60225
+ hd,
60226
+ rear: -hd,
60227
+ armWidth: armLeft.max[0] - armLeft.min[0],
60228
+ armTop: armLeft.max[1],
60229
+ armBottom: armLeft.min[1],
60230
+ backTop: back2.max[1],
60231
+ backDepth: back2.max[2] - back2.min[2],
60232
+ skirt: skirt.min[1],
60233
+ support: skirt.max[1],
60234
+ postX: Math.abs(feet[0].position[0]),
60235
+ postFront: frontFoot,
60236
+ postBack: backFoot,
60237
+ postFloor: 0,
60238
+ coverFront: skirt.max[2] - COVER22,
60239
+ railDepth: 0.07,
60240
+ springEnd: skirt.max[2] - 0.05,
60241
+ backFrame: backFoot - 0.025,
60242
+ armBack: armLeft.min[2],
60243
+ armFront: armLeft.max[2],
60244
+ rearHalf: hw - (armLeft.max[0] - armLeft.min[0]),
60245
+ stiles: "rail"
60246
+ };
60247
+ const colours = { wood: feet[0].color, skirt: skirt.color, back: back2.color, arm: armLeft.color };
60248
+ const structure = seatStructure(layout, colours, seatsOf(seatCushions), { plinth: false, boardBack: layout.backFrame });
60249
+ const cushions = [...seatCushions.map((block, k) => cushion(block, `seat_cushion_${k}`)), ...backCushions.map((block, k) => cushion(block, `back_cushion_${k}`)), cushion(pillow, "accent_pillow")];
60250
+ return [...structure, ...cushions];
60251
+ }
60252
+ var ARMCHAIR_SUPPORT = 0.28;
60253
+ function armchairParts(drawn) {
60254
+ const plinth = drawn.find((p) => p.key === "wood");
60255
+ const [seat, back2, armLeft] = drawn.filter((p) => p.key === "fabric");
60256
+ if (!plinth || !seat || !back2 || !armLeft) return [...drawn];
60257
+ const [hw, hd] = [(plinth.max[0] - plinth.min[0]) / 2, (plinth.max[2] - plinth.min[2]) / 2];
60258
+ const armWidth = armLeft.max[0] - armLeft.min[0];
60259
+ const rear = back2.min[2];
60260
+ const backFrame = rear + COVER22;
60261
+ const coverFront = hd - 0.04;
60262
+ const layout = {
60263
+ hw,
60264
+ hd,
60265
+ rear,
60266
+ armWidth,
60267
+ armTop: armLeft.max[1],
60268
+ armBottom: armLeft.min[1],
60269
+ backTop: back2.max[1],
60270
+ backDepth: back2.max[2] - rear,
60271
+ skirt: plinth.max[1],
60272
+ support: ARMCHAIR_SUPPORT,
60273
+ postX: hw - 0.07,
60274
+ postFront: hd - 0.065,
60275
+ postBack: backFrame + 0.025,
60276
+ postFloor: plinth.max[1],
60277
+ coverFront,
60278
+ railDepth: 0.05,
60279
+ springEnd: coverFront - 0.02,
60280
+ backFrame,
60281
+ armBack: backFrame,
60282
+ armFront: armLeft.max[2],
60283
+ rearHalf: (back2.max[0] - back2.min[0]) / 2,
60284
+ stiles: "posts"
60285
+ };
60286
+ const colours = { wood: plinth.color, skirt: seat.color, back: back2.color, arm: armLeft.color };
60287
+ const structure = seatStructure(layout, colours, [{ x: 0 }], { plinth: true, boardBack: backFrame + 0.05 });
60288
+ const ix = hw - armWidth;
60289
+ const seatCushion = { ...seat, id: "seat_cushion_0", min: [-(ix - 2e-3), ARMCHAIR_SUPPORT, rear + layout.backDepth], max: [ix - 2e-3, seat.max[1], seat.max[2]] };
60290
+ const size = [seatCushion.max[0] - seatCushion.min[0], seatCushion.max[1] - seatCushion.min[1], seatCushion.max[2] - seatCushion.min[2]];
60291
+ const position = [0, (seatCushion.min[1] + seatCushion.max[1]) / 2, (seatCushion.min[2] + seatCushion.max[2]) / 2];
60292
+ return [...structure, cushion({ ...seatCushion, shape: { kind: "box", size }, position }, "seat_cushion_0")];
60293
+ }
60294
+ function upholster(drawn, type) {
60295
+ const made2 = SOFAS.test(type) ? sofaParts(drawn) : ARMCHAIRS.test(type) ? armchairParts(drawn) : BEDS.test(type) ? bedParts(drawn) : void 0;
60296
+ if (!made2) return false;
60297
+ drawn.splice(0, drawn.length, ...made2);
60298
+ return true;
60299
+ }
59512
60300
  var WOOD_THIN = 0.035;
59513
60301
  var BOARD_TOP_THICK = 0.07;
59514
60302
  var BOARD_TOP_WIDTH = 0.5;
@@ -59735,6 +60523,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59735
60523
  run(A);
59736
60524
  if (!drawn.length) throw new Error(`game-floorplan-three: the builder of "${name}" drew no box or cylinder`);
59737
60525
  hollowCases(drawn, name);
60526
+ upholster(drawn, name);
59738
60527
  const boardsOf = splitTopsIntoBoards(drawn, materialOf, Boolean(opts.carcass));
59739
60528
  const parts2 = drawn.map((p) => {
59740
60529
  const thin = Math.min(...p.shape.kind === "box" ? p.shape.size : p.shape.kind === "cylinder" ? [p.shape.radius * 2, p.shape.height] : [p.shape.radius * 2]);
@@ -59747,6 +60536,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59747
60536
  const fill2 = structureFill(material, p.shape);
59748
60537
  if (fill2 < 1) part.fill = Math.round(fill2 * 1e4) / 1e4;
59749
60538
  if (p.rotation) part.rotation = p.rotation;
60539
+ if (p.layers) part.layers = p.layers;
59750
60540
  if (!LOOSE.has(material) && p.min[1] <= FLOOR_TOUCH2) part.anchored = true;
59751
60541
  if (opts.carcass && LOOSE.has(material)) {
59752
60542
  part.hands = 1;
@@ -59784,7 +60574,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59784
60574
  let top = null;
59785
60575
  for (const p of drawn) {
59786
60576
  const part = parts2.find((x) => x.id === p.id);
59787
- if (part.shape.kind === "sphere" || part.rotation || part.material === "fabric" || LOOSE.has(part.material)) continue;
60577
+ if (part.shape.kind === "sphere" || part.rotation || part.material === "fabric" || part.material === "foam" || LOOSE.has(part.material)) continue;
59788
60578
  const area3 = (p.max[0] - p.min[0]) * (p.max[2] - p.min[2]);
59789
60579
  if (area3 < 0.6 * footprint || p.max[1] < 0.2) continue;
59790
60580
  if (!top || p.max[1] > top.y + 1e-6) top = { part: p.id, y: p.max[1] };
@@ -60055,11 +60845,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
60055
60845
  var textOf = (locale) => TEXT[locale] ?? TEXT.en;
60056
60846
  var fill = (template, vars) => template.replace(/\{(\w+)\}/g, (_, key2) => String(vars[key2] ?? ""));
60057
60847
  var humanize = (id) => id.replace(/_/g, " ").replace(/^./, (c) => c.toUpperCase());
60058
- var stageOf = (catalog, item, base, ageDays, storage, powered) => {
60059
- if (item.shelfLife === void 0 || ageDays <= 0) return base;
60848
+ var stageOf = (catalog, item, base2, ageDays, storage, powered) => {
60849
+ if (item.shelfLife === void 0 || ageDays <= 0) return base2;
60060
60850
  const state = freshness(item, { ageDays: 0, since: 0, storage, storedAt: 0 }, ageDays, { powered, rules: catalog.rules });
60061
60851
  const aged = state === "fresh" ? 0 : state === "stale" ? 1 : 2;
60062
- return Math.max(base, aged);
60852
+ return Math.max(base2, aged);
60063
60853
  };
60064
60854
  var sizeOfModel = (modelSet, id) => {
60065
60855
  const entry2 = modelSet.entry(id);
@@ -60120,9 +60910,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
60120
60910
  name,
60121
60911
  movable: false,
60122
60912
  build: (THREE) => {
60123
- const piece2 = furnitureSpec(THREE, type, { ...size, options: { chairs: false } });
60124
- const root = piece2.build(THREE);
60125
- root.userData.furnitureSpec = { ...piece2.spec, name };
60913
+ const piece3 = furnitureSpec(THREE, type, { ...size, options: { chairs: false } });
60914
+ const root = piece3.build(THREE);
60915
+ root.userData.furnitureSpec = { ...piece3.spec, name };
60126
60916
  decorate?.(root);
60127
60917
  return root;
60128
60918
  },
@@ -60203,11 +60993,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
60203
60993
  build: (THREE) => {
60204
60994
  const T2 = THREE;
60205
60995
  const group = markKitOrigin(new T2.Group(), { owner: "game-items-three", kind: "aid" });
60206
- 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 }));
60207
- base.position.y = (STAND.height - 0.04) / 2;
60996
+ const base2 = new T2.Mesh(new T2.CylinderGeometry(STAND.radius, STAND.radius + 0.1, STAND.height - 0.04, 40), new T2.MeshStandardMaterial({ color: 3816772, roughness: 0.8 }));
60997
+ base2.position.y = (STAND.height - 0.04) / 2;
60208
60998
  const top = new T2.Mesh(new T2.CylinderGeometry(STAND.radius, STAND.radius, 0.04, 40), new T2.MeshStandardMaterial({ color: 13617848, roughness: 0.6 }));
60209
60999
  top.position.y = STAND.height - 0.02;
60210
- group.add(base, top);
61000
+ group.add(base2, top);
60211
61001
  return group;
60212
61002
  }
60213
61003
  });
@@ -60228,9 +61018,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
60228
61018
  mark.position.set(0.03 + (long ? 0.025 : 0.015), cm / 100, 0);
60229
61019
  group.add(mark);
60230
61020
  }
60231
- const base = new T2.Mesh(new T2.BoxGeometry(0.3, 0.03, 0.3), new T2.MeshStandardMaterial({ color: 5593180 }));
60232
- base.position.y = 0.015;
60233
- group.add(base);
61021
+ const base2 = new T2.Mesh(new T2.BoxGeometry(0.3, 0.03, 0.3), new T2.MeshStandardMaterial({ color: 5593180 }));
61022
+ base2.position.y = 0.015;
61023
+ group.add(base2);
60234
61024
  group.userData.height = RULER_HEIGHT;
60235
61025
  return group;
60236
61026
  }