@adatechnology/game-weapons-three 0.29.3 → 0.29.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.
@@ -219,7 +219,7 @@ var GameWeaponsThree = (() => {
219
219
  var positive = (n) => finite(n) && n > 0;
220
220
  var vec3 = (v) => Array.isArray(v) && v.length === 3 && v.every(finite);
221
221
  var nonNegative = (n) => n === void 0 || finite(n) && n >= 0;
222
- var FACES = ["both", "+", "-"];
222
+ var FACES = ["both", "+", "-", "all"];
223
223
  var BONDS = ["running", "stack"];
224
224
  var checkStagedFields = (p, label, materials, problems) => {
225
225
  const known = (m, what) => {
@@ -654,9 +654,9 @@ var GameWeaponsThree = (() => {
654
654
  };
655
655
  var UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
656
656
  var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
657
- var deepMerge = (base, patch) => {
658
- if (!patch) return base;
659
- const result2 = { ...base };
657
+ var deepMerge = (base2, patch) => {
658
+ if (!patch) return base2;
659
+ const result2 = { ...base2 };
660
660
  for (const [key2, value] of Object.entries(patch)) {
661
661
  if (value === void 0 || UNSAFE_KEYS.has(key2)) continue;
662
662
  const current = result2[key2];
@@ -15793,7 +15793,7 @@ var GameWeaponsThree = (() => {
15793
15793
  const energy = 0.5 * (caliber.bulletGrams / 1e3) * weaponSpeed(def.action, caliber) ** 2;
15794
15794
  return roundsToWarning({ def, caliber, energy, rpm: def.action.rpm, rules: arsenal.rules.heat });
15795
15795
  };
15796
- var burstNoise = (base, recentShots, rules) => base * (1 + Math.min(rules.cap, rules.step * recentShots));
15796
+ var burstNoise = (base2, recentShots, rules) => base2 * (1 + Math.min(rules.cap, rules.step * recentShots));
15797
15797
  var magazineOut = { stage: "magazine_out", at: 0 };
15798
15798
  var magazineIn = { stage: "magazine_in", at: 0.549 };
15799
15799
  var byMagazine = (chargeAt) => ({
@@ -15938,12 +15938,12 @@ var GameWeaponsThree = (() => {
15938
15938
  }
15939
15939
  return [added, taken];
15940
15940
  };
15941
- var stat = (name, base, sources, active) => {
15941
+ var stat = (name, base2, sources, active) => {
15942
15942
  const current = modifiersOf(name, sources.now, active);
15943
15943
  const lastSet = [...current].reverse().find((modifier) => modifier.set !== void 0)?.set;
15944
15944
  if (lastSet !== void 0) return (lastSet + sum(current)) * product(current);
15945
15945
  const [added, taken] = cancelShipped(current, modifiersOf(name, sources.shipped, sources.shippedActive ?? /* @__PURE__ */ new Set()));
15946
- return (base + (sum(added) - sum(taken))) * (product(added) / product(taken));
15946
+ return (base2 + (sum(added) - sum(taken))) * (product(added) / product(taken));
15947
15947
  };
15948
15948
  var baseSpeedOf = (action, caliber) => action.muzzleSpeed ?? (caliber?.muzzleSpeed ?? 0) * (action.barrel ?? 1);
15949
15949
  var scaleTimings = (timings, reload, empty) => ({
@@ -15982,7 +15982,7 @@ var GameWeaponsThree = (() => {
15982
15982
  const speed = firearm ? stat("muzzleSpeed", baseSpeedOf(firearm, context.caliber), sources, baseActive) : 0;
15983
15983
  const active = new Set(baseActive);
15984
15984
  if (firearm && speed < context.rules.attachments.speedOfSound) active.add("subsonic");
15985
- const read = (name, base) => stat(name, base, sources, active);
15985
+ const read = (name, base2) => stat(name, base2, sources, active);
15986
15986
  const mass = read("mass", def.mass + parts2.reduce((total, part) => total + part.mass, 0) - factory.reduce((total, part) => total + part.mass, 0));
15987
15987
  const hipFactor = context.aiming ? 1 : 1 + (context.rules.aim.hipSpread - 1) * read("hipSpreadExcess", 1);
15988
15988
  const dual = context.dualWield && context.rules.dualWield ? context.rules.dualWield : ONE_HAND;
@@ -16620,12 +16620,12 @@ var GameWeaponsThree = (() => {
16620
16620
  reload(request = "auto") {
16621
16621
  if (this.isWorking()) return false;
16622
16622
  if (this.underActive && this.under) return this.under.reload(request);
16623
- const base = this.action;
16623
+ const base2 = this.action;
16624
16624
  const factor = this.load.secondReloadFactor;
16625
- const isFast = factor !== 1 && this.reloadCount % 2 === 1 && base.kind === "firearm";
16626
- if (isFast && base.kind === "firearm") this.action = { ...base, reload: base.reload * factor, ...base.timings ? { timings: { ...base.timings, reload: base.timings.reload * factor, ...base.timings.reloadEmpty === void 0 ? {} : { reloadEmpty: base.timings.reloadEmpty * factor } } } : {} };
16625
+ const isFast = factor !== 1 && this.reloadCount % 2 === 1 && base2.kind === "firearm";
16626
+ if (isFast && base2.kind === "firearm") this.action = { ...base2, reload: base2.reload * factor, ...base2.timings ? { timings: { ...base2.timings, reload: base2.timings.reload * factor, ...base2.timings.reloadEmpty === void 0 ? {} : { reloadEmpty: base2.timings.reloadEmpty * factor } } } : {} };
16627
16627
  const started = super.reload(request);
16628
- this.action = base;
16628
+ this.action = base2;
16629
16629
  if (started) this.reloadCount += 1;
16630
16630
  return started;
16631
16631
  }
@@ -17611,18 +17611,18 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
17611
17611
  const indexCount = mesh22.geometry.index ? mesh22.geometry.index.count : vertices;
17612
17612
  return { mesh: mesh22, local: local2, vertices, indexCount };
17613
17613
  });
17614
- const totalVertices = pieces.reduce((sum2, piece2) => sum2 + piece2.vertices, 0);
17615
- const totalIndices = pieces.reduce((sum2, piece2) => sum2 + piece2.indexCount, 0);
17614
+ const totalVertices = pieces.reduce((sum2, piece3) => sum2 + piece3.vertices, 0);
17615
+ const totalIndices = pieces.reduce((sum2, piece3) => sum2 + piece3.indexCount, 0);
17616
17616
  const merged2 = new THREE.BufferGeometry();
17617
- const normalMatrices = names.includes("normal") ? pieces.map((piece2) => new THREE.Matrix3().getNormalMatrix(follow ? identity : piece2.local)) : [];
17617
+ const normalMatrices = names.includes("normal") ? pieces.map((piece3) => new THREE.Matrix3().getNormalMatrix(follow ? identity : piece3.local)) : [];
17618
17618
  for (const name of names) {
17619
17619
  const size = first.geometry.attributes[name].itemSize;
17620
17620
  const array = new Float32Array(totalVertices * size);
17621
17621
  let offset = 0;
17622
- for (const [at4, piece2] of pieces.entries()) {
17623
- const matrix = name === "normal" ? normalMatrices[at4] : follow ? identity : piece2.local;
17624
- copyAttribute(name, piece2.mesh.geometry.attributes[name], array, offset, matrix);
17625
- offset += piece2.vertices;
17622
+ for (const [at4, piece3] of pieces.entries()) {
17623
+ const matrix = name === "normal" ? normalMatrices[at4] : follow ? identity : piece3.local;
17624
+ copyAttribute(name, piece3.mesh.geometry.attributes[name], array, offset, matrix);
17625
+ offset += piece3.vertices;
17626
17626
  }
17627
17627
  merged2.setAttribute(name, new THREE.BufferAttribute(array, size));
17628
17628
  }
@@ -17644,30 +17644,30 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
17644
17644
  const sources = [];
17645
17645
  let vertexOffset = 0;
17646
17646
  let indexOffset = 0;
17647
- for (const piece2 of pieces) {
17648
- const index = piece2.mesh.geometry.index;
17647
+ for (const piece3 of pieces) {
17648
+ const index = piece3.mesh.geometry.index;
17649
17649
  if (index) {
17650
17650
  const indices = index.array;
17651
- for (let at4 = 0; at4 < piece2.indexCount; at4++) indexArray2[indexOffset + at4] = indices[at4] + vertexOffset;
17652
- } else for (let at4 = 0; at4 < piece2.indexCount; at4++) indexArray2[indexOffset + at4] = at4 + vertexOffset;
17651
+ for (let at4 = 0; at4 < piece3.indexCount; at4++) indexArray2[indexOffset + at4] = indices[at4] + vertexOffset;
17652
+ } else for (let at4 = 0; at4 < piece3.indexCount; at4++) indexArray2[indexOffset + at4] = at4 + vertexOffset;
17653
17653
  sources.push({
17654
- mesh: piece2.mesh,
17655
- geometry: piece2.mesh.geometry,
17656
- material: piece2.mesh.material,
17657
- version: piece2.mesh.geometry.attributes.position.version,
17658
- local: piece2.local,
17659
- world: piece2.mesh.matrixWorld.clone(),
17660
- mask: piece2.mesh.layers.mask,
17661
- castShadow: piece2.mesh.castShadow,
17654
+ mesh: piece3.mesh,
17655
+ geometry: piece3.mesh.geometry,
17656
+ material: piece3.mesh.material,
17657
+ version: piece3.mesh.geometry.attributes.position.version,
17658
+ local: piece3.local,
17659
+ world: piece3.mesh.matrixWorld.clone(),
17660
+ mask: piece3.mesh.layers.mask,
17661
+ castShadow: piece3.mesh.castShadow,
17662
17662
  batch,
17663
17663
  start: indexOffset,
17664
- count: piece2.indexCount,
17664
+ count: piece3.indexCount,
17665
17665
  released: false
17666
17666
  });
17667
- if (shadowOnly) piece2.mesh.castShadow = false;
17668
- else piece2.mesh.layers.set(BATCHED_LAYER);
17669
- vertexOffset += piece2.vertices;
17670
- indexOffset += piece2.indexCount;
17667
+ if (shadowOnly) piece3.mesh.castShadow = false;
17668
+ else piece3.mesh.layers.set(BATCHED_LAYER);
17669
+ vertexOffset += piece3.vertices;
17670
+ indexOffset += piece3.indexCount;
17671
17671
  }
17672
17672
  return sources;
17673
17673
  }
@@ -18128,11 +18128,11 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
18128
18128
  }
18129
18129
  for (let i = 0; i < segments; i++) {
18130
18130
  for (let j = 0; j < points.length - 1; j++) {
18131
- const base = j + i * points.length;
18132
- const a = base;
18133
- const b = base + points.length;
18134
- const c = base + points.length + 1;
18135
- const d = base + 1;
18131
+ const base2 = j + i * points.length;
18132
+ const a = base2;
18133
+ const b = base2 + points.length;
18134
+ const c = base2 + points.length + 1;
18135
+ const d = base2 + 1;
18136
18136
  indices.push(a, b, d);
18137
18137
  indices.push(c, d, b);
18138
18138
  }
@@ -18197,13 +18197,13 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
18197
18197
  const uvs = [];
18198
18198
  const indices = [];
18199
18199
  const quad = (corners, normal, uv) => {
18200
- const base = positions2.length / 3;
18200
+ const base2 = positions2.length / 3;
18201
18201
  for (let k = 0; k < 4; k++) {
18202
18202
  positions2.push(...corners[k]);
18203
18203
  normals.push(...normal);
18204
18204
  uvs.push(...uv[k]);
18205
18205
  }
18206
- indices.push(base, base + 1, base + 2, base, base + 2, base + 3);
18206
+ indices.push(base2, base2 + 1, base2 + 2, base2, base2 + 2, base2 + 3);
18207
18207
  };
18208
18208
  const fu = (x) => (x + hw) / w;
18209
18209
  const fv = (y) => (y + hh) / h;
@@ -19122,26 +19122,26 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
19122
19122
  };
19123
19123
  function mergeTransformed(pieces) {
19124
19124
  let total = 0;
19125
- for (const piece2 of pieces) total += piece2.indices ? piece2.indices.length : piece2.positions.length / 3;
19125
+ for (const piece3 of pieces) total += piece3.indices ? piece3.indices.length : piece3.positions.length / 3;
19126
19126
  const positions2 = new Float32Array(total * 3);
19127
19127
  const normals = new Float32Array(total * 3);
19128
19128
  const uvs = new Float32Array(total * 2);
19129
19129
  let at4 = 0;
19130
- for (const piece2 of pieces) {
19131
- const e = piece2.matrix;
19130
+ for (const piece3 of pieces) {
19131
+ const e = piece3.matrix;
19132
19132
  const nm = normalMatrix(e);
19133
- const count = piece2.indices ? piece2.indices.length : piece2.positions.length / 3;
19133
+ const count = piece3.indices ? piece3.indices.length : piece3.positions.length / 3;
19134
19134
  const p = new Float32Array(count * 3);
19135
19135
  const n = new Float32Array(count * 3);
19136
19136
  for (let k = 0; k < count; k++) {
19137
- const i = piece2.indices ? piece2.indices[k] : k;
19137
+ const i = piece3.indices ? piece3.indices[k] : k;
19138
19138
  for (let c = 0; c < 3; c++) {
19139
- p[k * 3 + c] = piece2.positions[i * 3 + c];
19140
- if (piece2.normals) n[k * 3 + c] = piece2.normals[i * 3 + c];
19139
+ p[k * 3 + c] = piece3.positions[i * 3 + c];
19140
+ if (piece3.normals) n[k * 3 + c] = piece3.normals[i * 3 + c];
19141
19141
  }
19142
- if (piece2.uvs) {
19143
- uvs[(at4 + k) * 2] = piece2.uvs[i * 2];
19144
- uvs[(at4 + k) * 2 + 1] = piece2.uvs[i * 2 + 1];
19142
+ if (piece3.uvs) {
19143
+ uvs[(at4 + k) * 2] = piece3.uvs[i * 2];
19144
+ uvs[(at4 + k) * 2 + 1] = piece3.uvs[i * 2 + 1];
19145
19145
  }
19146
19146
  }
19147
19147
  for (let k = 0; k < count; k++) {
@@ -19982,7 +19982,7 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
19982
19982
  T("open_door", true, 0.9, 0.15, 2.15, 0, false, "house_state")
19983
19983
  ];
19984
19984
  var DEFS = Object.fromEntries(TYPE_DEFS.map((t) => [t.id, t]));
19985
- var MATERIALS = ["plain", "metal", "wood", "glass", "fabric", "plant", "water", "emissive", "atlas_picture", "atlas_floor"];
19985
+ var MATERIALS = ["plain", "metal", "wood", "glass", "fabric", "foam", "plant", "water", "emissive", "atlas_picture", "atlas_floor"];
19986
19986
  function ceilingBuilders({ kit }) {
19987
19987
  const B = {};
19988
19988
  B.ceiling_light = (M, a) => {
@@ -21204,14 +21204,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21204
21204
  const uvs = [];
21205
21205
  const indices = [];
21206
21206
  for (const side of [1, -1]) {
21207
- const base = positions2.length / 3;
21207
+ const base2 = positions2.length / 3;
21208
21208
  for (let i = 0; i < 4; i++) {
21209
21209
  positions2.push(f[i * 3], f[i * 3 + 1], f[i * 3 + 2]);
21210
21210
  normals.push(0, 0, side);
21211
21211
  uvs.push(f[i * 3] + 0.5, f[i * 3 + 1]);
21212
21212
  }
21213
- if (side === 1) indices.push(base, base + 2, base + 1, base + 1, base + 2, base + 3);
21214
- else indices.push(base, base + 1, base + 2, base + 1, base + 3, base + 2);
21213
+ if (side === 1) indices.push(base2, base2 + 2, base2 + 1, base2 + 1, base2 + 2, base2 + 3);
21214
+ else indices.push(base2, base2 + 1, base2 + 2, base2 + 1, base2 + 3, base2 + 2);
21215
21215
  }
21216
21216
  return { positions: positions2, normals, uvs, indices };
21217
21217
  })();
@@ -21889,33 +21889,6 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21889
21889
  return out;
21890
21890
  };
21891
21891
  var granules = (inp, box5, count) => bsp(box5, 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] }));
21892
- var SLAB_MIN = 0.03;
21893
- var splitAtHit = (root, hit, axes, count, rnd2) => {
21894
- let pieces = [root];
21895
- for (const ax of axes) {
21896
- const half = root.s[ax] / 2;
21897
- if (hit[ax] - -half < SLAB_MIN || half - hit[ax] < SLAB_MIN) continue;
21898
- const next = [];
21899
- for (const b of pieces) {
21900
- const lo = b.c[ax] - b.s[ax] / 2;
21901
- const hi = b.c[ax] + b.s[ax] / 2;
21902
- for (const [from, to] of [[lo, hit[ax]], [hit[ax], hi]]) {
21903
- const c = [b.c[0], b.c[1], b.c[2]];
21904
- const s = [b.s[0], b.s[1], b.s[2]];
21905
- c[ax] = (from + to) / 2;
21906
- s[ax] = to - from;
21907
- next.push({ c, s });
21908
- }
21909
- }
21910
- pieces = next;
21911
- }
21912
- while (pieces.length < count) {
21913
- pieces.sort((a, b) => b.s[axes[0]] * b.s[axes[1]] - a.s[axes[0]] * a.s[axes[1]]);
21914
- const [big, ...rest2] = pieces;
21915
- pieces = [...bsp(big, 2, axes, rnd2), ...rest2];
21916
- }
21917
- return pieces;
21918
- };
21919
21892
  var CRUMBS = 6;
21920
21893
  var severAt = (inp, root, at4, gap) => {
21921
21894
  const dims = root.s;
@@ -21963,8 +21936,72 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21963
21936
  }
21964
21937
  return out;
21965
21938
  };
21939
+ var radialPlates = (inp, root, axes, n, th, cap, fit = false) => {
21940
+ const { rnd: rnd2, maxFragments } = inp;
21941
+ const { t, u, v } = axes;
21942
+ const dims = root.s;
21943
+ const out = [];
21944
+ const Hu = dims[u] / 2, Hv = dims[v] / 2;
21945
+ const hu = clamp(inp.hit[u] - root.c[u], -Hu * 0.95, Hu * 0.95);
21946
+ const hv = clamp(inp.hit[v] - root.c[v], -Hv * 0.95, Hv * 0.95);
21947
+ const R = Math.max(Math.hypot(Hu + Math.abs(hu), Hv + Math.abs(hv)), 0.02);
21948
+ const sectors = clamp(Math.round(Math.sqrt(n * 1.6)), Math.min(5, n), 10);
21949
+ const rings = Math.max(1, Math.ceil(n / sectors));
21950
+ const radii = [];
21951
+ for (let k = 0; k <= rings; k++) radii.push(R * Math.pow(k / rings, 1.3));
21952
+ for (let j = 0; j < sectors && out.length < maxFragments; j++) {
21953
+ const theta = (j + (rnd2() - 0.5) * 0.4) * (Math.PI * 2 / sectors);
21954
+ for (let k = 0; k < rings && out.length < maxFragments; k++) {
21955
+ const rm = (radii[k] + radii[k + 1]) / 2;
21956
+ const cu = hu + rm * Math.cos(theta);
21957
+ const cv = hv + rm * Math.sin(theta);
21958
+ if (Math.abs(cu) > Hu + 0.01 || Math.abs(cv) > Hv + 0.01) continue;
21959
+ const radial = clamp(radii[k + 1] - radii[k], 0.01, cap);
21960
+ const tang = clamp(radii[k + 1] * (Math.PI * 2 / sectors) * 0.9, 0.01, cap);
21961
+ const c = [root.c[0], root.c[1], root.c[2]];
21962
+ c[u] = root.c[u] + clamp(cu, -Hu * 0.98, Hu * 0.98);
21963
+ c[v] = root.c[v] + clamp(cv, -Hv * 0.98, Hv * 0.98);
21964
+ const shrink = fit ? fitInside(radial, tang, theta, Hu, Hv) : 1;
21965
+ if (fit) {
21966
+ const reach2 = reachOf(radial * shrink, tang * shrink, theta);
21967
+ c[u] = root.c[u] + clamp(c[u] - root.c[u], -(Hu - reach2[0]), Hu - reach2[0]);
21968
+ c[v] = root.c[v] + clamp(c[v] - root.c[v], -(Hv - reach2[1]), Hv - reach2[1]);
21969
+ }
21970
+ out.push({ center: c, size: [radial * shrink, tang * shrink, th], q: frame(u, v, t, theta), shape: "shard", weight: radial * tang * shrink * shrink });
21971
+ }
21972
+ }
21973
+ 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 });
21974
+ return out;
21975
+ };
21976
+ var reachOf = (radial, tang, theta) => {
21977
+ const cos2 = Math.abs(Math.cos(theta)), sin2 = Math.abs(Math.sin(theta));
21978
+ return [(cos2 * radial + sin2 * tang) / 2, (sin2 * radial + cos2 * tang) / 2];
21979
+ };
21980
+ var fitInside = (radial, tang, theta, halfU, halfV) => {
21981
+ const [reachU, reachV] = reachOf(radial, tang, theta);
21982
+ return Math.min(halfU / Math.max(reachU, 1e-9), halfV / Math.max(reachV, 1e-9), 1);
21983
+ };
21966
21984
  var STACK_LAYER = 0.012;
21985
+ var SOLID_VOLUME_MIN = 1e-6;
21967
21986
  var planFragments = (inp) => {
21987
+ const solids2 = inp.solids;
21988
+ if (!solids2 || solids2.length < 2) return planBox(inp);
21989
+ const volumes = solids2.map((solid2) => Math.max(SOLID_VOLUME_MIN, solid2.size[0] * solid2.size[1] * solid2.size[2]));
21990
+ const total = volumes.reduce((sum2, volume) => sum2 + volume, 0);
21991
+ const out = [];
21992
+ solids2.forEach((solid2, i) => {
21993
+ const share = Math.max(1, Math.round(inp.maxFragments * volumes[i] / total));
21994
+ const hit = [inp.hit[0] - solid2.center[0], inp.hit[1] - solid2.center[1], inp.hit[2] - solid2.center[2]];
21995
+ const { cut, solids: _all, ...rest2 } = inp;
21996
+ const along2 = cut ? [0, 1, 2].sort((a, b) => solid2.size[b] - solid2.size[a])[0] : -1;
21997
+ const inside3 = cut && Math.abs(cut.at - solid2.center[along2]) < solid2.size[along2] / 2 ? { cut: { at: cut.at - solid2.center[along2], gap: cut.gap } } : {};
21998
+ for (const f of planBox({ ...rest2, ...inside3, dims: [solid2.size[0], solid2.size[1], solid2.size[2]], hit, maxFragments: share, thickness: Math.min(inp.thickness, Math.min(...solid2.size)) })) {
21999
+ out.push({ ...f, center: [f.center[0] + solid2.center[0], f.center[1] + solid2.center[1], f.center[2] + solid2.center[2]] });
22000
+ }
22001
+ });
22002
+ return out;
22003
+ };
22004
+ var planBox = (inp) => {
21968
22005
  const { style, dims, rnd: rnd2, maxFragments } = inp;
21969
22006
  const [fmin, fmax] = inp.fragmentSize;
21970
22007
  const mean = (fmin + fmax) / 2;
@@ -21977,9 +22014,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21977
22014
  if (style === "snap") {
21978
22015
  if (inp.cut) return severAt(inp, root, inp.cut.at, inp.cut.gap);
21979
22016
  if (inp.form === "plies") return plyBreak(inp, root, maxFragments);
21980
- const n2 = Math.min(maxFragments, 2 + Math.floor(rnd2() * 3));
21981
- const slabs = inp.form === "granules" && dims[t] < Math.min(dims[u], dims[v]) / 4 ? splitAtHit(root, inp.hit, [u, v], n2, rnd2) : bsp(root, n2, [0, 1, 2], rnd2);
21982
- 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] });
22017
+ const thinBoard = dims[t] < Math.min(dims[u], dims[v]) / 4;
22018
+ if (thinBoard && inp.form !== "slivers") {
22019
+ const crumbled = inp.form === "granules" ? CRUMBS : 0;
22020
+ const plates = clamp(Math.round(dims[u] * dims[v] / (mean * mean)), 6, Math.max(6, maxFragments - crumbled));
22021
+ 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] });
22022
+ } else {
22023
+ const n2 = Math.min(maxFragments, 2 + Math.floor(rnd2() * 3));
22024
+ for (const b of bsp(root, n2, [0, 1, 2], rnd2)) out.push({ center: b.c, size: b.s, q: idq, shape: "slab", weight: b.s[0] * b.s[1] * b.s[2] });
22025
+ }
21983
22026
  if (inp.form !== "granules") return out;
21984
22027
  const crumbs = Math.min(CRUMBS, maxFragments - out.length);
21985
22028
  if (crumbs <= 0) return out;
@@ -22002,44 +22045,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
22002
22045
  return out;
22003
22046
  }
22004
22047
  if (style === "tear") {
22048
+ if (inp.form === "granules") return granules(inp, root, clamp(Math.ceil(dims[0] * dims[1] * dims[2] / (mean * mean * mean)), 3, maxFragments));
22005
22049
  const n2 = clamp(Math.round(dims[u] * dims[v] / (mean * mean)), 3, maxFragments);
22006
22050
  const sheet = inp.sheet ?? 0;
22007
22051
  if (sheet > 0 && dims[t] > sheet * 4) return tearStack(inp, root, t, u, v, n2, sheet);
22008
- const th2 = Math.min(inp.thickness, dims[t]);
22052
+ const th = Math.min(inp.thickness, dims[t]);
22009
22053
  for (const b of bsp(root, n2, [u, v], rnd2)) {
22010
- 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] });
22054
+ 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] });
22011
22055
  }
22012
22056
  return out;
22013
22057
  }
22014
- const th = Math.min(inp.thickness, dims[t]);
22015
- const Hu = dims[u] / 2, Hv = dims[v] / 2;
22016
- const hu = clamp(inp.hit[u], -Hu * 0.95, Hu * 0.95);
22017
- const hv = clamp(inp.hit[v], -Hv * 0.95, Hv * 0.95);
22018
- const R = Math.max(Math.hypot(Hu + Math.abs(hu), Hv + Math.abs(hv)), 0.02);
22019
22058
  const n = clamp(Math.round(dims[u] * dims[v] / (mean * mean)), 6, maxFragments);
22020
- const sectors = clamp(Math.round(Math.sqrt(n * 1.6)), 5, 10);
22021
- const rings = Math.max(1, Math.ceil(n / sectors));
22022
- const radii = [];
22023
- for (let k = 0; k <= rings; k++) radii.push(R * Math.pow(k / rings, 1.3));
22024
- const cap = fmax * 1.5;
22025
- for (let j = 0; j < sectors && out.length < maxFragments; j++) {
22026
- const theta = (j + (rnd2() - 0.5) * 0.4) * (Math.PI * 2 / sectors);
22027
- for (let k = 0; k < rings && out.length < maxFragments; k++) {
22028
- const rm = (radii[k] + radii[k + 1]) / 2;
22029
- const cu = hu + rm * Math.cos(theta);
22030
- const cv = hv + rm * Math.sin(theta);
22031
- if (Math.abs(cu) > Hu + 0.01 || Math.abs(cv) > Hv + 0.01) continue;
22032
- const radial = clamp(radii[k + 1] - radii[k], 0.01, cap);
22033
- const tang = clamp(radii[k + 1] * (Math.PI * 2 / sectors) * 0.9, 0.01, cap);
22034
- const c = [0, 0, 0];
22035
- c[u] = clamp(cu, -Hu * 0.98, Hu * 0.98);
22036
- c[v] = clamp(cv, -Hv * 0.98, Hv * 0.98);
22037
- c[t] = 0;
22038
- out.push({ center: c, size: [radial, tang, th], q: frame(u, v, t, theta), shape: "shard", weight: radial * tang });
22039
- }
22040
- }
22041
- 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 });
22042
- return out;
22059
+ return radialPlates(inp, root, { t, u, v }, n, Math.min(inp.thickness, dims[t]), fmax * 1.5);
22043
22060
  };
22044
22061
  var planeAxes = (thin) => thin === 1 ? [0, 2] : [thin === 0 ? 2 : 0, 1];
22045
22062
  var unitGrid = (dims, thin, units, cap) => {
@@ -22330,7 +22347,27 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
22330
22347
  var MAX_SPALLS = 64;
22331
22348
  var thinAxisOf = (dims) => dims[0] <= dims[1] && dims[0] <= dims[2] ? 0 : dims[1] <= dims[2] ? 1 : 2;
22332
22349
  var resolveLayer = (def, index, mat) => ({ index, def, mat, energy: mat.penetration * def.thickness * 1e3 });
22333
- var onFace = (layer3, face) => layer3.def.faces === "both" || layer3.def.faces === (face > 0 ? "+" : "-");
22350
+ var faceCode = (thin, axis2, sign2) => {
22351
+ const [u] = planeAxes(thin);
22352
+ return (sign2 >= 0 ? 1 : -1) * (axis2 === thin ? 1 : axis2 === u ? 2 : 3);
22353
+ };
22354
+ var faceAxis = (thin, face) => {
22355
+ const k = Math.abs(face);
22356
+ return k === 1 ? thin : planeAxes(thin)[k - 2];
22357
+ };
22358
+ var faceOfNormal = (layers, thin, localNormal) => {
22359
+ if (!layers.some((l) => l.def.faces === "all")) return localNormal[thin] >= 0 ? 1 : -1;
22360
+ let axis2 = thin;
22361
+ for (let k = 0; k < 3; k++) if (Math.abs(localNormal[k]) > Math.abs(localNormal[axis2])) axis2 = k;
22362
+ return faceCode(thin, axis2, localNormal[axis2]);
22363
+ };
22364
+ var onFace = (layer3, face) => {
22365
+ const faces = layer3.def.faces;
22366
+ if (faces === "all") return true;
22367
+ if (Math.abs(face) !== 1) return false;
22368
+ return faces === "both" || faces === (face > 0 ? "+" : "-");
22369
+ };
22370
+ var thinSidesOf = (def) => def.faces === "both" || def.faces === "all" ? [1, -1] : [def.faces === "+" ? 1 : -1];
22334
22371
  var isSpalled = (spalls, layer3, face, point) => {
22335
22372
  for (const s of spalls ?? []) {
22336
22373
  if (s[0] !== layer3 || s[1] !== face) continue;
@@ -22350,6 +22387,23 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
22350
22387
  for (const l of layers) if (onFace(l, face)) sum2 += l.def.thickness;
22351
22388
  return sum2;
22352
22389
  };
22390
+ var tornPatchAt = (layers, spalls, face, point, radius) => {
22391
+ for (const l of layers) {
22392
+ if (!onFace(l, face)) continue;
22393
+ if (l.mat.fracture === "tear") {
22394
+ let best = -1;
22395
+ (spalls ?? []).forEach((s, i) => {
22396
+ if (s[0] !== l.index || s[1] !== face) return;
22397
+ const dx = s[2] - point[0], dy = s[3] - point[1], dz = s[4] - point[2];
22398
+ const reach2 = s[5] + radius;
22399
+ if (dx * dx + dy * dy + dz * dz <= reach2 * reach2 && (best < 0 || s[5] > spalls[best][5])) best = i;
22400
+ });
22401
+ if (best >= 0) return { layer: l, spall: best };
22402
+ }
22403
+ if (!isSpalled(spalls, l.index, face, point)) return void 0;
22404
+ }
22405
+ return void 0;
22406
+ };
22353
22407
  var REBAR_COVER = 0.03;
22354
22408
  var COVER = REBAR_COVER;
22355
22409
  var MAX_BARS_PER_DIRECTION = 24;
@@ -23310,8 +23364,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23310
23364
  beams += cos2 * cos2 * q.elasticPa * c.beamFactor * inertia / Math.max(long, 1e-6);
23311
23365
  }
23312
23366
  const k = beams / kc;
23313
- const base = p.min[1] - ground < 0.05;
23314
- const a = base ? (0.5 + k) / (2 + k) : k / (2 + k);
23367
+ const base2 = p.min[1] - ground < 0.05;
23368
+ const a = base2 ? (0.5 + k) / (2 + k) : k / (2 + k);
23315
23369
  const stiffness = a * 12 * (p.elasticPa * c.stiffnessFactor) * (g[i].du ** 3 * g[i].dv / 12) / (h * h);
23316
23370
  for (let j = 0; j < n; j++) ga[j] += stiffness * share(p, j) / bands[j];
23317
23371
  }
@@ -23496,7 +23550,49 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23496
23550
  elasticGPa: 200,
23497
23551
  absorbed: 0.2
23498
23552
  },
23499
- failureMPa: 250
23553
+ failureMPa: 250,
23554
+ tension: {
23555
+ elasticGPa: 200,
23556
+ ultimateMPa: 400
23557
+ }
23558
+ },
23559
+ {
23560
+ id: "spring_steel",
23561
+ density: 7850,
23562
+ hpPerKg: 900,
23563
+ penetration: 110,
23564
+ penetrationClass: "steel",
23565
+ penetrationScale: 1.3,
23566
+ ductility: 0.95,
23567
+ fracture: "none",
23568
+ damageScale: {
23569
+ slash: 0.1,
23570
+ blunt: 0.8
23571
+ },
23572
+ hitDebris: "sparks",
23573
+ breakDebris: "sparks",
23574
+ ricochetDeg: 20,
23575
+ thermal: {
23576
+ meltC: 1450,
23577
+ meltRate: 0.05,
23578
+ conductivity: 0.5,
23579
+ heatCapacity: 3
23580
+ },
23581
+ visual: {
23582
+ glows: true
23583
+ },
23584
+ tags: [
23585
+ "metal",
23586
+ "conductive",
23587
+ "spring"
23588
+ ],
23589
+ compressive: 2e6,
23590
+ bending: {
23591
+ yieldMPa: 1200,
23592
+ elasticGPa: 200,
23593
+ absorbed: 0.2
23594
+ },
23595
+ failureMPa: 1400
23500
23596
  },
23501
23597
  {
23502
23598
  id: "cast_iron",
@@ -23563,7 +23659,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23563
23659
  "conductive"
23564
23660
  ],
23565
23661
  compressive: 8e5,
23566
- failureMPa: 90
23662
+ failureMPa: 90,
23663
+ tension: {
23664
+ elasticGPa: 69,
23665
+ ultimateMPa: 170
23666
+ }
23567
23667
  },
23568
23668
  {
23569
23669
  id: "copper",
@@ -23594,7 +23694,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23594
23694
  "conductive"
23595
23695
  ],
23596
23696
  compressive: 1e6,
23597
- failureMPa: 70
23697
+ failureMPa: 70,
23698
+ tension: {
23699
+ elasticGPa: 117,
23700
+ ultimateMPa: 250
23701
+ }
23598
23702
  },
23599
23703
  {
23600
23704
  id: "wood_soft",
@@ -24135,7 +24239,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24135
24239
  "flammable"
24136
24240
  ],
24137
24241
  compressive: 500,
24138
- failureMPa: 20
24242
+ failureMPa: 20,
24243
+ hits: {
24244
+ slash: {
24245
+ tear: "strips",
24246
+ tearJoules: 30
24247
+ },
24248
+ blunt: {
24249
+ tear: "strips",
24250
+ tearJoules: 150
24251
+ }
24252
+ }
24139
24253
  },
24140
24254
  {
24141
24255
  id: "foam",
@@ -24143,7 +24257,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24143
24257
  hpPerKg: 15,
24144
24258
  penetration: 0.5,
24145
24259
  ductility: 0.7,
24260
+ cellular: true,
24146
24261
  fracture: "tear",
24262
+ splitForm: "granules",
24147
24263
  fragmentSize: [
24148
24264
  0.03,
24149
24265
  0.15
@@ -24161,16 +24277,29 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24161
24277
  burnRate: 0.09,
24162
24278
  conductivity: 0.02,
24163
24279
  heatCapacity: 0.5,
24164
- smoke: "black"
24280
+ smoke: "black",
24281
+ meltC: 200,
24282
+ meltRate: 0.08
24165
24283
  },
24166
24284
  visual: {
24167
- charColor: 855309
24285
+ charColor: 855309,
24286
+ innerColor: 15254346
24168
24287
  },
24169
24288
  tags: [
24170
24289
  "fabric",
24171
24290
  "flammable"
24172
24291
  ],
24173
- compressive: 100
24292
+ compressive: 100,
24293
+ hits: {
24294
+ ballistic: {
24295
+ tear: "lumps",
24296
+ tearJoules: 250
24297
+ },
24298
+ slash: {
24299
+ tear: "lumps",
24300
+ tearJoules: 60
24301
+ }
24302
+ }
24174
24303
  },
24175
24304
  {
24176
24305
  id: "leather",
@@ -24960,19 +25089,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24960
25089
  };
24961
25090
  var placedPieces = /* @__PURE__ */ new WeakMap();
24962
25091
  var isSamePose = ({ known, position, rotation: rotation2 }) => known.position[0] === position[0] && known.position[1] === position[1] && known.position[2] === position[2] && known.rotation[0] === rotation2[0] && known.rotation[1] === rotation2[1] && known.rotation[2] === rotation2[2] && known.rotation[3] === rotation2[3];
24963
- var hostedPieces = (pieces, pose2) => pieces.map((piece2, index) => {
24964
- const known = placedPieces.get(piece2);
25092
+ var hostedPieces = (pieces, pose2) => pieces.map((piece3, index) => {
25093
+ const known = placedPieces.get(piece3);
24965
25094
  const p = pose2.position, q = pose2.rotation;
24966
- const isSamePlace = known !== void 0 && (piece2.key !== void 0 || known.index === index) && isSamePose({ known, position: p, rotation: q });
25095
+ const isSamePlace = known !== void 0 && (piece3.key !== void 0 || known.index === index) && isSamePose({ known, position: p, rotation: q });
24967
25096
  if (known && isSamePlace) return known.solid;
24968
- const solid2 = placedPiece(piece2, index, pose2);
24969
- placedPieces.set(piece2, { position: [p[0], p[1], p[2]], rotation: [q[0], q[1], q[2], q[3]], index, solid: solid2 });
25097
+ const solid2 = placedPiece(piece3, index, pose2);
25098
+ placedPieces.set(piece3, { position: [p[0], p[1], p[2]], rotation: [q[0], q[1], q[2], q[3]], index, solid: solid2 });
24970
25099
  return solid2;
24971
25100
  });
24972
- var placedPiece = (piece2, index, pose2) => {
24973
- const base = { center: toWorld(pose2.position, pose2.rotation, piece2.center), half: piece2.half, rotation: quat.mul(pose2.rotation, piece2.rotation), key: piece2.key ?? `${piece2.id}:${index}` };
24974
- if (!piece2.mesh) return base;
24975
- const source = piece2.mesh.vertices;
25101
+ var placedPiece = (piece3, index, pose2) => {
25102
+ const base2 = { center: toWorld(pose2.position, pose2.rotation, piece3.center), half: piece3.half, rotation: quat.mul(pose2.rotation, piece3.rotation), key: piece3.key ?? `${piece3.id}:${index}` };
25103
+ if (!piece3.mesh) return base2;
25104
+ const source = piece3.mesh.vertices;
24976
25105
  const vertices = new Float32Array(source.length);
24977
25106
  for (let i = 0; i < source.length; i += 3) {
24978
25107
  const world = toWorld(pose2.position, pose2.rotation, [source[i], source[i + 1], source[i + 2]]);
@@ -24980,9 +25109,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24980
25109
  vertices[i + 1] = world[1];
24981
25110
  vertices[i + 2] = world[2];
24982
25111
  }
24983
- return { ...base, mesh: { vertices, indices: piece2.mesh.indices } };
25112
+ return { ...base2, mesh: { vertices, indices: piece3.mesh.indices } };
24984
25113
  };
24985
25114
  var THIN_SHEET_DISHING = 5e-3;
25115
+ var SHELL_YIELD_SHARE = 0.5;
25116
+ var STEEL_YIELD_MPA = 250;
24986
25117
  var SWEEP_BACK = 0.01;
24987
25118
  function sweepOrigins(box5, d, spacing) {
24988
25119
  const origins = [];
@@ -25041,13 +25172,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
25041
25172
  var MEMBER_CRATER_CALIBRES = 3.4;
25042
25173
  var MEMBER_CUT_LOSS = 0.9;
25043
25174
  var MEMBER_UNIT_LOSS = 0.12;
25175
+ var CHIP_PROBE_DEPTH = 1e-4;
25044
25176
  var JOINT_OPEN_SHARE = 0.6;
25045
25177
  var BLAST_EDGE_WEAR = 0.6;
25046
25178
  var RESIDUAL_CAPACITY = 0.15;
25047
25179
  var SEVER_BAND = 0.1;
25180
+ var SURFACE_SLACK = 0.01;
25181
+ var SURFACE_SAME = 5e-4;
25048
25182
  var SEVER_ASPECT = 3;
25049
25183
  var SEVER_BALLISTIC = 2;
25050
25184
  var TEAR_JOULES = 150;
25185
+ var STRIP_THICKNESS = 15e-4;
25051
25186
  var tears = 0;
25052
25187
  var UNIT_FRAGMENT_FACTOR = 4;
25053
25188
  var BREACH_GRID_CAP = 4096;
@@ -25252,7 +25387,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
25252
25387
  if (typed) for (const fn of typed) fn(e);
25253
25388
  };
25254
25389
  let blow3;
25255
- const base = (o, source) => ({
25390
+ const base2 = (o, source) => ({
25256
25391
  object: o.id,
25257
25392
  time,
25258
25393
  ...source === void 0 ? {} : { source },
@@ -26140,7 +26275,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
26140
26275
  w.emitted = { t: time, peak: d.peak, status: st.status };
26141
26276
  const dir = windDirection(o, w.cfg);
26142
26277
  const world2 = rotateVec(o.base.rot, [dir[0], 0, dir[1]]);
26143
- emit2({ ...base(o), type: "sway", sway: d.x, peak: d.peak, drift: st.drift, overturn: st.overturn, frequency: st.frequency, direction: world2, status: st.status });
26278
+ emit2({ ...base2(o), type: "sway", sway: d.x, peak: d.peak, drift: st.drift, overturn: st.overturn, frequency: st.frequency, direction: world2, status: st.status });
26144
26279
  }
26145
26280
  };
26146
26281
  const isTerrain = (p) => !!p.spec.tags?.includes("terrain");
@@ -26348,7 +26483,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
26348
26483
  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);
26349
26484
  if (changed) {
26350
26485
  so.emitted = { t: time, s: st.settlement, tilt: st.tilt, status: st.status };
26351
- emit2({ ...base(o), type: "settle", settlement: st.settlement, tilt: st.tilt, direction: rotateVec(o.base.rot, st.direction), bearing: st.bearing, status: st.status });
26486
+ emit2({ ...base2(o), type: "settle", settlement: st.settlement, tilt: st.tilt, direction: rotateVec(o.base.rot, st.direction), bearing: st.bearing, status: st.status });
26352
26487
  }
26353
26488
  if (st.status === "toppled") topple(o);
26354
26489
  };
@@ -26397,7 +26532,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
26397
26532
  p.st.status = "broken";
26398
26533
  p.st.hp = 0;
26399
26534
  p.st.mass = 0;
26400
- emit2({ ...base(o, src), type: "fracture", part: p.spec.id, style: "crumble", fragments, point: c });
26535
+ emit2({ ...base2(o, src), type: "fracture", part: p.spec.id, style: "crumble", fragments, point: c });
26401
26536
  debris2(o, p, p.mat.breakDebris, c, [0, 1, 0], clamp2(Math.round(Math.cbrt(partVolume(p.spec.shape)) * 30), 3, 20), 2, src);
26402
26537
  setStage(o, p, 3, {}, src);
26403
26538
  partLost(o, p, src);
@@ -26419,7 +26554,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
26419
26554
  markHostedDirty(o, p.spec.id);
26420
26555
  setStage(o, p, 3, {}, src);
26421
26556
  }
26422
- if (whole2.length > 0) emit2({ ...base(o, src), type: "collapse", parts: whole2.map((p) => p.spec.id), mass: whole2.reduce((sum2, p) => sum2 + p.st.mass, 0) });
26557
+ if (whole2.length > 0) emit2({ ...base2(o, src), type: "collapse", parts: whole2.map((p) => p.spec.id), mass: whole2.reduce((sum2, p) => sum2 + p.st.mass, 0) });
26423
26558
  }
26424
26559
  for (const p of crumbling) crumbleMasonry(o, p, src);
26425
26560
  }
@@ -26740,7 +26875,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
26740
26875
  r.st.subsidence = Math.max(r.st.subsidence ?? 0, drop.reduce((sum2, v) => sum2 + v, 0) / count);
26741
26876
  const middle = [from[0], from[1], from[2]];
26742
26877
  middle[axis2] = (stretch[0] + stretch[1]) / 2;
26743
- emit2({ ...base(o, src), type: "subside", part: r.spec.id, drop: r.st.subsidence, share: (stretch[1] - stretch[0]) / Math.max(1e-6, box5.max[axis2] - box5.min[axis2]), point: toWorld(o.st.position, o.st.rotation, middle), status: "opened" });
26878
+ emit2({ ...base2(o, src), type: "subside", part: r.spec.id, drop: r.st.subsidence, share: (stretch[1] - stretch[0]) / Math.max(1e-6, box5.max[axis2] - box5.min[axis2]), point: toWorld(o.st.position, o.st.rotation, middle), status: "opened" });
26744
26879
  let lost = false;
26745
26880
  for (const j of [...o.byPart.get(r.spec.id) ?? []]) {
26746
26881
  settleStructure(o);
@@ -26780,7 +26915,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
26780
26915
  if (p.staged) {
26781
26916
  setStage(o, p, 1, {}, src);
26782
26917
  setStage(o, p, 2, { opening: { center: worldCenter, radius: hole.radius }, fragments }, src);
26783
- } else emit2({ ...base(o, src), type: "stage", part: p.spec.id, stage: 2, opening: { center: worldCenter, radius: hole.radius }, fragments });
26918
+ } else emit2({ ...base2(o, src), type: "stage", part: p.spec.id, stage: 2, opening: { center: worldCenter, radius: hole.radius }, fragments });
26784
26919
  debris2(o, p, p.mat.breakDebris, worldCenter, [0, 1, 0], 14, 2, src);
26785
26920
  if (p.spec.reinforcement) exposeRebar(o, p, src);
26786
26921
  };
@@ -26806,8 +26941,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
26806
26941
  const width = clamp2(beta * SETTLEMENT_CRACK_OPENING, MIN_CRACK_WIDTH, MAX_CRACK_WIDTH);
26807
26942
  const through = q.dims[q.thin];
26808
26943
  for (let c = 0; c < count; c++) {
26809
- const back = c * SETTLEMENT_CRACK_SPACING;
26810
- const local2 = [clamp2(at4[0] - toward2[0] / reach2 * back, box5.min[0], box5.max[0]), box5.min[1] + height * (0.2 + 0.12 * c), clamp2(at4[2] - toward2[2] / reach2 * back, box5.min[2], box5.max[2])];
26944
+ const back2 = c * SETTLEMENT_CRACK_SPACING;
26945
+ const local2 = [clamp2(at4[0] - toward2[0] / reach2 * back2, box5.min[0], box5.max[0]), box5.min[1] + height * (0.2 + 0.12 * c), clamp2(at4[2] - toward2[2] / reach2 * back2, box5.min[2], box5.max[2])];
26811
26946
  const face = toLocal(q.pos, q.q, local2);
26812
26947
  face[q.thin] = through / 2;
26813
26948
  addCrack(o, q, toWorld(o.st.position, o.st.rotation, toWorld(q.pos, q.q, face)), normal, length2, src, { along: along2, step, width, through });
@@ -26929,7 +27064,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
26929
27064
  }
26930
27065
  if (bearing2.status === "settled" && drop - before < SUBSIDE_MIN && peak() - peakBefore < SUBSIDE_MIN) continue;
26931
27066
  b.p.st.subsidence = drop;
26932
- emit2({ ...base(o, src), type: "subside", part: b.p.spec.id, drop, share: fp.share, point: fp.deepest, status: bearing2.status });
27067
+ emit2({ ...base2(o, src), type: "subside", part: b.p.spec.id, drop, share: fp.share, point: fp.deepest, status: bearing2.status });
26933
27068
  }
26934
27069
  for (const { b, fp } of settled) {
26935
27070
  settleStructure(o);
@@ -27044,7 +27179,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27044
27179
  const known = implSolids.get(im);
27045
27180
  if (known && known.spec === spec && known.state === state && im.impl.collidersPending?.() !== true && sameImplPlace(known.key, im)) return known.solids;
27046
27181
  const pieces = im.impl.colliders?.();
27047
- if (pieces && known?.pieces && known.spec === spec && sameImplPlace(known.key, im) && pieces.length === known.pieces.length && pieces.every((piece2, i) => piece2 === known.pieces?.[i])) {
27182
+ if (pieces && known?.pieces && known.spec === spec && sameImplPlace(known.key, im) && pieces.length === known.pieces.length && pieces.every((piece3, i) => piece3 === known.pieces?.[i])) {
27048
27183
  implSolids.set(im, { ...known, state });
27049
27184
  return known.solids;
27050
27185
  }
@@ -27129,6 +27264,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27129
27264
  return fresh.map(([nid]) => nid);
27130
27265
  };
27131
27266
  let rayBroad = null;
27267
+ let surfaceTracer = null;
27132
27268
  let uncovered = [];
27133
27269
  let uncoveredFor = { hook: null, coverage: -1, objects: -1 };
27134
27270
  const metObjects = [];
@@ -27158,7 +27294,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27158
27294
  }
27159
27295
  return rayObjects;
27160
27296
  };
27161
- const raycastInternal = (origin, dir, maxDist, ignore, worldOnly = false, precise = false, skip = {}, scope2) => {
27297
+ const raycastInternal = (origin, dir, maxDist, ignore, worldOnly = false, precise = false, skip = {}, scope2, drawn = false, passed) => {
27162
27298
  const d = vec.normalize(dir);
27163
27299
  const asked = rayBroad && !scope2 && rayBroad.begin(origin, d, maxDist) ? rayBroad : null;
27164
27300
  const candidates = asked ? candidatesOf2(asked) : null;
@@ -27186,12 +27322,22 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27186
27322
  if (!r || r.t0 < 0 || r.t0 > maxDist) continue;
27187
27323
  if (p.st.opening && insideOpening(o, p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
27188
27324
  if (p.spec.apertures && throughAperture(p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
27189
- if (p.st.chipped && insideChip(p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
27325
+ if (p.st.chipped && insideChip(p, objLocal(o, vec.madd(origin, d, Math.min(r.t0 + CHIP_PROBE_DEPTH, (r.t0 + r.t1) / 2))))) {
27326
+ passed?.push({ o, p, t: r.t0 });
27327
+ continue;
27328
+ }
27190
27329
  const gap = p.st.chipped?.length ? pastChips(o, p, origin, d, r.t0, r.t1) : null;
27191
27330
  if (gap === "through") continue;
27192
27331
  if (gap) {
27193
27332
  r.t0 = gap.t;
27194
27333
  r.n = gap.n;
27334
+ } else if (drawn && surfaceTracer) {
27335
+ 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 });
27336
+ if (drawn2 === null) continue;
27337
+ if (drawn2 && drawn2.distance <= maxDist && Math.abs(drawn2.distance - r.t0) > SURFACE_SAME) {
27338
+ r.t0 = drawn2.distance;
27339
+ r.n = [drawn2.normal[0], drawn2.normal[1], drawn2.normal[2]];
27340
+ }
27195
27341
  }
27196
27342
  if (!best || r.t0 < best.distance) {
27197
27343
  const point = vec.madd(origin, d, r.t0);
@@ -27332,14 +27478,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27332
27478
  arr[ni].radius = Math.max(arr[ni].radius, radius);
27333
27479
  } else arr.push(dent);
27334
27480
  markDamaged(p);
27335
- emit2({ ...base(o, src), type: "dent", part: p.spec.id, dent, worldPoint: wp });
27481
+ emit2({ ...base2(o, src), type: "dent", part: p.spec.id, dent, worldPoint: wp });
27336
27482
  };
27337
27483
  const addHole = (o, p, wp, wn, diameter, through, exit, src) => {
27338
27484
  const hole = { point: objLocal(o, wp), normal: objLocalDir(o, wn), diameter, through };
27339
27485
  p.st.holes.push(hole);
27340
27486
  if (p.st.holes.length > maxHoles) p.st.holes.shift();
27341
27487
  markDamaged(p);
27342
- emit2({ ...base(o, src), type: "hole", part: p.spec.id, hole, worldPoint: wp, ...exit ? { exitPoint: exit } : {}, ...p.spec.powder ? { powder: { ...p.spec.powder } } : {} });
27488
+ emit2({ ...base2(o, src), type: "hole", part: p.spec.id, hole, worldPoint: wp, ...exit ? { exitPoint: exit } : {}, ...p.spec.powder ? { powder: { ...p.spec.powder } } : {} });
27343
27489
  setStage(o, p, 1, {}, src);
27344
27490
  return hole;
27345
27491
  };
@@ -27348,13 +27494,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27348
27494
  p.st.cracks.push(crack);
27349
27495
  if (p.st.cracks.length > 16) p.st.cracks.shift();
27350
27496
  markDamaged(p);
27351
- emit2({ ...base(o, src), type: "crack", part: p.spec.id, crack, worldPoint: wp });
27497
+ emit2({ ...base2(o, src), type: "crack", part: p.spec.id, crack, worldPoint: wp });
27352
27498
  setStage(o, p, 1, {}, src);
27353
27499
  };
27354
- const debris2 = (o, p, kind, point, normal, count, speed, src, material) => emit2({ ...base(o, src), type: "debris", part: p.spec.id, kind, point, normal, count, speed, ...material && material !== p.spec.material ? { material } : {} });
27500
+ const debris2 = (o, p, kind, point, normal, count, speed, src, material) => emit2({ ...base2(o, src), type: "debris", part: p.spec.id, kind, point, normal, count, speed, ...material && material !== p.spec.material ? { material } : {} });
27355
27501
  const holeRate = (hole, pressurized) => (pressurized ? 0.5 : 0.1) * (hole.diameter / 9e-3);
27356
27502
  const detachEvents = (o, opened, by, src) => {
27357
- for (const j of opened) emit2({ ...base(o, src), type: "detach", joint: j.spec.id, parts: [j.spec.a, j.spec.b], by, groups: o.st.groups.map((g) => [...g]) });
27503
+ for (const j of opened) emit2({ ...base2(o, src), type: "detach", joint: j.spec.id, parts: [j.spec.a, j.spec.b], by, groups: o.st.groups.map((g) => [...g]) });
27358
27504
  };
27359
27505
  const loosened = (o, opened, by, src) => {
27360
27506
  if (runDepth === 0) {
@@ -27433,7 +27579,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27433
27579
  const checkDestroyed = (o, src) => {
27434
27580
  if (!o.st.destroyed && o.parts.length > 0 && o.parts.every(isLost)) {
27435
27581
  o.st.destroyed = true;
27436
- emit2({ ...base(o, src), type: "destroyed" });
27582
+ emit2({ ...base2(o, src), type: "destroyed" });
27437
27583
  }
27438
27584
  };
27439
27585
  const holeReaches = (host, box5) => {
@@ -27473,7 +27619,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27473
27619
  } else {
27474
27620
  o.hostedHosts = new Set(o.hosted.map((p) => p.spec.hostedIn));
27475
27621
  }
27476
- for (const p of shown) emit2({ ...base(o), type: "reveal", part: p.spec.id, host: p.spec.hostedIn });
27622
+ for (const p of shown) emit2({ ...base2(o), type: "reveal", part: p.spec.id, host: p.spec.hostedIn });
27477
27623
  if (opened.length > 0) {
27478
27624
  loosened(o, opened, "break");
27479
27625
  collapseCheck(o);
@@ -27599,26 +27745,48 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27599
27745
  const setStage = (o, p, stage2, extra = {}, src) => {
27600
27746
  if (!p.staged || (p.st.stage ?? 0) >= stage2) return;
27601
27747
  p.st.stage = stage2;
27602
- emit2({ ...base(o, src), type: "stage", part: p.spec.id, stage: stage2, ...extra });
27748
+ emit2({ ...base2(o, src), type: "stage", part: p.spec.id, stage: stage2, ...extra });
27749
+ };
27750
+ const faceOf = (o, p, worldNormal) => faceOfNormal(p.layers, p.thin, rotateVec(quat.conjugate(partXf(o, p).q), worldNormal));
27751
+ const spallNormal = (o, p, face) => {
27752
+ if (Math.abs(face) === 1) return {};
27753
+ const local2 = [0, 0, 0];
27754
+ local2[faceAxis(p.thin, face)] = face > 0 ? 1 : -1;
27755
+ return { normal: rotateVec(partXf(o, p).q, local2) };
27756
+ };
27757
+ const widenTear = (o, p, torn, lp, normal, radius, src) => {
27758
+ const spalls = p.rt.spalls;
27759
+ const s = spalls[torn.spall];
27760
+ const axis2 = faceAxis(p.thin, s[1]);
27761
+ const faceArea = p.dims.reduce((area3, size, k) => k === axis2 ? area3 : area3 * size, 1);
27762
+ const reach2 = Math.hypot(lp[0] - s[2], lp[1] - s[3], lp[2] - s[4]);
27763
+ const r = Math.min(Math.sqrt(faceArea / Math.PI), Math.max(Math.sqrt(s[5] * s[5] + radius * radius), reach2));
27764
+ if (r <= s[5]) return;
27765
+ spalls[torn.spall] = [s[0], s[1], s[2], s[3], s[4], r];
27766
+ markDamaged(p);
27767
+ const centre = toWorld(o.st.position, o.st.rotation, [s[2], s[3], s[4]]);
27768
+ emit2({ ...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]) });
27769
+ debris2(o, p, torn.layer.mat.hitDebris, toWorld(o.st.position, o.st.rotation, lp), normal, 5, 2, src, torn.layer.mat.id);
27603
27770
  };
27604
- const faceOf = (o, p, worldNormal) => rotateVec(quat.conjugate(partXf(o, p).q), worldNormal)[p.thin] >= 0 ? 1 : -1;
27605
27771
  const spallOuter = (o, p, wp, face, normal, radius, src) => {
27606
27772
  var _a;
27607
27773
  if (p.layers.length === 0) return;
27608
27774
  const lp = objLocal(o, wp);
27775
+ const torn = tornPatchAt(p.layers, p.rt.spalls, face, lp, radius);
27776
+ if (torn) return widenTear(o, p, torn, lp, normal, radius, src);
27609
27777
  const layer3 = outerLayer(p.layers, p.rt.spalls, face, lp);
27610
27778
  if (!layer3) return;
27611
27779
  const spalls = (_a = p.rt).spalls ?? (_a.spalls = []);
27612
27780
  spalls.push([layer3.index, face, lp[0], lp[1], lp[2], radius]);
27613
27781
  if (spalls.length > MAX_SPALLS) spalls.shift();
27614
27782
  markDamaged(p);
27615
- emit2({ ...base(o, src), type: "spall", part: p.spec.id, layer: layer3.index, point: wp, area: Math.PI * radius * radius });
27783
+ emit2({ ...base2(o, src), type: "spall", part: p.spec.id, layer: layer3.index, point: wp, area: Math.PI * radius * radius, ...spallNormal(o, p, face) });
27616
27784
  debris2(o, p, layer3.mat.hitDebris, wp, normal, 5, 2, src, layer3.mat.id);
27617
27785
  setStage(o, p, 1, {}, src);
27618
27786
  };
27619
27787
  const crater = (o, p, wp, normal, radius, src) => {
27620
27788
  markDamaged(p);
27621
- emit2({ ...base(o, src), type: "spall", part: p.spec.id, layer: -1, point: wp, area: Math.PI * radius * radius });
27789
+ emit2({ ...base2(o, src), type: "spall", part: p.spec.id, layer: -1, point: wp, area: Math.PI * radius * radius });
27622
27790
  debris2(o, p, p.mat.breakDebris, wp, normal, 6, 1.5, src);
27623
27791
  setStage(o, p, 1, {}, src);
27624
27792
  };
@@ -27687,7 +27855,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27687
27855
  if (!layer3 || cells.length === 0) return [];
27688
27856
  const { c, q } = partXf(o, p);
27689
27857
  const [u, v] = planeAxes(p.thin);
27690
- const faces = layer3.def.faces === "both" ? [1, -1] : [layer3.def.faces === "+" ? 1 : -1];
27858
+ const faces = thinSidesOf(layer3.def);
27691
27859
  const area3 = cells.reduce((sum2, cell) => sum2 + cell.size[u] * cell.size[v], 0) * faces.length;
27692
27860
  const count = Math.min(MAX_PLASTER_FLAKES, Math.ceil(area3 / PLASTER_FLAKE_AREA));
27693
27861
  const out = [];
@@ -27869,6 +28037,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27869
28037
  }
27870
28038
  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);
27871
28039
  };
28040
+ const alongAt = (along2, at4) => {
28041
+ const point = [0, 0, 0];
28042
+ point[along2] = at4;
28043
+ return point;
28044
+ };
27872
28045
  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";
27873
28046
  const wearMember = (o, p, entry2, d, E, caliber, penMm, src) => {
27874
28047
  var _a, _b, _c;
@@ -27903,7 +28076,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27903
28076
  const wear = (_c = p.rt).cellWear ?? (_c.cellWear = {});
27904
28077
  const cell = grid[hit];
27905
28078
  wear[hit] = (wear[hit] ?? 0) + volume;
27906
- if (wear[hit] >= MEMBER_UNIT_LOSS * cell.size[0] * cell.size[1] * cell.size[2]) knockOutUnits(o, p, entry2, E, [hit], src);
28079
+ if (wear[hit] >= MEMBER_UNIT_LOSS * cell.size[0] * cell.size[1] * cell.size[2]) knockOutUnits(o, p, entry2, E, [hit], src, d);
27907
28080
  return true;
27908
28081
  }
27909
28082
  const out = [];
@@ -27911,8 +28084,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27911
28084
  if (gone[i] === -1) continue;
27912
28085
  if (Math.abs(grid[i].center[along2] - bandCenter) <= height / 2 + 1e-6) out.push(i);
27913
28086
  }
27914
- if (out.length > 0) knockOutUnits(o, p, entry2, E, out, src);
27915
- giveAtCut(o, p, src);
28087
+ worn[band] = 1;
28088
+ if (out.length > 0) knockOutUnits(o, p, entry2, E, out, src, d);
28089
+ giveAtCut(o, p, src, { at: alongAt(along2, bandCenter), d });
27916
28090
  return true;
27917
28091
  };
27918
28092
  const chipUnits = (o, p, kind, wp, hitEnergy, dir, radius, src) => {
@@ -27984,7 +28158,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27984
28158
  p.rt.removed = (p.rt.removed ?? 0) + mass;
27985
28159
  markDamaged(p);
27986
28160
  setStage(o, p, 1, {}, src);
27987
- emit2({ ...base(o, src), type: "chip", part: p.spec.id, center, size: [cell.size[0], cell.size[1], cell.size[2]], rotation: q, fragments });
28161
+ emit2({ ...base2(o, src), type: "chip", part: p.spec.id, center, size: [cell.size[0], cell.size[1], cell.size[2]], rotation: q, fragments });
27988
28162
  debris2(o, p, p.mat.breakDebris, center, vec.scale(dir ?? [0, 1, 0], -1), 6, 2, src);
27989
28163
  }
27990
28164
  markHostedDirty(o, p.spec.id);
@@ -28019,18 +28193,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28019
28193
  const n = clamp2(Math.round(cell.size[u] * cell.size[v] / (bit * bit * 3)), 4, 10) + Math.floor(rnd2() * 3);
28020
28194
  const out = [];
28021
28195
  for (let i = 0; i < n; i++) {
28022
- const back = i % 3 === 2;
28196
+ const back2 = i % 3 === 2;
28023
28197
  const lc = [cell.center[0], cell.center[1], cell.center[2]];
28024
28198
  lc[u] += (rnd2() - 0.5) * cell.size[u] * 0.7;
28025
28199
  lc[v] += (rnd2() - 0.5) * cell.size[v] * 0.7;
28026
- lc[p.thin] += (back ? -exitSign : exitSign) * (p.thickness / 2 + 0.01);
28200
+ lc[p.thin] += (back2 ? -exitSign : exitSign) * (p.thickness / 2 + 0.01);
28027
28201
  const size = [0, 0, 0];
28028
28202
  size[u] = bit * (0.6 + 0.8 * rnd2());
28029
28203
  size[v] = bit * (0.5 + 0.7 * rnd2());
28030
28204
  size[p.thin] = bit * (0.4 + 0.6 * rnd2());
28031
28205
  const spread3 = [(rnd2() - 0.5) * 0.9, (rnd2() - 0.3) * 0.9, (rnd2() - 0.5) * 0.9];
28032
- const k = speed * (back ? 0.4 + 0.4 * rnd2() : 0.7 + 0.8 * rnd2());
28033
- const vdir = vec.normalize(vec.add(back ? vec.scale(d, -1) : d, spread3));
28206
+ const k = speed * (back2 ? 0.4 + 0.4 * rnd2() : 0.7 + 0.8 * rnd2());
28207
+ const vdir = vec.normalize(vec.add(back2 ? vec.scale(d, -1) : d, spread3));
28034
28208
  out.push({
28035
28209
  id: `${p.spec.id}#${tag}${i}`,
28036
28210
  part: p.spec.id,
@@ -28047,8 +28221,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28047
28221
  }
28048
28222
  return out;
28049
28223
  };
28050
- const exposeRebar = (o, p, src) => {
28051
- settleStructure(o);
28224
+ const exposeRebar = (o, p, src, bowed = true) => {
28225
+ if (bowed) settleStructure(o);
28052
28226
  const r = p.spec.reinforcement;
28053
28227
  if (!r) return;
28054
28228
  const [u, v] = planeAxes(p.thin);
@@ -28065,14 +28239,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28065
28239
  bars.push(...clipBarsToDisc(all, u, v, [lc[u], lc[v]], op.radius + 0.05));
28066
28240
  }
28067
28241
  }
28068
- const bow2 = clamp2(((p.st.stress ?? 0) - 1) / 0.5, 0, 1);
28242
+ const bow2 = bowed ? clamp2(((p.st.stress ?? 0) - 1) / 0.5, 0, 1) : 0;
28069
28243
  if (bow2 > 0) bars = bars.flatMap((bar2, i) => bendBar(bar2, p.thin, bow2 * BAR_BOW, i));
28070
28244
  const stirrups = memberStirrups(p.dims, void 0, p.spec.structure?.role);
28071
28245
  if (stirrups.length > 0 && bars.length > 0) {
28072
28246
  if (p.st.stripped) bars = [...bars, ...stirrups];
28073
28247
  else for (const box5 of [...p.st.chipped ?? [], ...p.rt.bared ?? []]) bars.push(...clipBarsToVolume(stirrups, box5.center, box5.size));
28074
28248
  }
28075
- emit2({ ...base(o, src), type: "expose", part: p.spec.id, bars: worldBars(o, p, bars) });
28249
+ emit2({ ...base2(o, src), type: "expose", part: p.spec.id, bars: worldBars(o, p, bars) });
28076
28250
  };
28077
28251
  const openBreach = (o, p, center, total, energy, dir, src) => {
28078
28252
  const [u, v] = planeAxes(p.thin);
@@ -28233,7 +28407,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28233
28407
  for (const i of out) worn[i] = -1;
28234
28408
  return knockOutUnits(o, p, point, energy, out, src);
28235
28409
  };
28236
- const knockOutUnits = (o, p, wp, energy, out, src) => {
28410
+ const knockOutUnits = (o, p, wp, energy, out, src, d) => {
28237
28411
  var _a, _b;
28238
28412
  const [u, v] = planeAxes(p.thin);
28239
28413
  const op = p.st.opening ? toLocal(p.pos, p.q, p.st.opening.center) : null;
@@ -28277,15 +28451,34 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28277
28451
  setStage(o, p, 1, {}, src);
28278
28452
  const center = toWorld(c, q, [(lo[0] + hi[0]) / 2, (lo[1] + hi[1]) / 2, (lo[2] + hi[2]) / 2]);
28279
28453
  const units = cells.map((cell) => ({ center: toWorld(c, q, cell.center), size: [cell.size[0], cell.size[1], cell.size[2]] }));
28280
- emit2({ ...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 });
28454
+ emit2({ ...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 });
28281
28455
  debris2(o, p, p.mat.breakDebris, center, vec.normalize(vec.sub(center, wp), [0, 1, 0]), 14, 3, src);
28282
- if (p.spec.reinforcement) exposeRebar(o, p, src);
28456
+ const cut = wornLocally(p) && cutBandsGone(o, p, cells, d ?? vec.normalize(vec.sub(partXf(o, p).c, wp), [1, 0, 0]), src);
28457
+ if (p.spec.reinforcement && !cut) exposeRebar(o, p, src);
28283
28458
  if (p.structural && !isLost(p)) {
28284
28459
  solveStructure(o);
28285
28460
  collapseCheck(o, src);
28286
28461
  }
28287
28462
  return true;
28288
28463
  };
28464
+ const cutBandsGone = (o, p, cells, d, src) => {
28465
+ var _a;
28466
+ const along2 = p.dims.indexOf(Math.max(...p.dims));
28467
+ const bands = Math.max(1, Math.round(p.dims[along2] / MEMBER_BAND));
28468
+ const height = p.dims[along2] / bands;
28469
+ const bandOf2 = (at4) => clamp2(Math.floor((at4 + p.dims[along2] / 2) / p.dims[along2] * bands), 0, bands - 1);
28470
+ const grid = gridOf(p);
28471
+ const gone = p.rt.chips ?? {};
28472
+ const worn = (_a = p.rt).bands ?? (_a.bands = {});
28473
+ for (const band of new Set(cells.map((cell) => bandOf2(cell.center[along2])))) {
28474
+ if ((worn[band] ?? 0) >= 1) continue;
28475
+ const center = -p.dims[along2] / 2 + (band + 0.5) * height;
28476
+ if (!grid.every((cell, i) => gone[i] === -1 || Math.abs(cell.center[along2] - center) > height / 2 + 1e-6)) continue;
28477
+ worn[band] = 1;
28478
+ return giveAtCut(o, p, src, { at: alongAt(along2, center), d });
28479
+ }
28480
+ return false;
28481
+ };
28289
28482
  const dropUnsupported = (o, p, src) => {
28290
28483
  var _a, _b;
28291
28484
  if (!p.spec.units || p.spec.units.mortar === p.spec.material || p.st.stripped || isLost(p)) return 0;
@@ -28319,17 +28512,90 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28319
28512
  p.rt.removed = (p.rt.removed ?? 0) + mass;
28320
28513
  markDamaged(p);
28321
28514
  const units = fallen.map((cell) => ({ center: toWorld(c, q, cell.center), size: [cell.size[0], cell.size[1], cell.size[2]] }));
28322
- emit2({ ...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 });
28515
+ emit2({ ...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 });
28323
28516
  debris2(o, p, p.mat.breakDebris, center, [0, -1, 0], 6, 1, src);
28324
28517
  return loose.length;
28325
28518
  };
28326
- const giveAtCut = (o, p, src) => {
28519
+ const barsMoment = (p) => {
28520
+ const r = p.spec.reinforcement;
28521
+ if (!r) return 0;
28522
+ const left = rebarBars(p.dims, p.thin, r.spacing, p.spec.structure?.role).length - (p.rt.severedBars?.length ?? 0);
28523
+ const along2 = p.dims.indexOf(Math.max(...p.dims));
28524
+ const side = Math.min(...p.dims.filter((_, a) => a !== along2));
28525
+ const fy = (materials.get(r.material)?.bending?.yieldMPa ?? STEEL_YIELD_MPA) * 1e6;
28526
+ return Math.max(0, left) / 2 * Math.PI * (r.diameter / 2) ** 2 * fy * Math.max(0, side - 2 * REBAR_COVER);
28527
+ };
28528
+ const memberSide = (p) => {
28529
+ const along2 = p.dims.indexOf(Math.max(...p.dims));
28530
+ return Math.min(...p.dims.filter((_, a) => a !== along2));
28531
+ };
28532
+ const tubeMoment = (p, share) => {
28533
+ const [a = 0, b = 0] = [...p.dims].sort((x, y) => x - y);
28534
+ const fy = (p.mat.bending?.yieldMPa ?? STEEL_YIELD_MPA) * 1e6;
28535
+ return fy * p.thickness * ((a + b) / 2) ** 2 * Math.max(0, 1 - share) ** 2;
28536
+ };
28537
+ const holdsAbove = (o, p, j) => {
28538
+ if (j.st.open) return false;
28539
+ const other = o.parts[j.ia === o.idx.get(p.spec.id) ? j.ib : j.ia];
28540
+ if (j.bears === "a_on_b") return j.spec.b === p.spec.id;
28541
+ if (j.bears === "b_on_a") return j.spec.a === p.spec.id;
28542
+ return partXf(o, other).c[1] > partXf(o, p).c[1] + 1e-6;
28543
+ };
28544
+ const hingeAcross = (o, p, opened, cut, src) => {
28545
+ var _a;
28546
+ const blow22 = cut.d ? objLocalDir(o, cut.d) : [1, 0, 0];
28547
+ const across2 = vec.normalize([blow22[0], 0, blow22[2]], [1, 0, 0]);
28548
+ const point = vec.madd(vec.add(p.pos, rotateVec(p.q, cut.at)), across2, cut.behind);
28549
+ const toward2 = vec.scale(across2, -1);
28550
+ const moment = cut.moment;
28551
+ const hinges = (_a = p.rt).hinges ?? (_a.hinges = []);
28552
+ for (const j of opened) {
28553
+ j.st.yields = { point, toward: toward2, moment };
28554
+ hinges.push({ joint: j.spec.id, point, toward: toward2, moment });
28555
+ }
28556
+ emitYields(o, p, src);
28557
+ };
28558
+ const reyield = (o, p, moment, src) => {
28559
+ for (const h of p.rt.hinges ?? []) h.moment = moment;
28560
+ for (const j of o.byPart.get(p.spec.id) ?? []) if (j.st.yields) j.st.yields.moment = moment;
28561
+ emitYields(o, p, src);
28562
+ };
28563
+ const emitYields = (o, p, src) => {
28564
+ for (const h of p.rt.hinges ?? []) {
28565
+ const point = toWorld(o.st.position, o.st.rotation, h.point);
28566
+ emit2({ ...base2(o, src), type: "yield", part: p.spec.id, joint: h.joint, point, toward: rotateVec(o.st.rotation, h.toward), moment: h.moment });
28567
+ }
28568
+ };
28569
+ const severBars = (o, p, origin, d, caliber, src) => {
28570
+ var _a;
28571
+ const r = p.spec.reinforcement;
28572
+ if (!r || isLost(p) || !isMember(p.dims, p.spec.structure?.role)) return;
28573
+ const along2 = p.dims.indexOf(Math.max(...p.dims));
28574
+ const [u, v] = [0, 1, 2].filter((k) => k !== along2);
28575
+ const lo = toLocal(p.pos, p.q, objLocal(o, origin));
28576
+ const ld = rotateVec(quat.conjugate(p.q), objLocalDir(o, d));
28577
+ const across2 = Math.hypot(ld[u], ld[v]);
28578
+ if (across2 < 1e-6) return;
28579
+ const cut = (_a = p.rt).severedBars ?? (_a.severedBars = []);
28580
+ let severed = 0;
28581
+ rebarBars(p.dims, p.thin, r.spacing, p.spec.structure?.role).forEach(([a], i) => {
28582
+ if (cut.includes(i)) return;
28583
+ const du = a[u] - lo[u];
28584
+ const dv = a[v] - lo[v];
28585
+ if (Math.abs(du * ld[v] - dv * ld[u]) / across2 > r.diameter / 2 + caliber / 2e3) return;
28586
+ cut.push(i);
28587
+ severed++;
28588
+ const s = (du * ld[u] + dv * ld[v]) / (across2 * across2);
28589
+ const at4 = vec.madd(origin, d, s * vec.length(d));
28590
+ debris2(o, p, "sparks", at4, vec.scale(d, -1), 6, 3, src);
28591
+ });
28592
+ if (severed > 0) reyield(o, p, barsMoment(p), src);
28593
+ };
28594
+ const giveAtCut = (o, p, src, cut) => {
28327
28595
  if (!p.spec.reinforcement || !p.spec.units || !p.st.chipped?.length || sectionLoss(p) <= 0) return false;
28328
28596
  const opened = [];
28329
28597
  for (const j of o.byPart.get(p.spec.id) ?? []) {
28330
- if (j.st.open) continue;
28331
- const onIt = j.bears === "a_on_b" && j.spec.b === p.spec.id || j.bears === "b_on_a" && j.spec.a === p.spec.id;
28332
- if (!onIt) continue;
28598
+ if (!j.bears || !holdsAbove(o, p, j)) continue;
28333
28599
  j.st.open = true;
28334
28600
  j.st.openedBy = "break";
28335
28601
  opened.push(j);
@@ -28337,8 +28603,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28337
28603
  if (opened.length === 0) return false;
28338
28604
  p.st.hp = Math.max(p.st.hp, p.st.maxHp * GIVE_AT_CUT_HP);
28339
28605
  markDamaged(p);
28606
+ if (cut) hingeAcross(o, p, opened, { at: cut.at, d: cut.d, behind: memberSide(p) / 2 - REBAR_COVER, moment: barsMoment(p) }, src);
28340
28607
  loosened(o, opened, "break", src);
28341
- exposeRebar(o, p, src);
28608
+ exposeRebar(o, p, src, !cut);
28342
28609
  collapseCheck(o, src);
28343
28610
  return true;
28344
28611
  };
@@ -28366,7 +28633,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28366
28633
  p.st.status = "broken";
28367
28634
  p.st.hp = 0;
28368
28635
  p.st.mass = 0;
28369
- emit2({ ...base(o, src), type: "expose", part: p.spec.id, bars: [] });
28636
+ emit2({ ...base2(o, src), type: "expose", part: p.spec.id, bars: [] });
28370
28637
  debris2(o, p, "sparks", partXf(o, p).c, [0, 1, 0], 6, 3, src);
28371
28638
  partLost(o, p, src);
28372
28639
  };
@@ -28428,7 +28695,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28428
28695
  rnd: planRnd,
28429
28696
  sheet: p.mat.sheet,
28430
28697
  ...p.mat.splitForm ? { form: p.mat.splitForm } : {},
28431
- ...cutAt2 !== void 0 ? { cut: { at: cutAt2, gap: SEVER_BAND } } : {}
28698
+ ...cutAt2 !== void 0 ? { cut: { at: cutAt2, gap: SEVER_BAND } } : {},
28699
+ ...p.spec.solids ? { solids: p.spec.solids } : {}
28432
28700
  });
28433
28701
  const holes = p.st.holes.length > 0 ? localHolesOf(p) : [];
28434
28702
  const mass = p.st.mass;
@@ -28464,7 +28732,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28464
28732
  p.st.burning = false;
28465
28733
  p.rt.jet = false;
28466
28734
  }
28467
- emit2({ ...base(o, src), type: "fracture", part: p.spec.id, style, fragments, point: hitW });
28735
+ emit2({ ...base2(o, src), type: "fracture", part: p.spec.id, style, fragments, point: hitW });
28468
28736
  debris2(o, p, p.mat.breakDebris, c, [0, 1, 0], clamp2(Math.round(Math.cbrt(partVolume(p.spec.shape)) * 30), 3, 20), 2, src);
28469
28737
  setStage(o, p, 3, {}, src);
28470
28738
  if (reinforcement) {
@@ -28472,7 +28740,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28472
28740
  return;
28473
28741
  }
28474
28742
  if (ex) {
28475
- emit2({ ...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 } : {} });
28743
+ emit2({ ...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 } : {} });
28476
28744
  const fuel = burstFuel(p);
28477
28745
  blasts.push({ point: c, energy: ex.energy, radius: ex.radius, ...ex.lethalRadius !== void 0 ? { lethalRadius: ex.lethalRadius } : {}, ...fuel > 0 ? { fuel } : {}, source: src });
28478
28746
  }
@@ -28485,7 +28753,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28485
28753
  p.rt.chainDue = time + delay;
28486
28754
  primed.set(p, o);
28487
28755
  o.active = true;
28488
- emit2({ ...base(o, src), type: "primed", part: p.spec.id, point: partXf(o, p).c, trigger, delay });
28756
+ emit2({ ...base2(o, src), type: "primed", part: p.spec.id, point: partXf(o, p).c, trigger, delay });
28489
28757
  };
28490
28758
  const CHAIN_TRIGGER_OF = { ballistic: "shot", explosive: "explosion" };
28491
28759
  const severAxis = (p) => {
@@ -28522,7 +28790,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28522
28790
  if (p.st.hp <= 0 && p.mat.fracture === "none" && !p.spec.explodes) p.st.hp = Math.min(prev, 1);
28523
28791
  if (p.st.hp <= 0 && type === "ballistic" && wornLocally(p)) p.st.hp = Math.min(prev, 1);
28524
28792
  const done = prev - p.st.hp;
28525
- if (done > 0) emit2({ ...base(o, src), type: "damage", part: p.spec.id, amount: done, hp: Math.max(0, p.st.hp), damageType: type });
28793
+ if (done > 0) emit2({ ...base2(o, src), type: "damage", part: p.spec.id, amount: done, hp: Math.max(0, p.st.hp), damageType: type });
28526
28794
  if (p.st.hp <= 0) failPart(o, p, origin, dir, fragEnergy * weight, cap, src);
28527
28795
  else if (chained && (trigger === "explosion" || 1 - p.st.hp / p.st.maxHp >= shotDamageFractionOf(p.spec))) prime(o, p, trigger, src);
28528
28796
  return done;
@@ -28564,27 +28832,29 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28564
28832
  const n = shot ? exit ? clamp2(Math.round(E / joules), 1, 7) : 1 : clamp2(Math.floor(E / joules), 0, 5);
28565
28833
  if (n === 0) return;
28566
28834
  const fibre = tear === "lumps";
28835
+ const strips = tear === "strips";
28567
28836
  const { q } = partXf(o, p);
28568
28837
  const along2 = (p.spec.grain ? AXIS[p.spec.grain] : void 0) ?? [0, 1, 2].sort((a, b) => p.dims[b] - p.dims[a])[0];
28569
28838
  const fragments = [];
28570
28839
  for (let i = 0; i < n; i++) {
28571
- const back = !exit || i % 3 === 2;
28840
+ const back2 = !exit || i % 3 === 2;
28572
28841
  const plies = p.mat.splitForm === "plies";
28573
- const len = scale * (fibre ? 1.2 + 1.2 * rnd2() : 3 + 4 * rnd2()), w = scale * (0.8 + 0.8 * rnd2()), t = scale * (fibre ? 0.7 + 0.6 * rnd2() : plies ? 0.15 + 0.15 * rnd2() : 0.4 + 0.4 * rnd2());
28842
+ const len = scale * (fibre ? 1.2 + 1.2 * rnd2() : strips ? 6 + 6 * rnd2() : 3 + 4 * rnd2()), w = scale * (strips ? 1 + rnd2() : 0.8 + 0.8 * rnd2());
28843
+ const t = strips ? Math.min(p.thickness, STRIP_THICKNESS) : scale * (fibre ? 0.7 + 0.6 * rnd2() : plies ? 0.15 + 0.15 * rnd2() : 0.4 + 0.4 * rnd2());
28574
28844
  const size = [w, w, w];
28575
28845
  size[along2] = len;
28576
28846
  size[(along2 + 1) % 3] = w;
28577
28847
  size[(along2 + 2) % 3] = t;
28578
28848
  const spread3 = [(rnd2() - 0.5) * 0.8, (rnd2() - 0.2) * 0.8, (rnd2() - 0.5) * 0.8];
28579
- const speed = shot ? back ? 1.5 + 2 * rnd2() : 2 + 4 * rnd2() : 0.8 + 1.2 * rnd2();
28580
- const v = vec.scale(vec.normalize(vec.add(back ? vec.scale(d, -1) : d, spread3)), speed);
28849
+ const speed = shot ? back2 ? 1.5 + 2 * rnd2() : 2 + 4 * rnd2() : 0.8 + 1.2 * rnd2();
28850
+ const v = vec.scale(vec.normalize(vec.add(back2 ? vec.scale(d, -1) : d, spread3)), speed);
28581
28851
  const mass = size[0] * size[1] * size[2] * p.mat.density;
28582
28852
  fragments.push({
28583
28853
  id: `${p.spec.id}#t${tears++}-${i}`,
28584
28854
  part: p.spec.id,
28585
28855
  material: p.spec.material,
28586
- shape: fibre ? "chunk" : "splinter",
28587
- center: back || !exit ? vec.madd(entry2, d, -0.01) : vec.madd(exit, d, 0.01),
28856
+ shape: fibre ? "chunk" : strips ? "scrap" : "splinter",
28857
+ center: back2 || !exit ? vec.madd(entry2, d, -0.01) : vec.madd(exit, d, 0.01),
28588
28858
  size,
28589
28859
  rotation: q,
28590
28860
  velocity: v,
@@ -28594,14 +28864,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28594
28864
  });
28595
28865
  }
28596
28866
  const patch = [scale * 4, scale * 4, scale * 4];
28597
- emit2({ ...base(o, src), type: "chip", part: p.spec.id, center: exit ?? entry2, size: patch, rotation: q, fragments, torn: true });
28867
+ emit2({ ...base2(o, src), type: "chip", part: p.spec.id, center: exit ?? entry2, size: patch, rotation: q, fragments, torn: true });
28598
28868
  };
28599
28869
  const ballistic = (o, p, entry2, n, d, E, caliber, pathLen, src, round5 = {}) => {
28600
28870
  const mat = p.mat;
28601
- const piece2 = round5.piece;
28602
- const weight = piece2?.weight ?? 1;
28871
+ const piece3 = round5.piece;
28872
+ const weight = piece3?.weight ?? 1;
28603
28873
  const piercing = round5.piercing ?? 1;
28604
- if (p.st.stripped || p.st.opening && insideOpening(o, p, objLocal(o, entry2)) || insideChip(p, objLocal(o, entry2))) {
28874
+ 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))))) {
28605
28875
  return { penetrated: true, exitEnergy: E, exitPoint: vec.madd(entry2, d, Math.min(pathLen, p.thickness)), damage: 0 };
28606
28876
  }
28607
28877
  const sin2 = Math.min(1, Math.abs(vec.dot(d, n)));
@@ -28615,14 +28885,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28615
28885
  const hard = mat.tags?.includes("metal") || mat.tags?.includes("masonry");
28616
28886
  const penMm = penetrationOf(mat, round5.penetration);
28617
28887
  const Ep = penMm !== void 0 ? penMm * mat.penetration : piercing === 1 || !hard ? E : E * piercing;
28618
- const strength = piece2 && mat.strength?.ndrc ? mat.strength.compressiveMPa : void 0;
28888
+ const strength = piece3 && mat.strength?.ndrc ? mat.strength.compressiveMPa : void 0;
28619
28889
  const path = strength === void 0 ? 0 : (p.thickness + layersThickness(p.layers, face) + layersThickness(p.layers, -face)) / slant;
28620
- 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);
28890
+ 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);
28621
28891
  const scale = (mat.damageScale?.ballistic ?? 1) * (mat.fracture === "shatter" ? fragility(mat.ductility, p.thickness) : 1);
28622
28892
  const id = p.spec.id;
28623
28893
  if (!penetrated && mat.ricochetDeg && angle < mat.ricochetDeg) {
28624
28894
  const r = vec.sub(d, vec.scale(n, 2 * vec.dot(d, n)));
28625
- emit2({ ...base(o, src), type: "ricochet", part: id, point: entry2, direction: vec.normalize(r), energy: E * 0.4 });
28895
+ emit2({ ...base2(o, src), type: "ricochet", part: id, point: entry2, direction: vec.normalize(r), energy: E * 0.4 });
28626
28896
  debris2(o, p, mat.hitDebris, entry2, n, 3, 3, src);
28627
28897
  const dmg2 = applyDamage(o, p, E * DMG_PER_J * scale * 0.2, "ballistic", entry2, d, E * 0.1, 12, src, weight);
28628
28898
  return { penetrated: false, exitEnergy: 0, damage: dmg2 };
@@ -28633,10 +28903,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28633
28903
  const ratio = Ep / Math.max(thr, 1e-6);
28634
28904
  const crackLen = clamp2(0.03 + ratio * 0.2, 0.03, 0.8);
28635
28905
  let exitPoint;
28906
+ let shellShare = 0;
28636
28907
  if (penetrated) {
28637
28908
  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);
28638
28909
  exitPoint = vec.madd(entry2, d, exitDist);
28639
28910
  const hole = addHole(o, p, entry2, n, caliber / 1e3 * (mat.ductility >= 0.3 ? 1 : 1.5), true, exitPoint, src);
28911
+ shellShare = wearsShell(p, hole.diameter * 2);
28640
28912
  if (p.layers.length > 0) spallOuter(o, p, exitPoint, -face, vec.scale(n, -1), Math.max(0.03, caliber / 1e3 * 4), src);
28641
28913
  addBreach(o, p, entry2, Math.PI * (hole.diameter / 2) * (hole.diameter / 2), E, d, src);
28642
28914
  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);
@@ -28644,7 +28916,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28644
28916
  if (p.spec.contains && (p.st.liters ?? 0) > 1e-4) {
28645
28917
  o.active = true;
28646
28918
  emit2({
28647
- ...base(o, src),
28919
+ ...base2(o, src),
28648
28920
  type: "leak",
28649
28921
  part: id,
28650
28922
  fluid: p.spec.contains.fluid,
@@ -28664,8 +28936,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28664
28936
  debris2(o, p, mat.hitDebris, entry2, n, clamp2(Math.round(E / 60) + 2, 2, 14), clamp2(Math.sqrt(E) / 6, 1, 8), src);
28665
28937
  wearJoints(o, p, (penetrated ? thr : E) * 0.02 * weight, void 0, 0, src, true, BULLET_JOINT_SPAN);
28666
28938
  const hollowTear = mat.fracture === "tear" && p.spec.fill !== void 0 && p.spec.fill < 0.5;
28667
- const absorbed = penetrated && (mat.ductility >= 0.5 && mat.fracture !== "tear" || hollowTear) ? Math.min(E, thr) : E;
28939
+ const absorbed = penetrated && (mat.ductility >= 0.5 && mat.fracture !== "tear" || hollowTear || mat.cellular === true) ? Math.min(E, thr) : E;
28668
28940
  const dmg = applyDamage(o, p, absorbed * DMG_PER_J * scale, "ballistic", entry2, d, absorbed * 0.1, 12, src, weight);
28941
+ if (shellShare > 0 && !isLost(p)) yieldShell(o, p, shellShare, entry2, d, src);
28669
28942
  if (!isLost(p)) tearAt(o, p, "ballistic", entry2, penetrated ? exitPoint : void 0, d, E, caliber / 1e3, src);
28670
28943
  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);
28671
28944
  return { penetrated, exitEnergy: penetrated ? penMm !== void 0 ? E * (1 - thr / Ep) : E - thr / (hard ? piercing : 1) : 0, exitPoint, damage: dmg };
@@ -28683,13 +28956,37 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28683
28956
  const hinge = plateHinge(p.dims, toLocal(c, q, point), local2);
28684
28957
  const toObject = (v) => rotateVec(p.q, v);
28685
28958
  p.st.bendHinge = { point: vec.add(p.pos, toObject(hinge.point)), axis: toObject(hinge.axis), side: toObject(hinge.side) };
28686
- emit2({ ...base(o), type: "bend", part: p.spec.id, hinge: p.st.bendHinge, angle: p.st.bend - before, worldPoint: point });
28959
+ emit2({ ...base2(o), type: "bend", part: p.spec.id, hinge: p.st.bendHinge, angle: p.st.bend - before, worldPoint: point });
28687
28960
  }
28688
28961
  const axis2 = severAxis(p);
28689
28962
  if (axis2 < 0 || snapRatio(p.dims, p.mat.bending, E, local2, SEVER_ASPECT) < 1) return 0;
28690
28963
  p.rt.cutAt = clamp2(toLocal(c, q, point)[axis2], -p.dims[axis2] / 2, p.dims[axis2] / 2);
28691
28964
  return Math.max(0, p.st.hp);
28692
28965
  };
28966
+ const wearsShell = (p, width) => {
28967
+ if (p.mat.ductility < 0.5 || p.thickness > THIN_SHEET_DISHING || p.spec.shape.kind !== "box") return 0;
28968
+ const [a = 0, b = 0, c = 0] = [...p.dims].sort((x, y) => x - y);
28969
+ if (c < 2 * b || b > 3 * a) return 0;
28970
+ p.rt.shellCut = (p.rt.shellCut ?? 0) + width;
28971
+ return Math.min(1, p.rt.shellCut / (2 * (a + b)));
28972
+ };
28973
+ const yieldShell = (o, p, share, entry2, d, src) => {
28974
+ if (share < SHELL_YIELD_SHARE) return;
28975
+ if (p.rt.hinges?.length) {
28976
+ reyield(o, p, tubeMoment(p, share), src);
28977
+ return;
28978
+ }
28979
+ const opened = (o.byPart.get(p.spec.id) ?? []).filter((j) => holdsAbove(o, p, j));
28980
+ if (opened.length === 0) return;
28981
+ for (const j of opened) {
28982
+ j.st.open = true;
28983
+ j.st.openedBy = "break";
28984
+ }
28985
+ const along2 = p.dims.indexOf(Math.max(...p.dims));
28986
+ 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);
28987
+ loosened(o, opened, "break", src);
28988
+ collapseCheck(o, src);
28989
+ };
28693
28990
  const melee = (o, p, kind, E, point, n, d, contactR, src) => {
28694
28991
  const mat = p.mat;
28695
28992
  const thrMm = mat.penetration * p.thickness * 1e3;
@@ -28780,7 +29077,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28780
29077
  frontQueue.push({ o, p, due: time + dist2 / blastFrontSpeed, amount, fragEnergy: Ein * 0.3, point, ...src !== void 0 ? { src } : {} });
28781
29078
  return reach2;
28782
29079
  }
28783
- 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);
29080
+ 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);
28784
29081
  const breachReach = BREACH_BLAST_REACH * Math.cbrt(Math.max(0, energy) / 1e3);
28785
29082
  const caged2 = Boolean(p.spec.reinforcement && p.spec.units);
28786
29083
  const member = caged2 && (isMember(p.dims, p.spec.structure?.role) || dist2 > MEMBER_CUT_REACH * breachReach);
@@ -29139,7 +29436,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29139
29436
  for (let i = 0; i < 4 && E > 0; i++) {
29140
29437
  const reach2 = flight ? E > flight.minEnergy ? Math.log(E / flight.minEnergy) / (2 * flight.drag) : 0 : Infinity;
29141
29438
  if (!(reach2 > 0)) break;
29142
- const rh = raycastInternal(org, d, reach2, ignore, false, true);
29439
+ const crossed = [];
29440
+ const rh = raycastInternal(org, d, reach2, ignore, false, true, {}, void 0, true, crossed);
29441
+ for (const c of crossed) if (!rh || c.t < rh.distance) severBars(c.o, c.p, org, d, caliber, source);
29143
29442
  if (!rh) break;
29144
29443
  if (flight) E *= Math.exp(-2 * flight.drag * vec.distance(org, rh.point));
29145
29444
  const im = impls.get(rh.object);
@@ -29336,14 +29635,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29336
29635
  }
29337
29636
  return out;
29338
29637
  }
29339
- const mergeResults = (base2, extra) => {
29340
- const byObject = new Map(base2.map((r) => [r.object, r]));
29638
+ const mergeResults = (base22, extra) => {
29639
+ const byObject = new Map(base22.map((r) => [r.object, r]));
29341
29640
  for (const r of extra) {
29342
29641
  const have = byObject.get(r.object);
29343
29642
  if (!have) {
29344
29643
  const copy2 = { ...r, events: [...r.events] };
29345
29644
  byObject.set(r.object, copy2);
29346
- base2.push(copy2);
29645
+ base22.push(copy2);
29347
29646
  continue;
29348
29647
  }
29349
29648
  have.damage += r.damage;
@@ -29351,7 +29650,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29351
29650
  have.events.push(...r.events);
29352
29651
  if (!have.part && r.part) have.part = r.part;
29353
29652
  }
29354
- return base2;
29653
+ return base22;
29355
29654
  };
29356
29655
  function* blastSteps(point, energy, radius, src, call3, only, lethal) {
29357
29656
  const cfg = blastCfg(call3);
@@ -29603,7 +29902,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29603
29902
  p.st.temperature = Math.max(p.st.temperature, th.flameC ?? 800);
29604
29903
  o.active = true;
29605
29904
  markDamaged(p);
29606
- emit2({ ...base(o, src), type: "ignite", part: p.spec.id, point: partXf(o, p).c });
29905
+ emit2({ ...base2(o, src), type: "ignite", part: p.spec.id, point: partXf(o, p).c });
29607
29906
  };
29608
29907
  const syncMass = (p) => {
29609
29908
  p.st.mass = Math.max(0, p.mass0 * (1 - p.st.melt) - (p.fuel0 - p.st.fuel));
@@ -29629,11 +29928,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29629
29928
  p.st.status = "ashes";
29630
29929
  p.st.hp = 0;
29631
29930
  p.st.mass = p.mass0 * (1 - (th.fuelFraction ?? 0));
29632
- emit2({ ...base(o), type: "burnout", part: p.spec.id, point: c });
29931
+ emit2({ ...base2(o), type: "burnout", part: p.spec.id, point: c });
29633
29932
  debris2(o, p, "ash", c, [0, 1, 0], clamp2(Math.round(Math.cbrt(partVolume(p.spec.shape)) * 30), 3, 20), 1);
29634
29933
  partLost(o, p);
29635
29934
  } else {
29636
- emit2({ ...base(o), type: "burnout", part: p.spec.id, point: c });
29935
+ emit2({ ...base2(o), type: "burnout", part: p.spec.id, point: c });
29637
29936
  }
29638
29937
  }
29639
29938
  };
@@ -29650,11 +29949,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29650
29949
  p.rt.dripT -= 0.25;
29651
29950
  const b = partWorldAabb(o, p);
29652
29951
  const pt = [b.min[0] + (b.max[0] - b.min[0]) * (0.2 + 0.6 * rnd2()), b.min[1], b.min[2] + (b.max[2] - b.min[2]) * (0.2 + 0.6 * rnd2())];
29653
- emit2({ ...base(o), type: "drip", part: p.spec.id, point: pt, material: p.mat.id });
29952
+ emit2({ ...base2(o), type: "drip", part: p.spec.id, point: pt, material: p.mat.id });
29654
29953
  }
29655
29954
  if (p.st.melt - p.rt.meltEmitted >= 0.05 || p.st.melt >= 1) {
29656
29955
  p.rt.meltEmitted = p.st.melt;
29657
- emit2({ ...base(o), type: "melt", part: p.spec.id, melt: p.st.melt });
29956
+ emit2({ ...base2(o), type: "melt", part: p.spec.id, melt: p.st.melt });
29658
29957
  }
29659
29958
  if (p.st.melt >= 1) {
29660
29959
  p.st.status = "melted";
@@ -29727,7 +30026,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29727
30026
  }
29728
30027
  p.rt.jet = true;
29729
30028
  s.burning = true;
29730
- emit2({ ...base(o), type: "ignite", part: p.spec.id, point: partXf(o, p).c });
30029
+ emit2({ ...base2(o), type: "ignite", part: p.spec.id, point: partXf(o, p).c });
29731
30030
  }
29732
30031
  }
29733
30032
  }
@@ -29735,7 +30034,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29735
30034
  if (p.rt.jet && (s.liters ?? 0) <= 0) {
29736
30035
  p.rt.jet = false;
29737
30036
  s.burning = false;
29738
- emit2({ ...base(o), type: "extinguish", part: p.spec.id });
30037
+ emit2({ ...base2(o), type: "extinguish", part: p.spec.id });
29739
30038
  }
29740
30039
  const sc = th.thermalShockC;
29741
30040
  if (sc !== void 0) {
@@ -29769,7 +30068,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29769
30068
  if (stress > 1) {
29770
30069
  if (p.rt.stressT <= 0) {
29771
30070
  p.rt.stressT = 0.5;
29772
- emit2({ ...base(o), type: "stress", part: p.spec.id, stress, load: p.st.load ?? 0 });
30071
+ emit2({ ...base2(o), type: "stress", part: p.spec.id, stress, load: p.st.load ?? 0 });
29773
30072
  if (p.spec.reinforcement && (p.st.stripped || p.st.chipped?.length || p.st.opening)) exposeRebar(o, p);
29774
30073
  }
29775
30074
  applyDamage(o, p, overloadRate(stress) * p.st.maxHp * dt, "blunt", null, null, 5, 3);
@@ -30083,6 +30382,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30083
30382
  setRayBroadPhase(broadPhase2) {
30084
30383
  rayBroad = broadPhase2;
30085
30384
  },
30385
+ setSurfaceTracer(tracer) {
30386
+ surfaceTracer = tracer;
30387
+ },
30086
30388
  groundLoss(loss) {
30087
30389
  if (!(loss.radius > 0) || !(loss.depth > 0) || !Number.isFinite(loss.x) || !Number.isFinite(loss.z)) return;
30088
30390
  pendingLosses.push({ ...loss });
@@ -30147,7 +30449,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30147
30449
  const step = Math.floor(j.st.progress * 10 + 1e-9);
30148
30450
  if (step > j.step || j.st.progress >= 1) {
30149
30451
  j.step = step;
30150
- emit2({ ...base(o), type: "disassemble_progress", joint: j.spec.id, tool: tool2, progress: j.st.progress });
30452
+ emit2({ ...base2(o), type: "disassemble_progress", joint: j.spec.id, tool: tool2, progress: j.st.progress });
30151
30453
  }
30152
30454
  if (j.st.progress >= 1) {
30153
30455
  j.st.open = true;
@@ -30233,7 +30535,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30233
30535
  if (p.st.burning) {
30234
30536
  p.st.burning = false;
30235
30537
  p.rt.jet = false;
30236
- emit2({ ...base(o), type: "extinguish", part: p.spec.id });
30538
+ emit2({ ...base2(o), type: "extinguish", part: p.spec.id });
30237
30539
  }
30238
30540
  p.st.temperature = Math.max(ambient, p.st.temperature - coolC);
30239
30541
  }
@@ -30265,7 +30567,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30265
30567
  if (p.st.holes.length > maxHoles) p.st.holes.shift();
30266
30568
  o.active = true;
30267
30569
  emit2({
30268
- ...base(o),
30570
+ ...base2(o),
30269
30571
  type: "leak",
30270
30572
  part: partId,
30271
30573
  fluid: c.fluid,
@@ -30475,7 +30777,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30475
30777
  var defaultSet;
30476
30778
  var defaultAssemblies = () => defaultSet ?? (defaultSet = assembliesOver(ASSEMBLIES));
30477
30779
  var getAssembly = (id) => defaultAssemblies().get(id);
30478
- var faceCount = (layer3) => layer3.faces === "both" ? 2 : 1;
30780
+ var faceCount = (layer3) => layer3.faces === "both" || layer3.faces === "all" ? 2 : 1;
30479
30781
  var assemblyDepth = (def) => def.depth ?? def.core.thickness + (def.layers ?? []).reduce((sum2, l) => sum2 + l.thickness * faceCount(l), 0);
30480
30782
  var buildAssemblyPart = (def, assemblyId, options) => {
30481
30783
  if (!def) throw new Error(`unknown assembly "${assemblyId}"`);
@@ -30649,8 +30951,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30649
30951
  const id = w.add(onRock(s));
30650
30952
  return new Map(w.state(id).parts.map((p) => [p.id, p.flexure ?? 0]));
30651
30953
  };
30652
- const base = bending(out);
30653
- const factor = new Map(targets.map((p) => [p.id, (base.get(p.id) ?? 0) / safetyOf(p.structure.role)]));
30954
+ const base2 = bending(out);
30955
+ const factor = new Map(targets.map((p) => [p.id, (base2.get(p.id) ?? 0) / safetyOf(p.structure.role)]));
30654
30956
  if (options.redundancy !== void 0) {
30655
30957
  const roles = options.redundancyRoles ?? ["column"];
30656
30958
  for (const lost of out.parts) {
@@ -30694,11 +30996,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30694
30996
  return new Map(w.state(id).parts.map((p) => [p.id, { load: p.load ?? 0, stress: p.stress ?? 0, wind: p.wind ?? 0 }]));
30695
30997
  };
30696
30998
  const out = structuredClone(spec);
30697
- const base = loads(out, options.wind);
30999
+ const base2 = loads(out, options.wind);
30698
31000
  const gamma = options.wind ? resolveWind(options.wind).loadFactor : 0;
30699
31001
  const structural = out.parts.filter((p) => p.structure && p.structure.role !== "none");
30700
31002
  const loadAt = (p) => {
30701
- const b = base.get(p.id);
31003
+ const b = base2.get(p.id);
30702
31004
  return b && b.stress > 0 ? b.load + (b.wind > 0 ? gamma * b.wind / GRAVITY : 0) : void 0;
30703
31005
  };
30704
31006
  const lossesOf = function* () {
@@ -30727,7 +31029,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30727
31029
  if (options.wind) {
30728
31030
  const yieldMPa = resolveFlexure(options.flexure).rebarYieldMPa;
30729
31031
  for (const p of out.parts) {
30730
- const b = base.get(p.id);
31032
+ const b = base2.get(p.id);
30731
31033
  if (!b || b.wind >= 0 || !p.reinforcement || p.shape.kind !== "box") continue;
30732
31034
  const pull = -(b.load + gamma * b.wind / GRAVITY) * GRAVITY;
30733
31035
  if (pull <= 0) continue;
@@ -31780,8 +32082,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
31780
32082
  return { parts: context.parts, supports: context.supports };
31781
32083
  }
31782
32084
  function anchorBalconies(context) {
31783
- const base = context.panelsOf.get("slab_base");
31784
- if (!base) return;
32085
+ const base2 = context.panelsOf.get("slab_base");
32086
+ if (!base2) return;
31785
32087
  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)));
31786
32088
  for (const deck of decks) {
31787
32089
  const pillars = new Set(context.supports.filter((s) => s.part === deck.id && /^balcony_column_/.test(s.on)).map((s) => s.on));
@@ -31800,7 +32102,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
31800
32102
  if (!splits.size) return input;
31801
32103
  const boxes = new Map(input.parts.map((part) => [part.id, part.aabb]));
31802
32104
  const pieceBox = /* @__PURE__ */ new Map();
31803
- for (const split of splits.values()) for (const piece2 of split.pieces) pieceBox.set(piece2.id, piece2.aabb);
32105
+ for (const split of splits.values()) for (const piece3 of split.pieces) pieceBox.set(piece3.id, piece3.aabb);
31804
32106
  const parts2 = input.parts.flatMap((part) => splits.get(part.id)?.pieces ?? [part]);
31805
32107
  const supports = [];
31806
32108
  for (const support of input.supports) {
@@ -31942,9 +32244,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
31942
32244
  const spandrel = spandrels[k];
31943
32245
  if (spandrel) internal.push({ part: spandrel.id, on: lintel.id, joint: style.wallJoint });
31944
32246
  });
31945
- const base = [...piers, ...drafts.filter((d) => d.id.includes("_sill_"))].map((d) => d.id);
32247
+ const base2 = [...piers, ...drafts.filter((d) => d.id.includes("_sill_"))].map((d) => d.id);
31946
32248
  const top = [...piers.map((p) => p.id), ...lintels.map((l, k) => spandrels[k]?.id ?? l.id)];
31947
- return { pieces, internal, base, top };
32249
+ return { pieces, internal, base: base2, top };
31948
32250
  }
31949
32251
  var LOG_DIAMETER = 0.26;
31950
32252
  var isWall = (part) => part.id.startsWith("wall_") && part.assembly !== void 0 && (part.role === "wall" || part.role === "partition");
@@ -32006,7 +32308,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
32006
32308
  if (capacity === void 0) continue;
32007
32309
  const along2 = (box22) => Math.max(box22[2] - box22[0], box22[3] - box22[1]);
32008
32310
  const length2 = along2(input.parts.find((part) => part.id === id).aabb);
32009
- for (const piece2 of split.pieces) capacities.set(piece2.id, Math.max(1, capacity * along2(piece2.aabb) / length2));
32311
+ for (const piece3 of split.pieces) capacities.set(piece3.id, Math.max(1, capacity * along2(piece3.aabb) / length2));
32010
32312
  }
32011
32313
  return { ...next, capacities };
32012
32314
  }
@@ -32230,10 +32532,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
32230
32532
  const joints = [...spec.joints ?? []];
32231
32533
  const reinforcement = { material: "steel", spacing: c.rebar.spacing, diameter: c.rebar.diameter };
32232
32534
  const raft2 = parts2.find((p) => p.id === "raft");
32233
- let base = raft2?.id;
32234
- if (!base) {
32235
- base = "core_mat";
32236
- parts2.push({ id: base, material: c.material, shape: box2([W + 1, c.matThickness, L + 1]), position: [cx, -c.matThickness / 2, cz], structure: { role: "foundation" }, anchored: true });
32535
+ let base2 = raft2?.id;
32536
+ if (!base2) {
32537
+ base2 = "core_mat";
32538
+ parts2.push({ id: base2, material: c.material, shape: box2([W + 1, c.matThickness, L + 1]), position: [cx, -c.matThickness / 2, cz], structure: { role: "foundation" }, anchored: true });
32237
32539
  }
32238
32540
  const innerX = x0 + t + c.stairWidth + ti / 2;
32239
32541
  for (let f = 0; f < g.floors; f++) {
@@ -32241,7 +32543,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
32241
32543
  const wall = (name, size, pos) => {
32242
32544
  const id = `core_${f}_${name}`;
32243
32545
  parts2.push({ id, material: c.material, shape: box2(size), position: [pos[0], yb + H / 2, pos[1]], structure: { role: "wall" }, reinforcement, tags: ["core"] });
32244
- rests(joints, id, f === 0 ? base : `core_${f - 1}_${name}`, "rebar");
32546
+ rests(joints, id, f === 0 ? base2 : `core_${f - 1}_${name}`, "rebar");
32245
32547
  return id;
32246
32548
  };
32247
32549
  const tube2 = [
@@ -32294,7 +32596,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
32294
32596
  mass: 1500,
32295
32597
  tags: ["elevator_car"]
32296
32598
  });
32297
- rests(joints, id, base, "resting", false);
32599
+ rests(joints, id, base2, "resting", false);
32298
32600
  }
32299
32601
  return { ...spec, parts: parts2, joints };
32300
32602
  }
@@ -32975,12 +33277,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
32975
33277
  var resolveUse = (item, effects, context = {}, rules = DEFAULT_RULES2) => {
32976
33278
  const def = findEffect(item, effects);
32977
33279
  if (!def) return void 0;
32978
- const base = { useId: def.id, effect: def.effect, params: def.params ?? {}, consumes: def.consumes };
32979
- if (def.effect !== "consume_nutrition") return base;
33280
+ const base2 = { useId: def.id, effect: def.effect, params: def.params ?? {}, consumes: def.consumes };
33281
+ if (def.effect !== "consume_nutrition") return base2;
32980
33282
  const nutrition = nutritionOf(item, context, rules);
32981
33283
  const blocked = item.seal && context.seal ? sealBlock(item.seal, context.seal) : void 0;
32982
- if (blocked) return { ...base, consumes: false, nutrition: { ...nutrition, isEdible: false }, blocked };
32983
- return { ...base, consumes: def.consumes && nutrition.isEdible, nutrition };
33284
+ if (blocked) return { ...base2, consumes: false, nutrition: { ...nutrition, isEdible: false }, blocked };
33285
+ return { ...base2, consumes: def.consumes && nutrition.isEdible, nutrition };
32984
33286
  };
32985
33287
  var MM = 1e-3;
32986
33288
  var BOX_WALL = 6 * MM;
@@ -52283,9 +52585,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52283
52585
  var goodsItemUse = createGoodsItemUse();
52284
52586
 
52285
52587
  // ../game-interactables-household/dist/index.js
52286
- var door = (material, joint2 = "hinge", piece2 = "door") => ({ material, joint: joint2, piece: piece2 });
52588
+ var door = (material, joint2 = "hinge", piece22 = "door") => ({ material, joint: joint2, piece: piece22 });
52287
52589
  var drawer = { material: "mdf", joint: "slide", piece: "drawer" };
52288
52590
  var knob = { material: "plastic", joint: "clip", piece: "knob" };
52591
+ var mainLever = { material: "plastic", joint: "clip", piece: "breaker" };
52289
52592
  var tap = { material: "steel", joint: "screw", piece: "handle" };
52290
52593
  var mdfBody = { material: "mdf", joint: "screw" };
52291
52594
  var cabinet = { body: mdfBody, parts: [[/^drawer/, drawer], [/^door/, door("mdf")]] };
@@ -52293,6 +52596,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52293
52596
  var bin = { body: { material: "plastic", joint: "fused" }, parts: [["lid", door("plastic", "hinge", "lid")]] };
52294
52597
  var upholstery = { material: "fabric", joint: "glue" };
52295
52598
  var POLE_CAGE = { material: "steel", spacing: 0.1, diameter: 0.01 };
52599
+ var BRICKWORK = { size: [0.23, 0.075, 0.11], bond: "running", mortar: "mortar" };
52296
52600
  var DESTRUCTION = {
52297
52601
  fridge: fridgeLike,
52298
52602
  fridge_compact: fridgeLike,
@@ -52319,19 +52623,23 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52319
52623
  wall_socket: { body: { material: "plastic", joint: "screw" }, parts: [] },
52320
52624
  wall_switch: { body: { material: "plastic", joint: "screw" }, parts: [["rocker", { material: "plastic", joint: "clip", piece: "rocker" }]] },
52321
52625
  // 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
52322
- service_entrance: { body: { material: "concrete", joint: "rebar", reinforcement: POLE_CAGE }, parts: [["meter_door", door("steel")]] },
52626
+ service_entrance: { body: { material: "concrete", joint: "rebar", reinforcement: POLE_CAGE }, parts: [["meter_door", door("steel")], ["main_breaker", mainLever]] },
52323
52627
  conduit_run: { body: { material: "plastic", joint: "clip" }, parts: [] },
52324
- service_mast: { body: { material: "steel", joint: "clip" }, parts: [] },
52628
+ // 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)
52629
+ service_mast: { body: { material: "steel", joint: "weld" }, parts: [] },
52325
52630
  electrical_panel: {
52326
52631
  body: { material: "steel", joint: "screw" },
52327
52632
  parts: [[/^breaker/, { material: "plastic", joint: "clip", piece: "breaker" }], ["door", door("steel")]]
52328
52633
  },
52329
- power_meter: { body: { material: "plastic", joint: "screw" }, parts: [["door", door("plastic")]] },
52634
+ power_meter: { body: { material: "plastic", joint: "screw" }, parts: [["door", door("plastic")], ["main_breaker", mainLever]] },
52330
52635
  tv: { body: { material: "plastic", joint: "screw" }, parts: [["power", { material: "plastic", joint: "clip", piece: "button" }]] },
52331
52636
  microwave: { body: { material: "steel", joint: "screw" }, parts: [["door", door("steel")], ["dial", knob]] },
52332
52637
  washing_machine: { body: { material: "steel", joint: "screw" }, parts: [["dial", knob], ["door", door("tempered_glass")]] },
52333
52638
  sofa: { body: upholstery, parts: [] },
52334
52639
  armchair: { body: upholstery, parts: [] },
52640
+ pouf: { body: upholstery, parts: [] },
52641
+ box_bed: { body: upholstery, parts: [] },
52642
+ upholstered_chair: { body: upholstery, parts: [] },
52335
52643
  dining_chair: { body: { material: "wood_hard", joint: "screw" }, parts: [] },
52336
52644
  bed_double: { body: { material: "wood_soft", joint: "screw" }, parts: [] },
52337
52645
  bed_single: { body: { material: "wood_soft", joint: "screw" }, parts: [] },
@@ -52348,13 +52656,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52348
52656
  parts: [["flap", door("steel", "hinge", "flap")], ["flag", { material: "steel", joint: "hinge", piece: "flag" }]]
52349
52657
  },
52350
52658
  dog_house: { body: { material: "plywood", joint: "nail" }, parts: [] },
52351
- bbq: { body: { material: "brick", joint: "mortar" }, parts: [["counter_door", door("steel")]] },
52659
+ bbq: { body: { material: "brick", joint: "mortar", units: BRICKWORK }, parts: [["counter_door", door("steel")]] },
52352
52660
  bunk_bed: { body: { material: "wood_soft", joint: "screw" }, parts: [] },
52353
52661
  wood_stove: {
52354
52662
  body: { material: "cast_iron", joint: "bolt" },
52355
52663
  parts: [["firebox_door", { material: "cast_iron", joint: "hinge", piece: "door" }]]
52356
52664
  },
52357
- fireplace: { body: { material: "brick", joint: "mortar" }, parts: [] },
52665
+ fireplace: { body: { material: "brick", joint: "mortar", units: BRICKWORK }, parts: [] },
52358
52666
  outhouse: {
52359
52667
  body: { material: "wood_soft", joint: "nail" },
52360
52668
  parts: [["door", door("wood_soft", "hinge", "door")], ["seat_lid", door("wood_soft", "hinge", "lid")]]
@@ -52403,9 +52711,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52403
52711
  "type.washing_machine": "Washing machine",
52404
52712
  "type.sofa": "Sofa",
52405
52713
  "type.armchair": "Armchair",
52714
+ "type.pouf": "Pouf",
52406
52715
  "type.dining_chair": "Dining chair",
52716
+ "type.upholstered_chair": "Upholstered chair",
52407
52717
  "type.bed_double": "Double bed",
52408
52718
  "type.bed_single": "Single bed",
52719
+ "type.box_bed": "Box bed",
52409
52720
  "type.bench": "Bench",
52410
52721
  "type.blinds": "Blinds",
52411
52722
  "type.curtain": "Curtain",
@@ -52558,6 +52869,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52558
52869
  "prompt.breaker.off": "Switch on {circuit}",
52559
52870
  "prompt.breaker.off.verb": "Switch on",
52560
52871
  "prompt.breaker.off.object": "{circuit}",
52872
+ "prompt.main_breaker": "Main breaker",
52873
+ "prompt.main_breaker.on": "Switch off the main breaker",
52874
+ "prompt.main_breaker.on.verb": "Switch off",
52875
+ "prompt.main_breaker.on.object": "the main breaker",
52876
+ "prompt.main_breaker.off": "Switch on the main breaker",
52877
+ "prompt.main_breaker.off.verb": "Switch on",
52878
+ "prompt.main_breaker.off.object": "the main breaker",
52561
52879
  "type.bunk_bed": "Bunk bed",
52562
52880
  "type.wood_stove": "Wood stove",
52563
52881
  "type.fireplace": "Fireplace",
@@ -52651,9 +52969,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52651
52969
  "type.washing_machine": "M\xE1quina de lavar",
52652
52970
  "type.sofa": "Sof\xE1",
52653
52971
  "type.armchair": "Poltrona",
52972
+ "type.pouf": "Pufe",
52654
52973
  "type.dining_chair": "Cadeira",
52974
+ "type.upholstered_chair": "Cadeira estofada",
52655
52975
  "type.bed_double": "Cama de casal",
52656
52976
  "type.bed_single": "Cama de solteiro",
52977
+ "type.box_bed": "Cama box",
52657
52978
  "type.bench": "Banco",
52658
52979
  "type.blinds": "Persiana",
52659
52980
  "type.curtain": "Cortina",
@@ -52806,6 +53127,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52806
53127
  "prompt.breaker.off": "Ligar {circuit}",
52807
53128
  "prompt.breaker.off.verb": "Ligar",
52808
53129
  "prompt.breaker.off.object": "{circuit}",
53130
+ "prompt.main_breaker": "Disjuntor geral",
53131
+ "prompt.main_breaker.on": "Desligar o disjuntor geral",
53132
+ "prompt.main_breaker.on.verb": "Desligar",
53133
+ "prompt.main_breaker.on.object": "o disjuntor geral",
53134
+ "prompt.main_breaker.off": "Ligar o disjuntor geral",
53135
+ "prompt.main_breaker.off.verb": "Ligar",
53136
+ "prompt.main_breaker.off.object": "o disjuntor geral",
52809
53137
  "type.bunk_bed": "Beliche",
52810
53138
  "type.wood_stove": "Fog\xE3o a lenha",
52811
53139
  "type.fireplace": "Lareira",
@@ -53256,6 +53584,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53256
53584
  pushable: true,
53257
53585
  massKg: 25
53258
53586
  },
53587
+ {
53588
+ id: "pouf",
53589
+ group: "seating",
53590
+ w: 0.45,
53591
+ d: 0.45,
53592
+ h: 0.42,
53593
+ y: 0,
53594
+ solid: true,
53595
+ pushable: true,
53596
+ massKg: 4
53597
+ },
53259
53598
  {
53260
53599
  id: "dining_chair",
53261
53600
  group: "seating",
@@ -53266,6 +53605,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53266
53605
  solid: true,
53267
53606
  massKg: 5
53268
53607
  },
53608
+ {
53609
+ id: "upholstered_chair",
53610
+ group: "seating",
53611
+ w: 0.46,
53612
+ d: 0.52,
53613
+ h: 0.92,
53614
+ y: 0,
53615
+ solid: true,
53616
+ massKg: 6
53617
+ },
53269
53618
  {
53270
53619
  id: "bed_double",
53271
53620
  group: "seating",
@@ -53288,6 +53637,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53288
53637
  pushable: true,
53289
53638
  massKg: 30
53290
53639
  },
53640
+ {
53641
+ id: "box_bed",
53642
+ group: "seating",
53643
+ w: 1.38,
53644
+ d: 1.88,
53645
+ h: 0.72,
53646
+ y: 0,
53647
+ solid: true,
53648
+ pushable: true,
53649
+ massKg: 75
53650
+ },
53291
53651
  {
53292
53652
  id: "bench",
53293
53653
  group: "seating",
@@ -53534,8 +53894,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53534
53894
  "warn.buildEmpty": "construir devolveu vazio para {id}"
53535
53895
  };
53536
53896
  function createTranslator(locale, table) {
53537
- const base = locale && /^pt/i.test(locale) ? ptBR : en;
53538
- const messages = { ...base, ...table ?? {} };
53897
+ const base2 = locale && /^pt/i.test(locale) ? ptBR : en;
53898
+ const messages = { ...base2, ...table ?? {} };
53539
53899
  return (key2, params) => (messages[key2] ?? key2).replace(/\{(\w+)\}/g, (_m, name) => params && params[name] !== void 0 ? String(params[name]) : `{${name}}`);
53540
53900
  }
53541
53901
  var TYPE_MAP = Object.freeze({
@@ -54028,8 +54388,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54028
54388
  var r3 = (n) => Math.round(n * 1e3) / 1e3;
54029
54389
  var CYLINDER_VALVE_Y = 0.47;
54030
54390
  var at = (it) => ({ x: it.x ?? 0, z: it.z ?? 0, ry: it.ry ?? 0 });
54031
- function mergeRegistry(base, extra) {
54032
- const out = { ...base };
54391
+ function mergeRegistry(base2, extra) {
54392
+ const out = { ...base2 };
54033
54393
  if (extra) {
54034
54394
  for (const [key2, value] of Object.entries(extra)) {
54035
54395
  if (value == null) delete out[key2];
@@ -55720,7 +56080,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55720
56080
  rooms: (w, d, op) => {
55721
56081
  const hu0 = r22(w * 0.3), hu1 = r22(w * 0.7), n = floorCount(op, 3), el = !!op.elevator && n > 1;
55722
56082
  const ex = hu0 + (el ? 4.2 : 2.4);
55723
- const base = [
56083
+ const base2 = [
55724
56084
  { id: "sitting_room", type: "living", label: "sitting_room", rect: [0, 0, hu0, 7] },
55725
56085
  { id: "kitchen", type: "kitchen", label: "kitchen", rect: [0, 7, hu0, d - 3.2] },
55726
56086
  { id: "laundry", type: "laundry", label: "laundry", rect: [0, d - 3.2, hu0, d] },
@@ -55731,10 +56091,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55731
56091
  { 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] } } },
55732
56092
  { id: "bathroom", type: "bathroom", label: "bathroom_suite", library: "bathroom_wc", rect: [hu1, d - 3.3, w, d] }
55733
56093
  ];
55734
- if (n > 1) base.push({ id: "stairs", type: "stairs", label: "stairs", rect: [hu0, d - 5, hu0 + 2.4, d], link: [0, 1] });
55735
- if (el) base.push({ id: "elevator", type: "elevator", label: "elevator", rect: [hu0 + 2.4, d - 5, hu0 + 4.2, d] });
55736
- base.push({ id: "office", type: "office", label: "office", rect: [n > 1 ? ex : hu0, d - 5, hu1, d] });
55737
- return base;
56094
+ if (n > 1) base2.push({ id: "stairs", type: "stairs", label: "stairs", rect: [hu0, d - 5, hu0 + 2.4, d], link: [0, 1] });
56095
+ if (el) base2.push({ id: "elevator", type: "elevator", label: "elevator", rect: [hu0 + 2.4, d - 5, hu0 + 4.2, d] });
56096
+ base2.push({ id: "office", type: "office", label: "office", rect: [n > 1 ? ex : hu0, d - 5, hu1, d] });
56097
+ return base2;
55738
56098
  },
55739
56099
  doors: (w, d, op) => {
55740
56100
  const hu0 = r22(w * 0.3), hu1 = r22(w * 0.7), n = floorCount(op, 3), el = !!op.elevator && n > 1;
@@ -56108,7 +56468,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56108
56468
  }
56109
56469
  var residentialTower = residentialTowerTemplate();
56110
56470
 
56111
- // ../game-floorplan-three/dist/chunk-OGYLJ4F7.js
56471
+ // ../game-floorplan-three/dist/chunk-XI3CKQAV.js
56112
56472
  var __defProp4 = Object.defineProperty;
56113
56473
  var __defNormalProp2 = (obj, key2, value) => key2 in obj ? __defProp4(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
56114
56474
  var __publicField2 = (obj, key2, value) => __defNormalProp2(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
@@ -56121,6 +56481,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56121
56481
  "what.door": "the door",
56122
56482
  "what.curtain": "the curtain",
56123
56483
  "what.mailbox": "the mailbox",
56484
+ "what.stallDoor": "the shower door",
56124
56485
  "what.pedestrianGate": "the small gate",
56125
56486
  "what.garageGate": "the garage gate",
56126
56487
  "what.drawer": "drawer",
@@ -56146,6 +56507,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56146
56507
  "what.door": "a porta",
56147
56508
  "what.curtain": "a cortina",
56148
56509
  "what.mailbox": "a caixa de correio",
56510
+ "what.stallDoor": "a porta do box",
56149
56511
  "what.pedestrianGate": "o port\xE3ozinho",
56150
56512
  "what.garageGate": "o port\xE3o da garagem",
56151
56513
  "what.drawer": "gaveta",
@@ -56181,15 +56543,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56181
56543
  for (let axis2 = 0; axis2 < 3; axis2++) {
56182
56544
  const lo = axis2, hi = axis2 + 3;
56183
56545
  if (b[lo] > box5[lo] + EPS6) {
56184
- const piece2 = [...box5];
56185
- piece2[hi] = b[lo];
56186
- out.push(piece2);
56546
+ const piece22 = [...box5];
56547
+ piece22[hi] = b[lo];
56548
+ out.push(piece22);
56187
56549
  box5[lo] = b[lo];
56188
56550
  }
56189
56551
  if (b[hi] < box5[hi] - EPS6) {
56190
- const piece2 = [...box5];
56191
- piece2[lo] = b[hi];
56192
- out.push(piece2);
56552
+ const piece22 = [...box5];
56553
+ piece22[lo] = b[hi];
56554
+ out.push(piece22);
56193
56555
  box5[hi] = b[hi];
56194
56556
  }
56195
56557
  }
@@ -56199,14 +56561,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56199
56561
  const laid = [];
56200
56562
  for (const solid2 of solids2) {
56201
56563
  let pieces = [solid2.box];
56202
- for (const before of laid) pieces = pieces.flatMap((piece2) => subtractBox(piece2, before.box));
56564
+ for (const before of laid) pieces = pieces.flatMap((piece22) => subtractBox(piece22, before.box));
56203
56565
  for (const box5 of pieces) laid.push({ ...solid2, box: box5 });
56204
56566
  }
56205
56567
  return laid;
56206
56568
  }
56207
56569
  function outsideBoxes(box5, taken) {
56208
56570
  let pieces = [box5];
56209
- for (const t of taken) pieces = pieces.flatMap((piece2) => subtractBox(piece2, t));
56571
+ for (const t of taken) pieces = pieces.flatMap((piece22) => subtractBox(piece22, t));
56210
56572
  return pieces;
56211
56573
  }
56212
56574
  function installKernelGeometry(K, shared3) {
@@ -56534,7 +56896,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56534
56896
  nz = -nz;
56535
56897
  [a, b] = [pts[0], pts[1]];
56536
56898
  }
56537
- const [cr, cg, cb] = rgbOf(color2), scale = UV_SCALE[mat] || 1, base = A.nv;
56899
+ const [cr, cg, cb] = rgbOf(color2), scale = UV_SCALE[mat] || 1, base2 = A.nv;
56538
56900
  let e1x = b[0] - a[0], e1y = b[1] - a[1], e1z = b[2] - a[2];
56539
56901
  const l1 = Math.hypot(e1x, e1y, e1z) || 1;
56540
56902
  e1x /= l1;
@@ -56542,7 +56904,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56542
56904
  e1z /= l1;
56543
56905
  const e2x = ny * e1z - nz * e1y, e2y = nz * e1x - nx * e1z, e2z = nx * e1y - ny * e1x;
56544
56906
  pts.forEach((p, k) => {
56545
- const o = base + k;
56907
+ const o = base2 + k;
56546
56908
  A.p[o * 3] = p[0] - O[0];
56547
56909
  A.p[o * 3 + 1] = p[1] - O[1];
56548
56910
  A.p[o * 3 + 2] = p[2] - O[2];
@@ -56557,9 +56919,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56557
56919
  A.u[o * 2 + 1] = (dx * e2x + dy * e2y + dz * e2z) / scale;
56558
56920
  });
56559
56921
  for (let k = 1; k < n - 1; k++) {
56560
- A.i[A.ni++] = base;
56561
- A.i[A.ni++] = base + k;
56562
- A.i[A.ni++] = base + k + 1;
56922
+ A.i[A.ni++] = base2;
56923
+ A.i[A.ni++] = base2 + k;
56924
+ A.i[A.ni++] = base2 + k + 1;
56563
56925
  }
56564
56926
  A.nv += n;
56565
56927
  }
@@ -57918,8 +58280,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57918
58280
  const puts = (f, type, m0, extra) => {
57919
58281
  const ent = T2[type];
57920
58282
  if (!ent) return;
57921
- const com = shared3.ctx.roomById[m0.room], g = "f" + f, base = Y0(f);
57922
- 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: shared3.ctx.colors, seed: m0.id, room: m0.room, typeWith: com ? com.type : null, ceiling: com ? com.ceiling : 2.8, on: shared3.ctx.night, light: shared3.ctx.night, lit: shared3.ctx.night }, extra || {});
58283
+ const com = shared3.ctx.roomById[m0.room], g = "f" + f, base2 = Y0(f);
58284
+ 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: shared3.ctx.colors, seed: m0.id, room: m0.room, typeWith: com ? com.type : null, ceiling: com ? com.ceiling : 2.8, on: shared3.ctx.night, light: shared3.ctx.night, lit: shared3.ctx.night }, extra || {});
57923
58285
  cursor.group = g;
57924
58286
  lightItem({ id: m0.id, room: m0.room }, M, ent, api, g);
57925
58287
  };
@@ -58740,7 +59102,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58740
59102
  }
58741
59103
  const AC = accFor(mat), m = L.length, [cr, cg, cb] = rgbOf(color2), O = cursor.org;
58742
59104
  AC.ensure(m * 2, (m - 1) * 6);
58743
- const base = AC.nv, w2 = 2 * Math.PI / P;
59105
+ const base2 = AC.nv, w2 = 2 * Math.PI / P;
58744
59106
  const profile = (sv) => {
58745
59107
  const ph = sv * w2, hh = A + A * Math.sin(ph), dh = A * w2 * Math.cos(ph), ql = Math.hypot(dh, 1);
58746
59108
  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);
@@ -58756,7 +59118,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58756
59118
  const sv = L[j], [hh, qx, qy, qz, v] = at4(sv);
58757
59119
  const cj = col[j] || col[j - 1] || col[j + 1] || [0, 0];
58758
59120
  for (let k = 0; k < 2; k++) {
58759
- 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;
59121
+ 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;
58760
59122
  AC.p[oo * 3] = px - O[0];
58761
59123
  AC.p[oo * 3 + 1] = py - O[1];
58762
59124
  AC.p[oo * 3 + 2] = pz - O[2];
@@ -58772,7 +59134,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58772
59134
  }
58773
59135
  for (let j = 0; j + 1 < m; j++) {
58774
59136
  if (!col[j] && !col[j + 1]) continue;
58775
- const a0 = base + j * 2, a1 = a0 + 1, b0 = a0 + 2, b1 = a0 + 3;
59137
+ const a0 = base2 + j * 2, a1 = a0 + 1, b0 = a0 + 2, b1 = a0 + 3;
58776
59138
  AC.i[AC.ni++] = a0;
58777
59139
  AC.i[AC.ni++] = b0;
58778
59140
  AC.i[AC.ni++] = a1;
@@ -59472,12 +59834,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59472
59834
  if (x1 - x0 < 1e-4 || y1 - y0 < 1e-4 || z1 - z0 < 1e-4) return;
59473
59835
  for (const [normal, corners] of FACES2) {
59474
59836
  if (openBottom && normal[1] < 0) continue;
59475
- const base = this.positions.length / 3;
59837
+ const base2 = this.positions.length / 3;
59476
59838
  for (const [cx, cy, cz] of corners) {
59477
59839
  this.positions.push(cx ? x1 : x0, cy ? y1 : y0, cz ? z1 : z0);
59478
59840
  this.normals.push(normal[0], normal[1], normal[2]);
59479
59841
  }
59480
- this.indices.push(base, base + 1, base + 2, base, base + 2, base + 3);
59842
+ this.indices.push(base2, base2 + 1, base2 + 2, base2, base2 + 2, base2 + 3);
59481
59843
  }
59482
59844
  }
59483
59845
  /**
@@ -59498,12 +59860,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59498
59860
  const out = [0, 1, 2].reduce((sum2, k) => sum2 + n[k] * ((a[k] + b[k] + c[k] + d[k]) / 4 - centre[k]), 0);
59499
59861
  const ring3 = out >= 0 ? [a, b, c, d] : [a, d, c, b];
59500
59862
  if (out < 0) n = n.map((x) => -x);
59501
- const base = this.positions.length / 3;
59863
+ const base2 = this.positions.length / 3;
59502
59864
  for (const p of ring3) {
59503
59865
  this.positions.push(p[0], p[1], p[2]);
59504
59866
  this.normals.push(n[0], n[1], n[2]);
59505
59867
  }
59506
- this.indices.push(base, base + 1, base + 2, base, base + 2, base + 3);
59868
+ this.indices.push(base2, base2 + 1, base2 + 2, base2, base2 + 2, base2 + 3);
59507
59869
  }
59508
59870
  }
59509
59871
  /** A flat four-cornered face that looks along `normal` (it is wound so). */
@@ -59513,12 +59875,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59513
59875
  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]];
59514
59876
  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];
59515
59877
  const ring3 = facing >= 0 ? corners : [corners[0], corners[3], corners[2], corners[1]];
59516
- const base = this.positions.length / 3;
59878
+ const base2 = this.positions.length / 3;
59517
59879
  for (const p of ring3) {
59518
59880
  this.positions.push(p[0], p[1], p[2]);
59519
59881
  this.normals.push(normal[0], normal[1], normal[2]);
59520
59882
  }
59521
- this.indices.push(base, base + 1, base + 2, base, base + 2, base + 3);
59883
+ this.indices.push(base2, base2 + 1, base2 + 2, base2, base2 + 2, base2 + 3);
59522
59884
  }
59523
59885
  /** The mesh of everything added, or null when nothing was. */
59524
59886
  mesh(THREE, material, name) {
@@ -59688,8 +60050,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59688
60050
  var DOOR_HEAD = 2.1;
59689
60051
  function crossesOpening(plan, a, b, y) {
59690
60052
  return plan.openings.some((o) => {
59691
- const base = plan.floors[o.floor]?.y0 ?? 0;
59692
- if (y <= base + (o.y0 ?? 0) || y >= base + (o.y1 ?? DOOR_HEAD)) return false;
60053
+ const base2 = plan.floors[o.floor]?.y0 ?? 0;
60054
+ if (y <= base2 + (o.y0 ?? 0) || y >= base2 + (o.y1 ?? DOOR_HEAD)) return false;
59693
60055
  const [p0, p1, q0, q1] = o.axis === "u" ? [a[1], b[1], a[0], b[0]] : [a[0], b[0], a[1], b[1]];
59694
60056
  const across2 = Math.min(p0, p1) <= o.pos + 0.1 && Math.max(p0, p1) >= o.pos - 0.1;
59695
60057
  return across2 && Math.max(Math.min(q0, q1), o.at - o.width / 2) < Math.min(Math.max(q0, q1), o.at + o.width / 2);
@@ -59909,10 +60271,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59909
60271
  const w = TRENCH.berm.width;
59910
60272
  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];
59911
60273
  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);
59912
- 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])) {
59913
- if (Math.min(piece2[2] - piece2[0], piece2[3] - piece2[1]) < TRENCH.berm.crest * 2) continue;
59914
- addHumps(heap, piece2);
59915
- laid.push(piece2);
60274
+ 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])) {
60275
+ if (Math.min(piece22[2] - piece22[0], piece22[3] - piece22[1]) < TRENCH.berm.crest * 2) continue;
60276
+ addHumps(heap, piece22);
60277
+ laid.push(piece22);
59916
60278
  }
59917
60279
  }
59918
60280
  });
@@ -60057,7 +60419,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
60057
60419
  function buriedSewerOf(plan) {
60058
60420
  const drains = drainsOf(plan);
60059
60421
  if (!drains.length) return [];
60060
- return sewerLayout(plan, drains).pieces.flatMap((piece2) => piece2.points.slice(1).map((b, i) => ({ a: piece2.points[i], b })));
60422
+ return sewerLayout(plan, drains).pieces.flatMap((piece22) => piece22.points.slice(1).map((b, i) => ({ a: piece22.points[i], b })));
60061
60423
  }
60062
60424
  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 } };
60063
60425
  function feedLayout(plan) {
@@ -60117,10 +60479,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
60117
60479
  const dug = [...layout.trenches, ...rainwater.trenches, ...feeds.trenches, ...boxes.map(pitOf)];
60118
60480
  addSpoil(THREE, group, dug, mats.heap, { solids: solids2, footprint: houseFootprint(routingPlanOf(plan)), buildings: (plan.outbuildings ?? []).map((o) => o.aabb) });
60119
60481
  group.userData.excavations = dug.map(excavationOf);
60120
- for (const piece2 of layout.pieces) addPipe(THREE, group, piece2.points, piece2.bore / 2, mats.pipe);
60482
+ for (const piece22 of layout.pieces) addPipe(THREE, group, piece22.points, piece22.bore / 2, mats.pipe);
60121
60483
  const rainGroup = new THREE.Group();
60122
60484
  rainGroup.name = "rain_drains";
60123
- for (const piece2 of rainwater.pieces) addPipe(THREE, rainGroup, piece2.points, piece2.bore / 2, mats.rain);
60485
+ for (const piece22 of rainwater.pieces) addPipe(THREE, rainGroup, piece22.points, piece22.bore / 2, mats.rain);
60124
60486
  group.add(rainGroup);
60125
60487
  addWarningTape(THREE, group, feeds.runs);
60126
60488
  const yard = new THREE.Group();
@@ -60413,11 +60775,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
60413
60775
  });
60414
60776
  }
60415
60777
  function stagedWallRuns(H) {
60416
- const r = shared3.ctx.r, nA = r.floors.length, plan = routingPlanOf(r), tank2 = r.waterTank, base = shared3.ctx.waterTankPos ? shared3.ctx.waterTankPos.y : tank2 ? tank2.y : atticFloor(plan);
60778
+ const r = shared3.ctx.r, nA = r.floors.length, plan = routingPlanOf(r), tank2 = r.waterTank, base2 = shared3.ctx.waterTankPos ? shared3.ctx.waterTankPos.y : tank2 ? tank2.y : atticFloor(plan);
60417
60779
  if (!tank2) return;
60418
60780
  const xyz = (p) => [p[0], p[1], p[2]];
60419
60781
  const out = [tank2.u, tank2.v - (tank2.d || 1.1) / 2 - 0.2], attic = atticFloor(plan) + ATTIC_LIFT.water;
60420
- 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]]];
60782
+ 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]]];
60421
60783
  cursor.group = shared3.ctx.waterTankPos && shared3.ctx.waterTankPos.group || "f0";
60422
60784
  cursor.pc = pieceRecord("pipe:run_outlet", "plastic", null, { tags: ["pipe"] });
60423
60785
  for (let i = 0; i + 1 < outlet.length; i++) pipe(outlet[i], outlet[i + 1], 0.032, PIPE_COLOR);
@@ -60572,8 +60934,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
60572
60934
  Object.assign(K, defined);
60573
60935
  }
60574
60936
  var EPS23 = 1e-4;
60575
- function subtractRects(base, holes) {
60576
- let pieces = [base];
60937
+ function subtractRects(base2, holes) {
60938
+ let pieces = [base2];
60577
60939
  for (const h of holes) {
60578
60940
  const next = [];
60579
60941
  for (const r of pieces) {
@@ -60714,8 +61076,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
60714
61076
  const depthOn = (side) => {
60715
61077
  const on = over.filter((c) => c.side === side);
60716
61078
  if (!on.length) return 0;
60717
- const least = Math.min(...on.map((c) => c.back)), back = Math.abs(least - mortar) < CHASE_CLEAR_OF_MORTAR ? mortar - CHASE_CLEAR_OF_MORTAR : least;
60718
- return t / 2 - (back - inset);
61079
+ const least = Math.min(...on.map((c) => c.back)), back2 = Math.abs(least - mortar) < CHASE_CLEAR_OF_MORTAR ? mortar - CHASE_CLEAR_OF_MORTAR : least;
61080
+ return t / 2 - (back2 - inset);
60719
61081
  };
60720
61082
  const low = depthOn(-1), high = depthOn(1);
60721
61083
  box5(batch, p0, q0, p1, q1, t - low - high, (low - high) / 2);
@@ -60855,8 +61217,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
60855
61217
  const along2 = wall.alongU ? r.u : r.v, across2 = (wall.alongU ? r.v : r.u) - core.line;
60856
61218
  if (along2 + r.radius + CHASE_CLEAR2 < wall.a0 || along2 - r.radius - CHASE_CLEAR2 > wall.a1 || r.y1 <= core.y0 || r.y0 >= core.y1) continue;
60857
61219
  if (Math.abs(across2) > wall.thickness / 2 + 1e-6) continue;
60858
- const back = Math.abs(across2) - (r.depth ?? r.radius) - CHASE_CLEAR2;
60859
- 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 } : {} });
61220
+ const back2 = Math.abs(across2) - (r.depth ?? r.radius) - CHASE_CLEAR2;
61221
+ 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 } : {} });
60860
61222
  }
60861
61223
  return out;
60862
61224
  }
@@ -61212,8 +61574,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
61212
61574
  const alongU = Math.abs(point.frontV) >= Math.abs(point.frontU);
61213
61575
  const intoRoom = Math.sign(alongU ? point.frontV : point.frontU);
61214
61576
  const face = wall.line + intoRoom * (wall.halfThickness - PLASTER_PER_FACE + WALL_BOX_PROUD);
61215
- const back = face - intoRoom * WALL_BOX.deep;
61216
- const [low, high] = face < back ? [face, back] : [back, face];
61577
+ const back2 = face - intoRoom * WALL_BOX.deep;
61578
+ const [low, high] = face < back2 ? [face, back2] : [back2, face];
61217
61579
  const half = WALL_BOX.along / 2;
61218
61580
  return {
61219
61581
  u0: alongU ? point.u - half : low,
@@ -61362,8 +61724,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
61362
61724
  const M = en22.meter;
61363
61725
  if (M) {
61364
61726
  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;
61365
- const back = shared3.ctx.visorScene ? 0 : 3e-3;
61366
- 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);
61727
+ const back2 = shared3.ctx.visorScene ? 0 : 3e-3;
61728
+ 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);
61367
61729
  const fz = fr < 0 ? [M.v - hd - 0.012, M.v - hd] : [M.v + hd, M.v + hd + 0.012];
61368
61730
  if (!(KV && KV.meter)) {
61369
61731
  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);
@@ -61542,7 +61904,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
61542
61904
  };
61543
61905
  for (const A of ws) for (const [side, sd] of [[A.w.sides[0], -1], [A.w.sides[1], 1]]) {
61544
61906
  if (!sideOf(side, false).exterior) continue;
61545
- const strip = (k, y1, y2, o0, o1, mat, c, piece2, laid = BASEBOARD_TILES) => {
61907
+ const strip = (k, y1, y2, o0, o1, mat, c, piece22, laid = BASEBOARD_TILES) => {
61546
61908
  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;
61547
61909
  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);
61548
61910
  if (s1 - s0 < 1e-3) return;
@@ -61566,7 +61928,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
61566
61928
  runs.push([from, s1]);
61567
61929
  runs.forEach(([r0, r1], k2) => {
61568
61930
  if (r1 - r0 < 1e-3) return;
61569
- const id = piece2 && runs.length > 1 ? `${piece2}:${k2}` : piece2;
61931
+ const id = piece22 && runs.length > 1 ? `${piece22}:${k2}` : piece22;
61570
61932
  if (!id) box5(r0, r1);
61571
61933
  else if (shared3.ctx.baseboardBand) tile(id, r0, r1);
61572
61934
  else {
@@ -61654,12 +62016,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
61654
62016
  const yA = roofHeightAt(p.u, p.v - hd), yB = roofHeightAt(p.u, p.v + hd), yC = roofHeightAt(p.u, p.v);
61655
62017
  let yc, tilt;
61656
62018
  if (onRack) {
61657
- const base = yC != null ? yC : Y0(fa) + 0.02, angle = (S.tilt || 15) * Math.PI / 180, high = Math.sin(angle) * p.length;
62019
+ const base2 = yC != null ? yC : Y0(fa) + 0.02, angle = (S.tilt || 15) * Math.PI / 180, high = Math.sin(angle) * p.length;
61658
62020
  tilt = sv * Math.atan2(high, d);
61659
- yc = base + 0.25 + high / 2;
61660
- const yLow = base + 0.25, yHigh = yLow + high;
61661
- 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);
61662
- 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);
62021
+ yc = base2 + 0.25 + high / 2;
62022
+ const yLow = base2 + 0.25, yHigh = yLow + high;
62023
+ 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);
62024
+ 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);
61663
62025
  } else {
61664
62026
  if (yA == null || yB == null || yC == null) continue;
61665
62027
  tilt = Math.atan2(yA - yB, d);
@@ -61761,7 +62123,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
61761
62123
  }
61762
62124
  function installFurnitureApi(K, shared3) {
61763
62125
  const { _e, _h2, _q, boxC, cursor, macroGround, polyFace, put } = K;
61764
- 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" };
62126
+ 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" };
61765
62127
  const mm = (k) => MATERIAL_MAP2[k] || "plain";
61766
62128
  const LIGHTS = [];
61767
62129
  function makeApi() {
@@ -62512,7 +62874,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62512
62874
  }
62513
62875
  function installFurnitureTaps(K, shared3) {
62514
62876
  shared3.tapCount = 0;
62515
- function counterTap(K2, x, y, z, reach2, back, meta = {}) {
62877
+ function counterTap(K2, x, y, z, reach2, back2, meta = {}) {
62516
62878
  const cr = 12896460, id = "tap_" + (K2.M.seed || "") + "_" + shared3.tapCount++;
62517
62879
  K2.c("metal", x, y, z, 0.028, 0.012, cr);
62518
62880
  K2.c("metal", x, y + 0.012, z, 0.014, 0.12, cr);
@@ -62539,11 +62901,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62539
62901
  );
62540
62902
  const ya = tip[1] - 0.05;
62541
62903
  K2.part("water_tap", tip[0], ya, tip[2], () => {
62542
- K2.t("water", [tip[0], ya, tip[2]], [tip[0], y - back, tip[2]], 6e-3, 13625588);
62904
+ K2.t("water", [tip[0], ya, tip[2]], [tip[0], y - back2, tip[2]], 6e-3, 13625588);
62543
62905
  }, { id: id + "_a", target: id, hidden: true, fluid: "water" });
62544
62906
  return id;
62545
62907
  }
62546
- function wallTap(K2, x, y, zw, direction, back, meta = {}) {
62908
+ function wallTap(K2, x, y, zw, direction, back2, meta = {}) {
62547
62909
  const cr = 12896460, id = "tap_" + (K2.M.seed || "") + "_" + shared3.tapCount++, s = direction || 1;
62548
62910
  K2.t("metal", [x, y, zw], [x, y, zw + s * 0.025], 0.03, cr);
62549
62911
  K2.t("metal", [x, y, zw + s * 0.02], [x, y, zw + s * 0.1], 0.016, cr);
@@ -62566,19 +62928,24 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62566
62928
  );
62567
62929
  const ya = y - 0.08;
62568
62930
  K2.part("water_tap", x, ya, zw + s * 0.105, () => {
62569
- K2.t("water", [x, ya, zw + s * 0.105], [x, back, zw + s * 0.105], 65e-4, 13625588);
62931
+ K2.t("water", [x, ya, zw + s * 0.105], [x, back2, zw + s * 0.105], 65e-4, 13625588);
62570
62932
  }, { id: id + "_a", target: id, hidden: true, fluid: "water" });
62571
62933
  return id;
62572
62934
  }
62573
62935
  const defined = { counterTap, wallTap };
62574
62936
  Object.assign(K, defined);
62575
62937
  }
62938
+ var SHOWER_DOOR = 0.72;
62939
+ var PANEL_THICKNESS = 0.02;
62940
+ var MIN_PANEL = 0.1;
62576
62941
  function installFurnitureFixtures(K, shared3) {
62942
+ const kernel = K;
62577
62943
  const seedKey = (id) => K.seedKey(id);
62578
62944
  const { FURNITURE, MIRRORS, SEED, arcPoints, cursor, kit2, rngString, sh } = K;
62579
62945
  FURNITURE.box = function(M, A) {
62580
62946
  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;
62581
- const R = Math.min(0.32, w * 0.34, d * 0.34), gh = 1.95, gt2 = 8e-3;
62947
+ const walkIn = !shared3.ctx.visorScene;
62948
+ 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, gt2 = 8e-3;
62582
62949
  K2.b("plain", 0, 0, 0, w - 0.02, 0.05, d - 0.02, 15132902);
62583
62950
  K2.c("metal", 0, 0.05, 0, 0.045, 6e-3, 11580600);
62584
62951
  if (shared3.ctx.visorScene) K2.c("plain", 0, 0.05, 0, 0.032, 8e-3, 4212812);
@@ -62591,17 +62958,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62591
62958
  gl(px0, -d / 2 + 0.05, px0, pzF - R);
62592
62959
  const arc = arcPoints(px0 - R, pzF - R, R, 0, Math.PI / 2, 6);
62593
62960
  for (let i = 0; i < arc.length - 1; i++) gl(arc[i][0], arc[i][1], arc[i + 1][0], arc[i + 1][1]);
62594
- const fx1 = Math.max(-w / 2 + 0.36, px0 - R - 0.5);
62595
- gl(px0 - R, pzF, fx1, pzF);
62961
+ const front = walkIn ? Math.min(px0 - R, -w / 2 + 0.03 + SHOWER_DOOR) : Math.max(-w / 2 + 0.36, px0 - R - 0.5);
62962
+ const fx1 = walkIn && px0 - R - front < MIN_PANEL ? px0 - R : front, panel = px0 - R - fx1 > 0.01;
62963
+ if (panel) gl(px0 - R, pzF, fx1, pzF);
62596
62964
  const rail2 = (y, r) => {
62597
62965
  tube2([px0, y, -d / 2 + 0.05], [px0, y, pzF - R], r);
62598
62966
  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);
62599
- tube2([px0 - R, y, pzF], [fx1, y, pzF], r);
62967
+ if (panel) tube2([px0 - R, y, pzF], [fx1, y, pzF], r);
62600
62968
  };
62601
62969
  rail2(gh, 0.011);
62602
62970
  rail2(0.055, 9e-3);
62603
62971
  for (const [x, z] of [[px0, -d / 2 + 0.05], [fx1, pzF]]) tube2([x, 0.05, z], [x, gh + 5e-3, z], 0.011);
62604
- 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);
62972
+ 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);
62605
62973
  const hx = fx1, dw = hx - (-w / 2 + 0.03);
62606
62974
  if (dw > 0.2) K2.part(
62607
62975
  "shower_door",
@@ -62616,6 +62984,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62616
62984
  },
62617
62985
  { id: id + "_door", opens: { type: "swing", axis: [0, 1, 0], angle: -1.7 } }
62618
62986
  );
62987
+ if (walkIn) {
62988
+ const panels = [[px0, -d / 2 + 0.05, px0, pzF - R]];
62989
+ 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]]);
62990
+ if (panel) panels.push([px0 - R, pzF, fx1, pzF]);
62991
+ kernel.walkInSolids(M, { panels, thickness: PANEL_THICKNESS, height: gh, door: dw > 0.2 ? { part: id + "_door", from: [hx, pzF], to: [hx - dw, pzF] } : null });
62992
+ }
62619
62993
  const ax = 0.1, ya = 2.08, z0 = zw + 0.012, Ra = 0.22, n = 6, pa = [];
62620
62994
  for (let i = 0; i <= n; i++) {
62621
62995
  const f = i / n * Math.PI / 2;
@@ -62826,12 +63200,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62826
63200
  var DOOR = { recess: 0.012, thick: 0.02, side: 4e-3, bottom: 0.03 };
62827
63201
  var LOUVRE = { proud: 3e-3, slat: 0.012, pitch: 0.025, count: 4 };
62828
63202
  function gasShelterBoxes({ side, height }) {
62829
- const half = side / 2, back = -half + SHELTER_OFF_WALL;
63203
+ const half = side / 2, back2 = -half + SHELTER_OFF_WALL;
62830
63204
  const boxes = [
62831
- { part: "wall", front: [back, back + WALL], across: [-half, half], y: [0, height] },
62832
- { part: "wall", front: [back + WALL, half], across: [-half, -half + WALL], y: [0, height] },
62833
- { part: "wall", front: [back + WALL, half], across: [half - WALL, half], y: [0, height] },
62834
- { part: "roof", front: [back, half + EAVE2], across: [-half - EAVE2, half + EAVE2], y: [height, height + ROOF] }
63205
+ { part: "wall", front: [back2, back2 + WALL], across: [-half, half], y: [0, height] },
63206
+ { part: "wall", front: [back2 + WALL, half], across: [-half, -half + WALL], y: [0, height] },
63207
+ { part: "wall", front: [back2 + WALL, half], across: [half - WALL, half], y: [0, height] },
63208
+ { part: "roof", front: [back2, half + EAVE2], across: [-half - EAVE2, half + EAVE2], y: [height, height + ROOF] }
62835
63209
  ];
62836
63210
  const doorFace = half - DOOR.recess, doorAcross = [-half + WALL + DOOR.side, half - WALL - DOOR.side];
62837
63211
  boxes.push({ part: "door", front: [doorFace - DOOR.thick, doorFace], across: doorAcross, y: [DOOR.bottom, height - DOOR.bottom] });
@@ -62982,10 +63356,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62982
63356
  if (shelterOf(M)) {
62983
63357
  } else if (M.hose && M.hose.length > 1) {
62984
63358
  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);
62985
- 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 = [];
63359
+ 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 = [];
62986
63360
  for (let k = 0; k <= n; k++) {
62987
63361
  const t = k / n, u = 1 - t;
62988
- 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]]);
63362
+ 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]]);
62989
63363
  }
62990
63364
  for (let k = 0; k < n; k++) K2.t("plain", pts[k], pts[k + 1], 0.011, 12071454);
62991
63365
  K2.c("metal", P2[0], P2[1] - 0.025, P2[2], 0.016, 0.05, brass);
@@ -63176,6 +63550,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
63176
63550
  const { THREE, Y0, _col, boxC, colorOf, cursor, decorLights, makeApi, structurePiece, OPEN_AREA, rectsOf: rectsOf2 } = K;
63177
63551
  const buildItem2 = (...a) => K.buildItem(...a);
63178
63552
  const registerCollision = (...a) => K.registerCollision(...a);
63553
+ const kitCollides = (...a) => K.kitCollides(...a);
63179
63554
  const vegItem = (...a) => K.vegItem(...a);
63180
63555
  const SLAB_UNDERSIDE = 0.24;
63181
63556
  function houseItems() {
@@ -63199,8 +63574,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
63199
63574
  if (exterior && m.category === "ground_cover" && shared3.ctx.noGroundSurfaces) continue;
63200
63575
  const f = exterior ? -1 : Math.min(m.floor, R.floors.length - 1);
63201
63576
  cursor.group = exterior && !(m.type === "cooking_gas_cylinder" && m.shelter && !shared3.ctx.visorScene) ? "lot" : "f" + Math.max(f, 0);
63202
- const com = m.room != null ? shared3.ctx.roomById[m.room] : void 0, lift = !exterior && f === 0 && shared3.ctx.constructionStages && !shared3.ctx.visorScene && !com?.outbuilding ? FLOOR_OVER_GROUND : 0, base = exterior ? 0 : Y0(f) + lift;
63203
- const M = { visorScene: shared3.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: shared3.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: shared3.ctx.night, light: shared3.ctx.night, lit: shared3.ctx.night, open: !!m.doorOpen, overhead: m.overhead, assembly: m.assembly, hose: m.hose, shelter: m.shelter, pipe: m.pipe };
63577
+ const com = m.room != null ? shared3.ctx.roomById[m.room] : void 0, lift = !exterior && f === 0 && shared3.ctx.constructionStages && !shared3.ctx.visorScene && !com?.outbuilding ? FLOOR_OVER_GROUND : 0, base2 = exterior ? 0 : Y0(f) + lift;
63578
+ const M = { visorScene: shared3.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: shared3.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: shared3.ctx.night, light: shared3.ctx.night, lit: shared3.ctx.night, open: !!m.doorOpen, overhead: m.overhead, assembly: m.assembly, hose: m.hose, shelter: m.shelter, pipe: m.pipe };
63204
63579
  if (!exterior && !shared3.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));
63205
63580
  if (lift) M.ceiling = (M.ceiling ?? 2.9) - lift;
63206
63581
  if (!exterior && !shared3.ctx.visorScene && f > 0) overRoof(m, M, f);
@@ -63243,13 +63618,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
63243
63618
  }
63244
63619
  }
63245
63620
  if (shared3.ctx.iv && shared3.ctx.iv.replace.has(m.id)) {
63246
- registerCollision(m, M);
63621
+ if (!kitCollides(m)) registerCollision(m, M);
63247
63622
  continue;
63248
63623
  }
63249
63624
  const ent = T2[m.type];
63250
63625
  const st0 = cursor.stage;
63251
63626
  if (shared3.ctx.constructionStages && (m.type === "cooking_gas_cylinder" || m.type === "gas_cylinder" || m.type === "water_tank")) cursor.stage = "installations";
63252
- shared3.ctx.restOn = exterior || shared3.ctx.visorScene ? void 0 : base;
63627
+ shared3.ctx.restOn = exterior || shared3.ctx.visorScene ? void 0 : base2;
63253
63628
  if (!shared3.ctx.visorScene) {
63254
63629
  const quarter = Math.round(M.ry / (Math.PI / 2));
63255
63630
  if (Math.abs(M.ry - quarter * Math.PI / 2) < 0.01) M.ry = quarter * Math.PI / 2;
@@ -63366,7 +63741,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
63366
63741
  return;
63367
63742
  }
63368
63743
  const lc = cd.place === "raised_slab" && cd.platform, slab = cd.place === "slab" || !!lc, nA = shared3.ctx.r.floors.length, f = Math.max(0, Math.min(nA - 1, cd.floor));
63369
- const base = lc ? cd.platform.topY : cd.y + (shared3.ctx.r.rooms.some((c) => c.id === cd.room && c.type === "terrace") ? 0 : 0.2 + (slab ? 0.03 : 0));
63744
+ const base2 = lc ? cd.platform.topY : cd.y + (shared3.ctx.r.rooms.some((c) => c.id === cd.room && c.type === "terrace") ? 0 : 0.2 + (slab ? 0.03 : 0));
63370
63745
  cursor.group = slab ? "f" + f : "attic_tank";
63371
63746
  const platformLift = !slab && !shared3.ctx.visorScene ? 0.12 : 0;
63372
63747
  if (lc) {
@@ -63385,12 +63760,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
63385
63760
  }
63386
63761
  if (!slab) {
63387
63762
  const color2 = shared3.ctx.colors.slab != null ? shared3.ctx.colors.slab : 12170668, yp = Y0(f), hw = cd.w / 2 + 0.1, hd = cd.d / 2 + 0.1;
63388
- const top = base + platformLift;
63763
+ const top = base2 + platformLift;
63389
63764
  boxC("plain", cd.u, top - 0.06, cd.v, hw * 2, 0.12, hd * 2, color2);
63390
- 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);
63765
+ 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);
63391
63766
  }
63392
- 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: shared3.ctx.colors, seed: "water_tank", room: cd.room, onSlab: true, ceiling: 2.9 };
63393
- shared3.ctx.waterTankPos = { x: cd.u, z: cd.v, y: base + platformLift, group: cursor.group };
63767
+ 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: shared3.ctx.colors, seed: "water_tank", room: cd.room, onSlab: true, ceiling: 2.9 };
63768
+ shared3.ctx.waterTankPos = { x: cd.u, z: cd.v, y: base2 + platformLift, group: cursor.group };
63394
63769
  shared3.ctx.types.water_tank.f(M, api);
63395
63770
  }
63396
63771
  function trestleTank(api, cd) {
@@ -63791,8 +64166,29 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
63791
64166
  const d1 = objectDistance(o, x, z);
63792
64167
  if (d1 < R && d1 < objectDistance(o, fx, fz) - 1e-6) return true;
63793
64168
  }
64169
+ return collideKit(x, z, fx, fz, floor2, R);
64170
+ }
64171
+ function collideKit(x, z, fx, fz, floor2, R) {
64172
+ const iv = shared3.ctx.iv, collided = iv && iv.collided;
64173
+ if (!iv || !collided || !collided.size) return false;
64174
+ for (const k of iv.world.colliders()) {
64175
+ const f = collided.get(k.object);
64176
+ if (f === void 0 || (f !== -1 ? f !== floor2 : floor2 !== 0)) continue;
64177
+ 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" };
64178
+ const d1 = objectDistance(o, x, z);
64179
+ if (d1 < R && d1 < objectDistance(o, fx, fz) - 1e-6) return true;
64180
+ }
63794
64181
  return false;
63795
64182
  }
64183
+ function kitCollides(m) {
64184
+ const iv = shared3.ctx.iv;
64185
+ if (!iv) return false;
64186
+ const own = [...iv.entries.values()].filter((e) => e.origin === m.id && (e.spec.colliders?.length ?? 0) > 0);
64187
+ if (!own.length) return false;
64188
+ const collided = iv.collided || (iv.collided = /* @__PURE__ */ new Map());
64189
+ for (const e of own) collided.set(e.id, e.floor);
64190
+ return true;
64191
+ }
63796
64192
  function collideAt(x, z, floor2, opt) {
63797
64193
  opt = opt || {};
63798
64194
  const R = opt.radius != null ? opt.radius : 0.24;
@@ -63806,7 +64202,24 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
63806
64202
  const de = opt.from || [x + 1e4, z + 1e4];
63807
64203
  return collideObject(x, z, de[0], de[1], floor2);
63808
64204
  }
63809
- const defined = { NO_COLLIDE, registerCollision, objectDistance, collideObject, collideAt };
64205
+ function walkInSolids(M, spec) {
64206
+ const objs = shared3.inter?.objs, colliders = shared3.ctx.colliders;
64207
+ if (!objs || !colliders) return;
64208
+ const at4 = objs.findIndex((o) => o.cx === M.x && o.cz === M.z && o.f === M.floor);
64209
+ const kept = at4 >= 0 ? objs.splice(at4, 1)[0] : void 0;
64210
+ const type = kept?.type ?? "walk_in";
64211
+ const half = spec.thickness / 2;
64212
+ for (const [x0, z0, x1, z1] of spec.panels) {
64213
+ const length2 = Math.hypot(x1 - x0, z1 - z0);
64214
+ if (length2 < 1e-3) continue;
64215
+ const [cx, cz] = K.localOf(M, (x0 + x1) / 2, (z0 + z1) / 2), turn2 = (M.ry || 0) + Math.atan2(-(z1 - z0), x1 - x0);
64216
+ objs.push({ f: M.floor, cx, cz, c: Math.cos(turn2), s: Math.sin(turn2), hw: length2 / 2, hd: half, h: spec.height, type });
64217
+ }
64218
+ if (!spec.door) return;
64219
+ 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]);
64220
+ 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 });
64221
+ }
64222
+ const defined = { NO_COLLIDE, registerCollision, objectDistance, collideObject, collideAt, walkInSolids, kitCollides };
63810
64223
  Object.assign(K, defined);
63811
64224
  }
63812
64225
  function installInteractionItems(K, shared3) {
@@ -64013,13 +64426,26 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
64013
64426
  const g = r.g;
64014
64427
  if (!isFinite(r.x0)) return;
64015
64428
  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";
64016
- const base = { parent: "lot", ry: 0, t0: g.open ? 1 : 0, col: cols[i], gate: g };
64017
- 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 }));
64429
+ const base2 = { parent: "lot", ry: 0, t0: g.open ? 1 : 0, col: cols[i], gate: g };
64430
+ 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 }));
64018
64431
  if (p.col) p.col.off = p.target > 0.5;
64019
64432
  const text = () => t(p.target > 0.5 ? "prompt.close" : "prompt.open", { what: t(ped ? "what.pedestrianGate" : "what.garageGate") });
64020
64433
  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 });
64021
64434
  });
64022
64435
  }
64436
+ function walkInInteractive() {
64437
+ for (const c of shared3.ctx.colliders) {
64438
+ if (c.type !== "walk_in_door" || typeof c.piece !== "string") continue;
64439
+ const g = shared3.ctx.parts && shared3.ctx.parts[c.piece];
64440
+ if (!g) continue;
64441
+ const def = definePiece("ix:walkin:" + c.piece, { kind: "part", pivot: [0, 0, 0], ry: 0, parent: "lot" });
64442
+ def.inner = g;
64443
+ def.col = c;
64444
+ c.off = def.t > 0.5;
64445
+ 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) });
64446
+ applyPiece(def);
64447
+ }
64448
+ }
64023
64449
  function mailboxInteractive() {
64024
64450
  for (const m of house().items) {
64025
64451
  if (m.type !== "mailbox") continue;
@@ -64077,15 +64503,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
64077
64503
  else bx("plain", Math.min(f2, f3), yc - 0.032, u - 0.016, Math.max(f2, f3), yc + 0.032, u + 0.016, 16250092);
64078
64504
  cursor.group = g0;
64079
64505
  const pv = alongU ? [u, yc, f2] : [f2, yc, u];
64080
- 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 });
64081
- piece2.t = piece2.target = lightOn(roomId) ? 1 : 0;
64506
+ 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 });
64507
+ piece22.t = piece22.target = lightOn(roomId) ? 1 : 0;
64082
64508
  const an = alongU ? [u, yc, face + sd * 0.12] : [face + sd * 0.12, yc, u];
64083
- 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) });
64509
+ 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) });
64084
64510
  return true;
64085
64511
  }
64086
64512
  return false;
64087
64513
  }
64088
- const defined = { gatesInteractive, mailboxInteractive, placeSwitches, putSwitch };
64514
+ const defined = { walkInInteractive, gatesInteractive, mailboxInteractive, placeSwitches, putSwitch };
64089
64515
  Object.assign(K, defined);
64090
64516
  }
64091
64517
  function installInteractionDoors(K, shared3) {
@@ -64248,7 +64674,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
64248
64674
  const { t, THREE, invalidate, invalidateShadow, cfg, DOC, LIGHT_TYPES, _Y, _q, _v3, accFor, applyLight, cursor, hashString, hudMessage, lightBase, pieceRecord, rgbOf, wallBlocks } = K;
64249
64675
  const enter = (...a) => K.enter(...a);
64250
64676
  const roomLightMask = (...a) => K.roomLightMask(...a);
64251
- 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" };
64677
+ 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" };
64252
64678
  const IV_WIRE = { conduit: 13618628, cable: 2762532, drop: 1381653, cord: 1776413, earth: 3111482, hose: 11556124 };
64253
64679
  const IV_DOOR = /^(door|drawer)/;
64254
64680
  const ivGroup = (e) => e.floor < 0 ? "lot" : "f" + Math.min(e.floor, shared3.ctx.r.floors.length - 1);
@@ -64318,7 +64744,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
64318
64744
  const entById = new Map(plane2.items.map((e) => [e.id, e]));
64319
64745
  const entByItem = new Map(plane2.items.map((e) => [e.item, e]));
64320
64746
  const mats = shared3.mats;
64321
- IV.mats = { plain: mats.plain, metal: shared3.mats.metal, wood: shared3.mats.wood, glass: shared3.mats.glass, fabric: shared3.mats.fabric, plant: shared3.mats.plant, water: shared3.mats.water, emissive: shared3.mats.emissive, atlas_picture: shared3.mats.picture, atlas_floor: shared3.mats.floor };
64747
+ IV.mats = { plain: mats.plain, metal: shared3.mats.metal, wood: shared3.mats.wood, glass: shared3.mats.glass, fabric: shared3.mats.fabric, foam: shared3.mats.fabric, plant: shared3.mats.plant, water: shared3.mats.water, emissive: shared3.mats.emissive, atlas_picture: shared3.mats.picture, atlas_floor: shared3.mats.floor };
64322
64748
  const ev = (e) => ivEvent(h, e);
64323
64749
  const world = IV.world = A.createWorld(source, { water, seed: r.seed, onEvent: ev });
64324
64750
  const add0 = world.add;
@@ -64429,7 +64855,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
64429
64855
  cursor.stage = stage0;
64430
64856
  cursor.pc = pieceBefore;
64431
64857
  }
64432
- const base = new Set(Object.values(IV.mats));
64858
+ const base2 = new Set(Object.values(IV.mats));
64433
64859
  root.traverse((o) => {
64434
64860
  if (!isMesh(o)) return;
64435
64861
  o.userData.iv = ent.id;
@@ -64437,7 +64863,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
64437
64863
  if (!o.geometry.boundingSphere) o.geometry.computeBoundingSphere();
64438
64864
  if (o.geometry.boundingSphere.radius < 0.07) o.castShadow = false;
64439
64865
  }
64440
- 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) {
64866
+ 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) {
64441
64867
  m.userData.roomLightMask = false;
64442
64868
  roomLightMask(m);
64443
64869
  }
@@ -64739,6 +65165,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
64739
65165
  roomStates: IV.roomStates,
64740
65166
  warnings: IV.warnings,
64741
65167
  water: IV.water,
65168
+ solidColliders: () => {
65169
+ const c = IV.collided;
65170
+ return c && c.size ? w.colliders().flatMap((k) => {
65171
+ const floor2 = c.get(k.object);
65172
+ return floor2 === void 0 ? [] : [{ ...k, floor: floor2 }];
65173
+ }) : [];
65174
+ },
64742
65175
  screens: IV.screens,
64743
65176
  effects: () => IV.efx || null,
64744
65177
  // TV screens (id -> kit screen) and the particle system (smoke), for whoever wants to inspect
@@ -65360,8 +65793,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
65360
65793
  return { depth: Math.max(drawn, declared2?.depth ?? 0), width: declared2?.width ?? Math.max(u1 - u0, v1 - v0) };
65361
65794
  }
65362
65795
  function groundJointStrength(part, kind) {
65363
- const base = buriedBase(part);
65364
- return base.depth > 0 ? embedmentStrength(kind, base) : void 0;
65796
+ const base2 = buriedBase(part);
65797
+ return base2.depth > 0 ? embedmentStrength(kind, base2) : void 0;
65365
65798
  }
65366
65799
  var NONE = { panels: [], replaced: [], supports: [] };
65367
65800
  var MEMO = /* @__PURE__ */ new WeakMap();
@@ -65473,7 +65906,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
65473
65906
  parts2.push(p);
65474
65907
  byId.set(p.id, p);
65475
65908
  }
65476
- const base = parts2.length, view = shared3.ctx.panelView || panelViewOf(null, false), panelIds = new Set(view.panels.map((e) => e.id));
65909
+ const base2 = parts2.length, view = shared3.ctx.panelView || panelViewOf(null, false), panelIds = new Set(view.panels.map((e) => e.id));
65477
65910
  for (const [id, pc] of shared3.ctx.pieces) {
65478
65911
  if (byId.has(id) || panelIds.has(id) || !meshes.has(id)) continue;
65479
65912
  const b = box32(id);
@@ -65503,7 +65936,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
65503
65936
  const floorUnder = (p) => {
65504
65937
  const cx = (p.aabb[0] + p.aabb[2]) / 2, cz = (p.aabb[1] + p.aabb[3]) / 2;
65505
65938
  let best = null;
65506
- for (const q of parts2.slice(0, base)) {
65939
+ for (const q of parts2.slice(0, base2)) {
65507
65940
  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;
65508
65941
  if (!best || q.y1 > best.y1 || q.y1 === best.y1 && q.id < best.id) best = q;
65509
65942
  }
@@ -65536,7 +65969,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
65536
65969
  return { part: p.id, on: "ground", joint: joint2, bears: false, extra: true, ...strength !== void 0 ? { strength } : {} };
65537
65970
  };
65538
65971
  const unheld = [];
65539
- for (const p of parts2.slice(base)) {
65972
+ for (const p of parts2.slice(base2)) {
65540
65973
  if (/^sidewalk:/.test(p.id)) {
65541
65974
  supports.push({ part: p.id, on: "ground", joint: "mortar", extra: true });
65542
65975
  continue;
@@ -65564,7 +65997,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
65564
65997
  if (!/^(window|window_pane|door|jamb|pipe|water_tank|baseboard)/.test(p.id)) continue;
65565
65998
  const target = /^water_tank/.test(p.id) ? ["slab"] : ["wall", "partition"];
65566
65999
  let m = null, md = 1e9;
65567
- for (const q of parts2.slice(0, base)) {
66000
+ for (const q of parts2.slice(0, base2)) {
65568
66001
  if (!target.includes(q.role) || !inside22(p, q, 0.2)) continue;
65569
66002
  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);
65570
66003
  if (d < md) {
@@ -65572,7 +66005,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
65572
66005
  m = q;
65573
66006
  }
65574
66007
  }
65575
- if (!m && /^(window|door|jamb)/.test(p.id)) for (const q of parts2.slice(0, base)) {
66008
+ if (!m && /^(window|door|jamb)/.test(p.id)) for (const q of parts2.slice(0, base2)) {
65576
66009
  if (!["wall", "partition", "column", "beam"].includes(q.role) || !touches2(p, q, 0.02)) continue;
65577
66010
  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);
65578
66011
  if (d < md) {
@@ -65710,6 +66143,119 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
65710
66143
  if (distance4 <= -depth) return true;
65711
66144
  return distance4 <= -depth * noise3();
65712
66145
  }
66146
+ var JOINT_SHARE = 0.5;
66147
+ var EPSILON22 = 1e-4;
66148
+ function carve(boxes, grid) {
66149
+ const { data, w, h, len, y0, height } = grid;
66150
+ const out = [];
66151
+ for (const box5 of boxes) {
66152
+ const j0 = Math.max(0, Math.floor((box5.y0 - y0) / height * h)), j1 = Math.min(h - 1, Math.ceil((box5.y1 - y0) / height * h) - 1);
66153
+ const i0 = Math.max(0, Math.floor(box5.a / len * w)), i1 = Math.min(w - 1, Math.ceil(box5.b / len * w) - 1);
66154
+ if (j1 < j0 || i1 < i0) {
66155
+ out.push(box5);
66156
+ continue;
66157
+ }
66158
+ for (let j = j0; j <= j1; j++) {
66159
+ const ry0 = Math.max(box5.y0, y0 + j / h * height), ry1 = Math.min(box5.y1, y0 + (j + 1) / h * height);
66160
+ let start = -1;
66161
+ for (let i = i0; i <= i1 + 1; i++) {
66162
+ const solid2 = i <= i1 && data[j * w + i] <= 127;
66163
+ if (solid2 && start < 0) start = i;
66164
+ if (!solid2 && start >= 0) {
66165
+ out.push({ a: Math.max(box5.a, start / w * len), b: Math.min(box5.b, i / w * len), y0: ry0, y1: ry1 });
66166
+ start = -1;
66167
+ }
66168
+ }
66169
+ }
66170
+ }
66171
+ return out;
66172
+ }
66173
+ var groupBy = (items, keyOf2) => {
66174
+ const groups = /* @__PURE__ */ new Map();
66175
+ for (const item of items) {
66176
+ const key2 = keyOf2(item);
66177
+ const group = groups.get(key2);
66178
+ if (group) group.push(item);
66179
+ else groups.set(key2, [item]);
66180
+ }
66181
+ return [...groups.values()];
66182
+ };
66183
+ function mergeSpans(spans, share = JOINT_SHARE) {
66184
+ const runs = [];
66185
+ const unitLengths = /* @__PURE__ */ new Map();
66186
+ for (const row of groupBy(spans, (s) => `${s.y0.toFixed(4)}:${s.y1.toFixed(4)}`)) {
66187
+ row.sort((p, q) => p.a - q.a);
66188
+ let run = { ...row[0] };
66189
+ let unitLength = run.b - run.a;
66190
+ for (const s of row.slice(1)) {
66191
+ if (s.a - run.b <= share * Math.min(s.b - s.a, unitLength) + EPSILON22) run.b = Math.max(run.b, s.b);
66192
+ else {
66193
+ runs.push(run);
66194
+ unitLengths.set(run, unitLength);
66195
+ run = { ...s };
66196
+ }
66197
+ unitLength = s.b - s.a;
66198
+ }
66199
+ runs.push(run);
66200
+ unitLengths.set(run, unitLength);
66201
+ }
66202
+ const out = [];
66203
+ const open = [];
66204
+ for (const r of [...runs].sort((p, q) => p.y0 - q.y0 || p.a - q.a)) {
66205
+ const height = r.y1 - r.y0;
66206
+ const top = open.find((o) => {
66207
+ const slack = share * Math.min(o.unitLength, r.b - r.a) + EPSILON22;
66208
+ 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;
66209
+ });
66210
+ if (top) {
66211
+ top.box.y1 = r.y1;
66212
+ top.box.a = Math.min(top.box.a, r.a);
66213
+ top.box.b = Math.max(top.box.b, r.b);
66214
+ top.unitHeight = height;
66215
+ } else {
66216
+ const box5 = { ...r };
66217
+ out.push(box5);
66218
+ open.push({ box: box5, unitHeight: height, unitLength: unitLengths.get(r) ?? r.b - r.a });
66219
+ }
66220
+ }
66221
+ return out;
66222
+ }
66223
+ function standingSolids(THREE, house, mesh3, line, parts2) {
66224
+ house.updateWorldMatrix(true, false);
66225
+ mesh3.updateWorldMatrix(true, false);
66226
+ const toMesh = new THREE.Matrix4().copy(mesh3.matrixWorld).invert().multiply(house.matrixWorld);
66227
+ const turn2 = new THREE.Quaternion();
66228
+ const scale = new THREE.Vector3();
66229
+ toMesh.decompose(new THREE.Vector3(), turn2, scale);
66230
+ const point = new THREE.Vector3();
66231
+ const out = [];
66232
+ for (const part of parts2) {
66233
+ const boxes = mergeSpans(part.spans);
66234
+ for (const s of line.open ? mergeSpans(carve(boxes, line.open), 0) : boxes) {
66235
+ const along2 = line.start + (s.a + s.b) / 2;
66236
+ point.set(line.alongU ? along2 : part.mid, (s.y0 + s.y1) / 2, line.alongU ? part.mid : along2).applyMatrix4(toMesh);
66237
+ const length2 = (s.b - s.a) / 2, up = (s.y1 - s.y0) / 2, across2 = part.thick / 2;
66238
+ out.push({
66239
+ center: [point.x, point.y, point.z],
66240
+ half: [(line.alongU ? length2 : across2) * scale.x, up * scale.y, (line.alongU ? across2 : length2) * scale.z],
66241
+ rotation: [turn2.x, turn2.y, turn2.z, turn2.w],
66242
+ kind: "box"
66243
+ });
66244
+ }
66245
+ }
66246
+ return out;
66247
+ }
66248
+ function publishSolids(mesh3, v0, v1, solids2) {
66249
+ const u = mesh3.userData;
66250
+ u.drawnSolids = [...(u.drawnSolids ?? []).filter((entry2) => entry2.v0 !== v0), { v0, v1, solids: solids2 }];
66251
+ u.drawnSolidsVersion = (u.drawnSolidsVersion ?? 0) + 1;
66252
+ }
66253
+ function withdrawSolids(mesh3, v0) {
66254
+ const u = mesh3.userData;
66255
+ if (!u.drawnSolids?.some((entry2) => entry2.v0 === v0)) return;
66256
+ u.drawnSolids = u.drawnSolids.filter((entry2) => entry2.v0 !== v0);
66257
+ u.drawnSolidsVersion = (u.drawnSolidsVersion ?? 0) + 1;
66258
+ }
65713
66259
  function collapseRange(mesh3, v0, v1) {
65714
66260
  const pos = mesh3.geometry.attributes.position;
65715
66261
  const a = pos.array;
@@ -65734,6 +66280,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
65734
66280
  markPositionsWritten(mesh3, v0, v0 + saved.length / 3);
65735
66281
  const list2 = mesh3.userData.collapsedRanges;
65736
66282
  if (list2) mesh3.userData.collapsedRanges = list2.filter((r) => r[0] !== v0);
66283
+ withdrawSolids(mesh3, v0);
65737
66284
  }
65738
66285
  function noise2(x, y, cell) {
65739
66286
  const h = (i2, j2) => {
@@ -66057,11 +66604,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
66057
66604
  }
66058
66605
  g.computeBoundingBox();
66059
66606
  g.computeBoundingSphere();
66060
- const base = it.mesh.material;
66061
- const material = base.clone();
66607
+ const base2 = it.mesh.material;
66608
+ const material = base2.clone();
66062
66609
  const toHouse = { value: new THREE.Matrix4() };
66063
66610
  material.onBeforeCompile = (sh) => {
66064
- base.onBeforeCompile?.(sh);
66611
+ base2.onBeforeCompile?.(sh);
66065
66612
  sh.uniforms.uToHouse = toHouse;
66066
66613
  sh.uniforms.uMask = { value: mask.texture };
66067
66614
  sh.uniforms.uMaskRect = { value: mask.rect };
@@ -66069,7 +66616,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
66069
66616
  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;");
66070
66617
  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;");
66071
66618
  };
66072
- material.customProgramCacheKey = () => "breachMask" + (base.customProgramCacheKey?.() ?? "");
66619
+ material.customProgramCacheKey = () => "breachMask" + (base2.customProgramCacheKey?.() ?? "");
66073
66620
  const mesh3 = new THREE.Mesh(g, material);
66074
66621
  mesh3.name = "breach-shell";
66075
66622
  mesh3.userData.breachMask = mask;
@@ -66184,6 +66731,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
66184
66731
  const around = { pillars: pillarSpans(view), gaps: windowGaps(view) };
66185
66732
  for (const id of view.parts) view.kept.set(id, splitUnits(view, id, around).kept);
66186
66733
  view.keptStale = false;
66734
+ publishStanding(view);
66735
+ }
66736
+ function publishStanding(view) {
66737
+ if (!view.saved) return;
66738
+ const { mask } = view;
66739
+ const parts2 = view.parts.map((id) => {
66740
+ const part = structure.byId.get(id);
66741
+ const thick = mask.alongU ? part.aabb[3] - part.aabb[1] : part.aabb[2] - part.aabb[0];
66742
+ const mid = mask.alongU ? (part.aabb[1] + part.aabb[3]) / 2 : (part.aabb[0] + part.aabb[2]) / 2;
66743
+ return { spans: view.kept.get(id) ?? [], thick, mid };
66744
+ });
66745
+ const line = { alongU: mask.alongU, start: mask.start, open: view.core };
66746
+ view.items.forEach((it, k) => publishSolids(it.mesh, it.v0, it.v1, k === 0 ? standingSolids(THREE, house, it.mesh, line, parts2) : []));
66187
66747
  }
66188
66748
  function paint2(view) {
66189
66749
  const { mask, core } = view;
@@ -66258,13 +66818,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
66258
66818
  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);
66259
66819
  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);
66260
66820
  };
66261
- const base = fragmentMaterial(part.material).color.getHex();
66821
+ const base2 = fragmentMaterial(part.material).color.getHex();
66262
66822
  const n = noise2(centre * 3.1, y * 2.7, 0.07);
66263
66823
  if (units2.mortar === "concrete") {
66264
- at4(len, h, thick - 2 * COVER2, tone(base, 0.9 + 0.04 * n));
66824
+ at4(len, h, thick - 2 * COVER2, tone(base2, 0.9 + 0.04 * n));
66265
66825
  } else {
66266
66826
  at4(len, h, thick - 2 * COVER2 - 0.012, 10327948);
66267
- at4(len - 0.012, h - 0.012, thick - 2 * COVER2, tone(base, 0.8 + 0.35 * n));
66827
+ at4(len - 0.012, h - 0.012, thick - 2 * COVER2, tone(base2, 0.8 + 0.35 * n));
66268
66828
  }
66269
66829
  }
66270
66830
  const lumps = stuckLumps(castGone, mask, view.bounds);
@@ -66288,6 +66848,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
66288
66848
  view.gone = holes.length;
66289
66849
  view.pits = pits.length;
66290
66850
  view.flakes = flakes.length;
66851
+ publishStanding(view);
66291
66852
  }
66292
66853
  function chipBox(chip, alongU) {
66293
66854
  house.updateWorldMatrix(true, false);
@@ -66399,6 +66960,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
66399
66960
  view.shells = view.items.map((it) => shell(it, view.mask));
66400
66961
  for (const m of view.shells) m.userData.behind = () => view.units;
66401
66962
  view.saved = view.items.map((it) => ({ it, v0: it.v0, data: collapseRange(it.mesh, it.v0, it.v1) }));
66963
+ refreshKept(view);
66402
66964
  }
66403
66965
  function draw2(partId, change) {
66404
66966
  if (lod !== 0) return false;
@@ -66449,6 +67011,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
66449
67011
  if (shown2) restoreRange(s.it.mesh, s.v0, s.data);
66450
67012
  else s.data = collapseRange(s.it.mesh, s.v0, s.it.v1);
66451
67013
  }
67014
+ if (!shown2) publishStanding(view);
66452
67015
  }
66453
67016
  function flush(budgetMs) {
66454
67017
  if (budgetMs !== void 0 || !cutState.attached) paintCut();
@@ -67415,9 +67978,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
67415
67978
  walk(house, void 0);
67416
67979
  return stages;
67417
67980
  }
67418
- function stageOfPiece(piece2, stages) {
67981
+ function stageOfPiece(piece22, stages) {
67419
67982
  let found;
67420
- piece2.root.traverse((o) => {
67983
+ piece22.root.traverse((o) => {
67421
67984
  if (found) return;
67422
67985
  const part = o.userData?.destructionPart;
67423
67986
  if (typeof part === "string") found = stages.get(part);
@@ -67426,20 +67989,20 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
67426
67989
  }
67427
67990
  function stageLoosePieces(pieces, stages, level, opts, held) {
67428
67991
  let hidden = 0;
67429
- for (const piece2 of pieces) {
67430
- const stage2 = stageOfPiece(piece2, stages);
67992
+ for (const piece22 of pieces) {
67993
+ const stage2 = stageOfPiece(piece22, stages);
67431
67994
  if (!stage2) continue;
67432
67995
  const shown2 = stageVisible(stage2, level, opts);
67433
- piece2.root.visible = shown2;
67996
+ piece22.root.visible = shown2;
67434
67997
  if (!shown2) {
67435
67998
  hidden++;
67436
- if (!piece2.held) {
67437
- piece2.held = true;
67438
- held.add(piece2);
67999
+ if (!piece22.held) {
68000
+ piece22.held = true;
68001
+ held.add(piece22);
67439
68002
  }
67440
- } else if (held.has(piece2)) {
67441
- piece2.held = false;
67442
- held.delete(piece2);
68003
+ } else if (held.has(piece22)) {
68004
+ piece22.held = false;
68005
+ held.delete(piece22);
67443
68006
  }
67444
68007
  }
67445
68008
  return hidden;
@@ -67821,7 +68384,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
67821
68384
  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 };
67822
68385
  }
67823
68386
  function installBuildBuild(K, shared3) {
67824
- const { THREE, cfg, rectsOf: rectsOf2, invalidateShadow, colliderChanged, VERSION: VERSION2, CARS, EPS: EPS42, 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;
68387
+ const { THREE, cfg, rectsOf: rectsOf2, invalidateShadow, colliderChanged, VERSION: VERSION2, CARS, EPS: EPS42, 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;
67825
68388
  function build(r0, options) {
67826
68389
  const opts = options || {};
67827
68390
  const r = withLaidConduits(applyOutbuildings(r0), !!(opts.constructionStages || opts.constructionLevel != null));
@@ -67968,6 +68531,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
67968
68531
  assembleInteractive(gs);
67969
68532
  linkDoorLeaves();
67970
68533
  mailboxInteractive();
68534
+ walkInInteractive();
67971
68535
  if (cs) {
67972
68536
  for (const def of shared3.inter.defs.values()) {
67973
68537
  if (def.outer && !def.outer.userData.constructionStage) def.outer.userData.constructionStage = /^gate/.test(def.kind) ? "perimeter" : "furniture";
@@ -68658,7 +69222,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
68658
69222
  joinBodies(params, byId);
68659
69223
  }
68660
69224
  function holdHanging({ parts: parts2, joints, boxOf: boxOf4 }, byId) {
68661
- const back = Math.min(...parts2.map((part) => boxOf4(part.id).min[2]));
69225
+ const back2 = Math.min(...parts2.map((part) => boxOf4(part.id).min[2]));
68662
69226
  for (let pass = 0; pass < parts2.length; pass++) {
68663
69227
  const groups = groupsOf(parts2, joints).map((ids) => ids.map((id) => byId.get(id)));
68664
69228
  const held = groups.filter((group) => group.some((part) => part.anchored)).flat();
@@ -68672,8 +69236,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
68672
69236
  changed = true;
68673
69237
  continue;
68674
69238
  }
68675
- const againstWall = held.length === 0 || held.some((part) => boxOf4(part.id).min[2] <= back + AGAINST_WALL);
68676
- const onWall = againstWall ? group.filter((part) => !SOFT.has(part.material) && boxOf4(part.id).min[2] <= back + BACK_TOUCH) : [];
69239
+ const againstWall = held.length === 0 || held.some((part) => boxOf4(part.id).min[2] <= back2 + AGAINST_WALL);
69240
+ const onWall = againstWall ? group.filter((part) => !SOFT.has(part.material) && boxOf4(part.id).min[2] <= back2 + BACK_TOUCH) : [];
68677
69241
  if (onWall.length === 0) continue;
68678
69242
  for (const part of onWall) part.anchored = true;
68679
69243
  changed = true;
@@ -68686,6 +69250,230 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
68686
69250
  return;
68687
69251
  }
68688
69252
  }
69253
+ var COVER22 = 6e-3;
69254
+ var SPRING = 3e-3;
69255
+ var SPRING_WIDTH = 0.012;
69256
+ var CLOTH_COVER = [{ material: "fabric", thickness: COVER22, faces: "all" }];
69257
+ function piece2(id, key2, material, min2, max2, color2) {
69258
+ const size = [max2[0] - min2[0], max2[1] - min2[1], max2[2] - min2[2]];
69259
+ const position = [(min2[0] + max2[0]) / 2, (min2[1] + max2[1]) / 2, (min2[2] + max2[2]) / 2];
69260
+ return { id, key: key2, material, shape: { kind: "box", size }, position, rotation: null, color: color2, min: min2, max: max2 };
69261
+ }
69262
+ var bothSides = (x0, x1) => [
69263
+ [x0, x1],
69264
+ [-x1, -x0]
69265
+ ];
69266
+ var SIDE_RAIL = 0.03;
69267
+ var SLAT_TOP = 0.297;
69268
+ var SLAT_THICK = 0.027;
69269
+ var SLAT_WIDTH = 0.07;
69270
+ var SLAT_PITCH = 0.12;
69271
+ var SPRING_STRIPS = 5;
69272
+ function bedParts(drawn) {
69273
+ const [frame2, ...otherWood] = drawn.filter((p) => p.key === "wood");
69274
+ const [mattress, ...bedclothes] = drawn.filter((p) => p.key === "fabric");
69275
+ if (!frame2 || !mattress) return [...drawn];
69276
+ const hw = (frame2.max[0] - frame2.min[0]) / 2;
69277
+ const [z0, z1] = [frame2.min[2], frame2.max[2]];
69278
+ const wood = frame2.color;
69279
+ const out = [...otherWood.map((p, k) => ({ ...p, id: k === 0 ? "bed_headboard" : "bed_footboard" }))];
69280
+ 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)));
69281
+ out.push(piece2("bed_centre_rail", "wood", "wood_soft", [-0.03, 0.2, z0], [0.03, SLAT_TOP - SLAT_THICK, z1], wood));
69282
+ const slats = Math.floor((z1 - z0 - 2 * 0.02 - SLAT_WIDTH) / SLAT_PITCH) + 1;
69283
+ for (let k = 0; k < slats; k++) {
69284
+ const z = z0 + 0.02 + k * SLAT_PITCH;
69285
+ 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));
69286
+ }
69287
+ const span = 2 * (hw - SIDE_RAIL);
69288
+ for (let k = 0; k < SPRING_STRIPS; k++) {
69289
+ const x = -hw + SIDE_RAIL + (k + 1) * span / (SPRING_STRIPS + 1);
69290
+ 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));
69291
+ }
69292
+ out.push({ ...mattress, id: "bed_mattress", material: "foam", layers: CLOTH_COVER });
69293
+ return [...out, ...bedclothes];
69294
+ }
69295
+ var RAIL_HEIGHT = 0.08;
69296
+ var POST = 0.05;
69297
+ var BOARD = 0.05;
69298
+ function base(L, c, seats, plinth) {
69299
+ const { hw, hd, armWidth: aT, postX: px } = L;
69300
+ const ix = hw - aT;
69301
+ const railTop = L.support - 6e-3;
69302
+ const railBottom = railTop - RAIL_HEIGHT;
69303
+ const zFrom = L.backFrame + BOARD;
69304
+ const zTo = L.coverFront - L.railDepth;
69305
+ const out = [];
69306
+ const wood = (id, min2, max2, material = "wood_hard") => out.push(piece2(id, "wood", material, min2, max2, c.wood));
69307
+ if (plinth) {
69308
+ wood("seat_plinth_front", [-hw, 0, hd - 0.06], [hw, L.postFloor, hd]);
69309
+ wood("seat_plinth_back", [-hw, 0, L.rear], [hw, L.postFloor, L.rear + 0.04]);
69310
+ 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]);
69311
+ }
69312
+ const upright = (id, x, z, top) => wood(id, [x - POST / 2, L.postFloor, z - POST / 2], [x + POST / 2, top, z + POST / 2]);
69313
+ for (const [k, sx] of [-1, 1].entries()) {
69314
+ upright(`seat_post_front_${k}`, sx * px, L.postFront, railTop);
69315
+ upright(`seat_post_back_${k}`, sx * px, L.postBack, L.stiles === "posts" ? L.armTop - 0.03 : railTop);
69316
+ }
69317
+ wood("seat_rail_front", [-(px - POST / 2), railBottom, zTo], [px - POST / 2, railTop, L.coverFront]);
69318
+ wood("seat_rail_back", [-(px - POST / 2), railBottom, L.backFrame], [px - POST / 2, railTop, zFrom]);
69319
+ 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]);
69320
+ for (const seat2 of seats) if (seat2.seam !== void 0) wood(`seat_divider_${out.length}`, [seat2.seam - 0.02, railBottom, zFrom], [seat2.seam + 0.02, railTop, zTo]);
69321
+ for (const [k, seat2] of seats.entries()) {
69322
+ for (const [j, dx] of [-0.12, 0.12].entries()) {
69323
+ const x = seat2.x + dx;
69324
+ 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));
69325
+ }
69326
+ }
69327
+ out.push(piece2("seat_cover_front", "fabric", "fabric", [-ix, L.skirt, L.coverFront], [ix, L.support, L.coverFront + COVER22], c.skirt));
69328
+ 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));
69329
+ return out;
69330
+ }
69331
+ function back(L, c) {
69332
+ const { hw, armWidth: aT } = L;
69333
+ const ix = hw - aT;
69334
+ const railTop = L.support - 6e-3;
69335
+ const top = L.backTop - COVER22;
69336
+ const zFrame = [L.backFrame, L.backFrame + BOARD];
69337
+ const out = [];
69338
+ if (L.stiles === "rail") {
69339
+ 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));
69340
+ out.push(piece2("back_top_rail", "wood", "wood_hard", [-(ix - POST), top - BOARD, zFrame[0]], [ix - POST, top, zFrame[1]], c.wood));
69341
+ }
69342
+ const midX = L.stiles === "rail" ? ix - POST : L.postX - POST / 2;
69343
+ out.push(piece2("back_mid_rail", "wood", "wood_hard", [-midX, 0.5, zFrame[0]], [midX, 0.5 + POST, zFrame[1]], c.wood));
69344
+ 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));
69345
+ out.push(piece2("back_pad", "fabric", "foam", [-ix, L.support, zFrame[1]], [ix, top, L.rear + L.backDepth], c.back));
69346
+ out.push(piece2("back_cover_rear", "fabric", "fabric", [-L.rearHalf, L.skirt, L.rear], [L.rearHalf, L.backTop, L.rear + COVER22], c.skirt));
69347
+ out.push(piece2("back_cover_top", "fabric", "fabric", [-L.rearHalf, top, L.rear + COVER22], [L.rearHalf, L.backTop, L.rear + L.backDepth], c.back));
69348
+ if (L.rearHalf > ix) {
69349
+ 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));
69350
+ }
69351
+ return out;
69352
+ }
69353
+ function arms(L, c, boardBack) {
69354
+ const { hw, armWidth: aT, postX: px } = L;
69355
+ const railTop = L.support - 6e-3;
69356
+ const padTop = L.armTop - 0.03;
69357
+ const front = L.armFront;
69358
+ const out = [];
69359
+ 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)];
69360
+ const [board2, outer, inner, top, coverOuter, coverInner] = sides;
69361
+ for (const k of [0, 1]) {
69362
+ const z0 = L.armBack;
69363
+ out.push(piece2(`arm_board_${k}`, "wood", "wood_hard", [board2[k][0], railTop, boardBack], [board2[k][1], padTop, L.postFront + POST / 2], c.wood));
69364
+ out.push(piece2(`arm_pad_outer_${k}`, "fabric", "foam", [outer[k][0], railTop, z0], [outer[k][1], padTop, front - COVER22], c.arm));
69365
+ out.push(piece2(`arm_pad_inner_${k}`, "fabric", "foam", [inner[k][0], railTop, z0], [inner[k][1], padTop, front - COVER22], c.arm));
69366
+ out.push(piece2(`arm_pad_top_${k}`, "fabric", "foam", [top[k][0], padTop, z0], [top[k][1], L.armTop - COVER22, front - COVER22], c.arm));
69367
+ out.push(piece2(`arm_cover_outer_${k}`, "fabric", "fabric", [coverOuter[k][0], L.armBottom, z0], [coverOuter[k][1], L.armTop, front], c.arm));
69368
+ out.push(piece2(`arm_cover_inner_${k}`, "fabric", "fabric", [coverInner[k][0], L.armBottom, z0], [coverInner[k][1], L.armTop, front], c.arm));
69369
+ 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));
69370
+ 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));
69371
+ 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));
69372
+ }
69373
+ return out;
69374
+ }
69375
+ function seatStructure(L, c, seats, options) {
69376
+ return [...base(L, c, seats, options.plinth), ...back(L, c), ...arms(L, c, options.boardBack)];
69377
+ }
69378
+ function cushion(block, id) {
69379
+ return { ...block, id, material: "foam", layers: CLOTH_COVER };
69380
+ }
69381
+ var SOFAS = /^sofa_/;
69382
+ var ARMCHAIRS = /^armchair/;
69383
+ var BEDS = /^(double_bed|queen_bed|king_bed|single_bed|mattress)$/;
69384
+ var seatsOf = (cushions) => cushions.map((block, k) => ({ x: block.position[0], ...cushions[k + 1] ? { seam: (block.position[0] + cushions[k + 1].position[0]) / 2 } : {} }));
69385
+ function sofaParts(drawn) {
69386
+ const woods = drawn.filter((p) => p.key === "wood");
69387
+ const cloth2 = drawn.filter((p) => p.key === "fabric");
69388
+ const count = (cloth2.length - 5) / 2;
69389
+ const [skirt, ...rest2] = cloth2;
69390
+ const seatCushions = rest2.slice(0, count);
69391
+ const [back2] = rest2.slice(count, count + 1);
69392
+ const backCushions = rest2.slice(count + 1, 2 * count + 1);
69393
+ const [armLeft, , pillow] = rest2.slice(2 * count + 1);
69394
+ const feet = woods.slice(1);
69395
+ if (!skirt || !back2 || !armLeft || !pillow || feet.length !== 4) return [...drawn];
69396
+ const hd = (armLeft.max[2] - armLeft.min[2]) / 2 + 0.02;
69397
+ const hw = (woods[0].max[0] - woods[0].min[0]) / 2;
69398
+ const frontFoot = Math.max(...feet.map((foot) => foot.position[2]));
69399
+ const backFoot = Math.min(...feet.map((foot) => foot.position[2]));
69400
+ const layout = {
69401
+ hw,
69402
+ hd,
69403
+ rear: -hd,
69404
+ armWidth: armLeft.max[0] - armLeft.min[0],
69405
+ armTop: armLeft.max[1],
69406
+ armBottom: armLeft.min[1],
69407
+ backTop: back2.max[1],
69408
+ backDepth: back2.max[2] - back2.min[2],
69409
+ skirt: skirt.min[1],
69410
+ support: skirt.max[1],
69411
+ postX: Math.abs(feet[0].position[0]),
69412
+ postFront: frontFoot,
69413
+ postBack: backFoot,
69414
+ postFloor: 0,
69415
+ coverFront: skirt.max[2] - COVER22,
69416
+ railDepth: 0.07,
69417
+ springEnd: skirt.max[2] - 0.05,
69418
+ backFrame: backFoot - 0.025,
69419
+ armBack: armLeft.min[2],
69420
+ armFront: armLeft.max[2],
69421
+ rearHalf: hw - (armLeft.max[0] - armLeft.min[0]),
69422
+ stiles: "rail"
69423
+ };
69424
+ const colours = { wood: feet[0].color, skirt: skirt.color, back: back2.color, arm: armLeft.color };
69425
+ const structure = seatStructure(layout, colours, seatsOf(seatCushions), { plinth: false, boardBack: layout.backFrame });
69426
+ const cushions = [...seatCushions.map((block, k) => cushion(block, `seat_cushion_${k}`)), ...backCushions.map((block, k) => cushion(block, `back_cushion_${k}`)), cushion(pillow, "accent_pillow")];
69427
+ return [...structure, ...cushions];
69428
+ }
69429
+ var ARMCHAIR_SUPPORT = 0.28;
69430
+ function armchairParts(drawn) {
69431
+ const plinth = drawn.find((p) => p.key === "wood");
69432
+ const [seat2, back2, armLeft] = drawn.filter((p) => p.key === "fabric");
69433
+ if (!plinth || !seat2 || !back2 || !armLeft) return [...drawn];
69434
+ const [hw, hd] = [(plinth.max[0] - plinth.min[0]) / 2, (plinth.max[2] - plinth.min[2]) / 2];
69435
+ const armWidth = armLeft.max[0] - armLeft.min[0];
69436
+ const rear = back2.min[2];
69437
+ const backFrame = rear + COVER22;
69438
+ const coverFront = hd - 0.04;
69439
+ const layout = {
69440
+ hw,
69441
+ hd,
69442
+ rear,
69443
+ armWidth,
69444
+ armTop: armLeft.max[1],
69445
+ armBottom: armLeft.min[1],
69446
+ backTop: back2.max[1],
69447
+ backDepth: back2.max[2] - rear,
69448
+ skirt: plinth.max[1],
69449
+ support: ARMCHAIR_SUPPORT,
69450
+ postX: hw - 0.07,
69451
+ postFront: hd - 0.065,
69452
+ postBack: backFrame + 0.025,
69453
+ postFloor: plinth.max[1],
69454
+ coverFront,
69455
+ railDepth: 0.05,
69456
+ springEnd: coverFront - 0.02,
69457
+ backFrame,
69458
+ armBack: backFrame,
69459
+ armFront: armLeft.max[2],
69460
+ rearHalf: (back2.max[0] - back2.min[0]) / 2,
69461
+ stiles: "posts"
69462
+ };
69463
+ const colours = { wood: plinth.color, skirt: seat2.color, back: back2.color, arm: armLeft.color };
69464
+ const structure = seatStructure(layout, colours, [{ x: 0 }], { plinth: true, boardBack: backFrame + 0.05 });
69465
+ const ix = hw - armWidth;
69466
+ const seatCushion = { ...seat2, id: "seat_cushion_0", min: [-(ix - 2e-3), ARMCHAIR_SUPPORT, rear + layout.backDepth], max: [ix - 2e-3, seat2.max[1], seat2.max[2]] };
69467
+ const size = [seatCushion.max[0] - seatCushion.min[0], seatCushion.max[1] - seatCushion.min[1], seatCushion.max[2] - seatCushion.min[2]];
69468
+ const position = [0, (seatCushion.min[1] + seatCushion.max[1]) / 2, (seatCushion.min[2] + seatCushion.max[2]) / 2];
69469
+ return [...structure, cushion({ ...seatCushion, shape: { kind: "box", size }, position }, "seat_cushion_0")];
69470
+ }
69471
+ function upholster(drawn, type) {
69472
+ const made2 = SOFAS.test(type) ? sofaParts(drawn) : ARMCHAIRS.test(type) ? armchairParts(drawn) : BEDS.test(type) ? bedParts(drawn) : void 0;
69473
+ if (!made2) return false;
69474
+ drawn.splice(0, drawn.length, ...made2);
69475
+ return true;
69476
+ }
68689
69477
  var WOOD_THIN = 0.035;
68690
69478
  var BOARD_TOP_THICK = 0.07;
68691
69479
  var BOARD_TOP_WIDTH = 0.5;
@@ -68912,6 +69700,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
68912
69700
  run(A);
68913
69701
  if (!drawn.length) throw new Error(`game-floorplan-three: the builder of "${name}" drew no box or cylinder`);
68914
69702
  hollowCases(drawn, name);
69703
+ upholster(drawn, name);
68915
69704
  const boardsOf = splitTopsIntoBoards(drawn, materialOf2, Boolean(opts.carcass));
68916
69705
  const parts2 = drawn.map((p) => {
68917
69706
  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]);
@@ -68924,6 +69713,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
68924
69713
  const fill22 = structureFill(material, p.shape);
68925
69714
  if (fill22 < 1) part.fill = Math.round(fill22 * 1e4) / 1e4;
68926
69715
  if (p.rotation) part.rotation = p.rotation;
69716
+ if (p.layers) part.layers = p.layers;
68927
69717
  if (!LOOSE.has(material) && p.min[1] <= FLOOR_TOUCH2) part.anchored = true;
68928
69718
  if (opts.carcass && LOOSE.has(material)) {
68929
69719
  part.hands = 1;
@@ -68961,7 +69751,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
68961
69751
  let top = null;
68962
69752
  for (const p of drawn) {
68963
69753
  const part = parts2.find((x) => x.id === p.id);
68964
- if (part.shape.kind === "sphere" || part.rotation || part.material === "fabric" || LOOSE.has(part.material)) continue;
69754
+ if (part.shape.kind === "sphere" || part.rotation || part.material === "fabric" || part.material === "foam" || LOOSE.has(part.material)) continue;
68965
69755
  const area3 = (p.max[0] - p.min[0]) * (p.max[2] - p.min[2]);
68966
69756
  if (area3 < 0.6 * footprint || p.max[1] < 0.2) continue;
68967
69757
  if (!top || p.max[1] > top.y + 1e-6) top = { part: p.id, y: p.max[1] };
@@ -73821,31 +74611,31 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
73821
74611
  const handguardHeight = frames.receiverHeight * 0.8;
73822
74612
  const railTopY = frames.receiverHeight / 2 + (frames.hasRail ? 6e-3 : 0);
73823
74613
  const forendMiddle = (frames.receiverEnd + frames.handguardEnd) / 2;
73824
- const base = { mount, barrelRadius: frames.barrelRadius, receiverWidth: frames.receiverWidth, receiverHeight: frames.receiverHeight, hasRail: frames.hasRail };
74614
+ const base2 = { mount, barrelRadius: frames.barrelRadius, receiverWidth: frames.receiverWidth, receiverHeight: frames.receiverHeight, hasRail: frames.hasRail };
73825
74615
  switch (mount) {
73826
74616
  case "muzzle":
73827
- return { ...base, position: toRoot(frames.length, frames.barrelY, 0), side: 0 };
74617
+ return { ...base2, position: toRoot(frames.length, frames.barrelY, 0), side: 0 };
73828
74618
  case "rail_top":
73829
- return { ...base, position: toRoot((frames.receiverStart + frames.receiverEnd) / 2 + 0.03, railTopY, 0), side: 0 };
74619
+ return { ...base2, position: toRoot((frames.receiverStart + frames.receiverEnd) / 2 + 0.03, railTopY, 0), side: 0 };
73830
74620
  case "rail_bottom":
73831
- return { ...base, position: toRoot(forendMiddle, frames.barrelY - handguardHeight / 2, 0), side: 0 };
74621
+ return { ...base2, position: toRoot(forendMiddle, frames.barrelY - handguardHeight / 2, 0), side: 0 };
73832
74622
  case "rail_left":
73833
- return { ...base, position: toRoot(forendMiddle, frames.barrelY, -(frames.receiverWidth * 0.54 + 4e-3)), side: -1 };
74623
+ return { ...base2, position: toRoot(forendMiddle, frames.barrelY, -(frames.receiverWidth * 0.54 + 4e-3)), side: -1 };
73834
74624
  case "rail_right":
73835
- return { ...base, position: toRoot(forendMiddle, frames.barrelY, frames.receiverWidth * 0.54 + 4e-3), side: 1 };
74625
+ return { ...base2, position: toRoot(forendMiddle, frames.barrelY, frames.receiverWidth * 0.54 + 4e-3), side: 1 };
73836
74626
  case "underbarrel": {
73837
74627
  const [x, y] = frames.underbarrel ?? [frames.receiverEnd + (frames.handguardEnd - frames.receiverEnd) * 0.25, frames.barrelY - handguardHeight / 2 - 0.02];
73838
- return { ...base, position: toRoot(x, y, 0), side: 0 };
74628
+ return { ...base2, position: toRoot(x, y, 0), side: 0 };
73839
74629
  }
73840
74630
  case "magazine":
73841
- return { ...base, position: toRoot(frames.magazineX, -frames.receiverHeight / 2, 0), side: 0 };
74631
+ return { ...base2, position: toRoot(frames.magazineX, -frames.receiverHeight / 2, 0), side: 0 };
73842
74632
  case "feed": {
73843
74633
  const belt = model.parts.belt?.position;
73844
- return { ...base, position: belt ? toRoot(belt.x, belt.y, belt.z) : toRoot(frames.magazineX + 0.02, -frames.receiverHeight / 2 - 0.05, -0.045), side: -1 };
74634
+ return { ...base2, position: belt ? toRoot(belt.x, belt.y, belt.z) : toRoot(frames.magazineX + 0.02, -frames.receiverHeight / 2 - 0.05, -0.045), side: -1 };
73845
74635
  }
73846
74636
  case "sling":
73847
74637
  return {
73848
- ...base,
74638
+ ...base2,
73849
74639
  position: toRoot(frames.receiverEnd + (frames.length - frames.receiverEnd) * 0.45, -frames.receiverHeight / 2 - 0.03, 0),
73850
74640
  secondary: toRoot(0.08, -0.09, 0),
73851
74641
  side: 0
@@ -75927,13 +76717,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
75927
76717
  ];
75928
76718
  }
75929
76719
  function showcasePedestalItem(name) {
75930
- const piece2 = (THREE) => furnitureSpec(THREE, PEDESTAL_FURNITURE, { w: SHOWCASE.size, d: SHOWCASE.size, h: SHOWCASE.height });
76720
+ const piece3 = (THREE) => furnitureSpec(THREE, PEDESTAL_FURNITURE, { w: SHOWCASE.size, d: SHOWCASE.size, h: SHOWCASE.height });
75931
76721
  return {
75932
76722
  id: SHOWCASE_PEDESTAL_ID,
75933
76723
  name,
75934
76724
  build: (lent) => {
75935
76725
  const THREE = lent;
75936
- const built2 = piece2(THREE);
76726
+ const built2 = piece3(THREE);
75937
76727
  const root = built2.build(THREE);
75938
76728
  root.userData.pedestalSpec = { ...built2.spec, name, tags: [...built2.spec.tags ?? [], "furniture"] };
75939
76729
  return root;
@@ -76037,15 +76827,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
76037
76827
  const samples = [];
76038
76828
  const tiersOf = /* @__PURE__ */ new Map();
76039
76829
  for (const sound3 of manifest.sounds) {
76040
- const { base, tier } = splitTier(sound3.id);
76041
- if (tier) tiersOf.set(base, [...tiersOf.get(base) ?? [], sound3]);
76830
+ const { base: base2, tier } = splitTier(sound3.id);
76831
+ if (tier) tiersOf.set(base2, [...tiersOf.get(base2) ?? [], sound3]);
76042
76832
  }
76043
76833
  const bases = /* @__PURE__ */ new Map();
76044
76834
  for (const sound3 of manifest.sounds) {
76045
76835
  if (!splitTier(sound3.id).tier) bases.set(sound3.id, sound3);
76046
76836
  }
76047
- for (const [base, tiers] of tiersOf) {
76048
- if (!bases.has(base)) bases.set(base, { id: base, category: tiers[0]?.category ?? "", layers: { close: tiers[0]?.layers.close ?? [] } });
76837
+ for (const [base2, tiers] of tiersOf) {
76838
+ if (!bases.has(base2)) bases.set(base2, { id: base2, category: tiers[0]?.category ?? "", layers: { close: tiers[0]?.layers.close ?? [] } });
76049
76839
  }
76050
76840
  for (const sound3 of bases.values()) {
76051
76841
  const numbers = options.sounds?.[sound3.id] ?? options.defaults?.(sound3);
@@ -76383,8 +77173,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
76383
77173
  function isPlainObject2(value) {
76384
77174
  return typeof value === "object" && value !== null && !Array.isArray(value);
76385
77175
  }
76386
- function mergeRecords(base, patch) {
76387
- const merged2 = { ...base };
77176
+ function mergeRecords(base2, patch) {
77177
+ const merged2 = { ...base2 };
76388
77178
  for (const [key2, value] of Object.entries(patch)) {
76389
77179
  if (value === void 0) continue;
76390
77180
  const current = merged2[key2];
@@ -76702,7 +77492,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
76702
77492
  const falloffLevel = falloffGain(recipe2.falloff, input.volume ?? 1, distance22);
76703
77493
  const level = occlusion > 0 ? falloffLevel * (1 - OCCLUSION_GAIN * occlusion) : falloffLevel;
76704
77494
  const silent = isSilent(recipe2.falloff, falloffLevel);
76705
- const base = {
77495
+ const base2 = {
76706
77496
  id: recipe2.id,
76707
77497
  bus: recipe2.bus,
76708
77498
  order: order2,
@@ -76712,7 +77502,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
76712
77502
  distance: distance22,
76713
77503
  ...recipe2.pan ? { pan: input.position ? panFor(listener, input.position) : 0 } : {}
76714
77504
  };
76715
- if (silent) return recipe2.keepSilent ? { ...base, silent: true, length: 0, layers: [] } : null;
77505
+ if (silent) return recipe2.keepSilent ? { ...base2, silent: true, length: 0, layers: [] } : null;
76716
77506
  const scope2 = { random: input.random ?? createRng3(1), params: { ...input.params } };
76717
77507
  for (const [name, range3] of Object.entries(recipe2.vars ?? {})) if (scope2.params[name] === void 0) scope2.params[name] = draw(range3, scope2);
76718
77508
  const defaults = {
@@ -76722,7 +77512,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
76722
77512
  };
76723
77513
  const divisor = cutoffDivisor(recipe2.falloff, distance22) / (1 - OCCLUSION_CUTOFF * occlusion);
76724
77514
  const layers = recipe2.layers.flatMap((layer3) => planLayer(layer3, scope2, defaults, order2 !== "layered", level)).map((layer3) => muffle(layer3, divisor));
76725
- return { ...base, silent: false, length: Math.max(0, ...layers.map(layerEnd)), layers };
77515
+ return { ...base2, silent: false, length: Math.max(0, ...layers.map(layerEnd)), layers };
76726
77516
  }
76727
77517
  function fillNoise(random, length2) {
76728
77518
  const samples = new Float32Array(length2);
@@ -80431,7 +81221,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
80431
81221
  var CRACK_CUTOFF = 3e3;
80432
81222
  var CRACK_SECONDS = 0.03;
80433
81223
  var BODY_TO_FREQUENCY = 40;
80434
- var linear = ([base, span], k) => base + span * k;
81224
+ var linear = ([base2, span], k) => base2 + span * k;
80435
81225
  var energyPosition = (energyJ, curve) => Math.min(1, Math.max(0, Math.log10(Math.max(energyJ, curve.floorJ) / curve.floorJ) / curve.spanDecades));
80436
81226
  var energyOfShot = (input) => {
80437
81227
  if (input.energyJ !== void 0) return input.energyJ;
@@ -82194,8 +82984,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
82194
82984
  var isGunshot = (id) => GUNSHOT_SAMPLE_IDS.includes(id);
82195
82985
  function weaponSampleDefaults(sound3, overrides = {}) {
82196
82986
  if (sound3.category !== "armas") return void 0;
82197
- const base = LAUNCH_IDS.has(sound3.id) ? LAUNCH_SAMPLE : sound3.id.startsWith("suppressed_") ? SUPPRESSED_SAMPLE : isGunshot(sound3.id) ? GUNSHOT_SAMPLE : droppedPartDefaults(sound3.id) ?? RELOAD_SAMPLE;
82198
- return { ...base, ...overrides[sound3.id] };
82987
+ const base2 = LAUNCH_IDS.has(sound3.id) ? LAUNCH_SAMPLE : sound3.id.startsWith("suppressed_") ? SUPPRESSED_SAMPLE : isGunshot(sound3.id) ? GUNSHOT_SAMPLE : droppedPartDefaults(sound3.id) ?? RELOAD_SAMPLE;
82988
+ return { ...base2, ...overrides[sound3.id] };
82199
82989
  }
82200
82990
  function weaponSampleBank(options) {
82201
82991
  const bank = sampleBankFromManifest(options.manifest, { id: "weapons_three_samples", ...options.url ? {} : { baseUrl: options.baseUrl ?? "" }, defaults: (sound3) => weaponSampleDefaults(sound3, options.sounds) });
@@ -82325,12 +83115,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
82325
83115
  return {
82326
83116
  shot(energyJ, category, extras = {}) {
82327
83117
  if (options.shotModel !== "game") {
82328
- const base = { energyJ, category, ...extras, space: extras.space ?? (extras.indoors ? "indoor" : "outdoor") };
82329
- const profile = computeGunshot(base, options.gunshot).profile;
83118
+ const base2 = { energyJ, category, ...extras, space: extras.space ?? (extras.indoors ? "indoor" : "outdoor") };
83119
+ const profile = computeGunshot(base2, options.gunshot).profile;
82330
83120
  const take = pickTake2(lastTake.get(profile), channel.random);
82331
83121
  lastTake.set(profile, take);
82332
83122
  const pitch = 1 + (channel.random() * 2 - 1) * pitchSpread;
82333
- const shot = computeGunshot({ ...base, take, pitch }, options.gunshot);
83123
+ const shot = computeGunshot({ ...base2, take, pitch }, options.gunshot);
82334
83124
  const recorded = shot.samples.close;
82335
83125
  const sample = shot.audible && sampleReady(recorded);
82336
83126
  const fitted = shot.audible && !sample && fittedReady(recorded);
@@ -82338,20 +83128,20 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
82338
83128
  const occlusion = Math.min(1, Math.max(0, extras.occlusion ?? 0));
82339
83129
  const handle = channel.play(recorded, {
82340
83130
  volume: (extras.volume ?? 1) * (1 - 0.5 * occlusion),
82341
- environment: base.space === "indoor" ? "indoor" : "outdoor",
83131
+ environment: base2.space === "indoor" ? "indoor" : "outdoor",
82342
83132
  ...extras.position ? { position: [extras.position[0], extras.position[1], extras.position[2]] } : {},
82343
83133
  ...extras.distance === void 0 ? {} : { distance: extras.distance },
82344
83134
  ...shot.delay > 0 ? { delay: shot.delay } : {}
82345
83135
  });
82346
- if (base.space === "indoor") {
83136
+ if (base2.space === "indoor") {
82347
83137
  for (const voice2 of shot.voices) if (voice2.group === "tail") playGunshotVoice(voice2, extras);
82348
83138
  }
82349
83139
  const layers = handle?.kind === "sample" ? handle.plan.layers.map((layer3) => ({ role: layer3.role, take: layer3.take, rate: layer3.rate })) : [];
82350
- options.onGunshot?.(shot, { ...base, take, pitch }, fitted ? { kind: "fitted", id: recorded } : { kind: "sample", id: recorded, layers });
83140
+ options.onGunshot?.(shot, { ...base2, take, pitch }, fitted ? { kind: "fitted", id: recorded } : { kind: "sample", id: recorded, layers });
82351
83141
  return;
82352
83142
  }
82353
83143
  for (const voice2 of shot.voices) playGunshotVoice(voice2, extras);
82354
- if (shot.audible) options.onGunshot?.(shot, { ...base, take, pitch }, { kind: "synth" });
83144
+ if (shot.audible) options.onGunshot?.(shot, { ...base2, take, pitch }, { kind: "synth" });
82355
83145
  return;
82356
83146
  }
82357
83147
  const sound3 = shotSound({ ...extras, energyJ, category });
@@ -83460,8 +84250,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
83460
84250
  const materials = [];
83461
84251
  const M = (color2, tag, options = {}) => {
83462
84252
  const material = new T2.MeshStandardMaterial(Object.assign({ color: color2, roughness: 0.78, metalness: 0 }, options));
83463
- const base = new T2.Color(color2);
83464
- const data = { base, baseRgb: channelsOf(color2), tag, rough: material.roughness };
84253
+ const base2 = new T2.Color(color2);
84254
+ const data = { base: base2, baseRgb: channelsOf(color2), tag, rough: material.roughness };
83465
84255
  material.userData = data;
83466
84256
  materials.push(material);
83467
84257
  return material;
@@ -87062,11 +87852,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
87062
87852
  const steel = metal2(6251625);
87063
87853
  const dark = metal2(4080199);
87064
87854
  const arm = (x, y, angle, z) => mesh3(bx(12.65, 1.2, 1.6), steel, [x, y, z], [0, 0, angle]);
87065
- 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)]);
87855
+ 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)]);
87066
87856
  return G(
87067
87857
  mesh3(bx(8, 1, 11), dark, [0, -5, 0]),
87068
87858
  mesh3(bx(8, 1, 11), dark, [0, 5, 0]),
87069
- ...arms,
87859
+ ...arms2,
87070
87860
  mesh3(cyl(0.6, 0.6, 30, 8), metal2(9277846), [0, 0, 0], [0, 0, Math.PI / 2]),
87071
87861
  mesh3(bx(1.6, 2.4, 3), dark, [-11.8, 0, 0]),
87072
87862
  mesh3(bx(1.6, 2.4, 3), dark, [11.8, 0, 0]),
@@ -87278,12 +88068,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
87278
88068
  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)]];
87279
88069
  const frame2 = wood(7031340);
87280
88070
  const band = cloth2(2039583);
87281
- const arms = [-1, 1].map((side) => rod(0, -0.15, side * 0.5675, 0.7, 0.1));
88071
+ const arms2 = [-1, 1].map((side) => rod(0, -0.15, side * 0.5675, 0.7, 0.1));
87282
88072
  const bands = [-1, 1].map((side) => rod(side * 0.5675, 0.7, side * 0.12, 0.25, 0.03));
87283
88073
  return G(
87284
88074
  mesh3(cyl(0.12, 0.1, 0.65, 8), frame2, [0, -0.425, 0]),
87285
88075
  mesh3(cyl(0.126, 0.126, 0.3, 8), cloth2(8007455), [0, -0.5, 0]),
87286
- ...arms.map(([geometry, position, rotation2]) => mesh3(geometry, frame2, [...position], [...rotation2])),
88076
+ ...arms2.map(([geometry, position, rotation2]) => mesh3(geometry, frame2, [...position], [...rotation2])),
87287
88077
  ...bands.map(([geometry, position, rotation2]) => mesh3(geometry, band, [...position], [...rotation2])),
87288
88078
  mesh3(bx(0.26, 0.2, 0.05), cloth2(9067061), [0, 0.2, 0])
87289
88079
  );
@@ -87483,10 +88273,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
87483
88273
  const R = Math.PI / 2;
87484
88274
  const pane = glass(12575711, 0.55);
87485
88275
  const deep = glass(8369584, 0.7);
87486
- const base = extrude2([[-0.6, -0.1], [0.45, -0.5], [0.6, 0.2], [-0.1, 0.5]], 0.04, 2e-3);
88276
+ const base2 = extrude2([[-0.6, -0.1], [0.45, -0.5], [0.6, 0.2], [-0.1, 0.5]], 0.04, 2e-3);
87487
88277
  const chip = extrude2([[0, 0], [0.25, 0.05], [0.1, 0.22]], 0.03, 2e-3);
87488
88278
  return G(
87489
- mesh3(base, pane, [0, 0, 0], [R, 0, 0]),
88279
+ mesh3(base2, pane, [0, 0, 0], [R, 0, 0]),
87490
88280
  mesh3(chip, deep, [0.2, 0.03, -0.35], [R, 0, 0.4]),
87491
88281
  mesh3(new T2.ConeGeometry(0.14, 0.46, 3), pane, [-0.2, 0.23, 0.1], [0, 0.3, 0.12]),
87492
88282
  mesh3(new T2.ConeGeometry(0.1, 0.34, 3), deep, [0.25, 0.17, -0.1], [0.15, 0, -0.2]),
@@ -87687,10 +88477,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
87687
88477
  );
87688
88478
  };
87689
88479
  var rag = ({ mesh: mesh3, bx, G, cloth: cloth2 }) => {
87690
- const base = cloth2(11028282);
88480
+ const base2 = cloth2(11028282);
87691
88481
  const fringe = cloth2(12877167);
87692
88482
  return G(
87693
- mesh3(bx(2, 0.1, 1.8), base, [0, -0.076, 0]),
88483
+ mesh3(bx(2, 0.1, 1.8), base2, [0, -0.076, 0]),
87694
88484
  mesh3(bx(1.7, 0.09, 1.5), cloth2(10108723), [0.1, 0.02, 0], [0, 0.1, 0]),
87695
88485
  mesh3(bx(1.5, 0.036, 1.2), cloth2(11818826), [0, 0.083, 0]),
87696
88486
  mesh3(bx(0.2, 0.02, 1.7), fringe, [1, -0.076, 0]),
@@ -87774,13 +88564,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
87774
88564
  );
87775
88565
  };
87776
88566
  var armyCamouflageUniform = ({ mesh: mesh3, bx, G, cloth: cloth2 }) => {
87777
- const base = cloth2(5857855);
88567
+ const base2 = cloth2(5857855);
87778
88568
  const dark = cloth2(3554600);
87779
88569
  const tan = cloth2(9076565);
87780
88570
  return G(
87781
- mesh3(bx(0.24, 0.08, 0.32), base, [0, 0.04, 0]),
87782
- mesh3(bx(0.08, 0.07, 0.2), base, [-0.16, 0.035, -0.06]),
87783
- mesh3(bx(0.08, 0.07, 0.2), base, [0.16, 0.035, -0.06]),
88571
+ mesh3(bx(0.24, 0.08, 0.32), base2, [0, 0.04, 0]),
88572
+ mesh3(bx(0.08, 0.07, 0.2), base2, [-0.16, 0.035, -0.06]),
88573
+ mesh3(bx(0.08, 0.07, 0.2), base2, [0.16, 0.035, -0.06]),
87784
88574
  mesh3(bx(0.08, 0.074, 0.024), dark, [-0.16, 0.037, 0.052]),
87785
88575
  mesh3(bx(0.08, 0.074, 0.024), dark, [0.16, 0.037, 0.052]),
87786
88576
  mesh3(bx(0.08, 0.01, 0.045), dark, [-0.04, 0.09, -0.135]),
@@ -90172,10 +90962,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
90172
90962
  var toggleClip = () => composeClip("toggle", [turn(ROOT2, "z", 0, TOGGLE_SECONDS / 2, 0, TOGGLE_TILT), turn(ROOT2, "z", TOGGLE_SECONDS / 2, TOGGLE_SECONDS / 2, TOGGLE_TILT, 0)]);
90173
90963
  function launcherClips(context) {
90174
90964
  if (!context.parts.ugl) return [];
90175
- const { open, loaded, close, end: end3, slide: slide2, back } = LAUNCHER_RELOAD;
90965
+ const { open, loaded, close, end: end3, slide: slide2, back: back2 } = LAUNCHER_RELOAD;
90176
90966
  const reload = composeClip(
90177
90967
  "reload_ugl",
90178
- [move("ugl", "x", open, slide2, 0, LAUNCHER_SLIDE), move("ugl", "x", close, back, LAUNCHER_SLIDE, 0)],
90968
+ [move("ugl", "x", open, slide2, 0, LAUNCHER_SLIDE), move("ugl", "x", close, back2, LAUNCHER_SLIDE, 0)],
90179
90969
  [stage("breech_open", open), stage("round_in", loaded), stage("breech_close", close)],
90180
90970
  end3
90181
90971
  );
@@ -90469,7 +91259,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
90469
91259
  if (!BLOWBACK.has(family) || !parts2[part]) return [misfire];
90470
91260
  const travel = strokeOf(parts2);
90471
91261
  const stopped = Object.entries(FAULT_SLIDE_BACK).map(
90472
- ([fault, back]) => composeClip(`fault_${fault}`, [move(part, "x", 0, 0.025, 0, travel), move(part, "x", 0.025, 0.04, travel, travel * back)], fault === "stovepipe" ? [cue(0.03, "stuck_case")] : [], 0.25)
91262
+ ([fault, back2]) => composeClip(`fault_${fault}`, [move(part, "x", 0, 0.025, 0, travel), move(part, "x", 0.025, 0.04, travel, travel * back2)], fault === "stovepipe" ? [cue(0.03, "stuck_case")] : [], 0.25)
90473
91263
  );
90474
91264
  return [misfire, ...stopped];
90475
91265
  }
@@ -90724,7 +91514,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
90724
91514
  const group = kit.group();
90725
91515
  const spare = kit.group();
90726
91516
  spare.position.set(0, 0, 0.032);
90727
- for (const piece2 of factoryMagazine) spare.add(piece2.clone(true));
91517
+ for (const piece3 of factoryMagazine) spare.add(piece3.clone(true));
90728
91518
  group.add(spare);
90729
91519
  box5(group, 0.05, 0.012, 0.04, M.tape, 0, -0.03, 0.016);
90730
91520
  return { object: group, hangsFrom: "magazine" };
@@ -90862,12 +91652,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
90862
91652
  kit.roundness = null;
90863
91653
  for (let i = 0; i < 3; i++) box5(grip, 6e-3, 0.012, 0.028, M.poly, 1e-3, -length2 * 0.25 - i * 0.02, 0);
90864
91654
  };
90865
- var triggerGuard = (kit, fixed2, back, front, bottom) => {
91655
+ var triggerGuard = (kit, fixed2, back2, front, bottom) => {
90866
91656
  const { M, box: box5 } = kit;
90867
91657
  const drop = 0.03;
90868
- box5(fixed2, front - back, 5e-3, 0.01, M.dark, (back + front) / 2, bottom - drop, 0);
91658
+ box5(fixed2, front - back2, 5e-3, 0.01, M.dark, (back2 + front) / 2, bottom - drop, 0);
90869
91659
  box5(fixed2, 5e-3, drop, 0.01, M.dark, front, bottom - drop / 2, 0);
90870
- box5(fixed2, 5e-3, 0.02, 6e-3, M.metal, back + (front - back) * 0.45, bottom - 0.011, 0, 0.25);
91660
+ box5(fixed2, 5e-3, 0.02, 6e-3, M.metal, back2 + (front - back2) * 0.45, bottom - 0.011, 0, 0.25);
90871
91661
  };
90872
91662
  var m203 = (kit, fixed2) => {
90873
91663
  const { M, box: box5 } = kit;
@@ -91131,14 +91921,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
91131
91921
  const mesh3 = object2;
91132
91922
  if (!mesh3.isMesh) return;
91133
91923
  (_a = mesh3.userData).baseMaterial ?? (_a.baseMaterial = mesh3.material);
91134
- const base = mesh3.userData.baseMaterial;
91924
+ const base2 = mesh3.userData.baseMaterial;
91135
91925
  if (glowing.has(mesh3)) {
91136
91926
  const material = mesh3.material;
91137
91927
  (_b = mesh3.userData).baseColor ?? (_b.baseColor = material.color.clone());
91138
91928
  material.color.copy(paint2 ?? mesh3.userData.baseColor);
91139
91929
  return;
91140
91930
  }
91141
- mesh3.material = replacement?.get(base) ?? base;
91931
+ mesh3.material = replacement?.get(base2) ?? base2;
91142
91932
  });
91143
91933
  }
91144
91934
 
@@ -94798,7 +95588,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
94798
95588
  var ORIGIN = [0, 0, 0];
94799
95589
  var FACING4 = [0, 0, 1];
94800
95590
  var UP11 = [0, 1, 0];
94801
- var grow = (piece2, factor) => [piece2[0] * factor, piece2[1] * factor, piece2[2] * factor];
95591
+ var grow = (piece3, factor) => [piece3[0] * factor, piece3[1] * factor, piece3[2] * factor];
94802
95592
  var debrisTone = (look) => or(variable(DEBRIS_COLOR_VARIABLE), look.debris);
94803
95593
  var dustTone = (look) => or(variable(DUST_COLOR_VARIABLE), look.dust);
94804
95594
  var sparks = (look, count) => look.sparks ? [call2("spark_at", ORIGIN, FACING4, count, 0.9)] : [];
@@ -95116,7 +95906,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
95116
95906
  ]
95117
95907
  };
95118
95908
  var VIEWMODEL_EFFECTS = [MUZZLE_FLASH2, SMOKE_PUFF, BACKBLAST, FLAME_JET];
95119
- var aliasOf = (base, id, changes) => ({ ...base, id, pageId: `vehicle:${id}`, anchor: CAR_ORIGIN2, ...changes });
95909
+ var aliasOf = (base2, id, changes) => ({ ...base2, id, pageId: `vehicle:${id}`, anchor: CAR_ORIGIN2, ...changes });
95120
95910
  var BODYWORK_IMPACT = {
95121
95911
  id: "impact_bodywork",
95122
95912
  pageId: "vehicle:impact_bodywork",
@@ -97850,8 +98640,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
97850
98640
  }
97851
98641
  var CELL2 = 0.12;
97852
98642
  var OBSTACLE_BOUNCE = 0.3;
97853
- var radiusOf = (piece2) => Math.max(piece2.sx, piece2.sz) * 0.5;
97854
- var thicknessOf2 = (piece2) => Math.min(piece2.sx, piece2.sy, piece2.sz);
98643
+ var radiusOf = (piece3) => Math.max(piece3.sx, piece3.sz) * 0.5;
98644
+ var thicknessOf2 = (piece3) => Math.min(piece3.sx, piece3.sy, piece3.sz);
97855
98645
  var cellKey2 = (i, k) => (i + 4096) * 8192 + (k + 4096);
97856
98646
  var RestingGrid = class {
97857
98647
  constructor() {
@@ -97862,50 +98652,50 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
97862
98652
  }
97863
98653
  rebuild(pieces) {
97864
98654
  this.clear();
97865
- for (const piece2 of pieces) {
97866
- if (!piece2.on || !piece2.rest) continue;
97867
- const key2 = cellKey2(Math.floor(piece2.x / CELL2), Math.floor(piece2.z / CELL2));
98655
+ for (const piece3 of pieces) {
98656
+ if (!piece3.on || !piece3.rest) continue;
98657
+ const key2 = cellKey2(Math.floor(piece3.x / CELL2), Math.floor(piece3.z / CELL2));
97868
98658
  const list2 = this.cells.get(key2);
97869
- if (list2) list2.push(piece2);
97870
- else this.cells.set(key2, [piece2]);
98659
+ if (list2) list2.push(piece3);
98660
+ else this.cells.set(key2, [piece3]);
97871
98661
  }
97872
98662
  }
97873
98663
  /** The height a piece at `piece`'s place lands at on the pieces under it (the top of the highest one it overlaps), or `-Infinity` over none. */
97874
- supportUnder(piece2) {
97875
- const i = Math.floor(piece2.x / CELL2);
97876
- const k = Math.floor(piece2.z / CELL2);
97877
- const reach2 = radiusOf(piece2);
98664
+ supportUnder(piece3) {
98665
+ const i = Math.floor(piece3.x / CELL2);
98666
+ const k = Math.floor(piece3.z / CELL2);
98667
+ const reach2 = radiusOf(piece3);
97878
98668
  let top = -Infinity;
97879
98669
  for (let di = -1; di <= 1; di++) {
97880
98670
  for (let dk = -1; dk <= 1; dk++) {
97881
98671
  for (const other of this.cells.get(cellKey2(i + di, k + dk)) ?? []) {
97882
- if (other === piece2) continue;
97883
- if (Math.hypot(other.x - piece2.x, other.z - piece2.z) > reach2 + radiusOf(other)) continue;
98672
+ if (other === piece3) continue;
98673
+ if (Math.hypot(other.x - piece3.x, other.z - piece3.z) > reach2 + radiusOf(other)) continue;
97884
98674
  const otherTop = other.y + thicknessOf2(other) * 0.5;
97885
- if (otherTop <= piece2.y + thicknessOf2(piece2) * 0.5) top = Math.max(top, otherTop + thicknessOf2(piece2) * 0.5);
98675
+ if (otherTop <= piece3.y + thicknessOf2(piece3) * 0.5) top = Math.max(top, otherTop + thicknessOf2(piece3) * 0.5);
97886
98676
  }
97887
98677
  }
97888
98678
  }
97889
98679
  return top;
97890
98680
  }
97891
98681
  };
97892
- function pushOutOfObstacles(piece2, obstacles) {
98682
+ function pushOutOfObstacles(piece3, obstacles) {
97893
98683
  let moved = false;
97894
98684
  for (const body of obstacles) {
97895
- if (piece2.y < body.bottom || piece2.y > body.top) continue;
97896
- const dx = piece2.x - body.x;
97897
- const dz = piece2.z - body.z;
98685
+ if (piece3.y < body.bottom || piece3.y > body.top) continue;
98686
+ const dx = piece3.x - body.x;
98687
+ const dz = piece3.z - body.z;
97898
98688
  const distance4 = Math.hypot(dx, dz);
97899
- const reach2 = body.radius + radiusOf(piece2);
98689
+ const reach2 = body.radius + radiusOf(piece3);
97900
98690
  if (distance4 >= reach2) continue;
97901
98691
  const nx = distance4 > 1e-6 ? dx / distance4 : 1;
97902
98692
  const nz = distance4 > 1e-6 ? dz / distance4 : 0;
97903
- piece2.x = body.x + nx * reach2;
97904
- piece2.z = body.z + nz * reach2;
97905
- const into = piece2.vx * nx + piece2.vz * nz;
98693
+ piece3.x = body.x + nx * reach2;
98694
+ piece3.z = body.z + nz * reach2;
98695
+ const into = piece3.vx * nx + piece3.vz * nz;
97906
98696
  if (into < 0) {
97907
- piece2.vx -= (1 + OBSTACLE_BOUNCE) * into * nx;
97908
- piece2.vz -= (1 + OBSTACLE_BOUNCE) * into * nz;
98697
+ piece3.vx -= (1 + OBSTACLE_BOUNCE) * into * nx;
98698
+ piece3.vz -= (1 + OBSTACLE_BOUNCE) * into * nz;
97909
98699
  }
97910
98700
  moved = true;
97911
98701
  }
@@ -97935,36 +98725,36 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
97935
98725
  }
97936
98726
  spawn(options) {
97937
98727
  const random = this.context.random;
97938
- const piece2 = this.pieces[this.next++ % CAPACITY];
98728
+ const piece3 = this.pieces[this.next++ % CAPACITY];
97939
98729
  coneDirection(random, options.dir, options.cone ?? 3.2, this.direction);
97940
98730
  const speed = drawRange(random, options.sp);
97941
98731
  const size = options.size ?? DEFAULT_SIZE;
97942
98732
  const scale = options.k ? drawRange(random, options.k) : 1;
97943
98733
  const box5 = options.box;
97944
98734
  const spin = options.spin || DEFAULT_SPIN;
97945
- piece2.on = true;
97946
- piece2.x = options.p[0] + (box5 ? random.between(-box5[0], box5[0]) : 0);
97947
- piece2.y = options.p[1] + (box5 ? random.between(-box5[1], box5[1]) : 0);
97948
- piece2.z = options.p[2] + (box5 ? random.between(-box5[2], box5[2]) : 0);
97949
- piece2.vx = this.direction.x * speed + (options.v ? options.v[0] : 0);
97950
- piece2.vy = this.direction.y * speed + (options.v ? options.v[1] : 0);
97951
- piece2.vz = this.direction.z * speed + (options.v ? options.v[2] : 0);
97952
- piece2.sx = size[0] * scale;
97953
- piece2.sy = size[1] * scale;
97954
- piece2.sz = size[2] * scale;
97955
- piece2.rx = random.between(0, FULL_TURN_DRAWN3);
97956
- piece2.ry = random.between(0, FULL_TURN_DRAWN3);
97957
- piece2.rz = random.between(0, FULL_TURN_DRAWN3);
97958
- piece2.ax = random.between(-1, 1) * spin;
97959
- piece2.ay = random.between(-1, 1) * spin;
97960
- piece2.az = random.between(-1, 1) * spin;
97961
- piece2.life = options.life || DEFAULT_LIFE;
97962
- piece2.bounce = options.bounce ?? DEFAULT_BOUNCE;
97963
- piece2.rest = false;
97964
- piece2.color = options.c ?? DEFAULT_COLOR32;
98735
+ piece3.on = true;
98736
+ piece3.x = options.p[0] + (box5 ? random.between(-box5[0], box5[0]) : 0);
98737
+ piece3.y = options.p[1] + (box5 ? random.between(-box5[1], box5[1]) : 0);
98738
+ piece3.z = options.p[2] + (box5 ? random.between(-box5[2], box5[2]) : 0);
98739
+ piece3.vx = this.direction.x * speed + (options.v ? options.v[0] : 0);
98740
+ piece3.vy = this.direction.y * speed + (options.v ? options.v[1] : 0);
98741
+ piece3.vz = this.direction.z * speed + (options.v ? options.v[2] : 0);
98742
+ piece3.sx = size[0] * scale;
98743
+ piece3.sy = size[1] * scale;
98744
+ piece3.sz = size[2] * scale;
98745
+ piece3.rx = random.between(0, FULL_TURN_DRAWN3);
98746
+ piece3.ry = random.between(0, FULL_TURN_DRAWN3);
98747
+ piece3.rz = random.between(0, FULL_TURN_DRAWN3);
98748
+ piece3.ax = random.between(-1, 1) * spin;
98749
+ piece3.ay = random.between(-1, 1) * spin;
98750
+ piece3.az = random.between(-1, 1) * spin;
98751
+ piece3.life = options.life || DEFAULT_LIFE;
98752
+ piece3.bounce = options.bounce ?? DEFAULT_BOUNCE;
98753
+ piece3.rest = false;
98754
+ piece3.color = options.c ?? DEFAULT_COLOR32;
97965
98755
  }
97966
98756
  clear() {
97967
- for (const piece2 of this.pieces) piece2.on = false;
98757
+ for (const piece3 of this.pieces) piece3.on = false;
97968
98758
  this.count = 0;
97969
98759
  }
97970
98760
  update(dt) {
@@ -97972,46 +98762,46 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
97972
98762
  const contacts = this.context.debrisContacts;
97973
98763
  const obstacles = contacts?.obstacles() ?? [];
97974
98764
  let moving = false;
97975
- for (const piece2 of this.pieces) {
97976
- if (!piece2.on) continue;
97977
- piece2.life -= dt;
97978
- if (piece2.life <= 0) piece2.on = false;
97979
- else if (!piece2.rest) moving = true;
98765
+ for (const piece3 of this.pieces) {
98766
+ if (!piece3.on) continue;
98767
+ piece3.life -= dt;
98768
+ if (piece3.life <= 0) piece3.on = false;
98769
+ else if (!piece3.rest) moving = true;
97980
98770
  }
97981
98771
  if (moving && contacts) this.resting.rebuild(this.pieces);
97982
98772
  else this.resting.clear();
97983
- for (const piece2 of this.pieces) {
97984
- if (!piece2.on) continue;
98773
+ for (const piece3 of this.pieces) {
98774
+ if (!piece3.on) continue;
97985
98775
  this.count++;
97986
- if (obstacles.length > 0 && pushOutOfObstacles(piece2, obstacles)) piece2.rest = false;
97987
- if (!piece2.rest) this.move(piece2, dt);
98776
+ if (obstacles.length > 0 && pushOutOfObstacles(piece3, obstacles)) piece3.rest = false;
98777
+ if (!piece3.rest) this.move(piece3, dt);
97988
98778
  }
97989
98779
  }
97990
98780
  /** Scale at the end of its life, 1 until the last half second (the renderer's `sh`). */
97991
- static fade(piece2) {
97992
- return Math.min(1, piece2.life / FADE_SECONDS);
97993
- }
97994
- move(piece2, dt) {
97995
- piece2.vy -= GRAVITY22 * dt;
97996
- piece2.x += piece2.vx * dt;
97997
- piece2.y += piece2.vy * dt;
97998
- piece2.z += piece2.vz * dt;
97999
- piece2.rx += piece2.ax * dt;
98000
- piece2.ry += piece2.ay * dt;
98001
- piece2.rz += piece2.az * dt;
98002
- const groundHeight = Math.max(this.context.groundAt(piece2.x, piece2.z) + Math.min(piece2.sx, piece2.sy, piece2.sz) * 0.5, this.resting.supportUnder(piece2));
98003
- if (piece2.y >= groundHeight) return;
98004
- piece2.y = groundHeight;
98005
- piece2.vy *= -piece2.bounce;
98006
- piece2.vx *= 0.55;
98007
- piece2.vz *= 0.55;
98008
- piece2.ax *= 0.5;
98009
- piece2.ay *= 0.5;
98010
- piece2.az *= 0.5;
98011
- if (Math.abs(piece2.vy) < 0.5 && Math.hypot(piece2.vx, piece2.vz) < 0.3) {
98012
- piece2.rest = true;
98013
- piece2.rx = Math.round(piece2.rx / QUARTER_TURN4) * QUARTER_TURN4;
98014
- piece2.rz = Math.round(piece2.rz / QUARTER_TURN4) * QUARTER_TURN4;
98781
+ static fade(piece3) {
98782
+ return Math.min(1, piece3.life / FADE_SECONDS);
98783
+ }
98784
+ move(piece3, dt) {
98785
+ piece3.vy -= GRAVITY22 * dt;
98786
+ piece3.x += piece3.vx * dt;
98787
+ piece3.y += piece3.vy * dt;
98788
+ piece3.z += piece3.vz * dt;
98789
+ piece3.rx += piece3.ax * dt;
98790
+ piece3.ry += piece3.ay * dt;
98791
+ piece3.rz += piece3.az * dt;
98792
+ const groundHeight = Math.max(this.context.groundAt(piece3.x, piece3.z) + Math.min(piece3.sx, piece3.sy, piece3.sz) * 0.5, this.resting.supportUnder(piece3));
98793
+ if (piece3.y >= groundHeight) return;
98794
+ piece3.y = groundHeight;
98795
+ piece3.vy *= -piece3.bounce;
98796
+ piece3.vx *= 0.55;
98797
+ piece3.vz *= 0.55;
98798
+ piece3.ax *= 0.5;
98799
+ piece3.ay *= 0.5;
98800
+ piece3.az *= 0.5;
98801
+ if (Math.abs(piece3.vy) < 0.5 && Math.hypot(piece3.vx, piece3.vz) < 0.3) {
98802
+ piece3.rest = true;
98803
+ piece3.rx = Math.round(piece3.rx / QUARTER_TURN4) * QUARTER_TURN4;
98804
+ piece3.rz = Math.round(piece3.rz / QUARTER_TURN4) * QUARTER_TURN4;
98015
98805
  }
98016
98806
  }
98017
98807
  };
@@ -98969,9 +99759,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
98969
99759
  peekWorkshop: () => engine,
98970
99760
  effectIds: () => "volumetric_fire" in effects ? Object.keys(effects) : [...Object.keys(effects), "volumetric_fire"],
98971
99761
  explosion(id, point, explosionOptions = {}) {
98972
- const base = definitionOf(id);
98973
- if (!base) return null;
98974
- const def = scaleDefinition(base, explosionOptions.scale ?? 1);
99762
+ const base2 = definitionOf(id);
99763
+ if (!base2) return null;
99764
+ const def = scaleDefinition(base2, explosionOptions.scale ?? 1);
98975
99765
  const handle = ++handles.next;
98976
99766
  const direction = explosionOptions.direction && { x: explosionOptions.direction[0], y: explosionOptions.direction[1], z: explosionOptions.direction[2] };
98977
99767
  const random = streamOf(explosionOptions.seed);
@@ -100172,8 +100962,8 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
100172
100962
  var REST_TRIES = 8;
100173
100963
  var SAME_NORMAL = 0.9995;
100174
100964
  var restBox = () => ({ c: new Float64Array(3), axes: new Float64Array(9), half: new Float64Array(3), ext: new Float64Array(3) });
100175
- function boxOf3(piece2, out) {
100176
- const cx = Math.cos(piece2.rx), sx = Math.sin(piece2.rx), cy = Math.cos(piece2.ry), sy = Math.sin(piece2.ry), cz = Math.cos(piece2.rz), sz = Math.sin(piece2.rz);
100965
+ function boxOf3(piece3, out) {
100966
+ const cx = Math.cos(piece3.rx), sx = Math.sin(piece3.rx), cy = Math.cos(piece3.ry), sy = Math.sin(piece3.ry), cz = Math.cos(piece3.rz), sz = Math.sin(piece3.rz);
100177
100967
  const a = out.axes;
100178
100968
  a[0] = cy * cz;
100179
100969
  a[1] = sx * sy * cz + cx * sz;
@@ -100184,12 +100974,12 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
100184
100974
  a[6] = sy;
100185
100975
  a[7] = -sx * cy;
100186
100976
  a[8] = cx * cy;
100187
- out.half[0] = piece2.sx / 2;
100188
- out.half[1] = piece2.sy / 2;
100189
- out.half[2] = piece2.sz / 2;
100190
- out.c[0] = piece2.x;
100191
- out.c[1] = piece2.y;
100192
- out.c[2] = piece2.z;
100977
+ out.half[0] = piece3.sx / 2;
100978
+ out.half[1] = piece3.sy / 2;
100979
+ out.half[2] = piece3.sz / 2;
100980
+ out.c[0] = piece3.x;
100981
+ out.c[1] = piece3.y;
100982
+ out.c[2] = piece3.z;
100193
100983
  for (let w = 0; w < 3; w++) out.ext[w] = Math.abs(a[w]) * out.half[0] + Math.abs(a[3 + w]) * out.half[1] + Math.abs(a[6 + w]) * out.half[2];
100194
100984
  }
100195
100985
  function sharedPlane(a, b, push) {
@@ -100261,21 +101051,21 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
100261
101051
  sync() {
100262
101052
  let drawn = false;
100263
101053
  for (let index = 0; index < DEBRIS_CAPACITY; index++) {
100264
- const piece2 = pool.pieces[index];
100265
- if (!piece2.on || !piece2.rest) settled[index] = 0;
100266
- if (!piece2.on) {
101054
+ const piece3 = pool.pieces[index];
101055
+ if (!piece3.on || !piece3.rest) settled[index] = 0;
101056
+ if (!piece3.on) {
100267
101057
  mesh3.setMatrixAt(index, hidden);
100268
101058
  continue;
100269
101059
  }
100270
- if (piece2.rest && !settled[index]) settle(index);
101060
+ if (piece3.rest && !settled[index]) settle(index);
100271
101061
  drawn = true;
100272
- const shrink = Math.min(1, piece2.life / FADE_SECONDS2);
100273
- euler.set(piece2.rx, piece2.ry, piece2.rz);
101062
+ const shrink = Math.min(1, piece3.life / FADE_SECONDS2);
101063
+ euler.set(piece3.rx, piece3.ry, piece3.rz);
100274
101064
  quaternion2.setFromEuler(euler);
100275
- const off = piece2.rest ? 3 * index : -1;
100276
- matrix.compose(position.set(piece2.x + (off >= 0 ? offset[off] : 0), piece2.y + (off >= 0 ? offset[off + 1] : 0), piece2.z + (off >= 0 ? offset[off + 2] : 0)), quaternion2, scale.set(piece2.sx * shrink, piece2.sy * shrink, piece2.sz * shrink));
101065
+ const off = piece3.rest ? 3 * index : -1;
101066
+ matrix.compose(position.set(piece3.x + (off >= 0 ? offset[off] : 0), piece3.y + (off >= 0 ? offset[off + 1] : 0), piece3.z + (off >= 0 ? offset[off + 2] : 0)), quaternion2, scale.set(piece3.sx * shrink, piece3.sy * shrink, piece3.sz * shrink));
100277
101067
  mesh3.setMatrixAt(index, matrix);
100278
- mesh3.setColorAt(index, colour.setHex(piece2.color));
101068
+ mesh3.setColorAt(index, colour.setHex(piece3.color));
100279
101069
  }
100280
101070
  mesh3.instanceMatrix.needsUpdate = true;
100281
101071
  if (mesh3.instanceColor) mesh3.instanceColor.needsUpdate = true;
@@ -100690,12 +101480,12 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
100690
101480
  if (reducedMotion || !(shake > SHAKE_FLOOR)) return () => {
100691
101481
  };
100692
101482
  const camera2 = options.camera;
100693
- const base = camera2.position.clone();
101483
+ const base2 = camera2.position.clone();
100694
101484
  const reach2 = shake * SHAKE_REACH;
100695
101485
  camera2.position.x += Math.sin(clock * 71) * reach2;
100696
101486
  camera2.position.y += Math.sin(clock * 53 + 1) * reach2 * 0.7;
100697
101487
  camera2.position.z += Math.sin(clock * 67 + 2) * reach2;
100698
- return () => camera2.position.copy(base);
101488
+ return () => camera2.position.copy(base2);
100699
101489
  },
100700
101490
  stats() {
100701
101491
  const { lastBlast, ...counters } = world.stats();
@@ -101163,12 +101953,12 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
101163
101953
  const rest2 = /* @__PURE__ */ new Map();
101164
101954
  for (const part of [...registry.values(), model.root]) rest2.set(part, { position: part.position.clone(), rotation: part.rotation.clone() });
101165
101955
  const apply = (object2, pose2) => {
101166
- const base = rest2.get(object2);
101167
- if (!base) return;
101956
+ const base2 = rest2.get(object2);
101957
+ if (!base2) return;
101168
101958
  const [dx, dy, dz] = pose2.position ?? [0, 0, 0];
101169
101959
  const [rx, ry, rz] = pose2.rotation ?? [0, 0, 0];
101170
- object2.position.set(base.position.x + dx, base.position.y + dy, base.position.z + dz);
101171
- object2.rotation.set(base.rotation.x + rx, base.rotation.y + ry, base.rotation.z + rz);
101960
+ object2.position.set(base2.position.x + dx, base2.position.y + dy, base2.position.z + dz);
101961
+ object2.rotation.set(base2.rotation.x + rx, base2.rotation.y + ry, base2.rotation.z + rz);
101172
101962
  };
101173
101963
  return {
101174
101964
  setPartPose(partId, pose2) {
@@ -102636,11 +103426,11 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
102636
103426
  const quaternion2 = hand.quaternion.clone().multiply(rig.grip.quaternion.clone().invert());
102637
103427
  return { position: hand.position.clone().sub(rig.grip.position.clone().applyQuaternion(quaternion2)), quaternion: quaternion2 };
102638
103428
  };
102639
- const relativeTo = (frame2, base) => {
102640
- const inverse = base.quaternion.clone().invert();
102641
- return { position: frame2.position.clone().sub(base.position).applyQuaternion(inverse), quaternion: inverse.multiply(frame2.quaternion) };
103429
+ const relativeTo = (frame2, base2) => {
103430
+ const inverse = base2.quaternion.clone().invert();
103431
+ return { position: frame2.position.clone().sub(base2.position).applyQuaternion(inverse), quaternion: inverse.multiply(frame2.quaternion) };
102642
103432
  };
102643
- const inFrame = (local2, base) => ({ position: local2.position.clone().applyQuaternion(base.quaternion).add(base.position), quaternion: base.quaternion.clone().multiply(local2.quaternion) });
103433
+ const inFrame = (local2, base2) => ({ position: local2.position.clone().applyQuaternion(base2.quaternion).add(base2.position), quaternion: base2.quaternion.clone().multiply(local2.quaternion) });
102644
103434
  const holdFrame = () => {
102645
103435
  const pose2 = options.holdFrame?.();
102646
103436
  return pose2 ? frameOf2(pose2) : null;
@@ -102653,8 +103443,8 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
102653
103443
  return { position: start.position.clone().addScaledVector(ahead, HOLSTER_TOSS.ahead).add(new THREE.Vector3(0, -HOLSTER_TOSS.drop, 0)), quaternion: turn2.multiply(start.quaternion.clone()) };
102654
103444
  }
102655
103445
  if (entry2.motion?.kind === "back") {
102656
- const base = holdFrame();
102657
- return base && entry2.taken ? inFrame(entry2.taken, base) : null;
103446
+ const base2 = holdFrame();
103447
+ return base2 && entry2.taken ? inFrame(entry2.taken, base2) : null;
102658
103448
  }
102659
103449
  const pose2 = options.bodySlot(entry2.slot);
102660
103450
  if (!pose2) return null;
@@ -102734,8 +103524,8 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
102734
103524
  const entry2 = { weapon: event.weapon, slot: event.slot, rig, motion: null, taken: null, swing: event.slot === "sling" ? createSlingSwing() : null, last: null, speed: new THREE.Vector3(), lean: 0 };
102735
103525
  if (event.from && seconds > 0) {
102736
103526
  const start = holderOnHand(rig, frameOf2(event.from));
102737
- const base = holdFrame();
102738
- entry2.taken = base ? relativeTo(start, base) : null;
103527
+ const base2 = holdFrame();
103528
+ entry2.taken = base2 ? relativeTo(start, base2) : null;
102739
103529
  entry2.motion = { kind: event.slot === GROUND_SLOT ? "toss" : "away", time: 0, seconds, start };
102740
103530
  } else if (event.slot === GROUND_SLOT) return;
102741
103531
  away.set(event.weapon, entry2);
@@ -103619,9 +104409,9 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
103619
104409
  return entry2?.source === "commons" && entry2.author && entry2.license ? `${entry2.author}, ${entry2.license}` : void 0;
103620
104410
  }
103621
104411
  var DEFAULT_THUMBNAIL_BASE = "weapon-svg/";
103622
- function weaponThumbnailUrl(id, base = DEFAULT_THUMBNAIL_BASE) {
104412
+ function weaponThumbnailUrl(id, base2 = DEFAULT_THUMBNAIL_BASE) {
103623
104413
  const entry2 = WEAPON_THUMBNAILS[id];
103624
- return entry2 ? `${base}${entry2.file}` : void 0;
104414
+ return entry2 ? `${base2}${entry2.file}` : void 0;
103625
104415
  }
103626
104416
 
103627
104417
  // src/world-explosives.ts
@@ -103987,9 +104777,9 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
103987
104777
  id: COUNTER_ITEM_ID,
103988
104778
  name,
103989
104779
  build: (THREE) => {
103990
- const piece2 = counter(THREE);
103991
- const root = piece2.build(THREE);
103992
- root.userData.counterSpec = { ...piece2.spec, name, tags: [...piece2.spec.tags ?? [], "furniture"] };
104780
+ const piece3 = counter(THREE);
104781
+ const root = piece3.build(THREE);
104782
+ root.userData.counterSpec = { ...piece3.spec, name, tags: [...piece3.spec.tags ?? [], "furniture"] };
103993
104783
  return root;
103994
104784
  },
103995
104785
  spec: (root) => root.userData.counterSpec,
@@ -104858,8 +105648,8 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
104858
105648
  if (!needRoom() || !room) return false;
104859
105649
  const vessel = withVessel();
104860
105650
  if (!vessel) return false;
104861
- const base = vessel.root.getWorldPosition(new (T2()).Vector3());
104862
- const point = [base.x + FIRE_OFFSET[0], base.y + FIRE_OFFSET[1], base.z + FIRE_OFFSET[2]];
105651
+ const base2 = vessel.root.getWorldPosition(new (T2()).Vector3());
105652
+ const point = [base2.x + FIRE_OFFSET[0], base2.y + FIRE_OFFSET[1], base2.z + FIRE_OFFSET[2]];
104863
105653
  const config = def.fire ?? { temperature: 700, radius: 1.4, seconds: 7 };
104864
105654
  vessel.firePoint = point;
104865
105655
  vessel.fireUntil = now() + config.seconds + 3;
@@ -105328,7 +106118,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
105328
106118
  area: () => {
105329
106119
  bench.areaOpened();
105330
106120
  const placements = [
105331
- ...scene.furniture.map((piece2) => ({ item: piece2.item, position: piece2.at, ...piece2.rotationY === void 0 ? {} : { rotationY: piece2.rotationY } })),
106121
+ ...scene.furniture.map((piece3) => ({ item: piece3.item, position: piece3.at, ...piece3.rotationY === void 0 ? {} : { rotationY: piece3.rotationY } })),
105332
106122
  { item: `${WORLD_EXPLOSIVE_PREFIX}${EXPLOSIVE_ID}`, position: scene.cylinder },
105333
106123
  // facing the cylinder (the front of an item looks to +z, the cylinder is at -z)
105334
106124
  { item: scene.zombie.item, position: scene.zombie.at, rotationY: Math.PI },