@adatechnology/game-weapons-three 0.29.4 → 0.29.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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
  })();
@@ -22347,7 +22347,27 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
22347
22347
  var MAX_SPALLS = 64;
22348
22348
  var thinAxisOf = (dims) => dims[0] <= dims[1] && dims[0] <= dims[2] ? 0 : dims[1] <= dims[2] ? 1 : 2;
22349
22349
  var resolveLayer = (def, index, mat) => ({ index, def, mat, energy: mat.penetration * def.thickness * 1e3 });
22350
- 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];
22351
22371
  var isSpalled = (spalls, layer3, face, point) => {
22352
22372
  for (const s of spalls ?? []) {
22353
22373
  if (s[0] !== layer3 || s[1] !== face) continue;
@@ -22367,6 +22387,23 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
22367
22387
  for (const l of layers) if (onFace(l, face)) sum2 += l.def.thickness;
22368
22388
  return sum2;
22369
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
+ };
22370
22407
  var REBAR_COVER = 0.03;
22371
22408
  var COVER = REBAR_COVER;
22372
22409
  var MAX_BARS_PER_DIRECTION = 24;
@@ -23327,8 +23364,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23327
23364
  beams += cos2 * cos2 * q.elasticPa * c.beamFactor * inertia / Math.max(long, 1e-6);
23328
23365
  }
23329
23366
  const k = beams / kc;
23330
- const base = p.min[1] - ground < 0.05;
23331
- 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);
23332
23369
  const stiffness = a * 12 * (p.elasticPa * c.stiffnessFactor) * (g[i].du ** 3 * g[i].dv / 12) / (h * h);
23333
23370
  for (let j = 0; j < n; j++) ga[j] += stiffness * share(p, j) / bands[j];
23334
23371
  }
@@ -23513,7 +23550,49 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23513
23550
  elasticGPa: 200,
23514
23551
  absorbed: 0.2
23515
23552
  },
23516
- 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
23517
23596
  },
23518
23597
  {
23519
23598
  id: "cast_iron",
@@ -23580,7 +23659,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23580
23659
  "conductive"
23581
23660
  ],
23582
23661
  compressive: 8e5,
23583
- failureMPa: 90
23662
+ failureMPa: 90,
23663
+ tension: {
23664
+ elasticGPa: 69,
23665
+ ultimateMPa: 170
23666
+ }
23584
23667
  },
23585
23668
  {
23586
23669
  id: "copper",
@@ -23611,7 +23694,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23611
23694
  "conductive"
23612
23695
  ],
23613
23696
  compressive: 1e6,
23614
- failureMPa: 70
23697
+ failureMPa: 70,
23698
+ tension: {
23699
+ elasticGPa: 117,
23700
+ ultimateMPa: 250
23701
+ }
23615
23702
  },
23616
23703
  {
23617
23704
  id: "wood_soft",
@@ -24152,7 +24239,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24152
24239
  "flammable"
24153
24240
  ],
24154
24241
  compressive: 500,
24155
- 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
+ }
24156
24253
  },
24157
24254
  {
24158
24255
  id: "foam",
@@ -24160,6 +24257,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24160
24257
  hpPerKg: 15,
24161
24258
  penetration: 0.5,
24162
24259
  ductility: 0.7,
24260
+ cellular: true,
24163
24261
  fracture: "tear",
24164
24262
  splitForm: "granules",
24165
24263
  fragmentSize: [
@@ -24179,16 +24277,29 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24179
24277
  burnRate: 0.09,
24180
24278
  conductivity: 0.02,
24181
24279
  heatCapacity: 0.5,
24182
- smoke: "black"
24280
+ smoke: "black",
24281
+ meltC: 200,
24282
+ meltRate: 0.08
24183
24283
  },
24184
24284
  visual: {
24185
- charColor: 855309
24285
+ charColor: 855309,
24286
+ innerColor: 15254346
24186
24287
  },
24187
24288
  tags: [
24188
24289
  "fabric",
24189
24290
  "flammable"
24190
24291
  ],
24191
- 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
+ }
24192
24303
  },
24193
24304
  {
24194
24305
  id: "leather",
@@ -24978,19 +25089,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24978
25089
  };
24979
25090
  var placedPieces = /* @__PURE__ */ new WeakMap();
24980
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];
24981
- var hostedPieces = (pieces, pose2) => pieces.map((piece2, index) => {
24982
- const known = placedPieces.get(piece2);
25092
+ var hostedPieces = (pieces, pose2) => pieces.map((piece3, index) => {
25093
+ const known = placedPieces.get(piece3);
24983
25094
  const p = pose2.position, q = pose2.rotation;
24984
- 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 });
24985
25096
  if (known && isSamePlace) return known.solid;
24986
- const solid2 = placedPiece(piece2, index, pose2);
24987
- 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 });
24988
25099
  return solid2;
24989
25100
  });
24990
- var placedPiece = (piece2, index, pose2) => {
24991
- 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}` };
24992
- if (!piece2.mesh) return base;
24993
- 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;
24994
25105
  const vertices = new Float32Array(source.length);
24995
25106
  for (let i = 0; i < source.length; i += 3) {
24996
25107
  const world = toWorld(pose2.position, pose2.rotation, [source[i], source[i + 1], source[i + 2]]);
@@ -24998,9 +25109,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24998
25109
  vertices[i + 1] = world[1];
24999
25110
  vertices[i + 2] = world[2];
25000
25111
  }
25001
- return { ...base, mesh: { vertices, indices: piece2.mesh.indices } };
25112
+ return { ...base2, mesh: { vertices, indices: piece3.mesh.indices } };
25002
25113
  };
25003
25114
  var THIN_SHEET_DISHING = 5e-3;
25115
+ var SHELL_YIELD_SHARE = 0.5;
25116
+ var STEEL_YIELD_MPA = 250;
25004
25117
  var SWEEP_BACK = 0.01;
25005
25118
  function sweepOrigins(box5, d, spacing) {
25006
25119
  const origins = [];
@@ -25059,14 +25172,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
25059
25172
  var MEMBER_CRATER_CALIBRES = 3.4;
25060
25173
  var MEMBER_CUT_LOSS = 0.9;
25061
25174
  var MEMBER_UNIT_LOSS = 0.12;
25175
+ var CHIP_PROBE_DEPTH = 1e-4;
25062
25176
  var JOINT_OPEN_SHARE = 0.6;
25063
25177
  var BLAST_EDGE_WEAR = 0.6;
25064
25178
  var RESIDUAL_CAPACITY = 0.15;
25065
25179
  var SEVER_BAND = 0.1;
25180
+ var SURFACE_SLACK = 0.01;
25181
+ var SURFACE_SAME = 5e-4;
25066
25182
  var SEVER_ASPECT = 3;
25067
25183
  var SEVER_BALLISTIC = 2;
25184
+ var SEVER_TRACK = 4;
25068
25185
  var TEAR_JOULES = 150;
25069
- var tears = 0;
25186
+ var STRIP_THICKNESS = 15e-4;
25070
25187
  var UNIT_FRAGMENT_FACTOR = 4;
25071
25188
  var BREACH_GRID_CAP = 4096;
25072
25189
  var MASONRY_CRUMBLE_SPEED = 0.6;
@@ -25237,6 +25354,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
25237
25354
  const rnd2 = () => rng2.next();
25238
25355
  let time = 0;
25239
25356
  let counter = 0;
25357
+ let tears = 0;
25240
25358
  const objects = /* @__PURE__ */ new Map();
25241
25359
  const slots = /* @__PURE__ */ new Map();
25242
25360
  let slotCounter = 0;
@@ -25270,7 +25388,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
25270
25388
  if (typed) for (const fn of typed) fn(e);
25271
25389
  };
25272
25390
  let blow3;
25273
- const base = (o, source) => ({
25391
+ const base2 = (o, source) => ({
25274
25392
  object: o.id,
25275
25393
  time,
25276
25394
  ...source === void 0 ? {} : { source },
@@ -26158,7 +26276,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
26158
26276
  w.emitted = { t: time, peak: d.peak, status: st.status };
26159
26277
  const dir = windDirection(o, w.cfg);
26160
26278
  const world2 = rotateVec(o.base.rot, [dir[0], 0, dir[1]]);
26161
- 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 });
26279
+ 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 });
26162
26280
  }
26163
26281
  };
26164
26282
  const isTerrain = (p) => !!p.spec.tags?.includes("terrain");
@@ -26366,7 +26484,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
26366
26484
  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);
26367
26485
  if (changed) {
26368
26486
  so.emitted = { t: time, s: st.settlement, tilt: st.tilt, status: st.status };
26369
- emit2({ ...base(o), type: "settle", settlement: st.settlement, tilt: st.tilt, direction: rotateVec(o.base.rot, st.direction), bearing: st.bearing, status: st.status });
26487
+ emit2({ ...base2(o), type: "settle", settlement: st.settlement, tilt: st.tilt, direction: rotateVec(o.base.rot, st.direction), bearing: st.bearing, status: st.status });
26370
26488
  }
26371
26489
  if (st.status === "toppled") topple(o);
26372
26490
  };
@@ -26415,7 +26533,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
26415
26533
  p.st.status = "broken";
26416
26534
  p.st.hp = 0;
26417
26535
  p.st.mass = 0;
26418
- emit2({ ...base(o, src), type: "fracture", part: p.spec.id, style: "crumble", fragments, point: c });
26536
+ emit2({ ...base2(o, src), type: "fracture", part: p.spec.id, style: "crumble", fragments, point: c });
26419
26537
  debris2(o, p, p.mat.breakDebris, c, [0, 1, 0], clamp2(Math.round(Math.cbrt(partVolume(p.spec.shape)) * 30), 3, 20), 2, src);
26420
26538
  setStage(o, p, 3, {}, src);
26421
26539
  partLost(o, p, src);
@@ -26437,7 +26555,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
26437
26555
  markHostedDirty(o, p.spec.id);
26438
26556
  setStage(o, p, 3, {}, src);
26439
26557
  }
26440
- 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) });
26558
+ 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) });
26441
26559
  }
26442
26560
  for (const p of crumbling) crumbleMasonry(o, p, src);
26443
26561
  }
@@ -26758,7 +26876,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
26758
26876
  r.st.subsidence = Math.max(r.st.subsidence ?? 0, drop.reduce((sum2, v) => sum2 + v, 0) / count);
26759
26877
  const middle = [from[0], from[1], from[2]];
26760
26878
  middle[axis2] = (stretch[0] + stretch[1]) / 2;
26761
- 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" });
26879
+ 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" });
26762
26880
  let lost = false;
26763
26881
  for (const j of [...o.byPart.get(r.spec.id) ?? []]) {
26764
26882
  settleStructure(o);
@@ -26798,7 +26916,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
26798
26916
  if (p.staged) {
26799
26917
  setStage(o, p, 1, {}, src);
26800
26918
  setStage(o, p, 2, { opening: { center: worldCenter, radius: hole.radius }, fragments }, src);
26801
- } else emit2({ ...base(o, src), type: "stage", part: p.spec.id, stage: 2, opening: { center: worldCenter, radius: hole.radius }, fragments });
26919
+ } else emit2({ ...base2(o, src), type: "stage", part: p.spec.id, stage: 2, opening: { center: worldCenter, radius: hole.radius }, fragments });
26802
26920
  debris2(o, p, p.mat.breakDebris, worldCenter, [0, 1, 0], 14, 2, src);
26803
26921
  if (p.spec.reinforcement) exposeRebar(o, p, src);
26804
26922
  };
@@ -26824,8 +26942,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
26824
26942
  const width = clamp2(beta * SETTLEMENT_CRACK_OPENING, MIN_CRACK_WIDTH, MAX_CRACK_WIDTH);
26825
26943
  const through = q.dims[q.thin];
26826
26944
  for (let c = 0; c < count; c++) {
26827
- const back = c * SETTLEMENT_CRACK_SPACING;
26828
- 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])];
26945
+ const back2 = c * SETTLEMENT_CRACK_SPACING;
26946
+ 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])];
26829
26947
  const face = toLocal(q.pos, q.q, local2);
26830
26948
  face[q.thin] = through / 2;
26831
26949
  addCrack(o, q, toWorld(o.st.position, o.st.rotation, toWorld(q.pos, q.q, face)), normal, length2, src, { along: along2, step, width, through });
@@ -26947,7 +27065,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
26947
27065
  }
26948
27066
  if (bearing2.status === "settled" && drop - before < SUBSIDE_MIN && peak() - peakBefore < SUBSIDE_MIN) continue;
26949
27067
  b.p.st.subsidence = drop;
26950
- emit2({ ...base(o, src), type: "subside", part: b.p.spec.id, drop, share: fp.share, point: fp.deepest, status: bearing2.status });
27068
+ emit2({ ...base2(o, src), type: "subside", part: b.p.spec.id, drop, share: fp.share, point: fp.deepest, status: bearing2.status });
26951
27069
  }
26952
27070
  for (const { b, fp } of settled) {
26953
27071
  settleStructure(o);
@@ -27062,7 +27180,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27062
27180
  const known = implSolids.get(im);
27063
27181
  if (known && known.spec === spec && known.state === state && im.impl.collidersPending?.() !== true && sameImplPlace(known.key, im)) return known.solids;
27064
27182
  const pieces = im.impl.colliders?.();
27065
- if (pieces && known?.pieces && known.spec === spec && sameImplPlace(known.key, im) && pieces.length === known.pieces.length && pieces.every((piece2, i) => piece2 === known.pieces?.[i])) {
27183
+ if (pieces && known?.pieces && known.spec === spec && sameImplPlace(known.key, im) && pieces.length === known.pieces.length && pieces.every((piece3, i) => piece3 === known.pieces?.[i])) {
27066
27184
  implSolids.set(im, { ...known, state });
27067
27185
  return known.solids;
27068
27186
  }
@@ -27147,6 +27265,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27147
27265
  return fresh.map(([nid]) => nid);
27148
27266
  };
27149
27267
  let rayBroad = null;
27268
+ let surfaceTracer = null;
27150
27269
  let uncovered = [];
27151
27270
  let uncoveredFor = { hook: null, coverage: -1, objects: -1 };
27152
27271
  const metObjects = [];
@@ -27176,7 +27295,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27176
27295
  }
27177
27296
  return rayObjects;
27178
27297
  };
27179
- const raycastInternal = (origin, dir, maxDist, ignore, worldOnly = false, precise = false, skip = {}, scope2) => {
27298
+ const raycastInternal = (origin, dir, maxDist, ignore, worldOnly = false, precise = false, skip = {}, scope2, drawn = false, passed) => {
27180
27299
  const d = vec.normalize(dir);
27181
27300
  const asked = rayBroad && !scope2 && rayBroad.begin(origin, d, maxDist) ? rayBroad : null;
27182
27301
  const candidates = asked ? candidatesOf2(asked) : null;
@@ -27204,12 +27323,22 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27204
27323
  if (!r || r.t0 < 0 || r.t0 > maxDist) continue;
27205
27324
  if (p.st.opening && insideOpening(o, p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
27206
27325
  if (p.spec.apertures && throughAperture(p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
27207
- if (p.st.chipped && insideChip(p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
27326
+ if (p.st.chipped && insideChip(p, objLocal(o, vec.madd(origin, d, Math.min(r.t0 + CHIP_PROBE_DEPTH, (r.t0 + r.t1) / 2))))) {
27327
+ passed?.push({ o, p, t: r.t0 });
27328
+ continue;
27329
+ }
27208
27330
  const gap = p.st.chipped?.length ? pastChips(o, p, origin, d, r.t0, r.t1) : null;
27209
27331
  if (gap === "through") continue;
27210
27332
  if (gap) {
27211
27333
  r.t0 = gap.t;
27212
27334
  r.n = gap.n;
27335
+ } else if (drawn && surfaceTracer) {
27336
+ 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 });
27337
+ if (drawn2 === null) continue;
27338
+ if (drawn2 && drawn2.distance <= maxDist && Math.abs(drawn2.distance - r.t0) > SURFACE_SAME) {
27339
+ r.t0 = drawn2.distance;
27340
+ r.n = [drawn2.normal[0], drawn2.normal[1], drawn2.normal[2]];
27341
+ }
27213
27342
  }
27214
27343
  if (!best || r.t0 < best.distance) {
27215
27344
  const point = vec.madd(origin, d, r.t0);
@@ -27350,14 +27479,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27350
27479
  arr[ni].radius = Math.max(arr[ni].radius, radius);
27351
27480
  } else arr.push(dent);
27352
27481
  markDamaged(p);
27353
- emit2({ ...base(o, src), type: "dent", part: p.spec.id, dent, worldPoint: wp });
27482
+ emit2({ ...base2(o, src), type: "dent", part: p.spec.id, dent, worldPoint: wp });
27354
27483
  };
27355
27484
  const addHole = (o, p, wp, wn, diameter, through, exit, src) => {
27356
27485
  const hole = { point: objLocal(o, wp), normal: objLocalDir(o, wn), diameter, through };
27357
27486
  p.st.holes.push(hole);
27358
27487
  if (p.st.holes.length > maxHoles) p.st.holes.shift();
27359
27488
  markDamaged(p);
27360
- emit2({ ...base(o, src), type: "hole", part: p.spec.id, hole, worldPoint: wp, ...exit ? { exitPoint: exit } : {}, ...p.spec.powder ? { powder: { ...p.spec.powder } } : {} });
27489
+ emit2({ ...base2(o, src), type: "hole", part: p.spec.id, hole, worldPoint: wp, ...exit ? { exitPoint: exit } : {}, ...p.spec.powder ? { powder: { ...p.spec.powder } } : {} });
27361
27490
  setStage(o, p, 1, {}, src);
27362
27491
  return hole;
27363
27492
  };
@@ -27366,13 +27495,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27366
27495
  p.st.cracks.push(crack);
27367
27496
  if (p.st.cracks.length > 16) p.st.cracks.shift();
27368
27497
  markDamaged(p);
27369
- emit2({ ...base(o, src), type: "crack", part: p.spec.id, crack, worldPoint: wp });
27498
+ emit2({ ...base2(o, src), type: "crack", part: p.spec.id, crack, worldPoint: wp });
27370
27499
  setStage(o, p, 1, {}, src);
27371
27500
  };
27372
- 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 } : {} });
27501
+ 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 } : {} });
27373
27502
  const holeRate = (hole, pressurized) => (pressurized ? 0.5 : 0.1) * (hole.diameter / 9e-3);
27374
27503
  const detachEvents = (o, opened, by, src) => {
27375
- 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]) });
27504
+ 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]) });
27376
27505
  };
27377
27506
  const loosened = (o, opened, by, src) => {
27378
27507
  if (runDepth === 0) {
@@ -27451,7 +27580,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27451
27580
  const checkDestroyed = (o, src) => {
27452
27581
  if (!o.st.destroyed && o.parts.length > 0 && o.parts.every(isLost)) {
27453
27582
  o.st.destroyed = true;
27454
- emit2({ ...base(o, src), type: "destroyed" });
27583
+ emit2({ ...base2(o, src), type: "destroyed" });
27455
27584
  }
27456
27585
  };
27457
27586
  const holeReaches = (host, box5) => {
@@ -27491,7 +27620,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27491
27620
  } else {
27492
27621
  o.hostedHosts = new Set(o.hosted.map((p) => p.spec.hostedIn));
27493
27622
  }
27494
- for (const p of shown) emit2({ ...base(o), type: "reveal", part: p.spec.id, host: p.spec.hostedIn });
27623
+ for (const p of shown) emit2({ ...base2(o), type: "reveal", part: p.spec.id, host: p.spec.hostedIn });
27495
27624
  if (opened.length > 0) {
27496
27625
  loosened(o, opened, "break");
27497
27626
  collapseCheck(o);
@@ -27617,26 +27746,48 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27617
27746
  const setStage = (o, p, stage2, extra = {}, src) => {
27618
27747
  if (!p.staged || (p.st.stage ?? 0) >= stage2) return;
27619
27748
  p.st.stage = stage2;
27620
- emit2({ ...base(o, src), type: "stage", part: p.spec.id, stage: stage2, ...extra });
27749
+ emit2({ ...base2(o, src), type: "stage", part: p.spec.id, stage: stage2, ...extra });
27750
+ };
27751
+ const faceOf = (o, p, worldNormal) => faceOfNormal(p.layers, p.thin, rotateVec(quat.conjugate(partXf(o, p).q), worldNormal));
27752
+ const spallNormal = (o, p, face) => {
27753
+ if (Math.abs(face) === 1) return {};
27754
+ const local2 = [0, 0, 0];
27755
+ local2[faceAxis(p.thin, face)] = face > 0 ? 1 : -1;
27756
+ return { normal: rotateVec(partXf(o, p).q, local2) };
27757
+ };
27758
+ const widenTear = (o, p, torn, lp, normal, radius, src) => {
27759
+ const spalls = p.rt.spalls;
27760
+ const s = spalls[torn.spall];
27761
+ const axis2 = faceAxis(p.thin, s[1]);
27762
+ const faceArea = p.dims.reduce((area3, size, k) => k === axis2 ? area3 : area3 * size, 1);
27763
+ const reach2 = Math.hypot(lp[0] - s[2], lp[1] - s[3], lp[2] - s[4]);
27764
+ const r = Math.min(Math.sqrt(faceArea / Math.PI), Math.max(Math.sqrt(s[5] * s[5] + radius * radius), reach2));
27765
+ if (r <= s[5]) return;
27766
+ spalls[torn.spall] = [s[0], s[1], s[2], s[3], s[4], r];
27767
+ markDamaged(p);
27768
+ const centre = toWorld(o.st.position, o.st.rotation, [s[2], s[3], s[4]]);
27769
+ 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]) });
27770
+ debris2(o, p, torn.layer.mat.hitDebris, toWorld(o.st.position, o.st.rotation, lp), normal, 5, 2, src, torn.layer.mat.id);
27621
27771
  };
27622
- const faceOf = (o, p, worldNormal) => rotateVec(quat.conjugate(partXf(o, p).q), worldNormal)[p.thin] >= 0 ? 1 : -1;
27623
27772
  const spallOuter = (o, p, wp, face, normal, radius, src) => {
27624
27773
  var _a;
27625
27774
  if (p.layers.length === 0) return;
27626
27775
  const lp = objLocal(o, wp);
27776
+ const torn = tornPatchAt(p.layers, p.rt.spalls, face, lp, radius);
27777
+ if (torn) return widenTear(o, p, torn, lp, normal, radius, src);
27627
27778
  const layer3 = outerLayer(p.layers, p.rt.spalls, face, lp);
27628
27779
  if (!layer3) return;
27629
27780
  const spalls = (_a = p.rt).spalls ?? (_a.spalls = []);
27630
27781
  spalls.push([layer3.index, face, lp[0], lp[1], lp[2], radius]);
27631
27782
  if (spalls.length > MAX_SPALLS) spalls.shift();
27632
27783
  markDamaged(p);
27633
- emit2({ ...base(o, src), type: "spall", part: p.spec.id, layer: layer3.index, point: wp, area: Math.PI * radius * radius });
27784
+ emit2({ ...base2(o, src), type: "spall", part: p.spec.id, layer: layer3.index, point: wp, area: Math.PI * radius * radius, ...spallNormal(o, p, face) });
27634
27785
  debris2(o, p, layer3.mat.hitDebris, wp, normal, 5, 2, src, layer3.mat.id);
27635
27786
  setStage(o, p, 1, {}, src);
27636
27787
  };
27637
27788
  const crater = (o, p, wp, normal, radius, src) => {
27638
27789
  markDamaged(p);
27639
- emit2({ ...base(o, src), type: "spall", part: p.spec.id, layer: -1, point: wp, area: Math.PI * radius * radius });
27790
+ emit2({ ...base2(o, src), type: "spall", part: p.spec.id, layer: -1, point: wp, area: Math.PI * radius * radius });
27640
27791
  debris2(o, p, p.mat.breakDebris, wp, normal, 6, 1.5, src);
27641
27792
  setStage(o, p, 1, {}, src);
27642
27793
  };
@@ -27705,7 +27856,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27705
27856
  if (!layer3 || cells.length === 0) return [];
27706
27857
  const { c, q } = partXf(o, p);
27707
27858
  const [u, v] = planeAxes(p.thin);
27708
- const faces = layer3.def.faces === "both" ? [1, -1] : [layer3.def.faces === "+" ? 1 : -1];
27859
+ const faces = thinSidesOf(layer3.def);
27709
27860
  const area3 = cells.reduce((sum2, cell) => sum2 + cell.size[u] * cell.size[v], 0) * faces.length;
27710
27861
  const count = Math.min(MAX_PLASTER_FLAKES, Math.ceil(area3 / PLASTER_FLAKE_AREA));
27711
27862
  const out = [];
@@ -27887,6 +28038,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27887
28038
  }
27888
28039
  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);
27889
28040
  };
28041
+ const alongAt = (along2, at4) => {
28042
+ const point = [0, 0, 0];
28043
+ point[along2] = at4;
28044
+ return point;
28045
+ };
27890
28046
  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";
27891
28047
  const wearMember = (o, p, entry2, d, E, caliber, penMm, src) => {
27892
28048
  var _a, _b, _c;
@@ -27921,7 +28077,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27921
28077
  const wear = (_c = p.rt).cellWear ?? (_c.cellWear = {});
27922
28078
  const cell = grid[hit];
27923
28079
  wear[hit] = (wear[hit] ?? 0) + volume;
27924
- if (wear[hit] >= MEMBER_UNIT_LOSS * cell.size[0] * cell.size[1] * cell.size[2]) knockOutUnits(o, p, entry2, E, [hit], src);
28080
+ if (wear[hit] >= MEMBER_UNIT_LOSS * cell.size[0] * cell.size[1] * cell.size[2]) knockOutUnits(o, p, entry2, E, [hit], src, d);
27925
28081
  return true;
27926
28082
  }
27927
28083
  const out = [];
@@ -27929,8 +28085,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27929
28085
  if (gone[i] === -1) continue;
27930
28086
  if (Math.abs(grid[i].center[along2] - bandCenter) <= height / 2 + 1e-6) out.push(i);
27931
28087
  }
27932
- if (out.length > 0) knockOutUnits(o, p, entry2, E, out, src);
27933
- giveAtCut(o, p, src);
28088
+ worn[band] = 1;
28089
+ if (out.length > 0) knockOutUnits(o, p, entry2, E, out, src, d);
28090
+ giveAtCut(o, p, src, { at: alongAt(along2, bandCenter), d });
27934
28091
  return true;
27935
28092
  };
27936
28093
  const chipUnits = (o, p, kind, wp, hitEnergy, dir, radius, src) => {
@@ -28002,7 +28159,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28002
28159
  p.rt.removed = (p.rt.removed ?? 0) + mass;
28003
28160
  markDamaged(p);
28004
28161
  setStage(o, p, 1, {}, src);
28005
- emit2({ ...base(o, src), type: "chip", part: p.spec.id, center, size: [cell.size[0], cell.size[1], cell.size[2]], rotation: q, fragments });
28162
+ emit2({ ...base2(o, src), type: "chip", part: p.spec.id, center, size: [cell.size[0], cell.size[1], cell.size[2]], rotation: q, fragments });
28006
28163
  debris2(o, p, p.mat.breakDebris, center, vec.scale(dir ?? [0, 1, 0], -1), 6, 2, src);
28007
28164
  }
28008
28165
  markHostedDirty(o, p.spec.id);
@@ -28037,18 +28194,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28037
28194
  const n = clamp2(Math.round(cell.size[u] * cell.size[v] / (bit * bit * 3)), 4, 10) + Math.floor(rnd2() * 3);
28038
28195
  const out = [];
28039
28196
  for (let i = 0; i < n; i++) {
28040
- const back = i % 3 === 2;
28197
+ const back2 = i % 3 === 2;
28041
28198
  const lc = [cell.center[0], cell.center[1], cell.center[2]];
28042
28199
  lc[u] += (rnd2() - 0.5) * cell.size[u] * 0.7;
28043
28200
  lc[v] += (rnd2() - 0.5) * cell.size[v] * 0.7;
28044
- lc[p.thin] += (back ? -exitSign : exitSign) * (p.thickness / 2 + 0.01);
28201
+ lc[p.thin] += (back2 ? -exitSign : exitSign) * (p.thickness / 2 + 0.01);
28045
28202
  const size = [0, 0, 0];
28046
28203
  size[u] = bit * (0.6 + 0.8 * rnd2());
28047
28204
  size[v] = bit * (0.5 + 0.7 * rnd2());
28048
28205
  size[p.thin] = bit * (0.4 + 0.6 * rnd2());
28049
28206
  const spread3 = [(rnd2() - 0.5) * 0.9, (rnd2() - 0.3) * 0.9, (rnd2() - 0.5) * 0.9];
28050
- const k = speed * (back ? 0.4 + 0.4 * rnd2() : 0.7 + 0.8 * rnd2());
28051
- const vdir = vec.normalize(vec.add(back ? vec.scale(d, -1) : d, spread3));
28207
+ const k = speed * (back2 ? 0.4 + 0.4 * rnd2() : 0.7 + 0.8 * rnd2());
28208
+ const vdir = vec.normalize(vec.add(back2 ? vec.scale(d, -1) : d, spread3));
28052
28209
  out.push({
28053
28210
  id: `${p.spec.id}#${tag}${i}`,
28054
28211
  part: p.spec.id,
@@ -28065,8 +28222,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28065
28222
  }
28066
28223
  return out;
28067
28224
  };
28068
- const exposeRebar = (o, p, src) => {
28069
- settleStructure(o);
28225
+ const exposeRebar = (o, p, src, bowed = true) => {
28226
+ if (bowed) settleStructure(o);
28070
28227
  const r = p.spec.reinforcement;
28071
28228
  if (!r) return;
28072
28229
  const [u, v] = planeAxes(p.thin);
@@ -28083,14 +28240,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28083
28240
  bars.push(...clipBarsToDisc(all, u, v, [lc[u], lc[v]], op.radius + 0.05));
28084
28241
  }
28085
28242
  }
28086
- const bow2 = clamp2(((p.st.stress ?? 0) - 1) / 0.5, 0, 1);
28243
+ const bow2 = bowed ? clamp2(((p.st.stress ?? 0) - 1) / 0.5, 0, 1) : 0;
28087
28244
  if (bow2 > 0) bars = bars.flatMap((bar2, i) => bendBar(bar2, p.thin, bow2 * BAR_BOW, i));
28088
28245
  const stirrups = memberStirrups(p.dims, void 0, p.spec.structure?.role);
28089
28246
  if (stirrups.length > 0 && bars.length > 0) {
28090
28247
  if (p.st.stripped) bars = [...bars, ...stirrups];
28091
28248
  else for (const box5 of [...p.st.chipped ?? [], ...p.rt.bared ?? []]) bars.push(...clipBarsToVolume(stirrups, box5.center, box5.size));
28092
28249
  }
28093
- emit2({ ...base(o, src), type: "expose", part: p.spec.id, bars: worldBars(o, p, bars) });
28250
+ emit2({ ...base2(o, src), type: "expose", part: p.spec.id, bars: worldBars(o, p, bars) });
28094
28251
  };
28095
28252
  const openBreach = (o, p, center, total, energy, dir, src) => {
28096
28253
  const [u, v] = planeAxes(p.thin);
@@ -28251,7 +28408,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28251
28408
  for (const i of out) worn[i] = -1;
28252
28409
  return knockOutUnits(o, p, point, energy, out, src);
28253
28410
  };
28254
- const knockOutUnits = (o, p, wp, energy, out, src) => {
28411
+ const knockOutUnits = (o, p, wp, energy, out, src, d) => {
28255
28412
  var _a, _b;
28256
28413
  const [u, v] = planeAxes(p.thin);
28257
28414
  const op = p.st.opening ? toLocal(p.pos, p.q, p.st.opening.center) : null;
@@ -28295,15 +28452,34 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28295
28452
  setStage(o, p, 1, {}, src);
28296
28453
  const center = toWorld(c, q, [(lo[0] + hi[0]) / 2, (lo[1] + hi[1]) / 2, (lo[2] + hi[2]) / 2]);
28297
28454
  const units = cells.map((cell) => ({ center: toWorld(c, q, cell.center), size: [cell.size[0], cell.size[1], cell.size[2]] }));
28298
- 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 });
28455
+ 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 });
28299
28456
  debris2(o, p, p.mat.breakDebris, center, vec.normalize(vec.sub(center, wp), [0, 1, 0]), 14, 3, src);
28300
- if (p.spec.reinforcement) exposeRebar(o, p, src);
28457
+ const cut = wornLocally(p) && cutBandsGone(o, p, cells, d ?? vec.normalize(vec.sub(partXf(o, p).c, wp), [1, 0, 0]), src);
28458
+ if (p.spec.reinforcement && !cut) exposeRebar(o, p, src);
28301
28459
  if (p.structural && !isLost(p)) {
28302
28460
  solveStructure(o);
28303
28461
  collapseCheck(o, src);
28304
28462
  }
28305
28463
  return true;
28306
28464
  };
28465
+ const cutBandsGone = (o, p, cells, d, src) => {
28466
+ var _a;
28467
+ const along2 = p.dims.indexOf(Math.max(...p.dims));
28468
+ const bands = Math.max(1, Math.round(p.dims[along2] / MEMBER_BAND));
28469
+ const height = p.dims[along2] / bands;
28470
+ const bandOf2 = (at4) => clamp2(Math.floor((at4 + p.dims[along2] / 2) / p.dims[along2] * bands), 0, bands - 1);
28471
+ const grid = gridOf(p);
28472
+ const gone = p.rt.chips ?? {};
28473
+ const worn = (_a = p.rt).bands ?? (_a.bands = {});
28474
+ for (const band of new Set(cells.map((cell) => bandOf2(cell.center[along2])))) {
28475
+ if ((worn[band] ?? 0) >= 1) continue;
28476
+ const center = -p.dims[along2] / 2 + (band + 0.5) * height;
28477
+ if (!grid.every((cell, i) => gone[i] === -1 || Math.abs(cell.center[along2] - center) > height / 2 + 1e-6)) continue;
28478
+ worn[band] = 1;
28479
+ return giveAtCut(o, p, src, { at: alongAt(along2, center), d });
28480
+ }
28481
+ return false;
28482
+ };
28307
28483
  const dropUnsupported = (o, p, src) => {
28308
28484
  var _a, _b;
28309
28485
  if (!p.spec.units || p.spec.units.mortar === p.spec.material || p.st.stripped || isLost(p)) return 0;
@@ -28337,17 +28513,90 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28337
28513
  p.rt.removed = (p.rt.removed ?? 0) + mass;
28338
28514
  markDamaged(p);
28339
28515
  const units = fallen.map((cell) => ({ center: toWorld(c, q, cell.center), size: [cell.size[0], cell.size[1], cell.size[2]] }));
28340
- 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 });
28516
+ 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 });
28341
28517
  debris2(o, p, p.mat.breakDebris, center, [0, -1, 0], 6, 1, src);
28342
28518
  return loose.length;
28343
28519
  };
28344
- const giveAtCut = (o, p, src) => {
28520
+ const barsMoment = (p) => {
28521
+ const r = p.spec.reinforcement;
28522
+ if (!r) return 0;
28523
+ const left = rebarBars(p.dims, p.thin, r.spacing, p.spec.structure?.role).length - (p.rt.severedBars?.length ?? 0);
28524
+ const along2 = p.dims.indexOf(Math.max(...p.dims));
28525
+ const side = Math.min(...p.dims.filter((_, a) => a !== along2));
28526
+ const fy = (materials.get(r.material)?.bending?.yieldMPa ?? STEEL_YIELD_MPA) * 1e6;
28527
+ return Math.max(0, left) / 2 * Math.PI * (r.diameter / 2) ** 2 * fy * Math.max(0, side - 2 * REBAR_COVER);
28528
+ };
28529
+ const memberSide = (p) => {
28530
+ const along2 = p.dims.indexOf(Math.max(...p.dims));
28531
+ return Math.min(...p.dims.filter((_, a) => a !== along2));
28532
+ };
28533
+ const tubeMoment = (p, share) => {
28534
+ const [a = 0, b = 0] = [...p.dims].sort((x, y) => x - y);
28535
+ const fy = (p.mat.bending?.yieldMPa ?? STEEL_YIELD_MPA) * 1e6;
28536
+ return fy * p.thickness * ((a + b) / 2) ** 2 * Math.max(0, 1 - share) ** 2;
28537
+ };
28538
+ const holdsAbove = (o, p, j) => {
28539
+ if (j.st.open) return false;
28540
+ const other = o.parts[j.ia === o.idx.get(p.spec.id) ? j.ib : j.ia];
28541
+ if (j.bears === "a_on_b") return j.spec.b === p.spec.id;
28542
+ if (j.bears === "b_on_a") return j.spec.a === p.spec.id;
28543
+ return partXf(o, other).c[1] > partXf(o, p).c[1] + 1e-6;
28544
+ };
28545
+ const hingeAcross = (o, p, opened, cut, src) => {
28546
+ var _a;
28547
+ const blow22 = cut.d ? objLocalDir(o, cut.d) : [1, 0, 0];
28548
+ const across2 = vec.normalize([blow22[0], 0, blow22[2]], [1, 0, 0]);
28549
+ const point = vec.madd(vec.add(p.pos, rotateVec(p.q, cut.at)), across2, cut.behind);
28550
+ const toward2 = vec.scale(across2, -1);
28551
+ const moment = cut.moment;
28552
+ const hinges = (_a = p.rt).hinges ?? (_a.hinges = []);
28553
+ for (const j of opened) {
28554
+ j.st.yields = { point, toward: toward2, moment };
28555
+ hinges.push({ joint: j.spec.id, point, toward: toward2, moment });
28556
+ }
28557
+ emitYields(o, p, src);
28558
+ };
28559
+ const reyield = (o, p, moment, src) => {
28560
+ for (const h of p.rt.hinges ?? []) h.moment = moment;
28561
+ for (const j of o.byPart.get(p.spec.id) ?? []) if (j.st.yields) j.st.yields.moment = moment;
28562
+ emitYields(o, p, src);
28563
+ };
28564
+ const emitYields = (o, p, src) => {
28565
+ for (const h of p.rt.hinges ?? []) {
28566
+ const point = toWorld(o.st.position, o.st.rotation, h.point);
28567
+ emit2({ ...base2(o, src), type: "yield", part: p.spec.id, joint: h.joint, point, toward: rotateVec(o.st.rotation, h.toward), moment: h.moment });
28568
+ }
28569
+ };
28570
+ const severBars = (o, p, origin, d, caliber, src) => {
28571
+ var _a;
28572
+ const r = p.spec.reinforcement;
28573
+ if (!r || isLost(p) || !isMember(p.dims, p.spec.structure?.role)) return;
28574
+ const along2 = p.dims.indexOf(Math.max(...p.dims));
28575
+ const [u, v] = [0, 1, 2].filter((k) => k !== along2);
28576
+ const lo = toLocal(p.pos, p.q, objLocal(o, origin));
28577
+ const ld = rotateVec(quat.conjugate(p.q), objLocalDir(o, d));
28578
+ const across2 = Math.hypot(ld[u], ld[v]);
28579
+ if (across2 < 1e-6) return;
28580
+ const cut = (_a = p.rt).severedBars ?? (_a.severedBars = []);
28581
+ let severed = 0;
28582
+ rebarBars(p.dims, p.thin, r.spacing, p.spec.structure?.role).forEach(([a], i) => {
28583
+ if (cut.includes(i)) return;
28584
+ const du = a[u] - lo[u];
28585
+ const dv = a[v] - lo[v];
28586
+ if (Math.abs(du * ld[v] - dv * ld[u]) / across2 > r.diameter / 2 + caliber / 2e3) return;
28587
+ cut.push(i);
28588
+ severed++;
28589
+ const s = (du * ld[u] + dv * ld[v]) / (across2 * across2);
28590
+ const at4 = vec.madd(origin, d, s * vec.length(d));
28591
+ debris2(o, p, "sparks", at4, vec.scale(d, -1), 6, 3, src);
28592
+ });
28593
+ if (severed > 0) reyield(o, p, barsMoment(p), src);
28594
+ };
28595
+ const giveAtCut = (o, p, src, cut) => {
28345
28596
  if (!p.spec.reinforcement || !p.spec.units || !p.st.chipped?.length || sectionLoss(p) <= 0) return false;
28346
28597
  const opened = [];
28347
28598
  for (const j of o.byPart.get(p.spec.id) ?? []) {
28348
- if (j.st.open) continue;
28349
- const onIt = j.bears === "a_on_b" && j.spec.b === p.spec.id || j.bears === "b_on_a" && j.spec.a === p.spec.id;
28350
- if (!onIt) continue;
28599
+ if (!j.bears || !holdsAbove(o, p, j)) continue;
28351
28600
  j.st.open = true;
28352
28601
  j.st.openedBy = "break";
28353
28602
  opened.push(j);
@@ -28355,8 +28604,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28355
28604
  if (opened.length === 0) return false;
28356
28605
  p.st.hp = Math.max(p.st.hp, p.st.maxHp * GIVE_AT_CUT_HP);
28357
28606
  markDamaged(p);
28607
+ if (cut) hingeAcross(o, p, opened, { at: cut.at, d: cut.d, behind: memberSide(p) / 2 - REBAR_COVER, moment: barsMoment(p) }, src);
28358
28608
  loosened(o, opened, "break", src);
28359
- exposeRebar(o, p, src);
28609
+ exposeRebar(o, p, src, !cut);
28360
28610
  collapseCheck(o, src);
28361
28611
  return true;
28362
28612
  };
@@ -28384,7 +28634,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28384
28634
  p.st.status = "broken";
28385
28635
  p.st.hp = 0;
28386
28636
  p.st.mass = 0;
28387
- emit2({ ...base(o, src), type: "expose", part: p.spec.id, bars: [] });
28637
+ emit2({ ...base2(o, src), type: "expose", part: p.spec.id, bars: [] });
28388
28638
  debris2(o, p, "sparks", partXf(o, p).c, [0, 1, 0], 6, 3, src);
28389
28639
  partLost(o, p, src);
28390
28640
  };
@@ -28483,7 +28733,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28483
28733
  p.st.burning = false;
28484
28734
  p.rt.jet = false;
28485
28735
  }
28486
- emit2({ ...base(o, src), type: "fracture", part: p.spec.id, style, fragments, point: hitW });
28736
+ emit2({ ...base2(o, src), type: "fracture", part: p.spec.id, style, fragments, point: hitW });
28487
28737
  debris2(o, p, p.mat.breakDebris, c, [0, 1, 0], clamp2(Math.round(Math.cbrt(partVolume(p.spec.shape)) * 30), 3, 20), 2, src);
28488
28738
  setStage(o, p, 3, {}, src);
28489
28739
  if (reinforcement) {
@@ -28491,7 +28741,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28491
28741
  return;
28492
28742
  }
28493
28743
  if (ex) {
28494
- 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 } : {} });
28744
+ 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 } : {} });
28495
28745
  const fuel = burstFuel(p);
28496
28746
  blasts.push({ point: c, energy: ex.energy, radius: ex.radius, ...ex.lethalRadius !== void 0 ? { lethalRadius: ex.lethalRadius } : {}, ...fuel > 0 ? { fuel } : {}, source: src });
28497
28747
  }
@@ -28504,7 +28754,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28504
28754
  p.rt.chainDue = time + delay;
28505
28755
  primed.set(p, o);
28506
28756
  o.active = true;
28507
- emit2({ ...base(o, src), type: "primed", part: p.spec.id, point: partXf(o, p).c, trigger, delay });
28757
+ emit2({ ...base2(o, src), type: "primed", part: p.spec.id, point: partXf(o, p).c, trigger, delay });
28508
28758
  };
28509
28759
  const CHAIN_TRIGGER_OF = { ballistic: "shot", explosive: "explosion" };
28510
28760
  const severAxis = (p) => {
@@ -28513,13 +28763,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28513
28763
  const order2 = [0, 1, 2].sort((a, b) => d[b] - d[a]);
28514
28764
  return d[order2[0]] >= SEVER_ASPECT * d[order2[1]] && d[order2[0]] >= 3 * SEVER_BAND ? order2[0] : -1;
28515
28765
  };
28766
+ const roundSection = (o, p, d, holeWidth, depth) => {
28767
+ const axis2 = severAxis(p);
28768
+ if (axis2 < 0) return 1;
28769
+ const local2 = rotateVec(quat.conjugate(partXf(o, p).q), d);
28770
+ const [a, b] = [0, 1, 2].filter((k) => k !== axis2);
28771
+ const across2 = Math.abs(local2[a]) >= Math.abs(local2[b]) ? p.dims[b] : p.dims[a];
28772
+ return Math.min(1, SEVER_TRACK * holeWidth / Math.max(across2, 1e-6)) * clamp2(depth, 0, 1);
28773
+ };
28516
28774
  const bandOf = (o, p, axis2, origin) => {
28517
28775
  const { c, q } = partXf(o, p);
28518
28776
  const along2 = toLocal(c, q, origin)[axis2];
28519
28777
  const L = p.dims[axis2];
28520
28778
  return clamp2(Math.floor((along2 + L / 2) / SEVER_BAND), 0, Math.ceil(L / SEVER_BAND) - 1);
28521
28779
  };
28522
- const applyDamage = (o, p, amount, type, origin, dir, fragEnergy, cap, src, weight = 1) => {
28780
+ const applyDamage = (o, p, amount, type, origin, dir, fragEnergy, cap, src, weight = 1, section = 1) => {
28523
28781
  var _a;
28524
28782
  if (isLost(p) || amount <= 0) return 0;
28525
28783
  const prev = p.st.hp;
@@ -28528,7 +28786,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28528
28786
  if (axis2 >= 0 && p.st.hp > 0) {
28529
28787
  const band = bandOf(o, p, axis2, origin);
28530
28788
  const cuts = (_a = p.rt).cuts ?? (_a.cuts = {});
28531
- cuts[band] = (cuts[band] ?? 0) + amount * (type === "ballistic" ? SEVER_BALLISTIC : 1);
28789
+ cuts[band] = (cuts[band] ?? 0) + amount * section * (type === "ballistic" ? SEVER_BALLISTIC : 1);
28532
28790
  if (cuts[band] >= p.st.maxHp * SEVER_BAND / p.dims[axis2]) {
28533
28791
  p.rt.cutAt = -p.dims[axis2] / 2 + (band + 0.5) * SEVER_BAND;
28534
28792
  p.st.hp = 0;
@@ -28541,7 +28799,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28541
28799
  if (p.st.hp <= 0 && p.mat.fracture === "none" && !p.spec.explodes) p.st.hp = Math.min(prev, 1);
28542
28800
  if (p.st.hp <= 0 && type === "ballistic" && wornLocally(p)) p.st.hp = Math.min(prev, 1);
28543
28801
  const done = prev - p.st.hp;
28544
- if (done > 0) emit2({ ...base(o, src), type: "damage", part: p.spec.id, amount: done, hp: Math.max(0, p.st.hp), damageType: type });
28802
+ if (done > 0) emit2({ ...base2(o, src), type: "damage", part: p.spec.id, amount: done, hp: Math.max(0, p.st.hp), damageType: type });
28545
28803
  if (p.st.hp <= 0) failPart(o, p, origin, dir, fragEnergy * weight, cap, src);
28546
28804
  else if (chained && (trigger === "explosion" || 1 - p.st.hp / p.st.maxHp >= shotDamageFractionOf(p.spec))) prime(o, p, trigger, src);
28547
28805
  return done;
@@ -28583,27 +28841,29 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28583
28841
  const n = shot ? exit ? clamp2(Math.round(E / joules), 1, 7) : 1 : clamp2(Math.floor(E / joules), 0, 5);
28584
28842
  if (n === 0) return;
28585
28843
  const fibre = tear === "lumps";
28844
+ const strips = tear === "strips";
28586
28845
  const { q } = partXf(o, p);
28587
28846
  const along2 = (p.spec.grain ? AXIS[p.spec.grain] : void 0) ?? [0, 1, 2].sort((a, b) => p.dims[b] - p.dims[a])[0];
28588
28847
  const fragments = [];
28589
28848
  for (let i = 0; i < n; i++) {
28590
- const back = !exit || i % 3 === 2;
28849
+ const back2 = !exit || i % 3 === 2;
28591
28850
  const plies = p.mat.splitForm === "plies";
28592
- 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());
28851
+ 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());
28852
+ 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());
28593
28853
  const size = [w, w, w];
28594
28854
  size[along2] = len;
28595
28855
  size[(along2 + 1) % 3] = w;
28596
28856
  size[(along2 + 2) % 3] = t;
28597
28857
  const spread3 = [(rnd2() - 0.5) * 0.8, (rnd2() - 0.2) * 0.8, (rnd2() - 0.5) * 0.8];
28598
- const speed = shot ? back ? 1.5 + 2 * rnd2() : 2 + 4 * rnd2() : 0.8 + 1.2 * rnd2();
28599
- const v = vec.scale(vec.normalize(vec.add(back ? vec.scale(d, -1) : d, spread3)), speed);
28858
+ const speed = shot ? back2 ? 1.5 + 2 * rnd2() : 2 + 4 * rnd2() : 0.8 + 1.2 * rnd2();
28859
+ const v = vec.scale(vec.normalize(vec.add(back2 ? vec.scale(d, -1) : d, spread3)), speed);
28600
28860
  const mass = size[0] * size[1] * size[2] * p.mat.density;
28601
28861
  fragments.push({
28602
28862
  id: `${p.spec.id}#t${tears++}-${i}`,
28603
28863
  part: p.spec.id,
28604
28864
  material: p.spec.material,
28605
- shape: fibre ? "chunk" : "splinter",
28606
- center: back || !exit ? vec.madd(entry2, d, -0.01) : vec.madd(exit, d, 0.01),
28865
+ shape: fibre ? "chunk" : strips ? "scrap" : "splinter",
28866
+ center: back2 || !exit ? vec.madd(entry2, d, -0.01) : vec.madd(exit, d, 0.01),
28607
28867
  size,
28608
28868
  rotation: q,
28609
28869
  velocity: v,
@@ -28613,14 +28873,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28613
28873
  });
28614
28874
  }
28615
28875
  const patch = [scale * 4, scale * 4, scale * 4];
28616
- emit2({ ...base(o, src), type: "chip", part: p.spec.id, center: exit ?? entry2, size: patch, rotation: q, fragments, torn: true });
28876
+ emit2({ ...base2(o, src), type: "chip", part: p.spec.id, center: exit ?? entry2, size: patch, rotation: q, fragments, torn: true });
28617
28877
  };
28618
28878
  const ballistic = (o, p, entry2, n, d, E, caliber, pathLen, src, round5 = {}) => {
28619
28879
  const mat = p.mat;
28620
- const piece2 = round5.piece;
28621
- const weight = piece2?.weight ?? 1;
28880
+ const piece3 = round5.piece;
28881
+ const weight = piece3?.weight ?? 1;
28622
28882
  const piercing = round5.piercing ?? 1;
28623
- if (p.st.stripped || p.st.opening && insideOpening(o, p, objLocal(o, entry2)) || insideChip(p, objLocal(o, entry2))) {
28883
+ 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))))) {
28624
28884
  return { penetrated: true, exitEnergy: E, exitPoint: vec.madd(entry2, d, Math.min(pathLen, p.thickness)), damage: 0 };
28625
28885
  }
28626
28886
  const sin2 = Math.min(1, Math.abs(vec.dot(d, n)));
@@ -28634,14 +28894,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28634
28894
  const hard = mat.tags?.includes("metal") || mat.tags?.includes("masonry");
28635
28895
  const penMm = penetrationOf(mat, round5.penetration);
28636
28896
  const Ep = penMm !== void 0 ? penMm * mat.penetration : piercing === 1 || !hard ? E : E * piercing;
28637
- const strength = piece2 && mat.strength?.ndrc ? mat.strength.compressiveMPa : void 0;
28897
+ const strength = piece3 && mat.strength?.ndrc ? mat.strength.compressiveMPa : void 0;
28638
28898
  const path = strength === void 0 ? 0 : (p.thickness + layersThickness(p.layers, face) + layersThickness(p.layers, -face)) / slant;
28639
- 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);
28899
+ 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);
28640
28900
  const scale = (mat.damageScale?.ballistic ?? 1) * (mat.fracture === "shatter" ? fragility(mat.ductility, p.thickness) : 1);
28641
28901
  const id = p.spec.id;
28642
28902
  if (!penetrated && mat.ricochetDeg && angle < mat.ricochetDeg) {
28643
28903
  const r = vec.sub(d, vec.scale(n, 2 * vec.dot(d, n)));
28644
- emit2({ ...base(o, src), type: "ricochet", part: id, point: entry2, direction: vec.normalize(r), energy: E * 0.4 });
28904
+ emit2({ ...base2(o, src), type: "ricochet", part: id, point: entry2, direction: vec.normalize(r), energy: E * 0.4 });
28645
28905
  debris2(o, p, mat.hitDebris, entry2, n, 3, 3, src);
28646
28906
  const dmg2 = applyDamage(o, p, E * DMG_PER_J * scale * 0.2, "ballistic", entry2, d, E * 0.1, 12, src, weight);
28647
28907
  return { penetrated: false, exitEnergy: 0, damage: dmg2 };
@@ -28652,10 +28912,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28652
28912
  const ratio = Ep / Math.max(thr, 1e-6);
28653
28913
  const crackLen = clamp2(0.03 + ratio * 0.2, 0.03, 0.8);
28654
28914
  let exitPoint;
28915
+ let shellShare = 0;
28916
+ const holeWidth = caliber / 1e3 * (mat.ductility >= 0.3 ? 1 : 1.5);
28655
28917
  if (penetrated) {
28656
28918
  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);
28657
28919
  exitPoint = vec.madd(entry2, d, exitDist);
28658
- const hole = addHole(o, p, entry2, n, caliber / 1e3 * (mat.ductility >= 0.3 ? 1 : 1.5), true, exitPoint, src);
28920
+ const hole = addHole(o, p, entry2, n, holeWidth, true, exitPoint, src);
28921
+ shellShare = wearsShell(p, hole.diameter * 2);
28659
28922
  if (p.layers.length > 0) spallOuter(o, p, exitPoint, -face, vec.scale(n, -1), Math.max(0.03, caliber / 1e3 * 4), src);
28660
28923
  addBreach(o, p, entry2, Math.PI * (hole.diameter / 2) * (hole.diameter / 2), E, d, src);
28661
28924
  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);
@@ -28663,7 +28926,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28663
28926
  if (p.spec.contains && (p.st.liters ?? 0) > 1e-4) {
28664
28927
  o.active = true;
28665
28928
  emit2({
28666
- ...base(o, src),
28929
+ ...base2(o, src),
28667
28930
  type: "leak",
28668
28931
  part: id,
28669
28932
  fluid: p.spec.contains.fluid,
@@ -28683,8 +28946,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28683
28946
  debris2(o, p, mat.hitDebris, entry2, n, clamp2(Math.round(E / 60) + 2, 2, 14), clamp2(Math.sqrt(E) / 6, 1, 8), src);
28684
28947
  wearJoints(o, p, (penetrated ? thr : E) * 0.02 * weight, void 0, 0, src, true, BULLET_JOINT_SPAN);
28685
28948
  const hollowTear = mat.fracture === "tear" && p.spec.fill !== void 0 && p.spec.fill < 0.5;
28686
- const absorbed = penetrated && (mat.ductility >= 0.5 && mat.fracture !== "tear" || hollowTear) ? Math.min(E, thr) : E;
28687
- const dmg = applyDamage(o, p, absorbed * DMG_PER_J * scale, "ballistic", entry2, d, absorbed * 0.1, 12, src, weight);
28949
+ const absorbed = penetrated && (mat.ductility >= 0.5 && mat.fracture !== "tear" || hollowTear || mat.cellular === true) ? Math.min(E, thr) : E;
28950
+ const dmg = applyDamage(o, p, absorbed * DMG_PER_J * scale, "ballistic", entry2, d, absorbed * 0.1, 12, src, weight, roundSection(o, p, d, holeWidth, penetrated ? 1 : ratio));
28951
+ if (shellShare > 0 && !isLost(p)) yieldShell(o, p, shellShare, entry2, d, src);
28688
28952
  if (!isLost(p)) tearAt(o, p, "ballistic", entry2, penetrated ? exitPoint : void 0, d, E, caliber / 1e3, src);
28689
28953
  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);
28690
28954
  return { penetrated, exitEnergy: penetrated ? penMm !== void 0 ? E * (1 - thr / Ep) : E - thr / (hard ? piercing : 1) : 0, exitPoint, damage: dmg };
@@ -28702,13 +28966,37 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28702
28966
  const hinge = plateHinge(p.dims, toLocal(c, q, point), local2);
28703
28967
  const toObject = (v) => rotateVec(p.q, v);
28704
28968
  p.st.bendHinge = { point: vec.add(p.pos, toObject(hinge.point)), axis: toObject(hinge.axis), side: toObject(hinge.side) };
28705
- emit2({ ...base(o), type: "bend", part: p.spec.id, hinge: p.st.bendHinge, angle: p.st.bend - before, worldPoint: point });
28969
+ emit2({ ...base2(o), type: "bend", part: p.spec.id, hinge: p.st.bendHinge, angle: p.st.bend - before, worldPoint: point });
28706
28970
  }
28707
28971
  const axis2 = severAxis(p);
28708
28972
  if (axis2 < 0 || snapRatio(p.dims, p.mat.bending, E, local2, SEVER_ASPECT) < 1) return 0;
28709
28973
  p.rt.cutAt = clamp2(toLocal(c, q, point)[axis2], -p.dims[axis2] / 2, p.dims[axis2] / 2);
28710
28974
  return Math.max(0, p.st.hp);
28711
28975
  };
28976
+ const wearsShell = (p, width) => {
28977
+ if (p.mat.ductility < 0.5 || p.thickness > THIN_SHEET_DISHING || p.spec.shape.kind !== "box") return 0;
28978
+ const [a = 0, b = 0, c = 0] = [...p.dims].sort((x, y) => x - y);
28979
+ if (c < 2 * b || b > 3 * a) return 0;
28980
+ p.rt.shellCut = (p.rt.shellCut ?? 0) + width;
28981
+ return Math.min(1, p.rt.shellCut / (2 * (a + b)));
28982
+ };
28983
+ const yieldShell = (o, p, share, entry2, d, src) => {
28984
+ if (share < SHELL_YIELD_SHARE) return;
28985
+ if (p.rt.hinges?.length) {
28986
+ reyield(o, p, tubeMoment(p, share), src);
28987
+ return;
28988
+ }
28989
+ const opened = (o.byPart.get(p.spec.id) ?? []).filter((j) => holdsAbove(o, p, j));
28990
+ if (opened.length === 0) return;
28991
+ for (const j of opened) {
28992
+ j.st.open = true;
28993
+ j.st.openedBy = "break";
28994
+ }
28995
+ const along2 = p.dims.indexOf(Math.max(...p.dims));
28996
+ 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);
28997
+ loosened(o, opened, "break", src);
28998
+ collapseCheck(o, src);
28999
+ };
28712
29000
  const melee = (o, p, kind, E, point, n, d, contactR, src) => {
28713
29001
  const mat = p.mat;
28714
29002
  const thrMm = mat.penetration * p.thickness * 1e3;
@@ -28799,7 +29087,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28799
29087
  frontQueue.push({ o, p, due: time + dist2 / blastFrontSpeed, amount, fragEnergy: Ein * 0.3, point, ...src !== void 0 ? { src } : {} });
28800
29088
  return reach2;
28801
29089
  }
28802
- 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);
29090
+ 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);
28803
29091
  const breachReach = BREACH_BLAST_REACH * Math.cbrt(Math.max(0, energy) / 1e3);
28804
29092
  const caged2 = Boolean(p.spec.reinforcement && p.spec.units);
28805
29093
  const member = caged2 && (isMember(p.dims, p.spec.structure?.role) || dist2 > MEMBER_CUT_REACH * breachReach);
@@ -29158,7 +29446,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29158
29446
  for (let i = 0; i < 4 && E > 0; i++) {
29159
29447
  const reach2 = flight ? E > flight.minEnergy ? Math.log(E / flight.minEnergy) / (2 * flight.drag) : 0 : Infinity;
29160
29448
  if (!(reach2 > 0)) break;
29161
- const rh = raycastInternal(org, d, reach2, ignore, false, true);
29449
+ const crossed = [];
29450
+ const rh = raycastInternal(org, d, reach2, ignore, false, true, {}, void 0, true, crossed);
29451
+ for (const c of crossed) if (!rh || c.t < rh.distance) severBars(c.o, c.p, org, d, caliber, source);
29162
29452
  if (!rh) break;
29163
29453
  if (flight) E *= Math.exp(-2 * flight.drag * vec.distance(org, rh.point));
29164
29454
  const im = impls.get(rh.object);
@@ -29355,14 +29645,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29355
29645
  }
29356
29646
  return out;
29357
29647
  }
29358
- const mergeResults = (base2, extra) => {
29359
- const byObject = new Map(base2.map((r) => [r.object, r]));
29648
+ const mergeResults = (base22, extra) => {
29649
+ const byObject = new Map(base22.map((r) => [r.object, r]));
29360
29650
  for (const r of extra) {
29361
29651
  const have = byObject.get(r.object);
29362
29652
  if (!have) {
29363
29653
  const copy2 = { ...r, events: [...r.events] };
29364
29654
  byObject.set(r.object, copy2);
29365
- base2.push(copy2);
29655
+ base22.push(copy2);
29366
29656
  continue;
29367
29657
  }
29368
29658
  have.damage += r.damage;
@@ -29370,7 +29660,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29370
29660
  have.events.push(...r.events);
29371
29661
  if (!have.part && r.part) have.part = r.part;
29372
29662
  }
29373
- return base2;
29663
+ return base22;
29374
29664
  };
29375
29665
  function* blastSteps(point, energy, radius, src, call3, only, lethal) {
29376
29666
  const cfg = blastCfg(call3);
@@ -29622,7 +29912,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29622
29912
  p.st.temperature = Math.max(p.st.temperature, th.flameC ?? 800);
29623
29913
  o.active = true;
29624
29914
  markDamaged(p);
29625
- emit2({ ...base(o, src), type: "ignite", part: p.spec.id, point: partXf(o, p).c });
29915
+ emit2({ ...base2(o, src), type: "ignite", part: p.spec.id, point: partXf(o, p).c });
29626
29916
  };
29627
29917
  const syncMass = (p) => {
29628
29918
  p.st.mass = Math.max(0, p.mass0 * (1 - p.st.melt) - (p.fuel0 - p.st.fuel));
@@ -29648,11 +29938,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29648
29938
  p.st.status = "ashes";
29649
29939
  p.st.hp = 0;
29650
29940
  p.st.mass = p.mass0 * (1 - (th.fuelFraction ?? 0));
29651
- emit2({ ...base(o), type: "burnout", part: p.spec.id, point: c });
29941
+ emit2({ ...base2(o), type: "burnout", part: p.spec.id, point: c });
29652
29942
  debris2(o, p, "ash", c, [0, 1, 0], clamp2(Math.round(Math.cbrt(partVolume(p.spec.shape)) * 30), 3, 20), 1);
29653
29943
  partLost(o, p);
29654
29944
  } else {
29655
- emit2({ ...base(o), type: "burnout", part: p.spec.id, point: c });
29945
+ emit2({ ...base2(o), type: "burnout", part: p.spec.id, point: c });
29656
29946
  }
29657
29947
  }
29658
29948
  };
@@ -29669,11 +29959,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29669
29959
  p.rt.dripT -= 0.25;
29670
29960
  const b = partWorldAabb(o, p);
29671
29961
  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())];
29672
- emit2({ ...base(o), type: "drip", part: p.spec.id, point: pt, material: p.mat.id });
29962
+ emit2({ ...base2(o), type: "drip", part: p.spec.id, point: pt, material: p.mat.id });
29673
29963
  }
29674
29964
  if (p.st.melt - p.rt.meltEmitted >= 0.05 || p.st.melt >= 1) {
29675
29965
  p.rt.meltEmitted = p.st.melt;
29676
- emit2({ ...base(o), type: "melt", part: p.spec.id, melt: p.st.melt });
29966
+ emit2({ ...base2(o), type: "melt", part: p.spec.id, melt: p.st.melt });
29677
29967
  }
29678
29968
  if (p.st.melt >= 1) {
29679
29969
  p.st.status = "melted";
@@ -29746,7 +30036,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29746
30036
  }
29747
30037
  p.rt.jet = true;
29748
30038
  s.burning = true;
29749
- emit2({ ...base(o), type: "ignite", part: p.spec.id, point: partXf(o, p).c });
30039
+ emit2({ ...base2(o), type: "ignite", part: p.spec.id, point: partXf(o, p).c });
29750
30040
  }
29751
30041
  }
29752
30042
  }
@@ -29754,7 +30044,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29754
30044
  if (p.rt.jet && (s.liters ?? 0) <= 0) {
29755
30045
  p.rt.jet = false;
29756
30046
  s.burning = false;
29757
- emit2({ ...base(o), type: "extinguish", part: p.spec.id });
30047
+ emit2({ ...base2(o), type: "extinguish", part: p.spec.id });
29758
30048
  }
29759
30049
  const sc = th.thermalShockC;
29760
30050
  if (sc !== void 0) {
@@ -29788,7 +30078,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29788
30078
  if (stress > 1) {
29789
30079
  if (p.rt.stressT <= 0) {
29790
30080
  p.rt.stressT = 0.5;
29791
- emit2({ ...base(o), type: "stress", part: p.spec.id, stress, load: p.st.load ?? 0 });
30081
+ emit2({ ...base2(o), type: "stress", part: p.spec.id, stress, load: p.st.load ?? 0 });
29792
30082
  if (p.spec.reinforcement && (p.st.stripped || p.st.chipped?.length || p.st.opening)) exposeRebar(o, p);
29793
30083
  }
29794
30084
  applyDamage(o, p, overloadRate(stress) * p.st.maxHp * dt, "blunt", null, null, 5, 3);
@@ -30102,6 +30392,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30102
30392
  setRayBroadPhase(broadPhase2) {
30103
30393
  rayBroad = broadPhase2;
30104
30394
  },
30395
+ setSurfaceTracer(tracer) {
30396
+ surfaceTracer = tracer;
30397
+ },
30105
30398
  groundLoss(loss) {
30106
30399
  if (!(loss.radius > 0) || !(loss.depth > 0) || !Number.isFinite(loss.x) || !Number.isFinite(loss.z)) return;
30107
30400
  pendingLosses.push({ ...loss });
@@ -30166,7 +30459,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30166
30459
  const step = Math.floor(j.st.progress * 10 + 1e-9);
30167
30460
  if (step > j.step || j.st.progress >= 1) {
30168
30461
  j.step = step;
30169
- emit2({ ...base(o), type: "disassemble_progress", joint: j.spec.id, tool: tool2, progress: j.st.progress });
30462
+ emit2({ ...base2(o), type: "disassemble_progress", joint: j.spec.id, tool: tool2, progress: j.st.progress });
30170
30463
  }
30171
30464
  if (j.st.progress >= 1) {
30172
30465
  j.st.open = true;
@@ -30252,7 +30545,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30252
30545
  if (p.st.burning) {
30253
30546
  p.st.burning = false;
30254
30547
  p.rt.jet = false;
30255
- emit2({ ...base(o), type: "extinguish", part: p.spec.id });
30548
+ emit2({ ...base2(o), type: "extinguish", part: p.spec.id });
30256
30549
  }
30257
30550
  p.st.temperature = Math.max(ambient, p.st.temperature - coolC);
30258
30551
  }
@@ -30284,7 +30577,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30284
30577
  if (p.st.holes.length > maxHoles) p.st.holes.shift();
30285
30578
  o.active = true;
30286
30579
  emit2({
30287
- ...base(o),
30580
+ ...base2(o),
30288
30581
  type: "leak",
30289
30582
  part: partId,
30290
30583
  fluid: c.fluid,
@@ -30378,6 +30671,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30378
30671
  time,
30379
30672
  rng: rng2.state(),
30380
30673
  counter,
30674
+ ...tears > 0 ? { tears } : {},
30381
30675
  objects: [...objects.values()].map(serializeObject),
30382
30676
  ...impls.size ? { impls: [...impls.values()].map((im) => ({ id: im.impl.id, position: [...im.position], rotation: [...im.rotation], data: im.impl.serialize?.() })) } : {}
30383
30677
  };
@@ -30402,6 +30696,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30402
30696
  time = snap.time;
30403
30697
  rng2.set(snap.rng);
30404
30698
  counter = snap.counter ?? 0;
30699
+ tears = snap.tears ?? 0;
30405
30700
  for (const e of snap.objects) putObject(e.id, buildFromEntry(e, e.id));
30406
30701
  for (const e of snap.impls ?? []) {
30407
30702
  const im = impls.get(e.id);
@@ -30494,7 +30789,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30494
30789
  var defaultSet;
30495
30790
  var defaultAssemblies = () => defaultSet ?? (defaultSet = assembliesOver(ASSEMBLIES));
30496
30791
  var getAssembly = (id) => defaultAssemblies().get(id);
30497
- var faceCount = (layer3) => layer3.faces === "both" ? 2 : 1;
30792
+ var faceCount = (layer3) => layer3.faces === "both" || layer3.faces === "all" ? 2 : 1;
30498
30793
  var assemblyDepth = (def) => def.depth ?? def.core.thickness + (def.layers ?? []).reduce((sum2, l) => sum2 + l.thickness * faceCount(l), 0);
30499
30794
  var buildAssemblyPart = (def, assemblyId, options) => {
30500
30795
  if (!def) throw new Error(`unknown assembly "${assemblyId}"`);
@@ -30668,8 +30963,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30668
30963
  const id = w.add(onRock(s));
30669
30964
  return new Map(w.state(id).parts.map((p) => [p.id, p.flexure ?? 0]));
30670
30965
  };
30671
- const base = bending(out);
30672
- const factor = new Map(targets.map((p) => [p.id, (base.get(p.id) ?? 0) / safetyOf(p.structure.role)]));
30966
+ const base2 = bending(out);
30967
+ const factor = new Map(targets.map((p) => [p.id, (base2.get(p.id) ?? 0) / safetyOf(p.structure.role)]));
30673
30968
  if (options.redundancy !== void 0) {
30674
30969
  const roles = options.redundancyRoles ?? ["column"];
30675
30970
  for (const lost of out.parts) {
@@ -30713,11 +31008,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30713
31008
  return new Map(w.state(id).parts.map((p) => [p.id, { load: p.load ?? 0, stress: p.stress ?? 0, wind: p.wind ?? 0 }]));
30714
31009
  };
30715
31010
  const out = structuredClone(spec);
30716
- const base = loads(out, options.wind);
31011
+ const base2 = loads(out, options.wind);
30717
31012
  const gamma = options.wind ? resolveWind(options.wind).loadFactor : 0;
30718
31013
  const structural = out.parts.filter((p) => p.structure && p.structure.role !== "none");
30719
31014
  const loadAt = (p) => {
30720
- const b = base.get(p.id);
31015
+ const b = base2.get(p.id);
30721
31016
  return b && b.stress > 0 ? b.load + (b.wind > 0 ? gamma * b.wind / GRAVITY : 0) : void 0;
30722
31017
  };
30723
31018
  const lossesOf = function* () {
@@ -30746,7 +31041,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30746
31041
  if (options.wind) {
30747
31042
  const yieldMPa = resolveFlexure(options.flexure).rebarYieldMPa;
30748
31043
  for (const p of out.parts) {
30749
- const b = base.get(p.id);
31044
+ const b = base2.get(p.id);
30750
31045
  if (!b || b.wind >= 0 || !p.reinforcement || p.shape.kind !== "box") continue;
30751
31046
  const pull = -(b.load + gamma * b.wind / GRAVITY) * GRAVITY;
30752
31047
  if (pull <= 0) continue;
@@ -31799,8 +32094,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
31799
32094
  return { parts: context.parts, supports: context.supports };
31800
32095
  }
31801
32096
  function anchorBalconies(context) {
31802
- const base = context.panelsOf.get("slab_base");
31803
- if (!base) return;
32097
+ const base2 = context.panelsOf.get("slab_base");
32098
+ if (!base2) return;
31804
32099
  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)));
31805
32100
  for (const deck of decks) {
31806
32101
  const pillars = new Set(context.supports.filter((s) => s.part === deck.id && /^balcony_column_/.test(s.on)).map((s) => s.on));
@@ -31819,7 +32114,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
31819
32114
  if (!splits.size) return input;
31820
32115
  const boxes = new Map(input.parts.map((part) => [part.id, part.aabb]));
31821
32116
  const pieceBox = /* @__PURE__ */ new Map();
31822
- for (const split of splits.values()) for (const piece2 of split.pieces) pieceBox.set(piece2.id, piece2.aabb);
32117
+ for (const split of splits.values()) for (const piece3 of split.pieces) pieceBox.set(piece3.id, piece3.aabb);
31823
32118
  const parts2 = input.parts.flatMap((part) => splits.get(part.id)?.pieces ?? [part]);
31824
32119
  const supports = [];
31825
32120
  for (const support of input.supports) {
@@ -31961,9 +32256,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
31961
32256
  const spandrel = spandrels[k];
31962
32257
  if (spandrel) internal.push({ part: spandrel.id, on: lintel.id, joint: style.wallJoint });
31963
32258
  });
31964
- const base = [...piers, ...drafts.filter((d) => d.id.includes("_sill_"))].map((d) => d.id);
32259
+ const base2 = [...piers, ...drafts.filter((d) => d.id.includes("_sill_"))].map((d) => d.id);
31965
32260
  const top = [...piers.map((p) => p.id), ...lintels.map((l, k) => spandrels[k]?.id ?? l.id)];
31966
- return { pieces, internal, base, top };
32261
+ return { pieces, internal, base: base2, top };
31967
32262
  }
31968
32263
  var LOG_DIAMETER = 0.26;
31969
32264
  var isWall = (part) => part.id.startsWith("wall_") && part.assembly !== void 0 && (part.role === "wall" || part.role === "partition");
@@ -32025,7 +32320,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
32025
32320
  if (capacity === void 0) continue;
32026
32321
  const along2 = (box22) => Math.max(box22[2] - box22[0], box22[3] - box22[1]);
32027
32322
  const length2 = along2(input.parts.find((part) => part.id === id).aabb);
32028
- for (const piece2 of split.pieces) capacities.set(piece2.id, Math.max(1, capacity * along2(piece2.aabb) / length2));
32323
+ for (const piece3 of split.pieces) capacities.set(piece3.id, Math.max(1, capacity * along2(piece3.aabb) / length2));
32029
32324
  }
32030
32325
  return { ...next, capacities };
32031
32326
  }
@@ -32249,10 +32544,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
32249
32544
  const joints = [...spec.joints ?? []];
32250
32545
  const reinforcement = { material: "steel", spacing: c.rebar.spacing, diameter: c.rebar.diameter };
32251
32546
  const raft2 = parts2.find((p) => p.id === "raft");
32252
- let base = raft2?.id;
32253
- if (!base) {
32254
- base = "core_mat";
32255
- 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 });
32547
+ let base2 = raft2?.id;
32548
+ if (!base2) {
32549
+ base2 = "core_mat";
32550
+ 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 });
32256
32551
  }
32257
32552
  const innerX = x0 + t + c.stairWidth + ti / 2;
32258
32553
  for (let f = 0; f < g.floors; f++) {
@@ -32260,7 +32555,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
32260
32555
  const wall = (name, size, pos) => {
32261
32556
  const id = `core_${f}_${name}`;
32262
32557
  parts2.push({ id, material: c.material, shape: box2(size), position: [pos[0], yb + H / 2, pos[1]], structure: { role: "wall" }, reinforcement, tags: ["core"] });
32263
- rests(joints, id, f === 0 ? base : `core_${f - 1}_${name}`, "rebar");
32558
+ rests(joints, id, f === 0 ? base2 : `core_${f - 1}_${name}`, "rebar");
32264
32559
  return id;
32265
32560
  };
32266
32561
  const tube2 = [
@@ -32313,7 +32608,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
32313
32608
  mass: 1500,
32314
32609
  tags: ["elevator_car"]
32315
32610
  });
32316
- rests(joints, id, base, "resting", false);
32611
+ rests(joints, id, base2, "resting", false);
32317
32612
  }
32318
32613
  return { ...spec, parts: parts2, joints };
32319
32614
  }
@@ -32994,12 +33289,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
32994
33289
  var resolveUse = (item, effects, context = {}, rules = DEFAULT_RULES2) => {
32995
33290
  const def = findEffect(item, effects);
32996
33291
  if (!def) return void 0;
32997
- const base = { useId: def.id, effect: def.effect, params: def.params ?? {}, consumes: def.consumes };
32998
- if (def.effect !== "consume_nutrition") return base;
33292
+ const base2 = { useId: def.id, effect: def.effect, params: def.params ?? {}, consumes: def.consumes };
33293
+ if (def.effect !== "consume_nutrition") return base2;
32999
33294
  const nutrition = nutritionOf(item, context, rules);
33000
33295
  const blocked = item.seal && context.seal ? sealBlock(item.seal, context.seal) : void 0;
33001
- if (blocked) return { ...base, consumes: false, nutrition: { ...nutrition, isEdible: false }, blocked };
33002
- return { ...base, consumes: def.consumes && nutrition.isEdible, nutrition };
33296
+ if (blocked) return { ...base2, consumes: false, nutrition: { ...nutrition, isEdible: false }, blocked };
33297
+ return { ...base2, consumes: def.consumes && nutrition.isEdible, nutrition };
33003
33298
  };
33004
33299
  var MM = 1e-3;
33005
33300
  var BOX_WALL = 6 * MM;
@@ -52302,9 +52597,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52302
52597
  var goodsItemUse = createGoodsItemUse();
52303
52598
 
52304
52599
  // ../game-interactables-household/dist/index.js
52305
- var door = (material, joint2 = "hinge", piece2 = "door") => ({ material, joint: joint2, piece: piece2 });
52600
+ var door = (material, joint2 = "hinge", piece22 = "door") => ({ material, joint: joint2, piece: piece22 });
52306
52601
  var drawer = { material: "mdf", joint: "slide", piece: "drawer" };
52307
52602
  var knob = { material: "plastic", joint: "clip", piece: "knob" };
52603
+ var mainLever = { material: "plastic", joint: "clip", piece: "breaker" };
52308
52604
  var tap = { material: "steel", joint: "screw", piece: "handle" };
52309
52605
  var mdfBody = { material: "mdf", joint: "screw" };
52310
52606
  var cabinet = { body: mdfBody, parts: [[/^drawer/, drawer], [/^door/, door("mdf")]] };
@@ -52339,19 +52635,23 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52339
52635
  wall_socket: { body: { material: "plastic", joint: "screw" }, parts: [] },
52340
52636
  wall_switch: { body: { material: "plastic", joint: "screw" }, parts: [["rocker", { material: "plastic", joint: "clip", piece: "rocker" }]] },
52341
52637
  // 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
52342
- service_entrance: { body: { material: "concrete", joint: "rebar", reinforcement: POLE_CAGE }, parts: [["meter_door", door("steel")]] },
52638
+ service_entrance: { body: { material: "concrete", joint: "rebar", reinforcement: POLE_CAGE }, parts: [["meter_door", door("steel")], ["main_breaker", mainLever]] },
52343
52639
  conduit_run: { body: { material: "plastic", joint: "clip" }, parts: [] },
52344
- service_mast: { body: { material: "steel", joint: "clip" }, parts: [] },
52640
+ // 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)
52641
+ service_mast: { body: { material: "steel", joint: "weld" }, parts: [] },
52345
52642
  electrical_panel: {
52346
52643
  body: { material: "steel", joint: "screw" },
52347
52644
  parts: [[/^breaker/, { material: "plastic", joint: "clip", piece: "breaker" }], ["door", door("steel")]]
52348
52645
  },
52349
- power_meter: { body: { material: "plastic", joint: "screw" }, parts: [["door", door("plastic")]] },
52646
+ power_meter: { body: { material: "plastic", joint: "screw" }, parts: [["door", door("plastic")], ["main_breaker", mainLever]] },
52350
52647
  tv: { body: { material: "plastic", joint: "screw" }, parts: [["power", { material: "plastic", joint: "clip", piece: "button" }]] },
52351
52648
  microwave: { body: { material: "steel", joint: "screw" }, parts: [["door", door("steel")], ["dial", knob]] },
52352
52649
  washing_machine: { body: { material: "steel", joint: "screw" }, parts: [["dial", knob], ["door", door("tempered_glass")]] },
52353
52650
  sofa: { body: upholstery, parts: [] },
52354
52651
  armchair: { body: upholstery, parts: [] },
52652
+ pouf: { body: upholstery, parts: [] },
52653
+ box_bed: { body: upholstery, parts: [] },
52654
+ upholstered_chair: { body: upholstery, parts: [] },
52355
52655
  dining_chair: { body: { material: "wood_hard", joint: "screw" }, parts: [] },
52356
52656
  bed_double: { body: { material: "wood_soft", joint: "screw" }, parts: [] },
52357
52657
  bed_single: { body: { material: "wood_soft", joint: "screw" }, parts: [] },
@@ -52423,9 +52723,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52423
52723
  "type.washing_machine": "Washing machine",
52424
52724
  "type.sofa": "Sofa",
52425
52725
  "type.armchair": "Armchair",
52726
+ "type.pouf": "Pouf",
52426
52727
  "type.dining_chair": "Dining chair",
52728
+ "type.upholstered_chair": "Upholstered chair",
52427
52729
  "type.bed_double": "Double bed",
52428
52730
  "type.bed_single": "Single bed",
52731
+ "type.box_bed": "Box bed",
52429
52732
  "type.bench": "Bench",
52430
52733
  "type.blinds": "Blinds",
52431
52734
  "type.curtain": "Curtain",
@@ -52578,6 +52881,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52578
52881
  "prompt.breaker.off": "Switch on {circuit}",
52579
52882
  "prompt.breaker.off.verb": "Switch on",
52580
52883
  "prompt.breaker.off.object": "{circuit}",
52884
+ "prompt.main_breaker": "Main breaker",
52885
+ "prompt.main_breaker.on": "Switch off the main breaker",
52886
+ "prompt.main_breaker.on.verb": "Switch off",
52887
+ "prompt.main_breaker.on.object": "the main breaker",
52888
+ "prompt.main_breaker.off": "Switch on the main breaker",
52889
+ "prompt.main_breaker.off.verb": "Switch on",
52890
+ "prompt.main_breaker.off.object": "the main breaker",
52581
52891
  "type.bunk_bed": "Bunk bed",
52582
52892
  "type.wood_stove": "Wood stove",
52583
52893
  "type.fireplace": "Fireplace",
@@ -52671,9 +52981,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52671
52981
  "type.washing_machine": "M\xE1quina de lavar",
52672
52982
  "type.sofa": "Sof\xE1",
52673
52983
  "type.armchair": "Poltrona",
52984
+ "type.pouf": "Pufe",
52674
52985
  "type.dining_chair": "Cadeira",
52986
+ "type.upholstered_chair": "Cadeira estofada",
52675
52987
  "type.bed_double": "Cama de casal",
52676
52988
  "type.bed_single": "Cama de solteiro",
52989
+ "type.box_bed": "Cama box",
52677
52990
  "type.bench": "Banco",
52678
52991
  "type.blinds": "Persiana",
52679
52992
  "type.curtain": "Cortina",
@@ -52826,6 +53139,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52826
53139
  "prompt.breaker.off": "Ligar {circuit}",
52827
53140
  "prompt.breaker.off.verb": "Ligar",
52828
53141
  "prompt.breaker.off.object": "{circuit}",
53142
+ "prompt.main_breaker": "Disjuntor geral",
53143
+ "prompt.main_breaker.on": "Desligar o disjuntor geral",
53144
+ "prompt.main_breaker.on.verb": "Desligar",
53145
+ "prompt.main_breaker.on.object": "o disjuntor geral",
53146
+ "prompt.main_breaker.off": "Ligar o disjuntor geral",
53147
+ "prompt.main_breaker.off.verb": "Ligar",
53148
+ "prompt.main_breaker.off.object": "o disjuntor geral",
52829
53149
  "type.bunk_bed": "Beliche",
52830
53150
  "type.wood_stove": "Fog\xE3o a lenha",
52831
53151
  "type.fireplace": "Lareira",
@@ -53276,6 +53596,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53276
53596
  pushable: true,
53277
53597
  massKg: 25
53278
53598
  },
53599
+ {
53600
+ id: "pouf",
53601
+ group: "seating",
53602
+ w: 0.45,
53603
+ d: 0.45,
53604
+ h: 0.42,
53605
+ y: 0,
53606
+ solid: true,
53607
+ pushable: true,
53608
+ massKg: 4
53609
+ },
53279
53610
  {
53280
53611
  id: "dining_chair",
53281
53612
  group: "seating",
@@ -53286,6 +53617,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53286
53617
  solid: true,
53287
53618
  massKg: 5
53288
53619
  },
53620
+ {
53621
+ id: "upholstered_chair",
53622
+ group: "seating",
53623
+ w: 0.46,
53624
+ d: 0.52,
53625
+ h: 0.92,
53626
+ y: 0,
53627
+ solid: true,
53628
+ massKg: 6
53629
+ },
53289
53630
  {
53290
53631
  id: "bed_double",
53291
53632
  group: "seating",
@@ -53308,6 +53649,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53308
53649
  pushable: true,
53309
53650
  massKg: 30
53310
53651
  },
53652
+ {
53653
+ id: "box_bed",
53654
+ group: "seating",
53655
+ w: 1.38,
53656
+ d: 1.88,
53657
+ h: 0.72,
53658
+ y: 0,
53659
+ solid: true,
53660
+ pushable: true,
53661
+ massKg: 75
53662
+ },
53311
53663
  {
53312
53664
  id: "bench",
53313
53665
  group: "seating",
@@ -53554,8 +53906,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53554
53906
  "warn.buildEmpty": "construir devolveu vazio para {id}"
53555
53907
  };
53556
53908
  function createTranslator(locale, table) {
53557
- const base = locale && /^pt/i.test(locale) ? ptBR : en;
53558
- const messages = { ...base, ...table ?? {} };
53909
+ const base2 = locale && /^pt/i.test(locale) ? ptBR : en;
53910
+ const messages = { ...base2, ...table ?? {} };
53559
53911
  return (key2, params) => (messages[key2] ?? key2).replace(/\{(\w+)\}/g, (_m, name) => params && params[name] !== void 0 ? String(params[name]) : `{${name}}`);
53560
53912
  }
53561
53913
  var TYPE_MAP = Object.freeze({
@@ -54048,8 +54400,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54048
54400
  var r3 = (n) => Math.round(n * 1e3) / 1e3;
54049
54401
  var CYLINDER_VALVE_Y = 0.47;
54050
54402
  var at = (it) => ({ x: it.x ?? 0, z: it.z ?? 0, ry: it.ry ?? 0 });
54051
- function mergeRegistry(base, extra) {
54052
- const out = { ...base };
54403
+ function mergeRegistry(base2, extra) {
54404
+ const out = { ...base2 };
54053
54405
  if (extra) {
54054
54406
  for (const [key2, value] of Object.entries(extra)) {
54055
54407
  if (value == null) delete out[key2];
@@ -55740,7 +56092,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55740
56092
  rooms: (w, d, op) => {
55741
56093
  const hu0 = r22(w * 0.3), hu1 = r22(w * 0.7), n = floorCount(op, 3), el = !!op.elevator && n > 1;
55742
56094
  const ex = hu0 + (el ? 4.2 : 2.4);
55743
- const base = [
56095
+ const base2 = [
55744
56096
  { id: "sitting_room", type: "living", label: "sitting_room", rect: [0, 0, hu0, 7] },
55745
56097
  { id: "kitchen", type: "kitchen", label: "kitchen", rect: [0, 7, hu0, d - 3.2] },
55746
56098
  { id: "laundry", type: "laundry", label: "laundry", rect: [0, d - 3.2, hu0, d] },
@@ -55751,10 +56103,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55751
56103
  { 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] } } },
55752
56104
  { id: "bathroom", type: "bathroom", label: "bathroom_suite", library: "bathroom_wc", rect: [hu1, d - 3.3, w, d] }
55753
56105
  ];
55754
- if (n > 1) base.push({ id: "stairs", type: "stairs", label: "stairs", rect: [hu0, d - 5, hu0 + 2.4, d], link: [0, 1] });
55755
- if (el) base.push({ id: "elevator", type: "elevator", label: "elevator", rect: [hu0 + 2.4, d - 5, hu0 + 4.2, d] });
55756
- base.push({ id: "office", type: "office", label: "office", rect: [n > 1 ? ex : hu0, d - 5, hu1, d] });
55757
- return base;
56106
+ if (n > 1) base2.push({ id: "stairs", type: "stairs", label: "stairs", rect: [hu0, d - 5, hu0 + 2.4, d], link: [0, 1] });
56107
+ if (el) base2.push({ id: "elevator", type: "elevator", label: "elevator", rect: [hu0 + 2.4, d - 5, hu0 + 4.2, d] });
56108
+ base2.push({ id: "office", type: "office", label: "office", rect: [n > 1 ? ex : hu0, d - 5, hu1, d] });
56109
+ return base2;
55758
56110
  },
55759
56111
  doors: (w, d, op) => {
55760
56112
  const hu0 = r22(w * 0.3), hu1 = r22(w * 0.7), n = floorCount(op, 3), el = !!op.elevator && n > 1;
@@ -56128,7 +56480,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56128
56480
  }
56129
56481
  var residentialTower = residentialTowerTemplate();
56130
56482
 
56131
- // ../game-floorplan-three/dist/chunk-OGYLJ4F7.js
56483
+ // ../game-floorplan-three/dist/chunk-XI3CKQAV.js
56132
56484
  var __defProp4 = Object.defineProperty;
56133
56485
  var __defNormalProp2 = (obj, key2, value) => key2 in obj ? __defProp4(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
56134
56486
  var __publicField2 = (obj, key2, value) => __defNormalProp2(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
@@ -56141,6 +56493,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56141
56493
  "what.door": "the door",
56142
56494
  "what.curtain": "the curtain",
56143
56495
  "what.mailbox": "the mailbox",
56496
+ "what.stallDoor": "the shower door",
56144
56497
  "what.pedestrianGate": "the small gate",
56145
56498
  "what.garageGate": "the garage gate",
56146
56499
  "what.drawer": "drawer",
@@ -56166,6 +56519,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56166
56519
  "what.door": "a porta",
56167
56520
  "what.curtain": "a cortina",
56168
56521
  "what.mailbox": "a caixa de correio",
56522
+ "what.stallDoor": "a porta do box",
56169
56523
  "what.pedestrianGate": "o port\xE3ozinho",
56170
56524
  "what.garageGate": "o port\xE3o da garagem",
56171
56525
  "what.drawer": "gaveta",
@@ -56201,15 +56555,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56201
56555
  for (let axis2 = 0; axis2 < 3; axis2++) {
56202
56556
  const lo = axis2, hi = axis2 + 3;
56203
56557
  if (b[lo] > box5[lo] + EPS6) {
56204
- const piece2 = [...box5];
56205
- piece2[hi] = b[lo];
56206
- out.push(piece2);
56558
+ const piece22 = [...box5];
56559
+ piece22[hi] = b[lo];
56560
+ out.push(piece22);
56207
56561
  box5[lo] = b[lo];
56208
56562
  }
56209
56563
  if (b[hi] < box5[hi] - EPS6) {
56210
- const piece2 = [...box5];
56211
- piece2[lo] = b[hi];
56212
- out.push(piece2);
56564
+ const piece22 = [...box5];
56565
+ piece22[lo] = b[hi];
56566
+ out.push(piece22);
56213
56567
  box5[hi] = b[hi];
56214
56568
  }
56215
56569
  }
@@ -56219,14 +56573,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56219
56573
  const laid = [];
56220
56574
  for (const solid2 of solids2) {
56221
56575
  let pieces = [solid2.box];
56222
- for (const before of laid) pieces = pieces.flatMap((piece2) => subtractBox(piece2, before.box));
56576
+ for (const before of laid) pieces = pieces.flatMap((piece22) => subtractBox(piece22, before.box));
56223
56577
  for (const box5 of pieces) laid.push({ ...solid2, box: box5 });
56224
56578
  }
56225
56579
  return laid;
56226
56580
  }
56227
56581
  function outsideBoxes(box5, taken) {
56228
56582
  let pieces = [box5];
56229
- for (const t of taken) pieces = pieces.flatMap((piece2) => subtractBox(piece2, t));
56583
+ for (const t of taken) pieces = pieces.flatMap((piece22) => subtractBox(piece22, t));
56230
56584
  return pieces;
56231
56585
  }
56232
56586
  function installKernelGeometry(K, shared3) {
@@ -56554,7 +56908,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56554
56908
  nz = -nz;
56555
56909
  [a, b] = [pts[0], pts[1]];
56556
56910
  }
56557
- const [cr, cg, cb] = rgbOf(color2), scale = UV_SCALE[mat] || 1, base = A.nv;
56911
+ const [cr, cg, cb] = rgbOf(color2), scale = UV_SCALE[mat] || 1, base2 = A.nv;
56558
56912
  let e1x = b[0] - a[0], e1y = b[1] - a[1], e1z = b[2] - a[2];
56559
56913
  const l1 = Math.hypot(e1x, e1y, e1z) || 1;
56560
56914
  e1x /= l1;
@@ -56562,7 +56916,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56562
56916
  e1z /= l1;
56563
56917
  const e2x = ny * e1z - nz * e1y, e2y = nz * e1x - nx * e1z, e2z = nx * e1y - ny * e1x;
56564
56918
  pts.forEach((p, k) => {
56565
- const o = base + k;
56919
+ const o = base2 + k;
56566
56920
  A.p[o * 3] = p[0] - O[0];
56567
56921
  A.p[o * 3 + 1] = p[1] - O[1];
56568
56922
  A.p[o * 3 + 2] = p[2] - O[2];
@@ -56577,9 +56931,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56577
56931
  A.u[o * 2 + 1] = (dx * e2x + dy * e2y + dz * e2z) / scale;
56578
56932
  });
56579
56933
  for (let k = 1; k < n - 1; k++) {
56580
- A.i[A.ni++] = base;
56581
- A.i[A.ni++] = base + k;
56582
- A.i[A.ni++] = base + k + 1;
56934
+ A.i[A.ni++] = base2;
56935
+ A.i[A.ni++] = base2 + k;
56936
+ A.i[A.ni++] = base2 + k + 1;
56583
56937
  }
56584
56938
  A.nv += n;
56585
56939
  }
@@ -57938,8 +58292,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57938
58292
  const puts = (f, type, m0, extra) => {
57939
58293
  const ent = T2[type];
57940
58294
  if (!ent) return;
57941
- const com = shared3.ctx.roomById[m0.room], g = "f" + f, base = Y0(f);
57942
- 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 || {});
58295
+ const com = shared3.ctx.roomById[m0.room], g = "f" + f, base2 = Y0(f);
58296
+ 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 || {});
57943
58297
  cursor.group = g;
57944
58298
  lightItem({ id: m0.id, room: m0.room }, M, ent, api, g);
57945
58299
  };
@@ -58760,7 +59114,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58760
59114
  }
58761
59115
  const AC = accFor(mat), m = L.length, [cr, cg, cb] = rgbOf(color2), O = cursor.org;
58762
59116
  AC.ensure(m * 2, (m - 1) * 6);
58763
- const base = AC.nv, w2 = 2 * Math.PI / P;
59117
+ const base2 = AC.nv, w2 = 2 * Math.PI / P;
58764
59118
  const profile = (sv) => {
58765
59119
  const ph = sv * w2, hh = A + A * Math.sin(ph), dh = A * w2 * Math.cos(ph), ql = Math.hypot(dh, 1);
58766
59120
  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);
@@ -58776,7 +59130,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58776
59130
  const sv = L[j], [hh, qx, qy, qz, v] = at4(sv);
58777
59131
  const cj = col[j] || col[j - 1] || col[j + 1] || [0, 0];
58778
59132
  for (let k = 0; k < 2; k++) {
58779
- 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;
59133
+ 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;
58780
59134
  AC.p[oo * 3] = px - O[0];
58781
59135
  AC.p[oo * 3 + 1] = py - O[1];
58782
59136
  AC.p[oo * 3 + 2] = pz - O[2];
@@ -58792,7 +59146,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58792
59146
  }
58793
59147
  for (let j = 0; j + 1 < m; j++) {
58794
59148
  if (!col[j] && !col[j + 1]) continue;
58795
- const a0 = base + j * 2, a1 = a0 + 1, b0 = a0 + 2, b1 = a0 + 3;
59149
+ const a0 = base2 + j * 2, a1 = a0 + 1, b0 = a0 + 2, b1 = a0 + 3;
58796
59150
  AC.i[AC.ni++] = a0;
58797
59151
  AC.i[AC.ni++] = b0;
58798
59152
  AC.i[AC.ni++] = a1;
@@ -59492,12 +59846,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59492
59846
  if (x1 - x0 < 1e-4 || y1 - y0 < 1e-4 || z1 - z0 < 1e-4) return;
59493
59847
  for (const [normal, corners] of FACES2) {
59494
59848
  if (openBottom && normal[1] < 0) continue;
59495
- const base = this.positions.length / 3;
59849
+ const base2 = this.positions.length / 3;
59496
59850
  for (const [cx, cy, cz] of corners) {
59497
59851
  this.positions.push(cx ? x1 : x0, cy ? y1 : y0, cz ? z1 : z0);
59498
59852
  this.normals.push(normal[0], normal[1], normal[2]);
59499
59853
  }
59500
- this.indices.push(base, base + 1, base + 2, base, base + 2, base + 3);
59854
+ this.indices.push(base2, base2 + 1, base2 + 2, base2, base2 + 2, base2 + 3);
59501
59855
  }
59502
59856
  }
59503
59857
  /**
@@ -59518,12 +59872,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59518
59872
  const out = [0, 1, 2].reduce((sum2, k) => sum2 + n[k] * ((a[k] + b[k] + c[k] + d[k]) / 4 - centre[k]), 0);
59519
59873
  const ring3 = out >= 0 ? [a, b, c, d] : [a, d, c, b];
59520
59874
  if (out < 0) n = n.map((x) => -x);
59521
- const base = this.positions.length / 3;
59875
+ const base2 = this.positions.length / 3;
59522
59876
  for (const p of ring3) {
59523
59877
  this.positions.push(p[0], p[1], p[2]);
59524
59878
  this.normals.push(n[0], n[1], n[2]);
59525
59879
  }
59526
- this.indices.push(base, base + 1, base + 2, base, base + 2, base + 3);
59880
+ this.indices.push(base2, base2 + 1, base2 + 2, base2, base2 + 2, base2 + 3);
59527
59881
  }
59528
59882
  }
59529
59883
  /** A flat four-cornered face that looks along `normal` (it is wound so). */
@@ -59533,12 +59887,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59533
59887
  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]];
59534
59888
  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];
59535
59889
  const ring3 = facing >= 0 ? corners : [corners[0], corners[3], corners[2], corners[1]];
59536
- const base = this.positions.length / 3;
59890
+ const base2 = this.positions.length / 3;
59537
59891
  for (const p of ring3) {
59538
59892
  this.positions.push(p[0], p[1], p[2]);
59539
59893
  this.normals.push(normal[0], normal[1], normal[2]);
59540
59894
  }
59541
- this.indices.push(base, base + 1, base + 2, base, base + 2, base + 3);
59895
+ this.indices.push(base2, base2 + 1, base2 + 2, base2, base2 + 2, base2 + 3);
59542
59896
  }
59543
59897
  /** The mesh of everything added, or null when nothing was. */
59544
59898
  mesh(THREE, material, name) {
@@ -59708,8 +60062,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59708
60062
  var DOOR_HEAD = 2.1;
59709
60063
  function crossesOpening(plan, a, b, y) {
59710
60064
  return plan.openings.some((o) => {
59711
- const base = plan.floors[o.floor]?.y0 ?? 0;
59712
- if (y <= base + (o.y0 ?? 0) || y >= base + (o.y1 ?? DOOR_HEAD)) return false;
60065
+ const base2 = plan.floors[o.floor]?.y0 ?? 0;
60066
+ if (y <= base2 + (o.y0 ?? 0) || y >= base2 + (o.y1 ?? DOOR_HEAD)) return false;
59713
60067
  const [p0, p1, q0, q1] = o.axis === "u" ? [a[1], b[1], a[0], b[0]] : [a[0], b[0], a[1], b[1]];
59714
60068
  const across2 = Math.min(p0, p1) <= o.pos + 0.1 && Math.max(p0, p1) >= o.pos - 0.1;
59715
60069
  return across2 && Math.max(Math.min(q0, q1), o.at - o.width / 2) < Math.min(Math.max(q0, q1), o.at + o.width / 2);
@@ -59929,10 +60283,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59929
60283
  const w = TRENCH.berm.width;
59930
60284
  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];
59931
60285
  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);
59932
- 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])) {
59933
- if (Math.min(piece2[2] - piece2[0], piece2[3] - piece2[1]) < TRENCH.berm.crest * 2) continue;
59934
- addHumps(heap, piece2);
59935
- laid.push(piece2);
60286
+ 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])) {
60287
+ if (Math.min(piece22[2] - piece22[0], piece22[3] - piece22[1]) < TRENCH.berm.crest * 2) continue;
60288
+ addHumps(heap, piece22);
60289
+ laid.push(piece22);
59936
60290
  }
59937
60291
  }
59938
60292
  });
@@ -60077,7 +60431,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
60077
60431
  function buriedSewerOf(plan) {
60078
60432
  const drains = drainsOf(plan);
60079
60433
  if (!drains.length) return [];
60080
- return sewerLayout(plan, drains).pieces.flatMap((piece2) => piece2.points.slice(1).map((b, i) => ({ a: piece2.points[i], b })));
60434
+ return sewerLayout(plan, drains).pieces.flatMap((piece22) => piece22.points.slice(1).map((b, i) => ({ a: piece22.points[i], b })));
60081
60435
  }
60082
60436
  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 } };
60083
60437
  function feedLayout(plan) {
@@ -60137,10 +60491,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
60137
60491
  const dug = [...layout.trenches, ...rainwater.trenches, ...feeds.trenches, ...boxes.map(pitOf)];
60138
60492
  addSpoil(THREE, group, dug, mats.heap, { solids: solids2, footprint: houseFootprint(routingPlanOf(plan)), buildings: (plan.outbuildings ?? []).map((o) => o.aabb) });
60139
60493
  group.userData.excavations = dug.map(excavationOf);
60140
- for (const piece2 of layout.pieces) addPipe(THREE, group, piece2.points, piece2.bore / 2, mats.pipe);
60494
+ for (const piece22 of layout.pieces) addPipe(THREE, group, piece22.points, piece22.bore / 2, mats.pipe);
60141
60495
  const rainGroup = new THREE.Group();
60142
60496
  rainGroup.name = "rain_drains";
60143
- for (const piece2 of rainwater.pieces) addPipe(THREE, rainGroup, piece2.points, piece2.bore / 2, mats.rain);
60497
+ for (const piece22 of rainwater.pieces) addPipe(THREE, rainGroup, piece22.points, piece22.bore / 2, mats.rain);
60144
60498
  group.add(rainGroup);
60145
60499
  addWarningTape(THREE, group, feeds.runs);
60146
60500
  const yard = new THREE.Group();
@@ -60433,11 +60787,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
60433
60787
  });
60434
60788
  }
60435
60789
  function stagedWallRuns(H) {
60436
- 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);
60790
+ 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);
60437
60791
  if (!tank2) return;
60438
60792
  const xyz = (p) => [p[0], p[1], p[2]];
60439
60793
  const out = [tank2.u, tank2.v - (tank2.d || 1.1) / 2 - 0.2], attic = atticFloor(plan) + ATTIC_LIFT.water;
60440
- 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]]];
60794
+ 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]]];
60441
60795
  cursor.group = shared3.ctx.waterTankPos && shared3.ctx.waterTankPos.group || "f0";
60442
60796
  cursor.pc = pieceRecord("pipe:run_outlet", "plastic", null, { tags: ["pipe"] });
60443
60797
  for (let i = 0; i + 1 < outlet.length; i++) pipe(outlet[i], outlet[i + 1], 0.032, PIPE_COLOR);
@@ -60592,8 +60946,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
60592
60946
  Object.assign(K, defined);
60593
60947
  }
60594
60948
  var EPS23 = 1e-4;
60595
- function subtractRects(base, holes) {
60596
- let pieces = [base];
60949
+ function subtractRects(base2, holes) {
60950
+ let pieces = [base2];
60597
60951
  for (const h of holes) {
60598
60952
  const next = [];
60599
60953
  for (const r of pieces) {
@@ -60734,8 +61088,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
60734
61088
  const depthOn = (side) => {
60735
61089
  const on = over.filter((c) => c.side === side);
60736
61090
  if (!on.length) return 0;
60737
- const least = Math.min(...on.map((c) => c.back)), back = Math.abs(least - mortar) < CHASE_CLEAR_OF_MORTAR ? mortar - CHASE_CLEAR_OF_MORTAR : least;
60738
- return t / 2 - (back - inset);
61091
+ const least = Math.min(...on.map((c) => c.back)), back2 = Math.abs(least - mortar) < CHASE_CLEAR_OF_MORTAR ? mortar - CHASE_CLEAR_OF_MORTAR : least;
61092
+ return t / 2 - (back2 - inset);
60739
61093
  };
60740
61094
  const low = depthOn(-1), high = depthOn(1);
60741
61095
  box5(batch, p0, q0, p1, q1, t - low - high, (low - high) / 2);
@@ -60875,8 +61229,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
60875
61229
  const along2 = wall.alongU ? r.u : r.v, across2 = (wall.alongU ? r.v : r.u) - core.line;
60876
61230
  if (along2 + r.radius + CHASE_CLEAR2 < wall.a0 || along2 - r.radius - CHASE_CLEAR2 > wall.a1 || r.y1 <= core.y0 || r.y0 >= core.y1) continue;
60877
61231
  if (Math.abs(across2) > wall.thickness / 2 + 1e-6) continue;
60878
- const back = Math.abs(across2) - (r.depth ?? r.radius) - CHASE_CLEAR2;
60879
- 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 } : {} });
61232
+ const back2 = Math.abs(across2) - (r.depth ?? r.radius) - CHASE_CLEAR2;
61233
+ 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 } : {} });
60880
61234
  }
60881
61235
  return out;
60882
61236
  }
@@ -61232,8 +61586,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
61232
61586
  const alongU = Math.abs(point.frontV) >= Math.abs(point.frontU);
61233
61587
  const intoRoom = Math.sign(alongU ? point.frontV : point.frontU);
61234
61588
  const face = wall.line + intoRoom * (wall.halfThickness - PLASTER_PER_FACE + WALL_BOX_PROUD);
61235
- const back = face - intoRoom * WALL_BOX.deep;
61236
- const [low, high] = face < back ? [face, back] : [back, face];
61589
+ const back2 = face - intoRoom * WALL_BOX.deep;
61590
+ const [low, high] = face < back2 ? [face, back2] : [back2, face];
61237
61591
  const half = WALL_BOX.along / 2;
61238
61592
  return {
61239
61593
  u0: alongU ? point.u - half : low,
@@ -61382,8 +61736,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
61382
61736
  const M = en22.meter;
61383
61737
  if (M) {
61384
61738
  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;
61385
- const back = shared3.ctx.visorScene ? 0 : 3e-3;
61386
- 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);
61739
+ const back2 = shared3.ctx.visorScene ? 0 : 3e-3;
61740
+ 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);
61387
61741
  const fz = fr < 0 ? [M.v - hd - 0.012, M.v - hd] : [M.v + hd, M.v + hd + 0.012];
61388
61742
  if (!(KV && KV.meter)) {
61389
61743
  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);
@@ -61562,7 +61916,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
61562
61916
  };
61563
61917
  for (const A of ws) for (const [side, sd] of [[A.w.sides[0], -1], [A.w.sides[1], 1]]) {
61564
61918
  if (!sideOf(side, false).exterior) continue;
61565
- const strip = (k, y1, y2, o0, o1, mat, c, piece2, laid = BASEBOARD_TILES) => {
61919
+ const strip = (k, y1, y2, o0, o1, mat, c, piece22, laid = BASEBOARD_TILES) => {
61566
61920
  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;
61567
61921
  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);
61568
61922
  if (s1 - s0 < 1e-3) return;
@@ -61586,7 +61940,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
61586
61940
  runs.push([from, s1]);
61587
61941
  runs.forEach(([r0, r1], k2) => {
61588
61942
  if (r1 - r0 < 1e-3) return;
61589
- const id = piece2 && runs.length > 1 ? `${piece2}:${k2}` : piece2;
61943
+ const id = piece22 && runs.length > 1 ? `${piece22}:${k2}` : piece22;
61590
61944
  if (!id) box5(r0, r1);
61591
61945
  else if (shared3.ctx.baseboardBand) tile(id, r0, r1);
61592
61946
  else {
@@ -61674,12 +62028,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
61674
62028
  const yA = roofHeightAt(p.u, p.v - hd), yB = roofHeightAt(p.u, p.v + hd), yC = roofHeightAt(p.u, p.v);
61675
62029
  let yc, tilt;
61676
62030
  if (onRack) {
61677
- const base = yC != null ? yC : Y0(fa) + 0.02, angle = (S.tilt || 15) * Math.PI / 180, high = Math.sin(angle) * p.length;
62031
+ const base2 = yC != null ? yC : Y0(fa) + 0.02, angle = (S.tilt || 15) * Math.PI / 180, high = Math.sin(angle) * p.length;
61678
62032
  tilt = sv * Math.atan2(high, d);
61679
- yc = base + 0.25 + high / 2;
61680
- const yLow = base + 0.25, yHigh = yLow + high;
61681
- 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);
61682
- 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);
62033
+ yc = base2 + 0.25 + high / 2;
62034
+ const yLow = base2 + 0.25, yHigh = yLow + high;
62035
+ 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);
62036
+ 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);
61683
62037
  } else {
61684
62038
  if (yA == null || yB == null || yC == null) continue;
61685
62039
  tilt = Math.atan2(yA - yB, d);
@@ -61781,7 +62135,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
61781
62135
  }
61782
62136
  function installFurnitureApi(K, shared3) {
61783
62137
  const { _e, _h2, _q, boxC, cursor, macroGround, polyFace, put } = K;
61784
- 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" };
62138
+ 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" };
61785
62139
  const mm = (k) => MATERIAL_MAP2[k] || "plain";
61786
62140
  const LIGHTS = [];
61787
62141
  function makeApi() {
@@ -62532,7 +62886,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62532
62886
  }
62533
62887
  function installFurnitureTaps(K, shared3) {
62534
62888
  shared3.tapCount = 0;
62535
- function counterTap(K2, x, y, z, reach2, back, meta = {}) {
62889
+ function counterTap(K2, x, y, z, reach2, back2, meta = {}) {
62536
62890
  const cr = 12896460, id = "tap_" + (K2.M.seed || "") + "_" + shared3.tapCount++;
62537
62891
  K2.c("metal", x, y, z, 0.028, 0.012, cr);
62538
62892
  K2.c("metal", x, y + 0.012, z, 0.014, 0.12, cr);
@@ -62559,11 +62913,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62559
62913
  );
62560
62914
  const ya = tip[1] - 0.05;
62561
62915
  K2.part("water_tap", tip[0], ya, tip[2], () => {
62562
- K2.t("water", [tip[0], ya, tip[2]], [tip[0], y - back, tip[2]], 6e-3, 13625588);
62916
+ K2.t("water", [tip[0], ya, tip[2]], [tip[0], y - back2, tip[2]], 6e-3, 13625588);
62563
62917
  }, { id: id + "_a", target: id, hidden: true, fluid: "water" });
62564
62918
  return id;
62565
62919
  }
62566
- function wallTap(K2, x, y, zw, direction, back, meta = {}) {
62920
+ function wallTap(K2, x, y, zw, direction, back2, meta = {}) {
62567
62921
  const cr = 12896460, id = "tap_" + (K2.M.seed || "") + "_" + shared3.tapCount++, s = direction || 1;
62568
62922
  K2.t("metal", [x, y, zw], [x, y, zw + s * 0.025], 0.03, cr);
62569
62923
  K2.t("metal", [x, y, zw + s * 0.02], [x, y, zw + s * 0.1], 0.016, cr);
@@ -62586,19 +62940,24 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62586
62940
  );
62587
62941
  const ya = y - 0.08;
62588
62942
  K2.part("water_tap", x, ya, zw + s * 0.105, () => {
62589
- K2.t("water", [x, ya, zw + s * 0.105], [x, back, zw + s * 0.105], 65e-4, 13625588);
62943
+ K2.t("water", [x, ya, zw + s * 0.105], [x, back2, zw + s * 0.105], 65e-4, 13625588);
62590
62944
  }, { id: id + "_a", target: id, hidden: true, fluid: "water" });
62591
62945
  return id;
62592
62946
  }
62593
62947
  const defined = { counterTap, wallTap };
62594
62948
  Object.assign(K, defined);
62595
62949
  }
62950
+ var SHOWER_DOOR = 0.72;
62951
+ var PANEL_THICKNESS = 0.02;
62952
+ var MIN_PANEL = 0.1;
62596
62953
  function installFurnitureFixtures(K, shared3) {
62954
+ const kernel = K;
62597
62955
  const seedKey = (id) => K.seedKey(id);
62598
62956
  const { FURNITURE, MIRRORS, SEED, arcPoints, cursor, kit2, rngString, sh } = K;
62599
62957
  FURNITURE.box = function(M, A) {
62600
62958
  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;
62601
- const R = Math.min(0.32, w * 0.34, d * 0.34), gh = 1.95, gt2 = 8e-3;
62959
+ const walkIn = !shared3.ctx.visorScene;
62960
+ 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;
62602
62961
  K2.b("plain", 0, 0, 0, w - 0.02, 0.05, d - 0.02, 15132902);
62603
62962
  K2.c("metal", 0, 0.05, 0, 0.045, 6e-3, 11580600);
62604
62963
  if (shared3.ctx.visorScene) K2.c("plain", 0, 0.05, 0, 0.032, 8e-3, 4212812);
@@ -62611,17 +62970,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62611
62970
  gl(px0, -d / 2 + 0.05, px0, pzF - R);
62612
62971
  const arc = arcPoints(px0 - R, pzF - R, R, 0, Math.PI / 2, 6);
62613
62972
  for (let i = 0; i < arc.length - 1; i++) gl(arc[i][0], arc[i][1], arc[i + 1][0], arc[i + 1][1]);
62614
- const fx1 = Math.max(-w / 2 + 0.36, px0 - R - 0.5);
62615
- gl(px0 - R, pzF, fx1, pzF);
62973
+ const front = walkIn ? Math.min(px0 - R, -w / 2 + 0.03 + SHOWER_DOOR) : Math.max(-w / 2 + 0.36, px0 - R - 0.5);
62974
+ const fx1 = walkIn && px0 - R - front < MIN_PANEL ? px0 - R : front, panel = px0 - R - fx1 > 0.01;
62975
+ if (panel) gl(px0 - R, pzF, fx1, pzF);
62616
62976
  const rail2 = (y, r) => {
62617
62977
  tube2([px0, y, -d / 2 + 0.05], [px0, y, pzF - R], r);
62618
62978
  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);
62619
- tube2([px0 - R, y, pzF], [fx1, y, pzF], r);
62979
+ if (panel) tube2([px0 - R, y, pzF], [fx1, y, pzF], r);
62620
62980
  };
62621
62981
  rail2(gh, 0.011);
62622
62982
  rail2(0.055, 9e-3);
62623
62983
  for (const [x, z] of [[px0, -d / 2 + 0.05], [fx1, pzF]]) tube2([x, 0.05, z], [x, gh + 5e-3, z], 0.011);
62624
- 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);
62984
+ 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);
62625
62985
  const hx = fx1, dw = hx - (-w / 2 + 0.03);
62626
62986
  if (dw > 0.2) K2.part(
62627
62987
  "shower_door",
@@ -62636,6 +62996,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62636
62996
  },
62637
62997
  { id: id + "_door", opens: { type: "swing", axis: [0, 1, 0], angle: -1.7 } }
62638
62998
  );
62999
+ if (walkIn) {
63000
+ const panels = [[px0, -d / 2 + 0.05, px0, pzF - R]];
63001
+ 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]]);
63002
+ if (panel) panels.push([px0 - R, pzF, fx1, pzF]);
63003
+ kernel.walkInSolids(M, { panels, thickness: PANEL_THICKNESS, height: gh, door: dw > 0.2 ? { part: id + "_door", from: [hx, pzF], to: [hx - dw, pzF] } : null });
63004
+ }
62639
63005
  const ax = 0.1, ya = 2.08, z0 = zw + 0.012, Ra = 0.22, n = 6, pa = [];
62640
63006
  for (let i = 0; i <= n; i++) {
62641
63007
  const f = i / n * Math.PI / 2;
@@ -62846,12 +63212,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62846
63212
  var DOOR = { recess: 0.012, thick: 0.02, side: 4e-3, bottom: 0.03 };
62847
63213
  var LOUVRE = { proud: 3e-3, slat: 0.012, pitch: 0.025, count: 4 };
62848
63214
  function gasShelterBoxes({ side, height }) {
62849
- const half = side / 2, back = -half + SHELTER_OFF_WALL;
63215
+ const half = side / 2, back2 = -half + SHELTER_OFF_WALL;
62850
63216
  const boxes = [
62851
- { part: "wall", front: [back, back + WALL], across: [-half, half], y: [0, height] },
62852
- { part: "wall", front: [back + WALL, half], across: [-half, -half + WALL], y: [0, height] },
62853
- { part: "wall", front: [back + WALL, half], across: [half - WALL, half], y: [0, height] },
62854
- { part: "roof", front: [back, half + EAVE2], across: [-half - EAVE2, half + EAVE2], y: [height, height + ROOF] }
63217
+ { part: "wall", front: [back2, back2 + WALL], across: [-half, half], y: [0, height] },
63218
+ { part: "wall", front: [back2 + WALL, half], across: [-half, -half + WALL], y: [0, height] },
63219
+ { part: "wall", front: [back2 + WALL, half], across: [half - WALL, half], y: [0, height] },
63220
+ { part: "roof", front: [back2, half + EAVE2], across: [-half - EAVE2, half + EAVE2], y: [height, height + ROOF] }
62855
63221
  ];
62856
63222
  const doorFace = half - DOOR.recess, doorAcross = [-half + WALL + DOOR.side, half - WALL - DOOR.side];
62857
63223
  boxes.push({ part: "door", front: [doorFace - DOOR.thick, doorFace], across: doorAcross, y: [DOOR.bottom, height - DOOR.bottom] });
@@ -63002,10 +63368,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
63002
63368
  if (shelterOf(M)) {
63003
63369
  } else if (M.hose && M.hose.length > 1) {
63004
63370
  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);
63005
- 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 = [];
63371
+ 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 = [];
63006
63372
  for (let k = 0; k <= n; k++) {
63007
63373
  const t = k / n, u = 1 - t;
63008
- 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]]);
63374
+ 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]]);
63009
63375
  }
63010
63376
  for (let k = 0; k < n; k++) K2.t("plain", pts[k], pts[k + 1], 0.011, 12071454);
63011
63377
  K2.c("metal", P2[0], P2[1] - 0.025, P2[2], 0.016, 0.05, brass);
@@ -63196,6 +63562,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
63196
63562
  const { THREE, Y0, _col, boxC, colorOf, cursor, decorLights, makeApi, structurePiece, OPEN_AREA, rectsOf: rectsOf2 } = K;
63197
63563
  const buildItem2 = (...a) => K.buildItem(...a);
63198
63564
  const registerCollision = (...a) => K.registerCollision(...a);
63565
+ const kitCollides = (...a) => K.kitCollides(...a);
63199
63566
  const vegItem = (...a) => K.vegItem(...a);
63200
63567
  const SLAB_UNDERSIDE = 0.24;
63201
63568
  function houseItems() {
@@ -63219,8 +63586,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
63219
63586
  if (exterior && m.category === "ground_cover" && shared3.ctx.noGroundSurfaces) continue;
63220
63587
  const f = exterior ? -1 : Math.min(m.floor, R.floors.length - 1);
63221
63588
  cursor.group = exterior && !(m.type === "cooking_gas_cylinder" && m.shelter && !shared3.ctx.visorScene) ? "lot" : "f" + Math.max(f, 0);
63222
- 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;
63223
- 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 };
63589
+ 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;
63590
+ 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 };
63224
63591
  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));
63225
63592
  if (lift) M.ceiling = (M.ceiling ?? 2.9) - lift;
63226
63593
  if (!exterior && !shared3.ctx.visorScene && f > 0) overRoof(m, M, f);
@@ -63263,13 +63630,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
63263
63630
  }
63264
63631
  }
63265
63632
  if (shared3.ctx.iv && shared3.ctx.iv.replace.has(m.id)) {
63266
- registerCollision(m, M);
63633
+ if (!kitCollides(m)) registerCollision(m, M);
63267
63634
  continue;
63268
63635
  }
63269
63636
  const ent = T2[m.type];
63270
63637
  const st0 = cursor.stage;
63271
63638
  if (shared3.ctx.constructionStages && (m.type === "cooking_gas_cylinder" || m.type === "gas_cylinder" || m.type === "water_tank")) cursor.stage = "installations";
63272
- shared3.ctx.restOn = exterior || shared3.ctx.visorScene ? void 0 : base;
63639
+ shared3.ctx.restOn = exterior || shared3.ctx.visorScene ? void 0 : base2;
63273
63640
  if (!shared3.ctx.visorScene) {
63274
63641
  const quarter = Math.round(M.ry / (Math.PI / 2));
63275
63642
  if (Math.abs(M.ry - quarter * Math.PI / 2) < 0.01) M.ry = quarter * Math.PI / 2;
@@ -63386,7 +63753,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
63386
63753
  return;
63387
63754
  }
63388
63755
  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));
63389
- 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));
63756
+ 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));
63390
63757
  cursor.group = slab ? "f" + f : "attic_tank";
63391
63758
  const platformLift = !slab && !shared3.ctx.visorScene ? 0.12 : 0;
63392
63759
  if (lc) {
@@ -63405,12 +63772,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
63405
63772
  }
63406
63773
  if (!slab) {
63407
63774
  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;
63408
- const top = base + platformLift;
63775
+ const top = base2 + platformLift;
63409
63776
  boxC("plain", cd.u, top - 0.06, cd.v, hw * 2, 0.12, hd * 2, color2);
63410
- 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);
63777
+ 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);
63411
63778
  }
63412
- 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 };
63413
- shared3.ctx.waterTankPos = { x: cd.u, z: cd.v, y: base + platformLift, group: cursor.group };
63779
+ 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 };
63780
+ shared3.ctx.waterTankPos = { x: cd.u, z: cd.v, y: base2 + platformLift, group: cursor.group };
63414
63781
  shared3.ctx.types.water_tank.f(M, api);
63415
63782
  }
63416
63783
  function trestleTank(api, cd) {
@@ -63811,8 +64178,29 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
63811
64178
  const d1 = objectDistance(o, x, z);
63812
64179
  if (d1 < R && d1 < objectDistance(o, fx, fz) - 1e-6) return true;
63813
64180
  }
64181
+ return collideKit(x, z, fx, fz, floor2, R);
64182
+ }
64183
+ function collideKit(x, z, fx, fz, floor2, R) {
64184
+ const iv = shared3.ctx.iv, collided = iv && iv.collided;
64185
+ if (!iv || !collided || !collided.size) return false;
64186
+ for (const k of iv.world.colliders()) {
64187
+ const f = collided.get(k.object);
64188
+ if (f === void 0 || (f !== -1 ? f !== floor2 : floor2 !== 0)) continue;
64189
+ 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" };
64190
+ const d1 = objectDistance(o, x, z);
64191
+ if (d1 < R && d1 < objectDistance(o, fx, fz) - 1e-6) return true;
64192
+ }
63814
64193
  return false;
63815
64194
  }
64195
+ function kitCollides(m) {
64196
+ const iv = shared3.ctx.iv;
64197
+ if (!iv) return false;
64198
+ const own = [...iv.entries.values()].filter((e) => e.origin === m.id && (e.spec.colliders?.length ?? 0) > 0);
64199
+ if (!own.length) return false;
64200
+ const collided = iv.collided || (iv.collided = /* @__PURE__ */ new Map());
64201
+ for (const e of own) collided.set(e.id, e.floor);
64202
+ return true;
64203
+ }
63816
64204
  function collideAt(x, z, floor2, opt) {
63817
64205
  opt = opt || {};
63818
64206
  const R = opt.radius != null ? opt.radius : 0.24;
@@ -63826,7 +64214,24 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
63826
64214
  const de = opt.from || [x + 1e4, z + 1e4];
63827
64215
  return collideObject(x, z, de[0], de[1], floor2);
63828
64216
  }
63829
- const defined = { NO_COLLIDE, registerCollision, objectDistance, collideObject, collideAt };
64217
+ function walkInSolids(M, spec) {
64218
+ const objs = shared3.inter?.objs, colliders = shared3.ctx.colliders;
64219
+ if (!objs || !colliders) return;
64220
+ const at4 = objs.findIndex((o) => o.cx === M.x && o.cz === M.z && o.f === M.floor);
64221
+ const kept = at4 >= 0 ? objs.splice(at4, 1)[0] : void 0;
64222
+ const type = kept?.type ?? "walk_in";
64223
+ const half = spec.thickness / 2;
64224
+ for (const [x0, z0, x1, z1] of spec.panels) {
64225
+ const length2 = Math.hypot(x1 - x0, z1 - z0);
64226
+ if (length2 < 1e-3) continue;
64227
+ const [cx, cz] = K.localOf(M, (x0 + x1) / 2, (z0 + z1) / 2), turn2 = (M.ry || 0) + Math.atan2(-(z1 - z0), x1 - x0);
64228
+ objs.push({ f: M.floor, cx, cz, c: Math.cos(turn2), s: Math.sin(turn2), hw: length2 / 2, hd: half, h: spec.height, type });
64229
+ }
64230
+ if (!spec.door) return;
64231
+ 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]);
64232
+ 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 });
64233
+ }
64234
+ const defined = { NO_COLLIDE, registerCollision, objectDistance, collideObject, collideAt, walkInSolids, kitCollides };
63830
64235
  Object.assign(K, defined);
63831
64236
  }
63832
64237
  function installInteractionItems(K, shared3) {
@@ -64033,13 +64438,26 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
64033
64438
  const g = r.g;
64034
64439
  if (!isFinite(r.x0)) return;
64035
64440
  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";
64036
- const base = { parent: "lot", ry: 0, t0: g.open ? 1 : 0, col: cols[i], gate: g };
64037
- 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 }));
64441
+ const base2 = { parent: "lot", ry: 0, t0: g.open ? 1 : 0, col: cols[i], gate: g };
64442
+ 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 }));
64038
64443
  if (p.col) p.col.off = p.target > 0.5;
64039
64444
  const text = () => t(p.target > 0.5 ? "prompt.close" : "prompt.open", { what: t(ped ? "what.pedestrianGate" : "what.garageGate") });
64040
64445
  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 });
64041
64446
  });
64042
64447
  }
64448
+ function walkInInteractive() {
64449
+ for (const c of shared3.ctx.colliders) {
64450
+ if (c.type !== "walk_in_door" || typeof c.piece !== "string") continue;
64451
+ const g = shared3.ctx.parts && shared3.ctx.parts[c.piece];
64452
+ if (!g) continue;
64453
+ const def = definePiece("ix:walkin:" + c.piece, { kind: "part", pivot: [0, 0, 0], ry: 0, parent: "lot" });
64454
+ def.inner = g;
64455
+ def.col = c;
64456
+ c.off = def.t > 0.5;
64457
+ 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) });
64458
+ applyPiece(def);
64459
+ }
64460
+ }
64043
64461
  function mailboxInteractive() {
64044
64462
  for (const m of house().items) {
64045
64463
  if (m.type !== "mailbox") continue;
@@ -64097,15 +64515,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
64097
64515
  else bx("plain", Math.min(f2, f3), yc - 0.032, u - 0.016, Math.max(f2, f3), yc + 0.032, u + 0.016, 16250092);
64098
64516
  cursor.group = g0;
64099
64517
  const pv = alongU ? [u, yc, f2] : [f2, yc, u];
64100
- 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 });
64101
- piece2.t = piece2.target = lightOn(roomId) ? 1 : 0;
64518
+ 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 });
64519
+ piece22.t = piece22.target = lightOn(roomId) ? 1 : 0;
64102
64520
  const an = alongU ? [u, yc, face + sd * 0.12] : [face + sd * 0.12, yc, u];
64103
- 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) });
64521
+ 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) });
64104
64522
  return true;
64105
64523
  }
64106
64524
  return false;
64107
64525
  }
64108
- const defined = { gatesInteractive, mailboxInteractive, placeSwitches, putSwitch };
64526
+ const defined = { walkInInteractive, gatesInteractive, mailboxInteractive, placeSwitches, putSwitch };
64109
64527
  Object.assign(K, defined);
64110
64528
  }
64111
64529
  function installInteractionDoors(K, shared3) {
@@ -64268,7 +64686,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
64268
64686
  const { t, THREE, invalidate, invalidateShadow, cfg, DOC, LIGHT_TYPES, _Y, _q, _v3, accFor, applyLight, cursor, hashString, hudMessage, lightBase, pieceRecord, rgbOf, wallBlocks } = K;
64269
64687
  const enter = (...a) => K.enter(...a);
64270
64688
  const roomLightMask = (...a) => K.roomLightMask(...a);
64271
- 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" };
64689
+ 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" };
64272
64690
  const IV_WIRE = { conduit: 13618628, cable: 2762532, drop: 1381653, cord: 1776413, earth: 3111482, hose: 11556124 };
64273
64691
  const IV_DOOR = /^(door|drawer)/;
64274
64692
  const ivGroup = (e) => e.floor < 0 ? "lot" : "f" + Math.min(e.floor, shared3.ctx.r.floors.length - 1);
@@ -64338,7 +64756,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
64338
64756
  const entById = new Map(plane2.items.map((e) => [e.id, e]));
64339
64757
  const entByItem = new Map(plane2.items.map((e) => [e.item, e]));
64340
64758
  const mats = shared3.mats;
64341
- 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 };
64759
+ 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 };
64342
64760
  const ev = (e) => ivEvent(h, e);
64343
64761
  const world = IV.world = A.createWorld(source, { water, seed: r.seed, onEvent: ev });
64344
64762
  const add0 = world.add;
@@ -64449,7 +64867,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
64449
64867
  cursor.stage = stage0;
64450
64868
  cursor.pc = pieceBefore;
64451
64869
  }
64452
- const base = new Set(Object.values(IV.mats));
64870
+ const base2 = new Set(Object.values(IV.mats));
64453
64871
  root.traverse((o) => {
64454
64872
  if (!isMesh(o)) return;
64455
64873
  o.userData.iv = ent.id;
@@ -64457,7 +64875,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
64457
64875
  if (!o.geometry.boundingSphere) o.geometry.computeBoundingSphere();
64458
64876
  if (o.geometry.boundingSphere.radius < 0.07) o.castShadow = false;
64459
64877
  }
64460
- 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) {
64878
+ 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) {
64461
64879
  m.userData.roomLightMask = false;
64462
64880
  roomLightMask(m);
64463
64881
  }
@@ -64759,6 +65177,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
64759
65177
  roomStates: IV.roomStates,
64760
65178
  warnings: IV.warnings,
64761
65179
  water: IV.water,
65180
+ solidColliders: () => {
65181
+ const c = IV.collided;
65182
+ return c && c.size ? w.colliders().flatMap((k) => {
65183
+ const floor2 = c.get(k.object);
65184
+ return floor2 === void 0 ? [] : [{ ...k, floor: floor2 }];
65185
+ }) : [];
65186
+ },
64762
65187
  screens: IV.screens,
64763
65188
  effects: () => IV.efx || null,
64764
65189
  // TV screens (id -> kit screen) and the particle system (smoke), for whoever wants to inspect
@@ -65380,8 +65805,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
65380
65805
  return { depth: Math.max(drawn, declared2?.depth ?? 0), width: declared2?.width ?? Math.max(u1 - u0, v1 - v0) };
65381
65806
  }
65382
65807
  function groundJointStrength(part, kind) {
65383
- const base = buriedBase(part);
65384
- return base.depth > 0 ? embedmentStrength(kind, base) : void 0;
65808
+ const base2 = buriedBase(part);
65809
+ return base2.depth > 0 ? embedmentStrength(kind, base2) : void 0;
65385
65810
  }
65386
65811
  var NONE = { panels: [], replaced: [], supports: [] };
65387
65812
  var MEMO = /* @__PURE__ */ new WeakMap();
@@ -65493,7 +65918,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
65493
65918
  parts2.push(p);
65494
65919
  byId.set(p.id, p);
65495
65920
  }
65496
- const base = parts2.length, view = shared3.ctx.panelView || panelViewOf(null, false), panelIds = new Set(view.panels.map((e) => e.id));
65921
+ const base2 = parts2.length, view = shared3.ctx.panelView || panelViewOf(null, false), panelIds = new Set(view.panels.map((e) => e.id));
65497
65922
  for (const [id, pc] of shared3.ctx.pieces) {
65498
65923
  if (byId.has(id) || panelIds.has(id) || !meshes.has(id)) continue;
65499
65924
  const b = box32(id);
@@ -65523,7 +65948,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
65523
65948
  const floorUnder = (p) => {
65524
65949
  const cx = (p.aabb[0] + p.aabb[2]) / 2, cz = (p.aabb[1] + p.aabb[3]) / 2;
65525
65950
  let best = null;
65526
- for (const q of parts2.slice(0, base)) {
65951
+ for (const q of parts2.slice(0, base2)) {
65527
65952
  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;
65528
65953
  if (!best || q.y1 > best.y1 || q.y1 === best.y1 && q.id < best.id) best = q;
65529
65954
  }
@@ -65556,7 +65981,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
65556
65981
  return { part: p.id, on: "ground", joint: joint2, bears: false, extra: true, ...strength !== void 0 ? { strength } : {} };
65557
65982
  };
65558
65983
  const unheld = [];
65559
- for (const p of parts2.slice(base)) {
65984
+ for (const p of parts2.slice(base2)) {
65560
65985
  if (/^sidewalk:/.test(p.id)) {
65561
65986
  supports.push({ part: p.id, on: "ground", joint: "mortar", extra: true });
65562
65987
  continue;
@@ -65584,7 +66009,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
65584
66009
  if (!/^(window|window_pane|door|jamb|pipe|water_tank|baseboard)/.test(p.id)) continue;
65585
66010
  const target = /^water_tank/.test(p.id) ? ["slab"] : ["wall", "partition"];
65586
66011
  let m = null, md = 1e9;
65587
- for (const q of parts2.slice(0, base)) {
66012
+ for (const q of parts2.slice(0, base2)) {
65588
66013
  if (!target.includes(q.role) || !inside22(p, q, 0.2)) continue;
65589
66014
  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);
65590
66015
  if (d < md) {
@@ -65592,7 +66017,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
65592
66017
  m = q;
65593
66018
  }
65594
66019
  }
65595
- if (!m && /^(window|door|jamb)/.test(p.id)) for (const q of parts2.slice(0, base)) {
66020
+ if (!m && /^(window|door|jamb)/.test(p.id)) for (const q of parts2.slice(0, base2)) {
65596
66021
  if (!["wall", "partition", "column", "beam"].includes(q.role) || !touches2(p, q, 0.02)) continue;
65597
66022
  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);
65598
66023
  if (d < md) {
@@ -65730,6 +66155,119 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
65730
66155
  if (distance4 <= -depth) return true;
65731
66156
  return distance4 <= -depth * noise3();
65732
66157
  }
66158
+ var JOINT_SHARE = 0.5;
66159
+ var EPSILON22 = 1e-4;
66160
+ function carve(boxes, grid) {
66161
+ const { data, w, h, len, y0, height } = grid;
66162
+ const out = [];
66163
+ for (const box5 of boxes) {
66164
+ 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);
66165
+ const i0 = Math.max(0, Math.floor(box5.a / len * w)), i1 = Math.min(w - 1, Math.ceil(box5.b / len * w) - 1);
66166
+ if (j1 < j0 || i1 < i0) {
66167
+ out.push(box5);
66168
+ continue;
66169
+ }
66170
+ for (let j = j0; j <= j1; j++) {
66171
+ const ry0 = Math.max(box5.y0, y0 + j / h * height), ry1 = Math.min(box5.y1, y0 + (j + 1) / h * height);
66172
+ let start = -1;
66173
+ for (let i = i0; i <= i1 + 1; i++) {
66174
+ const solid2 = i <= i1 && data[j * w + i] <= 127;
66175
+ if (solid2 && start < 0) start = i;
66176
+ if (!solid2 && start >= 0) {
66177
+ out.push({ a: Math.max(box5.a, start / w * len), b: Math.min(box5.b, i / w * len), y0: ry0, y1: ry1 });
66178
+ start = -1;
66179
+ }
66180
+ }
66181
+ }
66182
+ }
66183
+ return out;
66184
+ }
66185
+ var groupBy = (items, keyOf2) => {
66186
+ const groups = /* @__PURE__ */ new Map();
66187
+ for (const item of items) {
66188
+ const key2 = keyOf2(item);
66189
+ const group = groups.get(key2);
66190
+ if (group) group.push(item);
66191
+ else groups.set(key2, [item]);
66192
+ }
66193
+ return [...groups.values()];
66194
+ };
66195
+ function mergeSpans(spans, share = JOINT_SHARE) {
66196
+ const runs = [];
66197
+ const unitLengths = /* @__PURE__ */ new Map();
66198
+ for (const row of groupBy(spans, (s) => `${s.y0.toFixed(4)}:${s.y1.toFixed(4)}`)) {
66199
+ row.sort((p, q) => p.a - q.a);
66200
+ let run = { ...row[0] };
66201
+ let unitLength = run.b - run.a;
66202
+ for (const s of row.slice(1)) {
66203
+ if (s.a - run.b <= share * Math.min(s.b - s.a, unitLength) + EPSILON22) run.b = Math.max(run.b, s.b);
66204
+ else {
66205
+ runs.push(run);
66206
+ unitLengths.set(run, unitLength);
66207
+ run = { ...s };
66208
+ }
66209
+ unitLength = s.b - s.a;
66210
+ }
66211
+ runs.push(run);
66212
+ unitLengths.set(run, unitLength);
66213
+ }
66214
+ const out = [];
66215
+ const open = [];
66216
+ for (const r of [...runs].sort((p, q) => p.y0 - q.y0 || p.a - q.a)) {
66217
+ const height = r.y1 - r.y0;
66218
+ const top = open.find((o) => {
66219
+ const slack = share * Math.min(o.unitLength, r.b - r.a) + EPSILON22;
66220
+ 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;
66221
+ });
66222
+ if (top) {
66223
+ top.box.y1 = r.y1;
66224
+ top.box.a = Math.min(top.box.a, r.a);
66225
+ top.box.b = Math.max(top.box.b, r.b);
66226
+ top.unitHeight = height;
66227
+ } else {
66228
+ const box5 = { ...r };
66229
+ out.push(box5);
66230
+ open.push({ box: box5, unitHeight: height, unitLength: unitLengths.get(r) ?? r.b - r.a });
66231
+ }
66232
+ }
66233
+ return out;
66234
+ }
66235
+ function standingSolids(THREE, house, mesh3, line, parts2) {
66236
+ house.updateWorldMatrix(true, false);
66237
+ mesh3.updateWorldMatrix(true, false);
66238
+ const toMesh = new THREE.Matrix4().copy(mesh3.matrixWorld).invert().multiply(house.matrixWorld);
66239
+ const turn2 = new THREE.Quaternion();
66240
+ const scale = new THREE.Vector3();
66241
+ toMesh.decompose(new THREE.Vector3(), turn2, scale);
66242
+ const point = new THREE.Vector3();
66243
+ const out = [];
66244
+ for (const part of parts2) {
66245
+ const boxes = mergeSpans(part.spans);
66246
+ for (const s of line.open ? mergeSpans(carve(boxes, line.open), 0) : boxes) {
66247
+ const along2 = line.start + (s.a + s.b) / 2;
66248
+ point.set(line.alongU ? along2 : part.mid, (s.y0 + s.y1) / 2, line.alongU ? part.mid : along2).applyMatrix4(toMesh);
66249
+ const length2 = (s.b - s.a) / 2, up = (s.y1 - s.y0) / 2, across2 = part.thick / 2;
66250
+ out.push({
66251
+ center: [point.x, point.y, point.z],
66252
+ half: [(line.alongU ? length2 : across2) * scale.x, up * scale.y, (line.alongU ? across2 : length2) * scale.z],
66253
+ rotation: [turn2.x, turn2.y, turn2.z, turn2.w],
66254
+ kind: "box"
66255
+ });
66256
+ }
66257
+ }
66258
+ return out;
66259
+ }
66260
+ function publishSolids(mesh3, v0, v1, solids2) {
66261
+ const u = mesh3.userData;
66262
+ u.drawnSolids = [...(u.drawnSolids ?? []).filter((entry2) => entry2.v0 !== v0), { v0, v1, solids: solids2 }];
66263
+ u.drawnSolidsVersion = (u.drawnSolidsVersion ?? 0) + 1;
66264
+ }
66265
+ function withdrawSolids(mesh3, v0) {
66266
+ const u = mesh3.userData;
66267
+ if (!u.drawnSolids?.some((entry2) => entry2.v0 === v0)) return;
66268
+ u.drawnSolids = u.drawnSolids.filter((entry2) => entry2.v0 !== v0);
66269
+ u.drawnSolidsVersion = (u.drawnSolidsVersion ?? 0) + 1;
66270
+ }
65733
66271
  function collapseRange(mesh3, v0, v1) {
65734
66272
  const pos = mesh3.geometry.attributes.position;
65735
66273
  const a = pos.array;
@@ -65754,6 +66292,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
65754
66292
  markPositionsWritten(mesh3, v0, v0 + saved.length / 3);
65755
66293
  const list2 = mesh3.userData.collapsedRanges;
65756
66294
  if (list2) mesh3.userData.collapsedRanges = list2.filter((r) => r[0] !== v0);
66295
+ withdrawSolids(mesh3, v0);
65757
66296
  }
65758
66297
  function noise2(x, y, cell) {
65759
66298
  const h = (i2, j2) => {
@@ -66077,11 +66616,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
66077
66616
  }
66078
66617
  g.computeBoundingBox();
66079
66618
  g.computeBoundingSphere();
66080
- const base = it.mesh.material;
66081
- const material = base.clone();
66619
+ const base2 = it.mesh.material;
66620
+ const material = base2.clone();
66082
66621
  const toHouse = { value: new THREE.Matrix4() };
66083
66622
  material.onBeforeCompile = (sh) => {
66084
- base.onBeforeCompile?.(sh);
66623
+ base2.onBeforeCompile?.(sh);
66085
66624
  sh.uniforms.uToHouse = toHouse;
66086
66625
  sh.uniforms.uMask = { value: mask.texture };
66087
66626
  sh.uniforms.uMaskRect = { value: mask.rect };
@@ -66089,7 +66628,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
66089
66628
  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;");
66090
66629
  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;");
66091
66630
  };
66092
- material.customProgramCacheKey = () => "breachMask" + (base.customProgramCacheKey?.() ?? "");
66631
+ material.customProgramCacheKey = () => "breachMask" + (base2.customProgramCacheKey?.() ?? "");
66093
66632
  const mesh3 = new THREE.Mesh(g, material);
66094
66633
  mesh3.name = "breach-shell";
66095
66634
  mesh3.userData.breachMask = mask;
@@ -66204,6 +66743,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
66204
66743
  const around = { pillars: pillarSpans(view), gaps: windowGaps(view) };
66205
66744
  for (const id of view.parts) view.kept.set(id, splitUnits(view, id, around).kept);
66206
66745
  view.keptStale = false;
66746
+ publishStanding(view);
66747
+ }
66748
+ function publishStanding(view) {
66749
+ if (!view.saved) return;
66750
+ const { mask } = view;
66751
+ const parts2 = view.parts.map((id) => {
66752
+ const part = structure.byId.get(id);
66753
+ const thick = mask.alongU ? part.aabb[3] - part.aabb[1] : part.aabb[2] - part.aabb[0];
66754
+ const mid = mask.alongU ? (part.aabb[1] + part.aabb[3]) / 2 : (part.aabb[0] + part.aabb[2]) / 2;
66755
+ return { spans: view.kept.get(id) ?? [], thick, mid };
66756
+ });
66757
+ const line = { alongU: mask.alongU, start: mask.start, open: view.core };
66758
+ view.items.forEach((it, k) => publishSolids(it.mesh, it.v0, it.v1, k === 0 ? standingSolids(THREE, house, it.mesh, line, parts2) : []));
66207
66759
  }
66208
66760
  function paint2(view) {
66209
66761
  const { mask, core } = view;
@@ -66278,13 +66830,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
66278
66830
  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);
66279
66831
  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);
66280
66832
  };
66281
- const base = fragmentMaterial(part.material).color.getHex();
66833
+ const base2 = fragmentMaterial(part.material).color.getHex();
66282
66834
  const n = noise2(centre * 3.1, y * 2.7, 0.07);
66283
66835
  if (units2.mortar === "concrete") {
66284
- at4(len, h, thick - 2 * COVER2, tone(base, 0.9 + 0.04 * n));
66836
+ at4(len, h, thick - 2 * COVER2, tone(base2, 0.9 + 0.04 * n));
66285
66837
  } else {
66286
66838
  at4(len, h, thick - 2 * COVER2 - 0.012, 10327948);
66287
- at4(len - 0.012, h - 0.012, thick - 2 * COVER2, tone(base, 0.8 + 0.35 * n));
66839
+ at4(len - 0.012, h - 0.012, thick - 2 * COVER2, tone(base2, 0.8 + 0.35 * n));
66288
66840
  }
66289
66841
  }
66290
66842
  const lumps = stuckLumps(castGone, mask, view.bounds);
@@ -66308,6 +66860,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
66308
66860
  view.gone = holes.length;
66309
66861
  view.pits = pits.length;
66310
66862
  view.flakes = flakes.length;
66863
+ publishStanding(view);
66311
66864
  }
66312
66865
  function chipBox(chip, alongU) {
66313
66866
  house.updateWorldMatrix(true, false);
@@ -66419,6 +66972,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
66419
66972
  view.shells = view.items.map((it) => shell(it, view.mask));
66420
66973
  for (const m of view.shells) m.userData.behind = () => view.units;
66421
66974
  view.saved = view.items.map((it) => ({ it, v0: it.v0, data: collapseRange(it.mesh, it.v0, it.v1) }));
66975
+ refreshKept(view);
66422
66976
  }
66423
66977
  function draw2(partId, change) {
66424
66978
  if (lod !== 0) return false;
@@ -66469,6 +67023,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
66469
67023
  if (shown2) restoreRange(s.it.mesh, s.v0, s.data);
66470
67024
  else s.data = collapseRange(s.it.mesh, s.v0, s.it.v1);
66471
67025
  }
67026
+ if (!shown2) publishStanding(view);
66472
67027
  }
66473
67028
  function flush(budgetMs) {
66474
67029
  if (budgetMs !== void 0 || !cutState.attached) paintCut();
@@ -67435,9 +67990,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
67435
67990
  walk(house, void 0);
67436
67991
  return stages;
67437
67992
  }
67438
- function stageOfPiece(piece2, stages) {
67993
+ function stageOfPiece(piece22, stages) {
67439
67994
  let found;
67440
- piece2.root.traverse((o) => {
67995
+ piece22.root.traverse((o) => {
67441
67996
  if (found) return;
67442
67997
  const part = o.userData?.destructionPart;
67443
67998
  if (typeof part === "string") found = stages.get(part);
@@ -67446,20 +68001,20 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
67446
68001
  }
67447
68002
  function stageLoosePieces(pieces, stages, level, opts, held) {
67448
68003
  let hidden = 0;
67449
- for (const piece2 of pieces) {
67450
- const stage2 = stageOfPiece(piece2, stages);
68004
+ for (const piece22 of pieces) {
68005
+ const stage2 = stageOfPiece(piece22, stages);
67451
68006
  if (!stage2) continue;
67452
68007
  const shown2 = stageVisible(stage2, level, opts);
67453
- piece2.root.visible = shown2;
68008
+ piece22.root.visible = shown2;
67454
68009
  if (!shown2) {
67455
68010
  hidden++;
67456
- if (!piece2.held) {
67457
- piece2.held = true;
67458
- held.add(piece2);
68011
+ if (!piece22.held) {
68012
+ piece22.held = true;
68013
+ held.add(piece22);
67459
68014
  }
67460
- } else if (held.has(piece2)) {
67461
- piece2.held = false;
67462
- held.delete(piece2);
68015
+ } else if (held.has(piece22)) {
68016
+ piece22.held = false;
68017
+ held.delete(piece22);
67463
68018
  }
67464
68019
  }
67465
68020
  return hidden;
@@ -67841,7 +68396,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
67841
68396
  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 };
67842
68397
  }
67843
68398
  function installBuildBuild(K, shared3) {
67844
- 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;
68399
+ 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;
67845
68400
  function build(r0, options) {
67846
68401
  const opts = options || {};
67847
68402
  const r = withLaidConduits(applyOutbuildings(r0), !!(opts.constructionStages || opts.constructionLevel != null));
@@ -67988,6 +68543,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
67988
68543
  assembleInteractive(gs);
67989
68544
  linkDoorLeaves();
67990
68545
  mailboxInteractive();
68546
+ walkInInteractive();
67991
68547
  if (cs) {
67992
68548
  for (const def of shared3.inter.defs.values()) {
67993
68549
  if (def.outer && !def.outer.userData.constructionStage) def.outer.userData.constructionStage = /^gate/.test(def.kind) ? "perimeter" : "furniture";
@@ -68678,7 +69234,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
68678
69234
  joinBodies(params, byId);
68679
69235
  }
68680
69236
  function holdHanging({ parts: parts2, joints, boxOf: boxOf4 }, byId) {
68681
- const back = Math.min(...parts2.map((part) => boxOf4(part.id).min[2]));
69237
+ const back2 = Math.min(...parts2.map((part) => boxOf4(part.id).min[2]));
68682
69238
  for (let pass = 0; pass < parts2.length; pass++) {
68683
69239
  const groups = groupsOf(parts2, joints).map((ids) => ids.map((id) => byId.get(id)));
68684
69240
  const held = groups.filter((group) => group.some((part) => part.anchored)).flat();
@@ -68692,8 +69248,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
68692
69248
  changed = true;
68693
69249
  continue;
68694
69250
  }
68695
- const againstWall = held.length === 0 || held.some((part) => boxOf4(part.id).min[2] <= back + AGAINST_WALL);
68696
- const onWall = againstWall ? group.filter((part) => !SOFT.has(part.material) && boxOf4(part.id).min[2] <= back + BACK_TOUCH) : [];
69251
+ const againstWall = held.length === 0 || held.some((part) => boxOf4(part.id).min[2] <= back2 + AGAINST_WALL);
69252
+ const onWall = againstWall ? group.filter((part) => !SOFT.has(part.material) && boxOf4(part.id).min[2] <= back2 + BACK_TOUCH) : [];
68697
69253
  if (onWall.length === 0) continue;
68698
69254
  for (const part of onWall) part.anchored = true;
68699
69255
  changed = true;
@@ -68706,6 +69262,230 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
68706
69262
  return;
68707
69263
  }
68708
69264
  }
69265
+ var COVER22 = 6e-3;
69266
+ var SPRING = 3e-3;
69267
+ var SPRING_WIDTH = 0.012;
69268
+ var CLOTH_COVER = [{ material: "fabric", thickness: COVER22, faces: "all" }];
69269
+ function piece2(id, key2, material, min2, max2, color2) {
69270
+ const size = [max2[0] - min2[0], max2[1] - min2[1], max2[2] - min2[2]];
69271
+ const position = [(min2[0] + max2[0]) / 2, (min2[1] + max2[1]) / 2, (min2[2] + max2[2]) / 2];
69272
+ return { id, key: key2, material, shape: { kind: "box", size }, position, rotation: null, color: color2, min: min2, max: max2 };
69273
+ }
69274
+ var bothSides = (x0, x1) => [
69275
+ [x0, x1],
69276
+ [-x1, -x0]
69277
+ ];
69278
+ var SIDE_RAIL = 0.03;
69279
+ var SLAT_TOP = 0.297;
69280
+ var SLAT_THICK = 0.027;
69281
+ var SLAT_WIDTH = 0.07;
69282
+ var SLAT_PITCH = 0.12;
69283
+ var SPRING_STRIPS = 5;
69284
+ function bedParts(drawn) {
69285
+ const [frame2, ...otherWood] = drawn.filter((p) => p.key === "wood");
69286
+ const [mattress, ...bedclothes] = drawn.filter((p) => p.key === "fabric");
69287
+ if (!frame2 || !mattress) return [...drawn];
69288
+ const hw = (frame2.max[0] - frame2.min[0]) / 2;
69289
+ const [z0, z1] = [frame2.min[2], frame2.max[2]];
69290
+ const wood = frame2.color;
69291
+ const out = [...otherWood.map((p, k) => ({ ...p, id: k === 0 ? "bed_headboard" : "bed_footboard" }))];
69292
+ 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)));
69293
+ out.push(piece2("bed_centre_rail", "wood", "wood_soft", [-0.03, 0.2, z0], [0.03, SLAT_TOP - SLAT_THICK, z1], wood));
69294
+ const slats = Math.floor((z1 - z0 - 2 * 0.02 - SLAT_WIDTH) / SLAT_PITCH) + 1;
69295
+ for (let k = 0; k < slats; k++) {
69296
+ const z = z0 + 0.02 + k * SLAT_PITCH;
69297
+ 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));
69298
+ }
69299
+ const span = 2 * (hw - SIDE_RAIL);
69300
+ for (let k = 0; k < SPRING_STRIPS; k++) {
69301
+ const x = -hw + SIDE_RAIL + (k + 1) * span / (SPRING_STRIPS + 1);
69302
+ 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));
69303
+ }
69304
+ out.push({ ...mattress, id: "bed_mattress", material: "foam", layers: CLOTH_COVER });
69305
+ return [...out, ...bedclothes];
69306
+ }
69307
+ var RAIL_HEIGHT = 0.08;
69308
+ var POST = 0.05;
69309
+ var BOARD = 0.05;
69310
+ function base(L, c, seats, plinth) {
69311
+ const { hw, hd, armWidth: aT, postX: px } = L;
69312
+ const ix = hw - aT;
69313
+ const railTop = L.support - 6e-3;
69314
+ const railBottom = railTop - RAIL_HEIGHT;
69315
+ const zFrom = L.backFrame + BOARD;
69316
+ const zTo = L.coverFront - L.railDepth;
69317
+ const out = [];
69318
+ const wood = (id, min2, max2, material = "wood_hard") => out.push(piece2(id, "wood", material, min2, max2, c.wood));
69319
+ if (plinth) {
69320
+ wood("seat_plinth_front", [-hw, 0, hd - 0.06], [hw, L.postFloor, hd]);
69321
+ wood("seat_plinth_back", [-hw, 0, L.rear], [hw, L.postFloor, L.rear + 0.04]);
69322
+ 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]);
69323
+ }
69324
+ const upright = (id, x, z, top) => wood(id, [x - POST / 2, L.postFloor, z - POST / 2], [x + POST / 2, top, z + POST / 2]);
69325
+ for (const [k, sx] of [-1, 1].entries()) {
69326
+ upright(`seat_post_front_${k}`, sx * px, L.postFront, railTop);
69327
+ upright(`seat_post_back_${k}`, sx * px, L.postBack, L.stiles === "posts" ? L.armTop - 0.03 : railTop);
69328
+ }
69329
+ wood("seat_rail_front", [-(px - POST / 2), railBottom, zTo], [px - POST / 2, railTop, L.coverFront]);
69330
+ wood("seat_rail_back", [-(px - POST / 2), railBottom, L.backFrame], [px - POST / 2, railTop, zFrom]);
69331
+ 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]);
69332
+ 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]);
69333
+ for (const [k, seat2] of seats.entries()) {
69334
+ for (const [j, dx] of [-0.12, 0.12].entries()) {
69335
+ const x = seat2.x + dx;
69336
+ 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));
69337
+ }
69338
+ }
69339
+ out.push(piece2("seat_cover_front", "fabric", "fabric", [-ix, L.skirt, L.coverFront], [ix, L.support, L.coverFront + COVER22], c.skirt));
69340
+ 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));
69341
+ return out;
69342
+ }
69343
+ function back(L, c) {
69344
+ const { hw, armWidth: aT } = L;
69345
+ const ix = hw - aT;
69346
+ const railTop = L.support - 6e-3;
69347
+ const top = L.backTop - COVER22;
69348
+ const zFrame = [L.backFrame, L.backFrame + BOARD];
69349
+ const out = [];
69350
+ if (L.stiles === "rail") {
69351
+ 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));
69352
+ out.push(piece2("back_top_rail", "wood", "wood_hard", [-(ix - POST), top - BOARD, zFrame[0]], [ix - POST, top, zFrame[1]], c.wood));
69353
+ }
69354
+ const midX = L.stiles === "rail" ? ix - POST : L.postX - POST / 2;
69355
+ out.push(piece2("back_mid_rail", "wood", "wood_hard", [-midX, 0.5, zFrame[0]], [midX, 0.5 + POST, zFrame[1]], c.wood));
69356
+ 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));
69357
+ out.push(piece2("back_pad", "fabric", "foam", [-ix, L.support, zFrame[1]], [ix, top, L.rear + L.backDepth], c.back));
69358
+ out.push(piece2("back_cover_rear", "fabric", "fabric", [-L.rearHalf, L.skirt, L.rear], [L.rearHalf, L.backTop, L.rear + COVER22], c.skirt));
69359
+ out.push(piece2("back_cover_top", "fabric", "fabric", [-L.rearHalf, top, L.rear + COVER22], [L.rearHalf, L.backTop, L.rear + L.backDepth], c.back));
69360
+ if (L.rearHalf > ix) {
69361
+ 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));
69362
+ }
69363
+ return out;
69364
+ }
69365
+ function arms(L, c, boardBack) {
69366
+ const { hw, armWidth: aT, postX: px } = L;
69367
+ const railTop = L.support - 6e-3;
69368
+ const padTop = L.armTop - 0.03;
69369
+ const front = L.armFront;
69370
+ const out = [];
69371
+ 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)];
69372
+ const [board2, outer, inner, top, coverOuter, coverInner] = sides;
69373
+ for (const k of [0, 1]) {
69374
+ const z0 = L.armBack;
69375
+ out.push(piece2(`arm_board_${k}`, "wood", "wood_hard", [board2[k][0], railTop, boardBack], [board2[k][1], padTop, L.postFront + POST / 2], c.wood));
69376
+ out.push(piece2(`arm_pad_outer_${k}`, "fabric", "foam", [outer[k][0], railTop, z0], [outer[k][1], padTop, front - COVER22], c.arm));
69377
+ out.push(piece2(`arm_pad_inner_${k}`, "fabric", "foam", [inner[k][0], railTop, z0], [inner[k][1], padTop, front - COVER22], c.arm));
69378
+ out.push(piece2(`arm_pad_top_${k}`, "fabric", "foam", [top[k][0], padTop, z0], [top[k][1], L.armTop - COVER22, front - COVER22], c.arm));
69379
+ out.push(piece2(`arm_cover_outer_${k}`, "fabric", "fabric", [coverOuter[k][0], L.armBottom, z0], [coverOuter[k][1], L.armTop, front], c.arm));
69380
+ out.push(piece2(`arm_cover_inner_${k}`, "fabric", "fabric", [coverInner[k][0], L.armBottom, z0], [coverInner[k][1], L.armTop, front], c.arm));
69381
+ 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));
69382
+ 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));
69383
+ 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));
69384
+ }
69385
+ return out;
69386
+ }
69387
+ function seatStructure(L, c, seats, options) {
69388
+ return [...base(L, c, seats, options.plinth), ...back(L, c), ...arms(L, c, options.boardBack)];
69389
+ }
69390
+ function cushion(block, id) {
69391
+ return { ...block, id, material: "foam", layers: CLOTH_COVER };
69392
+ }
69393
+ var SOFAS = /^sofa_/;
69394
+ var ARMCHAIRS = /^armchair/;
69395
+ var BEDS = /^(double_bed|queen_bed|king_bed|single_bed|mattress)$/;
69396
+ var seatsOf = (cushions) => cushions.map((block, k) => ({ x: block.position[0], ...cushions[k + 1] ? { seam: (block.position[0] + cushions[k + 1].position[0]) / 2 } : {} }));
69397
+ function sofaParts(drawn) {
69398
+ const woods = drawn.filter((p) => p.key === "wood");
69399
+ const cloth2 = drawn.filter((p) => p.key === "fabric");
69400
+ const count = (cloth2.length - 5) / 2;
69401
+ const [skirt, ...rest2] = cloth2;
69402
+ const seatCushions = rest2.slice(0, count);
69403
+ const [back2] = rest2.slice(count, count + 1);
69404
+ const backCushions = rest2.slice(count + 1, 2 * count + 1);
69405
+ const [armLeft, , pillow] = rest2.slice(2 * count + 1);
69406
+ const feet = woods.slice(1);
69407
+ if (!skirt || !back2 || !armLeft || !pillow || feet.length !== 4) return [...drawn];
69408
+ const hd = (armLeft.max[2] - armLeft.min[2]) / 2 + 0.02;
69409
+ const hw = (woods[0].max[0] - woods[0].min[0]) / 2;
69410
+ const frontFoot = Math.max(...feet.map((foot) => foot.position[2]));
69411
+ const backFoot = Math.min(...feet.map((foot) => foot.position[2]));
69412
+ const layout = {
69413
+ hw,
69414
+ hd,
69415
+ rear: -hd,
69416
+ armWidth: armLeft.max[0] - armLeft.min[0],
69417
+ armTop: armLeft.max[1],
69418
+ armBottom: armLeft.min[1],
69419
+ backTop: back2.max[1],
69420
+ backDepth: back2.max[2] - back2.min[2],
69421
+ skirt: skirt.min[1],
69422
+ support: skirt.max[1],
69423
+ postX: Math.abs(feet[0].position[0]),
69424
+ postFront: frontFoot,
69425
+ postBack: backFoot,
69426
+ postFloor: 0,
69427
+ coverFront: skirt.max[2] - COVER22,
69428
+ railDepth: 0.07,
69429
+ springEnd: skirt.max[2] - 0.05,
69430
+ backFrame: backFoot - 0.025,
69431
+ armBack: armLeft.min[2],
69432
+ armFront: armLeft.max[2],
69433
+ rearHalf: hw - (armLeft.max[0] - armLeft.min[0]),
69434
+ stiles: "rail"
69435
+ };
69436
+ const colours = { wood: feet[0].color, skirt: skirt.color, back: back2.color, arm: armLeft.color };
69437
+ const structure = seatStructure(layout, colours, seatsOf(seatCushions), { plinth: false, boardBack: layout.backFrame });
69438
+ const cushions = [...seatCushions.map((block, k) => cushion(block, `seat_cushion_${k}`)), ...backCushions.map((block, k) => cushion(block, `back_cushion_${k}`)), cushion(pillow, "accent_pillow")];
69439
+ return [...structure, ...cushions];
69440
+ }
69441
+ var ARMCHAIR_SUPPORT = 0.28;
69442
+ function armchairParts(drawn) {
69443
+ const plinth = drawn.find((p) => p.key === "wood");
69444
+ const [seat2, back2, armLeft] = drawn.filter((p) => p.key === "fabric");
69445
+ if (!plinth || !seat2 || !back2 || !armLeft) return [...drawn];
69446
+ const [hw, hd] = [(plinth.max[0] - plinth.min[0]) / 2, (plinth.max[2] - plinth.min[2]) / 2];
69447
+ const armWidth = armLeft.max[0] - armLeft.min[0];
69448
+ const rear = back2.min[2];
69449
+ const backFrame = rear + COVER22;
69450
+ const coverFront = hd - 0.04;
69451
+ const layout = {
69452
+ hw,
69453
+ hd,
69454
+ rear,
69455
+ armWidth,
69456
+ armTop: armLeft.max[1],
69457
+ armBottom: armLeft.min[1],
69458
+ backTop: back2.max[1],
69459
+ backDepth: back2.max[2] - rear,
69460
+ skirt: plinth.max[1],
69461
+ support: ARMCHAIR_SUPPORT,
69462
+ postX: hw - 0.07,
69463
+ postFront: hd - 0.065,
69464
+ postBack: backFrame + 0.025,
69465
+ postFloor: plinth.max[1],
69466
+ coverFront,
69467
+ railDepth: 0.05,
69468
+ springEnd: coverFront - 0.02,
69469
+ backFrame,
69470
+ armBack: backFrame,
69471
+ armFront: armLeft.max[2],
69472
+ rearHalf: (back2.max[0] - back2.min[0]) / 2,
69473
+ stiles: "posts"
69474
+ };
69475
+ const colours = { wood: plinth.color, skirt: seat2.color, back: back2.color, arm: armLeft.color };
69476
+ const structure = seatStructure(layout, colours, [{ x: 0 }], { plinth: true, boardBack: backFrame + 0.05 });
69477
+ const ix = hw - armWidth;
69478
+ 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]] };
69479
+ const size = [seatCushion.max[0] - seatCushion.min[0], seatCushion.max[1] - seatCushion.min[1], seatCushion.max[2] - seatCushion.min[2]];
69480
+ const position = [0, (seatCushion.min[1] + seatCushion.max[1]) / 2, (seatCushion.min[2] + seatCushion.max[2]) / 2];
69481
+ return [...structure, cushion({ ...seatCushion, shape: { kind: "box", size }, position }, "seat_cushion_0")];
69482
+ }
69483
+ function upholster(drawn, type) {
69484
+ const made2 = SOFAS.test(type) ? sofaParts(drawn) : ARMCHAIRS.test(type) ? armchairParts(drawn) : BEDS.test(type) ? bedParts(drawn) : void 0;
69485
+ if (!made2) return false;
69486
+ drawn.splice(0, drawn.length, ...made2);
69487
+ return true;
69488
+ }
68709
69489
  var WOOD_THIN = 0.035;
68710
69490
  var BOARD_TOP_THICK = 0.07;
68711
69491
  var BOARD_TOP_WIDTH = 0.5;
@@ -68932,6 +69712,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
68932
69712
  run(A);
68933
69713
  if (!drawn.length) throw new Error(`game-floorplan-three: the builder of "${name}" drew no box or cylinder`);
68934
69714
  hollowCases(drawn, name);
69715
+ upholster(drawn, name);
68935
69716
  const boardsOf = splitTopsIntoBoards(drawn, materialOf2, Boolean(opts.carcass));
68936
69717
  const parts2 = drawn.map((p) => {
68937
69718
  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]);
@@ -68944,6 +69725,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
68944
69725
  const fill22 = structureFill(material, p.shape);
68945
69726
  if (fill22 < 1) part.fill = Math.round(fill22 * 1e4) / 1e4;
68946
69727
  if (p.rotation) part.rotation = p.rotation;
69728
+ if (p.layers) part.layers = p.layers;
68947
69729
  if (!LOOSE.has(material) && p.min[1] <= FLOOR_TOUCH2) part.anchored = true;
68948
69730
  if (opts.carcass && LOOSE.has(material)) {
68949
69731
  part.hands = 1;
@@ -68981,7 +69763,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
68981
69763
  let top = null;
68982
69764
  for (const p of drawn) {
68983
69765
  const part = parts2.find((x) => x.id === p.id);
68984
- if (part.shape.kind === "sphere" || part.rotation || part.material === "fabric" || LOOSE.has(part.material)) continue;
69766
+ if (part.shape.kind === "sphere" || part.rotation || part.material === "fabric" || part.material === "foam" || LOOSE.has(part.material)) continue;
68985
69767
  const area3 = (p.max[0] - p.min[0]) * (p.max[2] - p.min[2]);
68986
69768
  if (area3 < 0.6 * footprint || p.max[1] < 0.2) continue;
68987
69769
  if (!top || p.max[1] > top.y + 1e-6) top = { part: p.id, y: p.max[1] };
@@ -73841,31 +74623,31 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
73841
74623
  const handguardHeight = frames.receiverHeight * 0.8;
73842
74624
  const railTopY = frames.receiverHeight / 2 + (frames.hasRail ? 6e-3 : 0);
73843
74625
  const forendMiddle = (frames.receiverEnd + frames.handguardEnd) / 2;
73844
- const base = { mount, barrelRadius: frames.barrelRadius, receiverWidth: frames.receiverWidth, receiverHeight: frames.receiverHeight, hasRail: frames.hasRail };
74626
+ const base2 = { mount, barrelRadius: frames.barrelRadius, receiverWidth: frames.receiverWidth, receiverHeight: frames.receiverHeight, hasRail: frames.hasRail };
73845
74627
  switch (mount) {
73846
74628
  case "muzzle":
73847
- return { ...base, position: toRoot(frames.length, frames.barrelY, 0), side: 0 };
74629
+ return { ...base2, position: toRoot(frames.length, frames.barrelY, 0), side: 0 };
73848
74630
  case "rail_top":
73849
- return { ...base, position: toRoot((frames.receiverStart + frames.receiverEnd) / 2 + 0.03, railTopY, 0), side: 0 };
74631
+ return { ...base2, position: toRoot((frames.receiverStart + frames.receiverEnd) / 2 + 0.03, railTopY, 0), side: 0 };
73850
74632
  case "rail_bottom":
73851
- return { ...base, position: toRoot(forendMiddle, frames.barrelY - handguardHeight / 2, 0), side: 0 };
74633
+ return { ...base2, position: toRoot(forendMiddle, frames.barrelY - handguardHeight / 2, 0), side: 0 };
73852
74634
  case "rail_left":
73853
- return { ...base, position: toRoot(forendMiddle, frames.barrelY, -(frames.receiverWidth * 0.54 + 4e-3)), side: -1 };
74635
+ return { ...base2, position: toRoot(forendMiddle, frames.barrelY, -(frames.receiverWidth * 0.54 + 4e-3)), side: -1 };
73854
74636
  case "rail_right":
73855
- return { ...base, position: toRoot(forendMiddle, frames.barrelY, frames.receiverWidth * 0.54 + 4e-3), side: 1 };
74637
+ return { ...base2, position: toRoot(forendMiddle, frames.barrelY, frames.receiverWidth * 0.54 + 4e-3), side: 1 };
73856
74638
  case "underbarrel": {
73857
74639
  const [x, y] = frames.underbarrel ?? [frames.receiverEnd + (frames.handguardEnd - frames.receiverEnd) * 0.25, frames.barrelY - handguardHeight / 2 - 0.02];
73858
- return { ...base, position: toRoot(x, y, 0), side: 0 };
74640
+ return { ...base2, position: toRoot(x, y, 0), side: 0 };
73859
74641
  }
73860
74642
  case "magazine":
73861
- return { ...base, position: toRoot(frames.magazineX, -frames.receiverHeight / 2, 0), side: 0 };
74643
+ return { ...base2, position: toRoot(frames.magazineX, -frames.receiverHeight / 2, 0), side: 0 };
73862
74644
  case "feed": {
73863
74645
  const belt = model.parts.belt?.position;
73864
- 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 };
74646
+ 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 };
73865
74647
  }
73866
74648
  case "sling":
73867
74649
  return {
73868
- ...base,
74650
+ ...base2,
73869
74651
  position: toRoot(frames.receiverEnd + (frames.length - frames.receiverEnd) * 0.45, -frames.receiverHeight / 2 - 0.03, 0),
73870
74652
  secondary: toRoot(0.08, -0.09, 0),
73871
74653
  side: 0
@@ -75947,13 +76729,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
75947
76729
  ];
75948
76730
  }
75949
76731
  function showcasePedestalItem(name) {
75950
- const piece2 = (THREE) => furnitureSpec(THREE, PEDESTAL_FURNITURE, { w: SHOWCASE.size, d: SHOWCASE.size, h: SHOWCASE.height });
76732
+ const piece3 = (THREE) => furnitureSpec(THREE, PEDESTAL_FURNITURE, { w: SHOWCASE.size, d: SHOWCASE.size, h: SHOWCASE.height });
75951
76733
  return {
75952
76734
  id: SHOWCASE_PEDESTAL_ID,
75953
76735
  name,
75954
76736
  build: (lent) => {
75955
76737
  const THREE = lent;
75956
- const built2 = piece2(THREE);
76738
+ const built2 = piece3(THREE);
75957
76739
  const root = built2.build(THREE);
75958
76740
  root.userData.pedestalSpec = { ...built2.spec, name, tags: [...built2.spec.tags ?? [], "furniture"] };
75959
76741
  return root;
@@ -76057,15 +76839,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
76057
76839
  const samples = [];
76058
76840
  const tiersOf = /* @__PURE__ */ new Map();
76059
76841
  for (const sound3 of manifest.sounds) {
76060
- const { base, tier } = splitTier(sound3.id);
76061
- if (tier) tiersOf.set(base, [...tiersOf.get(base) ?? [], sound3]);
76842
+ const { base: base2, tier } = splitTier(sound3.id);
76843
+ if (tier) tiersOf.set(base2, [...tiersOf.get(base2) ?? [], sound3]);
76062
76844
  }
76063
76845
  const bases = /* @__PURE__ */ new Map();
76064
76846
  for (const sound3 of manifest.sounds) {
76065
76847
  if (!splitTier(sound3.id).tier) bases.set(sound3.id, sound3);
76066
76848
  }
76067
- for (const [base, tiers] of tiersOf) {
76068
- if (!bases.has(base)) bases.set(base, { id: base, category: tiers[0]?.category ?? "", layers: { close: tiers[0]?.layers.close ?? [] } });
76849
+ for (const [base2, tiers] of tiersOf) {
76850
+ if (!bases.has(base2)) bases.set(base2, { id: base2, category: tiers[0]?.category ?? "", layers: { close: tiers[0]?.layers.close ?? [] } });
76069
76851
  }
76070
76852
  for (const sound3 of bases.values()) {
76071
76853
  const numbers = options.sounds?.[sound3.id] ?? options.defaults?.(sound3);
@@ -76403,8 +77185,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
76403
77185
  function isPlainObject2(value) {
76404
77186
  return typeof value === "object" && value !== null && !Array.isArray(value);
76405
77187
  }
76406
- function mergeRecords(base, patch) {
76407
- const merged2 = { ...base };
77188
+ function mergeRecords(base2, patch) {
77189
+ const merged2 = { ...base2 };
76408
77190
  for (const [key2, value] of Object.entries(patch)) {
76409
77191
  if (value === void 0) continue;
76410
77192
  const current = merged2[key2];
@@ -76722,7 +77504,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
76722
77504
  const falloffLevel = falloffGain(recipe2.falloff, input.volume ?? 1, distance22);
76723
77505
  const level = occlusion > 0 ? falloffLevel * (1 - OCCLUSION_GAIN * occlusion) : falloffLevel;
76724
77506
  const silent = isSilent(recipe2.falloff, falloffLevel);
76725
- const base = {
77507
+ const base2 = {
76726
77508
  id: recipe2.id,
76727
77509
  bus: recipe2.bus,
76728
77510
  order: order2,
@@ -76732,7 +77514,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
76732
77514
  distance: distance22,
76733
77515
  ...recipe2.pan ? { pan: input.position ? panFor(listener, input.position) : 0 } : {}
76734
77516
  };
76735
- if (silent) return recipe2.keepSilent ? { ...base, silent: true, length: 0, layers: [] } : null;
77517
+ if (silent) return recipe2.keepSilent ? { ...base2, silent: true, length: 0, layers: [] } : null;
76736
77518
  const scope2 = { random: input.random ?? createRng3(1), params: { ...input.params } };
76737
77519
  for (const [name, range3] of Object.entries(recipe2.vars ?? {})) if (scope2.params[name] === void 0) scope2.params[name] = draw(range3, scope2);
76738
77520
  const defaults = {
@@ -76742,7 +77524,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
76742
77524
  };
76743
77525
  const divisor = cutoffDivisor(recipe2.falloff, distance22) / (1 - OCCLUSION_CUTOFF * occlusion);
76744
77526
  const layers = recipe2.layers.flatMap((layer3) => planLayer(layer3, scope2, defaults, order2 !== "layered", level)).map((layer3) => muffle(layer3, divisor));
76745
- return { ...base, silent: false, length: Math.max(0, ...layers.map(layerEnd)), layers };
77527
+ return { ...base2, silent: false, length: Math.max(0, ...layers.map(layerEnd)), layers };
76746
77528
  }
76747
77529
  function fillNoise(random, length2) {
76748
77530
  const samples = new Float32Array(length2);
@@ -80451,7 +81233,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
80451
81233
  var CRACK_CUTOFF = 3e3;
80452
81234
  var CRACK_SECONDS = 0.03;
80453
81235
  var BODY_TO_FREQUENCY = 40;
80454
- var linear = ([base, span], k) => base + span * k;
81236
+ var linear = ([base2, span], k) => base2 + span * k;
80455
81237
  var energyPosition = (energyJ, curve) => Math.min(1, Math.max(0, Math.log10(Math.max(energyJ, curve.floorJ) / curve.floorJ) / curve.spanDecades));
80456
81238
  var energyOfShot = (input) => {
80457
81239
  if (input.energyJ !== void 0) return input.energyJ;
@@ -82214,8 +82996,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
82214
82996
  var isGunshot = (id) => GUNSHOT_SAMPLE_IDS.includes(id);
82215
82997
  function weaponSampleDefaults(sound3, overrides = {}) {
82216
82998
  if (sound3.category !== "armas") return void 0;
82217
- 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;
82218
- return { ...base, ...overrides[sound3.id] };
82999
+ 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;
83000
+ return { ...base2, ...overrides[sound3.id] };
82219
83001
  }
82220
83002
  function weaponSampleBank(options) {
82221
83003
  const bank = sampleBankFromManifest(options.manifest, { id: "weapons_three_samples", ...options.url ? {} : { baseUrl: options.baseUrl ?? "" }, defaults: (sound3) => weaponSampleDefaults(sound3, options.sounds) });
@@ -82345,12 +83127,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
82345
83127
  return {
82346
83128
  shot(energyJ, category, extras = {}) {
82347
83129
  if (options.shotModel !== "game") {
82348
- const base = { energyJ, category, ...extras, space: extras.space ?? (extras.indoors ? "indoor" : "outdoor") };
82349
- const profile = computeGunshot(base, options.gunshot).profile;
83130
+ const base2 = { energyJ, category, ...extras, space: extras.space ?? (extras.indoors ? "indoor" : "outdoor") };
83131
+ const profile = computeGunshot(base2, options.gunshot).profile;
82350
83132
  const take = pickTake2(lastTake.get(profile), channel.random);
82351
83133
  lastTake.set(profile, take);
82352
83134
  const pitch = 1 + (channel.random() * 2 - 1) * pitchSpread;
82353
- const shot = computeGunshot({ ...base, take, pitch }, options.gunshot);
83135
+ const shot = computeGunshot({ ...base2, take, pitch }, options.gunshot);
82354
83136
  const recorded = shot.samples.close;
82355
83137
  const sample = shot.audible && sampleReady(recorded);
82356
83138
  const fitted = shot.audible && !sample && fittedReady(recorded);
@@ -82358,20 +83140,20 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
82358
83140
  const occlusion = Math.min(1, Math.max(0, extras.occlusion ?? 0));
82359
83141
  const handle = channel.play(recorded, {
82360
83142
  volume: (extras.volume ?? 1) * (1 - 0.5 * occlusion),
82361
- environment: base.space === "indoor" ? "indoor" : "outdoor",
83143
+ environment: base2.space === "indoor" ? "indoor" : "outdoor",
82362
83144
  ...extras.position ? { position: [extras.position[0], extras.position[1], extras.position[2]] } : {},
82363
83145
  ...extras.distance === void 0 ? {} : { distance: extras.distance },
82364
83146
  ...shot.delay > 0 ? { delay: shot.delay } : {}
82365
83147
  });
82366
- if (base.space === "indoor") {
83148
+ if (base2.space === "indoor") {
82367
83149
  for (const voice2 of shot.voices) if (voice2.group === "tail") playGunshotVoice(voice2, extras);
82368
83150
  }
82369
83151
  const layers = handle?.kind === "sample" ? handle.plan.layers.map((layer3) => ({ role: layer3.role, take: layer3.take, rate: layer3.rate })) : [];
82370
- options.onGunshot?.(shot, { ...base, take, pitch }, fitted ? { kind: "fitted", id: recorded } : { kind: "sample", id: recorded, layers });
83152
+ options.onGunshot?.(shot, { ...base2, take, pitch }, fitted ? { kind: "fitted", id: recorded } : { kind: "sample", id: recorded, layers });
82371
83153
  return;
82372
83154
  }
82373
83155
  for (const voice2 of shot.voices) playGunshotVoice(voice2, extras);
82374
- if (shot.audible) options.onGunshot?.(shot, { ...base, take, pitch }, { kind: "synth" });
83156
+ if (shot.audible) options.onGunshot?.(shot, { ...base2, take, pitch }, { kind: "synth" });
82375
83157
  return;
82376
83158
  }
82377
83159
  const sound3 = shotSound({ ...extras, energyJ, category });
@@ -83480,8 +84262,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
83480
84262
  const materials = [];
83481
84263
  const M = (color2, tag, options = {}) => {
83482
84264
  const material = new T2.MeshStandardMaterial(Object.assign({ color: color2, roughness: 0.78, metalness: 0 }, options));
83483
- const base = new T2.Color(color2);
83484
- const data = { base, baseRgb: channelsOf(color2), tag, rough: material.roughness };
84265
+ const base2 = new T2.Color(color2);
84266
+ const data = { base: base2, baseRgb: channelsOf(color2), tag, rough: material.roughness };
83485
84267
  material.userData = data;
83486
84268
  materials.push(material);
83487
84269
  return material;
@@ -87082,11 +87864,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
87082
87864
  const steel = metal2(6251625);
87083
87865
  const dark = metal2(4080199);
87084
87866
  const arm = (x, y, angle, z) => mesh3(bx(12.65, 1.2, 1.6), steel, [x, y, z], [0, 0, angle]);
87085
- 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)]);
87867
+ 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)]);
87086
87868
  return G(
87087
87869
  mesh3(bx(8, 1, 11), dark, [0, -5, 0]),
87088
87870
  mesh3(bx(8, 1, 11), dark, [0, 5, 0]),
87089
- ...arms,
87871
+ ...arms2,
87090
87872
  mesh3(cyl(0.6, 0.6, 30, 8), metal2(9277846), [0, 0, 0], [0, 0, Math.PI / 2]),
87091
87873
  mesh3(bx(1.6, 2.4, 3), dark, [-11.8, 0, 0]),
87092
87874
  mesh3(bx(1.6, 2.4, 3), dark, [11.8, 0, 0]),
@@ -87298,12 +88080,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
87298
88080
  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)]];
87299
88081
  const frame2 = wood(7031340);
87300
88082
  const band = cloth2(2039583);
87301
- const arms = [-1, 1].map((side) => rod(0, -0.15, side * 0.5675, 0.7, 0.1));
88083
+ const arms2 = [-1, 1].map((side) => rod(0, -0.15, side * 0.5675, 0.7, 0.1));
87302
88084
  const bands = [-1, 1].map((side) => rod(side * 0.5675, 0.7, side * 0.12, 0.25, 0.03));
87303
88085
  return G(
87304
88086
  mesh3(cyl(0.12, 0.1, 0.65, 8), frame2, [0, -0.425, 0]),
87305
88087
  mesh3(cyl(0.126, 0.126, 0.3, 8), cloth2(8007455), [0, -0.5, 0]),
87306
- ...arms.map(([geometry, position, rotation2]) => mesh3(geometry, frame2, [...position], [...rotation2])),
88088
+ ...arms2.map(([geometry, position, rotation2]) => mesh3(geometry, frame2, [...position], [...rotation2])),
87307
88089
  ...bands.map(([geometry, position, rotation2]) => mesh3(geometry, band, [...position], [...rotation2])),
87308
88090
  mesh3(bx(0.26, 0.2, 0.05), cloth2(9067061), [0, 0.2, 0])
87309
88091
  );
@@ -87503,10 +88285,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
87503
88285
  const R = Math.PI / 2;
87504
88286
  const pane = glass(12575711, 0.55);
87505
88287
  const deep = glass(8369584, 0.7);
87506
- const base = extrude2([[-0.6, -0.1], [0.45, -0.5], [0.6, 0.2], [-0.1, 0.5]], 0.04, 2e-3);
88288
+ const base2 = extrude2([[-0.6, -0.1], [0.45, -0.5], [0.6, 0.2], [-0.1, 0.5]], 0.04, 2e-3);
87507
88289
  const chip = extrude2([[0, 0], [0.25, 0.05], [0.1, 0.22]], 0.03, 2e-3);
87508
88290
  return G(
87509
- mesh3(base, pane, [0, 0, 0], [R, 0, 0]),
88291
+ mesh3(base2, pane, [0, 0, 0], [R, 0, 0]),
87510
88292
  mesh3(chip, deep, [0.2, 0.03, -0.35], [R, 0, 0.4]),
87511
88293
  mesh3(new T2.ConeGeometry(0.14, 0.46, 3), pane, [-0.2, 0.23, 0.1], [0, 0.3, 0.12]),
87512
88294
  mesh3(new T2.ConeGeometry(0.1, 0.34, 3), deep, [0.25, 0.17, -0.1], [0.15, 0, -0.2]),
@@ -87707,10 +88489,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
87707
88489
  );
87708
88490
  };
87709
88491
  var rag = ({ mesh: mesh3, bx, G, cloth: cloth2 }) => {
87710
- const base = cloth2(11028282);
88492
+ const base2 = cloth2(11028282);
87711
88493
  const fringe = cloth2(12877167);
87712
88494
  return G(
87713
- mesh3(bx(2, 0.1, 1.8), base, [0, -0.076, 0]),
88495
+ mesh3(bx(2, 0.1, 1.8), base2, [0, -0.076, 0]),
87714
88496
  mesh3(bx(1.7, 0.09, 1.5), cloth2(10108723), [0.1, 0.02, 0], [0, 0.1, 0]),
87715
88497
  mesh3(bx(1.5, 0.036, 1.2), cloth2(11818826), [0, 0.083, 0]),
87716
88498
  mesh3(bx(0.2, 0.02, 1.7), fringe, [1, -0.076, 0]),
@@ -87794,13 +88576,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
87794
88576
  );
87795
88577
  };
87796
88578
  var armyCamouflageUniform = ({ mesh: mesh3, bx, G, cloth: cloth2 }) => {
87797
- const base = cloth2(5857855);
88579
+ const base2 = cloth2(5857855);
87798
88580
  const dark = cloth2(3554600);
87799
88581
  const tan = cloth2(9076565);
87800
88582
  return G(
87801
- mesh3(bx(0.24, 0.08, 0.32), base, [0, 0.04, 0]),
87802
- mesh3(bx(0.08, 0.07, 0.2), base, [-0.16, 0.035, -0.06]),
87803
- mesh3(bx(0.08, 0.07, 0.2), base, [0.16, 0.035, -0.06]),
88583
+ mesh3(bx(0.24, 0.08, 0.32), base2, [0, 0.04, 0]),
88584
+ mesh3(bx(0.08, 0.07, 0.2), base2, [-0.16, 0.035, -0.06]),
88585
+ mesh3(bx(0.08, 0.07, 0.2), base2, [0.16, 0.035, -0.06]),
87804
88586
  mesh3(bx(0.08, 0.074, 0.024), dark, [-0.16, 0.037, 0.052]),
87805
88587
  mesh3(bx(0.08, 0.074, 0.024), dark, [0.16, 0.037, 0.052]),
87806
88588
  mesh3(bx(0.08, 0.01, 0.045), dark, [-0.04, 0.09, -0.135]),
@@ -90192,10 +90974,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
90192
90974
  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)]);
90193
90975
  function launcherClips(context) {
90194
90976
  if (!context.parts.ugl) return [];
90195
- const { open, loaded, close, end: end3, slide: slide2, back } = LAUNCHER_RELOAD;
90977
+ const { open, loaded, close, end: end3, slide: slide2, back: back2 } = LAUNCHER_RELOAD;
90196
90978
  const reload = composeClip(
90197
90979
  "reload_ugl",
90198
- [move("ugl", "x", open, slide2, 0, LAUNCHER_SLIDE), move("ugl", "x", close, back, LAUNCHER_SLIDE, 0)],
90980
+ [move("ugl", "x", open, slide2, 0, LAUNCHER_SLIDE), move("ugl", "x", close, back2, LAUNCHER_SLIDE, 0)],
90199
90981
  [stage("breech_open", open), stage("round_in", loaded), stage("breech_close", close)],
90200
90982
  end3
90201
90983
  );
@@ -90489,7 +91271,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
90489
91271
  if (!BLOWBACK.has(family) || !parts2[part]) return [misfire];
90490
91272
  const travel = strokeOf(parts2);
90491
91273
  const stopped = Object.entries(FAULT_SLIDE_BACK).map(
90492
- ([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)
91274
+ ([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)
90493
91275
  );
90494
91276
  return [misfire, ...stopped];
90495
91277
  }
@@ -90744,7 +91526,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
90744
91526
  const group = kit.group();
90745
91527
  const spare = kit.group();
90746
91528
  spare.position.set(0, 0, 0.032);
90747
- for (const piece2 of factoryMagazine) spare.add(piece2.clone(true));
91529
+ for (const piece3 of factoryMagazine) spare.add(piece3.clone(true));
90748
91530
  group.add(spare);
90749
91531
  box5(group, 0.05, 0.012, 0.04, M.tape, 0, -0.03, 0.016);
90750
91532
  return { object: group, hangsFrom: "magazine" };
@@ -90882,12 +91664,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
90882
91664
  kit.roundness = null;
90883
91665
  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);
90884
91666
  };
90885
- var triggerGuard = (kit, fixed2, back, front, bottom) => {
91667
+ var triggerGuard = (kit, fixed2, back2, front, bottom) => {
90886
91668
  const { M, box: box5 } = kit;
90887
91669
  const drop = 0.03;
90888
- box5(fixed2, front - back, 5e-3, 0.01, M.dark, (back + front) / 2, bottom - drop, 0);
91670
+ box5(fixed2, front - back2, 5e-3, 0.01, M.dark, (back2 + front) / 2, bottom - drop, 0);
90889
91671
  box5(fixed2, 5e-3, drop, 0.01, M.dark, front, bottom - drop / 2, 0);
90890
- box5(fixed2, 5e-3, 0.02, 6e-3, M.metal, back + (front - back) * 0.45, bottom - 0.011, 0, 0.25);
91672
+ box5(fixed2, 5e-3, 0.02, 6e-3, M.metal, back2 + (front - back2) * 0.45, bottom - 0.011, 0, 0.25);
90891
91673
  };
90892
91674
  var m203 = (kit, fixed2) => {
90893
91675
  const { M, box: box5 } = kit;
@@ -91151,14 +91933,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
91151
91933
  const mesh3 = object2;
91152
91934
  if (!mesh3.isMesh) return;
91153
91935
  (_a = mesh3.userData).baseMaterial ?? (_a.baseMaterial = mesh3.material);
91154
- const base = mesh3.userData.baseMaterial;
91936
+ const base2 = mesh3.userData.baseMaterial;
91155
91937
  if (glowing.has(mesh3)) {
91156
91938
  const material = mesh3.material;
91157
91939
  (_b = mesh3.userData).baseColor ?? (_b.baseColor = material.color.clone());
91158
91940
  material.color.copy(paint2 ?? mesh3.userData.baseColor);
91159
91941
  return;
91160
91942
  }
91161
- mesh3.material = replacement?.get(base) ?? base;
91943
+ mesh3.material = replacement?.get(base2) ?? base2;
91162
91944
  });
91163
91945
  }
91164
91946
 
@@ -94818,7 +95600,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
94818
95600
  var ORIGIN = [0, 0, 0];
94819
95601
  var FACING4 = [0, 0, 1];
94820
95602
  var UP11 = [0, 1, 0];
94821
- var grow = (piece2, factor) => [piece2[0] * factor, piece2[1] * factor, piece2[2] * factor];
95603
+ var grow = (piece3, factor) => [piece3[0] * factor, piece3[1] * factor, piece3[2] * factor];
94822
95604
  var debrisTone = (look) => or(variable(DEBRIS_COLOR_VARIABLE), look.debris);
94823
95605
  var dustTone = (look) => or(variable(DUST_COLOR_VARIABLE), look.dust);
94824
95606
  var sparks = (look, count) => look.sparks ? [call2("spark_at", ORIGIN, FACING4, count, 0.9)] : [];
@@ -95136,7 +95918,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
95136
95918
  ]
95137
95919
  };
95138
95920
  var VIEWMODEL_EFFECTS = [MUZZLE_FLASH2, SMOKE_PUFF, BACKBLAST, FLAME_JET];
95139
- var aliasOf = (base, id, changes) => ({ ...base, id, pageId: `vehicle:${id}`, anchor: CAR_ORIGIN2, ...changes });
95921
+ var aliasOf = (base2, id, changes) => ({ ...base2, id, pageId: `vehicle:${id}`, anchor: CAR_ORIGIN2, ...changes });
95140
95922
  var BODYWORK_IMPACT = {
95141
95923
  id: "impact_bodywork",
95142
95924
  pageId: "vehicle:impact_bodywork",
@@ -97870,8 +98652,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
97870
98652
  }
97871
98653
  var CELL2 = 0.12;
97872
98654
  var OBSTACLE_BOUNCE = 0.3;
97873
- var radiusOf = (piece2) => Math.max(piece2.sx, piece2.sz) * 0.5;
97874
- var thicknessOf2 = (piece2) => Math.min(piece2.sx, piece2.sy, piece2.sz);
98655
+ var radiusOf = (piece3) => Math.max(piece3.sx, piece3.sz) * 0.5;
98656
+ var thicknessOf2 = (piece3) => Math.min(piece3.sx, piece3.sy, piece3.sz);
97875
98657
  var cellKey2 = (i, k) => (i + 4096) * 8192 + (k + 4096);
97876
98658
  var RestingGrid = class {
97877
98659
  constructor() {
@@ -97882,50 +98664,50 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
97882
98664
  }
97883
98665
  rebuild(pieces) {
97884
98666
  this.clear();
97885
- for (const piece2 of pieces) {
97886
- if (!piece2.on || !piece2.rest) continue;
97887
- const key2 = cellKey2(Math.floor(piece2.x / CELL2), Math.floor(piece2.z / CELL2));
98667
+ for (const piece3 of pieces) {
98668
+ if (!piece3.on || !piece3.rest) continue;
98669
+ const key2 = cellKey2(Math.floor(piece3.x / CELL2), Math.floor(piece3.z / CELL2));
97888
98670
  const list2 = this.cells.get(key2);
97889
- if (list2) list2.push(piece2);
97890
- else this.cells.set(key2, [piece2]);
98671
+ if (list2) list2.push(piece3);
98672
+ else this.cells.set(key2, [piece3]);
97891
98673
  }
97892
98674
  }
97893
98675
  /** 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. */
97894
- supportUnder(piece2) {
97895
- const i = Math.floor(piece2.x / CELL2);
97896
- const k = Math.floor(piece2.z / CELL2);
97897
- const reach2 = radiusOf(piece2);
98676
+ supportUnder(piece3) {
98677
+ const i = Math.floor(piece3.x / CELL2);
98678
+ const k = Math.floor(piece3.z / CELL2);
98679
+ const reach2 = radiusOf(piece3);
97898
98680
  let top = -Infinity;
97899
98681
  for (let di = -1; di <= 1; di++) {
97900
98682
  for (let dk = -1; dk <= 1; dk++) {
97901
98683
  for (const other of this.cells.get(cellKey2(i + di, k + dk)) ?? []) {
97902
- if (other === piece2) continue;
97903
- if (Math.hypot(other.x - piece2.x, other.z - piece2.z) > reach2 + radiusOf(other)) continue;
98684
+ if (other === piece3) continue;
98685
+ if (Math.hypot(other.x - piece3.x, other.z - piece3.z) > reach2 + radiusOf(other)) continue;
97904
98686
  const otherTop = other.y + thicknessOf2(other) * 0.5;
97905
- if (otherTop <= piece2.y + thicknessOf2(piece2) * 0.5) top = Math.max(top, otherTop + thicknessOf2(piece2) * 0.5);
98687
+ if (otherTop <= piece3.y + thicknessOf2(piece3) * 0.5) top = Math.max(top, otherTop + thicknessOf2(piece3) * 0.5);
97906
98688
  }
97907
98689
  }
97908
98690
  }
97909
98691
  return top;
97910
98692
  }
97911
98693
  };
97912
- function pushOutOfObstacles(piece2, obstacles) {
98694
+ function pushOutOfObstacles(piece3, obstacles) {
97913
98695
  let moved = false;
97914
98696
  for (const body of obstacles) {
97915
- if (piece2.y < body.bottom || piece2.y > body.top) continue;
97916
- const dx = piece2.x - body.x;
97917
- const dz = piece2.z - body.z;
98697
+ if (piece3.y < body.bottom || piece3.y > body.top) continue;
98698
+ const dx = piece3.x - body.x;
98699
+ const dz = piece3.z - body.z;
97918
98700
  const distance4 = Math.hypot(dx, dz);
97919
- const reach2 = body.radius + radiusOf(piece2);
98701
+ const reach2 = body.radius + radiusOf(piece3);
97920
98702
  if (distance4 >= reach2) continue;
97921
98703
  const nx = distance4 > 1e-6 ? dx / distance4 : 1;
97922
98704
  const nz = distance4 > 1e-6 ? dz / distance4 : 0;
97923
- piece2.x = body.x + nx * reach2;
97924
- piece2.z = body.z + nz * reach2;
97925
- const into = piece2.vx * nx + piece2.vz * nz;
98705
+ piece3.x = body.x + nx * reach2;
98706
+ piece3.z = body.z + nz * reach2;
98707
+ const into = piece3.vx * nx + piece3.vz * nz;
97926
98708
  if (into < 0) {
97927
- piece2.vx -= (1 + OBSTACLE_BOUNCE) * into * nx;
97928
- piece2.vz -= (1 + OBSTACLE_BOUNCE) * into * nz;
98709
+ piece3.vx -= (1 + OBSTACLE_BOUNCE) * into * nx;
98710
+ piece3.vz -= (1 + OBSTACLE_BOUNCE) * into * nz;
97929
98711
  }
97930
98712
  moved = true;
97931
98713
  }
@@ -97955,36 +98737,36 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
97955
98737
  }
97956
98738
  spawn(options) {
97957
98739
  const random = this.context.random;
97958
- const piece2 = this.pieces[this.next++ % CAPACITY];
98740
+ const piece3 = this.pieces[this.next++ % CAPACITY];
97959
98741
  coneDirection(random, options.dir, options.cone ?? 3.2, this.direction);
97960
98742
  const speed = drawRange(random, options.sp);
97961
98743
  const size = options.size ?? DEFAULT_SIZE;
97962
98744
  const scale = options.k ? drawRange(random, options.k) : 1;
97963
98745
  const box5 = options.box;
97964
98746
  const spin = options.spin || DEFAULT_SPIN;
97965
- piece2.on = true;
97966
- piece2.x = options.p[0] + (box5 ? random.between(-box5[0], box5[0]) : 0);
97967
- piece2.y = options.p[1] + (box5 ? random.between(-box5[1], box5[1]) : 0);
97968
- piece2.z = options.p[2] + (box5 ? random.between(-box5[2], box5[2]) : 0);
97969
- piece2.vx = this.direction.x * speed + (options.v ? options.v[0] : 0);
97970
- piece2.vy = this.direction.y * speed + (options.v ? options.v[1] : 0);
97971
- piece2.vz = this.direction.z * speed + (options.v ? options.v[2] : 0);
97972
- piece2.sx = size[0] * scale;
97973
- piece2.sy = size[1] * scale;
97974
- piece2.sz = size[2] * scale;
97975
- piece2.rx = random.between(0, FULL_TURN_DRAWN3);
97976
- piece2.ry = random.between(0, FULL_TURN_DRAWN3);
97977
- piece2.rz = random.between(0, FULL_TURN_DRAWN3);
97978
- piece2.ax = random.between(-1, 1) * spin;
97979
- piece2.ay = random.between(-1, 1) * spin;
97980
- piece2.az = random.between(-1, 1) * spin;
97981
- piece2.life = options.life || DEFAULT_LIFE;
97982
- piece2.bounce = options.bounce ?? DEFAULT_BOUNCE;
97983
- piece2.rest = false;
97984
- piece2.color = options.c ?? DEFAULT_COLOR32;
98747
+ piece3.on = true;
98748
+ piece3.x = options.p[0] + (box5 ? random.between(-box5[0], box5[0]) : 0);
98749
+ piece3.y = options.p[1] + (box5 ? random.between(-box5[1], box5[1]) : 0);
98750
+ piece3.z = options.p[2] + (box5 ? random.between(-box5[2], box5[2]) : 0);
98751
+ piece3.vx = this.direction.x * speed + (options.v ? options.v[0] : 0);
98752
+ piece3.vy = this.direction.y * speed + (options.v ? options.v[1] : 0);
98753
+ piece3.vz = this.direction.z * speed + (options.v ? options.v[2] : 0);
98754
+ piece3.sx = size[0] * scale;
98755
+ piece3.sy = size[1] * scale;
98756
+ piece3.sz = size[2] * scale;
98757
+ piece3.rx = random.between(0, FULL_TURN_DRAWN3);
98758
+ piece3.ry = random.between(0, FULL_TURN_DRAWN3);
98759
+ piece3.rz = random.between(0, FULL_TURN_DRAWN3);
98760
+ piece3.ax = random.between(-1, 1) * spin;
98761
+ piece3.ay = random.between(-1, 1) * spin;
98762
+ piece3.az = random.between(-1, 1) * spin;
98763
+ piece3.life = options.life || DEFAULT_LIFE;
98764
+ piece3.bounce = options.bounce ?? DEFAULT_BOUNCE;
98765
+ piece3.rest = false;
98766
+ piece3.color = options.c ?? DEFAULT_COLOR32;
97985
98767
  }
97986
98768
  clear() {
97987
- for (const piece2 of this.pieces) piece2.on = false;
98769
+ for (const piece3 of this.pieces) piece3.on = false;
97988
98770
  this.count = 0;
97989
98771
  }
97990
98772
  update(dt) {
@@ -97992,46 +98774,46 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
97992
98774
  const contacts = this.context.debrisContacts;
97993
98775
  const obstacles = contacts?.obstacles() ?? [];
97994
98776
  let moving = false;
97995
- for (const piece2 of this.pieces) {
97996
- if (!piece2.on) continue;
97997
- piece2.life -= dt;
97998
- if (piece2.life <= 0) piece2.on = false;
97999
- else if (!piece2.rest) moving = true;
98777
+ for (const piece3 of this.pieces) {
98778
+ if (!piece3.on) continue;
98779
+ piece3.life -= dt;
98780
+ if (piece3.life <= 0) piece3.on = false;
98781
+ else if (!piece3.rest) moving = true;
98000
98782
  }
98001
98783
  if (moving && contacts) this.resting.rebuild(this.pieces);
98002
98784
  else this.resting.clear();
98003
- for (const piece2 of this.pieces) {
98004
- if (!piece2.on) continue;
98785
+ for (const piece3 of this.pieces) {
98786
+ if (!piece3.on) continue;
98005
98787
  this.count++;
98006
- if (obstacles.length > 0 && pushOutOfObstacles(piece2, obstacles)) piece2.rest = false;
98007
- if (!piece2.rest) this.move(piece2, dt);
98788
+ if (obstacles.length > 0 && pushOutOfObstacles(piece3, obstacles)) piece3.rest = false;
98789
+ if (!piece3.rest) this.move(piece3, dt);
98008
98790
  }
98009
98791
  }
98010
98792
  /** Scale at the end of its life, 1 until the last half second (the renderer's `sh`). */
98011
- static fade(piece2) {
98012
- return Math.min(1, piece2.life / FADE_SECONDS);
98013
- }
98014
- move(piece2, dt) {
98015
- piece2.vy -= GRAVITY22 * dt;
98016
- piece2.x += piece2.vx * dt;
98017
- piece2.y += piece2.vy * dt;
98018
- piece2.z += piece2.vz * dt;
98019
- piece2.rx += piece2.ax * dt;
98020
- piece2.ry += piece2.ay * dt;
98021
- piece2.rz += piece2.az * dt;
98022
- 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));
98023
- if (piece2.y >= groundHeight) return;
98024
- piece2.y = groundHeight;
98025
- piece2.vy *= -piece2.bounce;
98026
- piece2.vx *= 0.55;
98027
- piece2.vz *= 0.55;
98028
- piece2.ax *= 0.5;
98029
- piece2.ay *= 0.5;
98030
- piece2.az *= 0.5;
98031
- if (Math.abs(piece2.vy) < 0.5 && Math.hypot(piece2.vx, piece2.vz) < 0.3) {
98032
- piece2.rest = true;
98033
- piece2.rx = Math.round(piece2.rx / QUARTER_TURN4) * QUARTER_TURN4;
98034
- piece2.rz = Math.round(piece2.rz / QUARTER_TURN4) * QUARTER_TURN4;
98793
+ static fade(piece3) {
98794
+ return Math.min(1, piece3.life / FADE_SECONDS);
98795
+ }
98796
+ move(piece3, dt) {
98797
+ piece3.vy -= GRAVITY22 * dt;
98798
+ piece3.x += piece3.vx * dt;
98799
+ piece3.y += piece3.vy * dt;
98800
+ piece3.z += piece3.vz * dt;
98801
+ piece3.rx += piece3.ax * dt;
98802
+ piece3.ry += piece3.ay * dt;
98803
+ piece3.rz += piece3.az * dt;
98804
+ 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));
98805
+ if (piece3.y >= groundHeight) return;
98806
+ piece3.y = groundHeight;
98807
+ piece3.vy *= -piece3.bounce;
98808
+ piece3.vx *= 0.55;
98809
+ piece3.vz *= 0.55;
98810
+ piece3.ax *= 0.5;
98811
+ piece3.ay *= 0.5;
98812
+ piece3.az *= 0.5;
98813
+ if (Math.abs(piece3.vy) < 0.5 && Math.hypot(piece3.vx, piece3.vz) < 0.3) {
98814
+ piece3.rest = true;
98815
+ piece3.rx = Math.round(piece3.rx / QUARTER_TURN4) * QUARTER_TURN4;
98816
+ piece3.rz = Math.round(piece3.rz / QUARTER_TURN4) * QUARTER_TURN4;
98035
98817
  }
98036
98818
  }
98037
98819
  };
@@ -98989,9 +99771,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
98989
99771
  peekWorkshop: () => engine,
98990
99772
  effectIds: () => "volumetric_fire" in effects ? Object.keys(effects) : [...Object.keys(effects), "volumetric_fire"],
98991
99773
  explosion(id, point, explosionOptions = {}) {
98992
- const base = definitionOf(id);
98993
- if (!base) return null;
98994
- const def = scaleDefinition(base, explosionOptions.scale ?? 1);
99774
+ const base2 = definitionOf(id);
99775
+ if (!base2) return null;
99776
+ const def = scaleDefinition(base2, explosionOptions.scale ?? 1);
98995
99777
  const handle = ++handles.next;
98996
99778
  const direction = explosionOptions.direction && { x: explosionOptions.direction[0], y: explosionOptions.direction[1], z: explosionOptions.direction[2] };
98997
99779
  const random = streamOf(explosionOptions.seed);
@@ -100192,8 +100974,8 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
100192
100974
  var REST_TRIES = 8;
100193
100975
  var SAME_NORMAL = 0.9995;
100194
100976
  var restBox = () => ({ c: new Float64Array(3), axes: new Float64Array(9), half: new Float64Array(3), ext: new Float64Array(3) });
100195
- function boxOf3(piece2, out) {
100196
- 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);
100977
+ function boxOf3(piece3, out) {
100978
+ 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);
100197
100979
  const a = out.axes;
100198
100980
  a[0] = cy * cz;
100199
100981
  a[1] = sx * sy * cz + cx * sz;
@@ -100204,12 +100986,12 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
100204
100986
  a[6] = sy;
100205
100987
  a[7] = -sx * cy;
100206
100988
  a[8] = cx * cy;
100207
- out.half[0] = piece2.sx / 2;
100208
- out.half[1] = piece2.sy / 2;
100209
- out.half[2] = piece2.sz / 2;
100210
- out.c[0] = piece2.x;
100211
- out.c[1] = piece2.y;
100212
- out.c[2] = piece2.z;
100989
+ out.half[0] = piece3.sx / 2;
100990
+ out.half[1] = piece3.sy / 2;
100991
+ out.half[2] = piece3.sz / 2;
100992
+ out.c[0] = piece3.x;
100993
+ out.c[1] = piece3.y;
100994
+ out.c[2] = piece3.z;
100213
100995
  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];
100214
100996
  }
100215
100997
  function sharedPlane(a, b, push) {
@@ -100281,21 +101063,21 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
100281
101063
  sync() {
100282
101064
  let drawn = false;
100283
101065
  for (let index = 0; index < DEBRIS_CAPACITY; index++) {
100284
- const piece2 = pool.pieces[index];
100285
- if (!piece2.on || !piece2.rest) settled[index] = 0;
100286
- if (!piece2.on) {
101066
+ const piece3 = pool.pieces[index];
101067
+ if (!piece3.on || !piece3.rest) settled[index] = 0;
101068
+ if (!piece3.on) {
100287
101069
  mesh3.setMatrixAt(index, hidden);
100288
101070
  continue;
100289
101071
  }
100290
- if (piece2.rest && !settled[index]) settle(index);
101072
+ if (piece3.rest && !settled[index]) settle(index);
100291
101073
  drawn = true;
100292
- const shrink = Math.min(1, piece2.life / FADE_SECONDS2);
100293
- euler.set(piece2.rx, piece2.ry, piece2.rz);
101074
+ const shrink = Math.min(1, piece3.life / FADE_SECONDS2);
101075
+ euler.set(piece3.rx, piece3.ry, piece3.rz);
100294
101076
  quaternion2.setFromEuler(euler);
100295
- const off = piece2.rest ? 3 * index : -1;
100296
- 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));
101077
+ const off = piece3.rest ? 3 * index : -1;
101078
+ 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));
100297
101079
  mesh3.setMatrixAt(index, matrix);
100298
- mesh3.setColorAt(index, colour.setHex(piece2.color));
101080
+ mesh3.setColorAt(index, colour.setHex(piece3.color));
100299
101081
  }
100300
101082
  mesh3.instanceMatrix.needsUpdate = true;
100301
101083
  if (mesh3.instanceColor) mesh3.instanceColor.needsUpdate = true;
@@ -100710,12 +101492,12 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
100710
101492
  if (reducedMotion || !(shake > SHAKE_FLOOR)) return () => {
100711
101493
  };
100712
101494
  const camera2 = options.camera;
100713
- const base = camera2.position.clone();
101495
+ const base2 = camera2.position.clone();
100714
101496
  const reach2 = shake * SHAKE_REACH;
100715
101497
  camera2.position.x += Math.sin(clock * 71) * reach2;
100716
101498
  camera2.position.y += Math.sin(clock * 53 + 1) * reach2 * 0.7;
100717
101499
  camera2.position.z += Math.sin(clock * 67 + 2) * reach2;
100718
- return () => camera2.position.copy(base);
101500
+ return () => camera2.position.copy(base2);
100719
101501
  },
100720
101502
  stats() {
100721
101503
  const { lastBlast, ...counters } = world.stats();
@@ -101183,12 +101965,12 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
101183
101965
  const rest2 = /* @__PURE__ */ new Map();
101184
101966
  for (const part of [...registry.values(), model.root]) rest2.set(part, { position: part.position.clone(), rotation: part.rotation.clone() });
101185
101967
  const apply = (object2, pose2) => {
101186
- const base = rest2.get(object2);
101187
- if (!base) return;
101968
+ const base2 = rest2.get(object2);
101969
+ if (!base2) return;
101188
101970
  const [dx, dy, dz] = pose2.position ?? [0, 0, 0];
101189
101971
  const [rx, ry, rz] = pose2.rotation ?? [0, 0, 0];
101190
- object2.position.set(base.position.x + dx, base.position.y + dy, base.position.z + dz);
101191
- object2.rotation.set(base.rotation.x + rx, base.rotation.y + ry, base.rotation.z + rz);
101972
+ object2.position.set(base2.position.x + dx, base2.position.y + dy, base2.position.z + dz);
101973
+ object2.rotation.set(base2.rotation.x + rx, base2.rotation.y + ry, base2.rotation.z + rz);
101192
101974
  };
101193
101975
  return {
101194
101976
  setPartPose(partId, pose2) {
@@ -102656,11 +103438,11 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
102656
103438
  const quaternion2 = hand.quaternion.clone().multiply(rig.grip.quaternion.clone().invert());
102657
103439
  return { position: hand.position.clone().sub(rig.grip.position.clone().applyQuaternion(quaternion2)), quaternion: quaternion2 };
102658
103440
  };
102659
- const relativeTo = (frame2, base) => {
102660
- const inverse = base.quaternion.clone().invert();
102661
- return { position: frame2.position.clone().sub(base.position).applyQuaternion(inverse), quaternion: inverse.multiply(frame2.quaternion) };
103441
+ const relativeTo = (frame2, base2) => {
103442
+ const inverse = base2.quaternion.clone().invert();
103443
+ return { position: frame2.position.clone().sub(base2.position).applyQuaternion(inverse), quaternion: inverse.multiply(frame2.quaternion) };
102662
103444
  };
102663
- const inFrame = (local2, base) => ({ position: local2.position.clone().applyQuaternion(base.quaternion).add(base.position), quaternion: base.quaternion.clone().multiply(local2.quaternion) });
103445
+ const inFrame = (local2, base2) => ({ position: local2.position.clone().applyQuaternion(base2.quaternion).add(base2.position), quaternion: base2.quaternion.clone().multiply(local2.quaternion) });
102664
103446
  const holdFrame = () => {
102665
103447
  const pose2 = options.holdFrame?.();
102666
103448
  return pose2 ? frameOf2(pose2) : null;
@@ -102673,8 +103455,8 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
102673
103455
  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()) };
102674
103456
  }
102675
103457
  if (entry2.motion?.kind === "back") {
102676
- const base = holdFrame();
102677
- return base && entry2.taken ? inFrame(entry2.taken, base) : null;
103458
+ const base2 = holdFrame();
103459
+ return base2 && entry2.taken ? inFrame(entry2.taken, base2) : null;
102678
103460
  }
102679
103461
  const pose2 = options.bodySlot(entry2.slot);
102680
103462
  if (!pose2) return null;
@@ -102754,8 +103536,8 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
102754
103536
  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 };
102755
103537
  if (event.from && seconds > 0) {
102756
103538
  const start = holderOnHand(rig, frameOf2(event.from));
102757
- const base = holdFrame();
102758
- entry2.taken = base ? relativeTo(start, base) : null;
103539
+ const base2 = holdFrame();
103540
+ entry2.taken = base2 ? relativeTo(start, base2) : null;
102759
103541
  entry2.motion = { kind: event.slot === GROUND_SLOT ? "toss" : "away", time: 0, seconds, start };
102760
103542
  } else if (event.slot === GROUND_SLOT) return;
102761
103543
  away.set(event.weapon, entry2);
@@ -103639,9 +104421,9 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
103639
104421
  return entry2?.source === "commons" && entry2.author && entry2.license ? `${entry2.author}, ${entry2.license}` : void 0;
103640
104422
  }
103641
104423
  var DEFAULT_THUMBNAIL_BASE = "weapon-svg/";
103642
- function weaponThumbnailUrl(id, base = DEFAULT_THUMBNAIL_BASE) {
104424
+ function weaponThumbnailUrl(id, base2 = DEFAULT_THUMBNAIL_BASE) {
103643
104425
  const entry2 = WEAPON_THUMBNAILS[id];
103644
- return entry2 ? `${base}${entry2.file}` : void 0;
104426
+ return entry2 ? `${base2}${entry2.file}` : void 0;
103645
104427
  }
103646
104428
 
103647
104429
  // src/world-explosives.ts
@@ -104007,9 +104789,9 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
104007
104789
  id: COUNTER_ITEM_ID,
104008
104790
  name,
104009
104791
  build: (THREE) => {
104010
- const piece2 = counter(THREE);
104011
- const root = piece2.build(THREE);
104012
- root.userData.counterSpec = { ...piece2.spec, name, tags: [...piece2.spec.tags ?? [], "furniture"] };
104792
+ const piece3 = counter(THREE);
104793
+ const root = piece3.build(THREE);
104794
+ root.userData.counterSpec = { ...piece3.spec, name, tags: [...piece3.spec.tags ?? [], "furniture"] };
104013
104795
  return root;
104014
104796
  },
104015
104797
  spec: (root) => root.userData.counterSpec,
@@ -104878,8 +105660,8 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
104878
105660
  if (!needRoom() || !room) return false;
104879
105661
  const vessel = withVessel();
104880
105662
  if (!vessel) return false;
104881
- const base = vessel.root.getWorldPosition(new (T2()).Vector3());
104882
- const point = [base.x + FIRE_OFFSET[0], base.y + FIRE_OFFSET[1], base.z + FIRE_OFFSET[2]];
105663
+ const base2 = vessel.root.getWorldPosition(new (T2()).Vector3());
105664
+ const point = [base2.x + FIRE_OFFSET[0], base2.y + FIRE_OFFSET[1], base2.z + FIRE_OFFSET[2]];
104883
105665
  const config = def.fire ?? { temperature: 700, radius: 1.4, seconds: 7 };
104884
105666
  vessel.firePoint = point;
104885
105667
  vessel.fireUntil = now() + config.seconds + 3;
@@ -105348,7 +106130,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
105348
106130
  area: () => {
105349
106131
  bench.areaOpened();
105350
106132
  const placements = [
105351
- ...scene.furniture.map((piece2) => ({ item: piece2.item, position: piece2.at, ...piece2.rotationY === void 0 ? {} : { rotationY: piece2.rotationY } })),
106133
+ ...scene.furniture.map((piece3) => ({ item: piece3.item, position: piece3.at, ...piece3.rotationY === void 0 ? {} : { rotationY: piece3.rotationY } })),
105352
106134
  { item: `${WORLD_EXPLOSIVE_PREFIX}${EXPLOSIVE_ID}`, position: scene.cylinder },
105353
106135
  // facing the cylinder (the front of an item looks to +z, the cylinder is at -z)
105354
106136
  { item: scene.zombie.item, position: scene.zombie.at, rotationY: Math.PI },