@adatechnology/game-weapons-three 0.29.10 → 0.30.1

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.
Files changed (46) hide show
  1. package/assets/weapon-svg/CREDITS.md +1 -1
  2. package/assets/weapon-svg/credits.html +1 -1
  3. package/assets/weapon-svg/generated/beretta_92fs.svg +1 -1
  4. package/assets/weapon-svg/generated/colt_m1911.svg +1 -1
  5. package/assets/weapon-svg/generated/colt_python.svg +1 -1
  6. package/assets/weapon-svg/generated/cz_75.svg +1 -1
  7. package/assets/weapon-svg/generated/desert_eagle_mark_xix.svg +1 -1
  8. package/assets/weapon-svg/generated/fists.svg +1 -0
  9. package/assets/weapon-svg/generated/fn_five_seven.svg +1 -1
  10. package/assets/weapon-svg/generated/glock_17.svg +1 -1
  11. package/assets/weapon-svg/generated/glock_18.svg +1 -1
  12. package/assets/weapon-svg/generated/glock_19.svg +1 -1
  13. package/assets/weapon-svg/generated/hand.svg +1 -0
  14. package/assets/weapon-svg/generated/hk_usp.svg +1 -1
  15. package/assets/weapon-svg/generated/kel_tec_ksg.svg +1 -1
  16. package/assets/weapon-svg/generated/kick.svg +1 -0
  17. package/assets/weapon-svg/generated/kriss_vector.svg +1 -1
  18. package/assets/weapon-svg/generated/makarov_pm.svg +1 -1
  19. package/assets/weapon-svg/generated/pistol_45.svg +1 -1
  20. package/assets/weapon-svg/generated/pistol_9mm.svg +1 -1
  21. package/assets/weapon-svg/generated/revolver_357.svg +1 -1
  22. package/assets/weapon-svg/generated/revolver_38.svg +1 -1
  23. package/assets/weapon-svg/generated/shove.svg +1 -0
  24. package/assets/weapon-svg/generated/sig_sauer_p226.svg +1 -1
  25. package/assets/weapon-svg/generated/sig_sauer_p320.svg +1 -1
  26. package/assets/weapon-svg/generated/sw_686.svg +1 -1
  27. package/assets/weapon-svg/generated/sw_model_29.svg +1 -1
  28. package/assets/weapon-svg/generated/taurus_82.svg +1 -1
  29. package/assets/weapon-svg/generated/taurus_g2c.svg +1 -1
  30. package/assets/weapon-svg/generated/taurus_pt100.svg +1 -1
  31. package/assets/weapon-svg/generated/taurus_th380.svg +1 -1
  32. package/assets/weapon-svg/generated/taurus_ts9.svg +1 -1
  33. package/assets/weapon-svg/generated/walther_p99.svg +1 -1
  34. package/assets/weapon-svg/manifest.json +16 -0
  35. package/dist/{chunk-WAZHNY5J.js → chunk-RAWW6JTZ.js} +333 -95
  36. package/dist/chunk-RAWW6JTZ.js.map +1 -0
  37. package/dist/index.d.ts +17 -4
  38. package/dist/index.global.js +1582 -834
  39. package/dist/index.global.js.map +1 -1
  40. package/dist/index.js +47 -1
  41. package/dist/index.js.map +1 -1
  42. package/dist/{testing-Bk34V-6X.d.ts → testing-44lDo2Cx.d.ts} +34 -1
  43. package/dist/testing.d.ts +1 -1
  44. package/dist/testing.js +1 -1
  45. package/package.json +15 -14
  46. package/dist/chunk-WAZHNY5J.js.map +0 -1
@@ -62,6 +62,7 @@ var GameWeaponsThree = (() => {
62
62
  WORLD_EXPLOSIVE_IDS: () => WORLD_EXPLOSIVE_IDS,
63
63
  WORLD_EXPLOSIVE_PREFIX: () => WORLD_EXPLOSIVE_PREFIX,
64
64
  applyCondition: () => applyCondition,
65
+ buildBodyActionModel: () => buildBodyActionModel,
65
66
  buildCartridge: () => buildCartridge,
66
67
  buildCasing: () => buildCasing,
67
68
  buildExplosiveModel: () => buildExplosiveModel,
@@ -365,6 +366,7 @@ var GameWeaponsThree = (() => {
365
366
  return void 0;
366
367
  };
367
368
  var FIRST_PERSON_LAYER = 9;
369
+ var CARRY_HANDLE_TAG = "carryHandle";
368
370
  var TOOL_CLIP = {
369
371
  DRAW: "draw",
370
372
  SHOT: "shot",
@@ -19349,28 +19351,29 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
19349
19351
  }
19350
19352
  function catenary(a, b, sag, n = 12) {
19351
19353
  const count = Math.max(2, Math.floor(n));
19352
- const span = Math.hypot(b[0] - a[0], b[2] - a[2]) || Math.hypot(b[0] - a[0], b[1] - a[1], b[2] - a[2]);
19353
- const depth = Math.max(0, sag);
19354
+ const { span, c } = catenaryOf(a[0], a[1], a[2], b[0], b[1], b[2], sag);
19354
19355
  const out = [];
19355
- let shape = () => 0;
19356
- if (depth > 1e-6 && span > 1e-6) {
19357
- let lo = 1e-4;
19358
- let hi = span * 1e3;
19359
- for (let i = 0; i < 80; i++) {
19360
- const c2 = (lo + hi) / 2;
19361
- const d = c2 * (Math.cosh(span / (2 * c2)) - 1);
19362
- if (d > depth) lo = c2;
19363
- else hi = c2;
19364
- }
19365
- const c = (lo + hi) / 2;
19366
- shape = (s) => c * (Math.cosh((s - 0.5) * span / c) - Math.cosh(span / (2 * c)));
19367
- }
19368
19356
  for (let i = 0; i < count; i++) {
19369
19357
  const s = i / (count - 1);
19370
- out.push([a[0] + (b[0] - a[0]) * s, a[1] + (b[1] - a[1]) * s + shape(s), a[2] + (b[2] - a[2]) * s]);
19358
+ out.push([a[0] + (b[0] - a[0]) * s, a[1] + (b[1] - a[1]) * s + catenaryDrop(span, c, s), a[2] + (b[2] - a[2]) * s]);
19371
19359
  }
19372
19360
  return out;
19373
19361
  }
19362
+ var catenaryOf = (ax, ay, az, bx, by, bz, sag) => {
19363
+ const span = Math.hypot(bx - ax, bz - az) || Math.hypot(bx - ax, by - ay, bz - az);
19364
+ const depth = Math.max(0, sag);
19365
+ if (depth <= 1e-6 || span <= 1e-6) return { span, c: 0 };
19366
+ let lo = 1e-4;
19367
+ let hi = span * 1e3;
19368
+ for (let i = 0; i < 80; i++) {
19369
+ const c = (lo + hi) / 2;
19370
+ const d = c * (Math.cosh(span / (2 * c)) - 1);
19371
+ if (d > depth) lo = c;
19372
+ else hi = c;
19373
+ }
19374
+ return { span, c: (lo + hi) / 2 };
19375
+ };
19376
+ var catenaryDrop = (span, c, s) => c > 0 ? c * (Math.cosh((s - 0.5) * span / c) - Math.cosh(span / (2 * c))) : 0;
19374
19377
  function createCord(THREE, points, radius, material, radialSegments = 5) {
19375
19378
  if (points.length < 2) throw new Error("createCord needs at least two points");
19376
19379
  const curve = new THREE.CatmullRomCurve3(points.map((p) => new THREE.Vector3(p[0], p[1], p[2])), false, "centripetal");
@@ -19380,6 +19383,96 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
19380
19383
  mesh3.castShadow = true;
19381
19384
  return mesh3;
19382
19385
  }
19386
+ function createHangingCord(THREE, options) {
19387
+ const segments = Math.max(1, Math.floor(options.segments));
19388
+ const radial = Math.max(3, Math.floor(options.radialSegments ?? 5));
19389
+ const ring22 = radial + 1;
19390
+ const positions2 = new Float32Array((segments + 1) * ring22 * 3);
19391
+ const normals = new Float32Array((segments + 1) * ring22 * 3);
19392
+ const index = [];
19393
+ for (let i = 0; i < segments; i++) {
19394
+ for (let j = 0; j < radial; j++) {
19395
+ const a = i * ring22 + j;
19396
+ const b = (i + 1) * ring22 + j;
19397
+ index.push(a, b, a + 1, b, b + 1, a + 1);
19398
+ }
19399
+ }
19400
+ const geometry = new THREE.BufferGeometry();
19401
+ const positionAttribute = new THREE.BufferAttribute(positions2, 3);
19402
+ const normalAttribute = new THREE.BufferAttribute(normals, 3);
19403
+ geometry.setAttribute("position", positionAttribute);
19404
+ geometry.setAttribute("normal", normalAttribute);
19405
+ geometry.setIndex(index);
19406
+ const sphere2 = new THREE.Sphere();
19407
+ geometry.boundingSphere = sphere2;
19408
+ const mesh3 = new THREE.Mesh(geometry, options.material);
19409
+ mesh3.name = "cord";
19410
+ mesh3.castShadow = true;
19411
+ const centre = new Float64Array((segments + 1) * 3);
19412
+ const tangent = new THREE.Vector3();
19413
+ const normal = new THREE.Vector3();
19414
+ const binormal = new THREE.Vector3();
19415
+ const previous = new THREE.Vector3();
19416
+ const low = new THREE.Vector3();
19417
+ const high = new THREE.Vector3();
19418
+ const tangentAt = (i) => {
19419
+ const from = Math.max(0, i - 1);
19420
+ const to = Math.min(segments, i + 1);
19421
+ tangent.set(centre[to * 3] - centre[from * 3], centre[to * 3 + 1] - centre[from * 3 + 1], centre[to * 3 + 2] - centre[from * 3 + 2]).normalize();
19422
+ };
19423
+ return {
19424
+ mesh: mesh3,
19425
+ hang(a, b, sag) {
19426
+ const { span, c } = catenaryOf(a.x, a.y, a.z, b.x, b.y, b.z, sag);
19427
+ for (let i = 0; i <= segments; i++) {
19428
+ const s = i / segments;
19429
+ centre[i * 3] = a.x + (b.x - a.x) * s;
19430
+ centre[i * 3 + 1] = a.y + (b.y - a.y) * s + catenaryDrop(span, c, s);
19431
+ centre[i * 3 + 2] = a.z + (b.z - a.z) * s;
19432
+ }
19433
+ low.set(Infinity, Infinity, Infinity);
19434
+ high.set(-Infinity, -Infinity, -Infinity);
19435
+ for (let i = 0; i <= segments; i++) {
19436
+ tangentAt(i);
19437
+ if (i === 0) {
19438
+ const ax = Math.abs(tangent.x);
19439
+ const ay = Math.abs(tangent.y);
19440
+ const az = Math.abs(tangent.z);
19441
+ normal.set(ax <= ay && ax <= az ? 1 : 0, ay < ax && ay <= az ? 1 : 0, az < ax && az < ay ? 1 : 0);
19442
+ normal.sub(binormal.copy(tangent).multiplyScalar(normal.dot(tangent))).normalize();
19443
+ } else {
19444
+ normal.copy(previous).sub(binormal.copy(tangent).multiplyScalar(previous.dot(tangent))).normalize();
19445
+ }
19446
+ previous.copy(normal);
19447
+ binormal.crossVectors(tangent, normal);
19448
+ const px = centre[i * 3];
19449
+ const py = centre[i * 3 + 1];
19450
+ const pz = centre[i * 3 + 2];
19451
+ for (let j = 0; j <= radial; j++) {
19452
+ const angle = j / radial * Math.PI * 2;
19453
+ const cos2 = Math.cos(angle);
19454
+ const sin2 = -Math.sin(angle);
19455
+ const nx = cos2 * normal.x + sin2 * binormal.x;
19456
+ const ny = cos2 * normal.y + sin2 * binormal.y;
19457
+ const nz = cos2 * normal.z + sin2 * binormal.z;
19458
+ const at4 = (i * ring22 + j) * 3;
19459
+ normals[at4] = nx;
19460
+ normals[at4 + 1] = ny;
19461
+ normals[at4 + 2] = nz;
19462
+ positions2[at4] = px + options.radius * nx;
19463
+ positions2[at4 + 1] = py + options.radius * ny;
19464
+ positions2[at4 + 2] = pz + options.radius * nz;
19465
+ }
19466
+ low.set(Math.min(low.x, px), Math.min(low.y, py), Math.min(low.z, pz));
19467
+ high.set(Math.max(high.x, px), Math.max(high.y, py), Math.max(high.z, pz));
19468
+ }
19469
+ positionAttribute.needsUpdate = true;
19470
+ normalAttribute.needsUpdate = true;
19471
+ sphere2.center.addVectors(low, high).multiplyScalar(0.5);
19472
+ sphere2.radius = sphere2.center.distanceTo(high) + options.radius;
19473
+ }
19474
+ };
19475
+ }
19383
19476
  var isTexture = (v) => !!v && typeof v === "object" && v.isTexture === true;
19384
19477
  function texturesOf(material, out) {
19385
19478
  for (const value of Object.values(material)) if (isTexture(value)) out.add(value);
@@ -19388,13 +19481,16 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
19388
19481
  for (const u of Object.values(uniforms)) if (isTexture(u?.value)) out.add(u.value);
19389
19482
  }
19390
19483
  }
19484
+ var isInstanced = (o) => o.isInstancedMesh === true;
19391
19485
  function collect(roots) {
19392
19486
  const geometries = /* @__PURE__ */ new Set();
19393
19487
  const materials = /* @__PURE__ */ new Set();
19394
19488
  const textures = /* @__PURE__ */ new Set();
19395
19489
  const skeletons = /* @__PURE__ */ new Set();
19490
+ const instanced = /* @__PURE__ */ new Set();
19396
19491
  for (const root of roots) {
19397
19492
  root.traverse((object2) => {
19493
+ if (isInstanced(object2)) instanced.add(object2);
19398
19494
  const o = object2;
19399
19495
  if (o.geometry && typeof o.geometry.dispose === "function") geometries.add(o.geometry);
19400
19496
  if (o.skeleton && typeof o.skeleton.dispose === "function") skeletons.add(o.skeleton);
@@ -19406,7 +19502,7 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
19406
19502
  }
19407
19503
  });
19408
19504
  }
19409
- return { geometries, materials, textures, skeletons };
19505
+ return { geometries, materials, textures, skeletons, instanced };
19410
19506
  }
19411
19507
  var marked = /* @__PURE__ */ new WeakSet();
19412
19508
  function markShared(...resources) {
@@ -19455,6 +19551,7 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
19455
19551
  report.textures++;
19456
19552
  }
19457
19553
  for (const s of found.skeletons) s.dispose();
19554
+ for (const mesh3 of found.instanced) mesh3.dispose();
19458
19555
  return report;
19459
19556
  }
19460
19557
  function discardObject3D(objects, options = {}) {
@@ -21440,63 +21537,6 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21440
21537
  }
21441
21538
 
21442
21539
  // ../game-destruction/dist/index.js
21443
- var AIR_DENSITY = 1.2;
21444
- var DRAG_AREA_FACTOR = 1.5;
21445
- var STEEL_DENSITY = 7850;
21446
- var FRAGMENT_MIN_SPEED = 30;
21447
- var GLASS_STIFFENING = 2.5;
21448
- var PLATE_COEFFICIENT = 0.2874;
21449
- var BEAM_COEFFICIENT = 0.75;
21450
- var TNT_PER_JOULE = DEFAULT_BLAST_IMPULSE.tntPerJoule;
21451
- function projectedArea(shape, toward2) {
21452
- const [dx, dy, dz] = [Math.abs(toward2[0]), Math.abs(toward2[1]), Math.abs(toward2[2])];
21453
- if (shape.kind === "box") return dx * shape.size[1] * shape.size[2] + dy * shape.size[0] * shape.size[2] + dz * shape.size[0] * shape.size[1];
21454
- if (shape.kind === "cylinder") return Math.PI * shape.radius ** 2 * dy + 2 * shape.radius * shape.height * Math.sqrt(Math.max(0, 1 - dy * dy));
21455
- return Math.PI * shape.radius ** 2;
21456
- }
21457
- function failureWork(input) {
21458
- const ratio = input.thickness / Math.max(input.span, input.thickness);
21459
- const stiffening = input.isGlass ? GLASS_STIFFENING : 1;
21460
- const pressure = stiffening * input.failureMPa * 1e6 * ratio * ratio / (input.isBeam ? BEAM_COEFFICIENT : PLATE_COEFFICIENT);
21461
- const deflection = input.thickness * (1 + 25 * input.ductility * input.ductility);
21462
- return { pressure, work: (0.5 + 0.5 * input.ductility) * pressure * input.loaded * deflection };
21463
- }
21464
- function casingFlight(casing2) {
21465
- const k = casing2.geometry === "cylinder" ? 0.5 : 0.6;
21466
- return {
21467
- mottScale: casing2.mass / (2 * Math.max(1, casing2.fragments)),
21468
- speed: casing2.gurneyVelocity / Math.sqrt(casing2.mass / Math.max(casing2.chargeMass, 1e-6) + k)
21469
- };
21470
- }
21471
- function mottMass(u, scale, fragments) {
21472
- const lowest = 1 / Math.max(1, fragments);
21473
- return scale * Math.log(1 / Math.max(u, lowest)) ** 2;
21474
- }
21475
- function fragmentCaliberMm(mass) {
21476
- return 2e3 * Math.cbrt(3 * mass / (4 * Math.PI * STEEL_DENSITY));
21477
- }
21478
- function fragmentDrag(mass) {
21479
- const sphereArea = Math.PI * Math.cbrt(3 * mass / (4 * Math.PI * STEEL_DENSITY)) ** 2;
21480
- return AIR_DENSITY * DRAG_AREA_FACTOR * sphereArea / (2 * mass);
21481
- }
21482
- var BLUNT_FRAGMENT_NOSE = 0.84;
21483
- var NDRC_CONSTANT = 38e-6;
21484
- function concretePerforation(input) {
21485
- const { mass, caliber, speed } = input;
21486
- if (!(mass > 0) || !(caliber > 0) || !(speed > 0)) return { depth: 0, perforation: 0 };
21487
- const g = NDRC_CONSTANT * (input.nose ?? BLUNT_FRAGMENT_NOSE) * mass / (caliber * Math.sqrt(input.compressiveMPa * 1e6)) * (speed / caliber) ** 1.8;
21488
- const relative = g <= 1 ? 2 * Math.sqrt(g) : g + 1;
21489
- const through = relative <= 1.35 ? 3.19 * relative - 0.718 * relative * relative : 1.32 + 1.24 * relative;
21490
- return { depth: relative * caliber, perforation: through * caliber };
21491
- }
21492
- var FIRE_PRIME_C = 300;
21493
- var drawChainDelay = (delay, random) => {
21494
- if (typeof delay === "number") return delay;
21495
- const [min2, max2] = delay;
21496
- return min2 + random() * (max2 - min2);
21497
- };
21498
- var chainDelayOf = (spec, trigger) => spec.explodes?.chain?.[trigger];
21499
- var shotDamageFractionOf = (spec) => spec.explodes?.chain?.shotDamageFraction ?? 0;
21500
21540
  var EPS4 = 1e-9;
21501
21541
  var vec = {
21502
21542
  add: (a, b) => [a[0] + b[0], a[1] + b[1], a[2] + b[2]],
@@ -21778,6 +21818,343 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21778
21818
  }
21779
21819
  };
21780
21820
  };
21821
+ var planeAxes = (thin) => thin === 1 ? [0, 2] : [thin === 0 ? 2 : 0, 1];
21822
+ var BREACH_GRID_CAP = 4096;
21823
+ var unitGrid = (dims, thin, units, cap) => {
21824
+ const [u, v] = planeAxes(thin);
21825
+ let unitU = Math.min(units.size[0], dims[u]), unitV = Math.min(units.size[1], dims[v]);
21826
+ const rowsFor = (h) => Math.ceil(dims[v] / h - 1e-9);
21827
+ const colsFor = (w) => Math.ceil(dims[u] / w - 1e-9) + (units.bond === "running" ? 1 : 0);
21828
+ const merge = Math.ceil(Math.sqrt(rowsFor(unitV) * colsFor(unitU) / cap));
21829
+ if (merge > 1) {
21830
+ unitU = Math.min(unitU * merge, dims[u]);
21831
+ unitV = Math.min(unitV * merge, dims[v]);
21832
+ }
21833
+ const cells = [];
21834
+ for (let row = 0; row < rowsFor(unitV); row++) {
21835
+ const v0 = -dims[v] / 2 + row * unitV, v1 = Math.min(v0 + unitV, dims[v] / 2);
21836
+ const shift = units.bond === "running" && row % 2 === 1 ? unitU / 2 : 0;
21837
+ for (let col = 0; col < colsFor(unitU); col++) {
21838
+ const u0 = Math.max(-dims[u] / 2 + col * unitU - shift, -dims[u] / 2), u1 = Math.min(-dims[u] / 2 + (col + 1) * unitU - shift, dims[u] / 2);
21839
+ if (u1 - u0 < 0.01) continue;
21840
+ const center = [0, 0, 0], size = [0, 0, 0];
21841
+ center[u] = (u0 + u1) / 2;
21842
+ center[v] = (v0 + v1) / 2;
21843
+ size[u] = u1 - u0;
21844
+ size[v] = v1 - v0;
21845
+ size[thin] = dims[thin];
21846
+ cells.push({ center, size });
21847
+ }
21848
+ }
21849
+ return cells;
21850
+ };
21851
+ var rowsOfGrid = /* @__PURE__ */ new WeakMap();
21852
+ var unitRowsWithin = (cells, thin, point, radius) => {
21853
+ const [u, v] = planeAxes(thin);
21854
+ if (!Number.isFinite(point[u]) || !Number.isFinite(point[v]) || !Number.isFinite(radius)) return [[0, cells.length]];
21855
+ let rows = rowsOfGrid.get(cells);
21856
+ if (!rows) {
21857
+ const found = [];
21858
+ cells.forEach((cell, i) => {
21859
+ const last = found[found.length - 1];
21860
+ if (last && last.center === cell.center[v] && last.size === cell.size[v]) last.to = i + 1;
21861
+ else found.push({ from: i, to: i + 1, center: cell.center[v], size: cell.size[v] });
21862
+ });
21863
+ rowsOfGrid.set(cells, rows = found);
21864
+ }
21865
+ const ranges = [];
21866
+ for (const row of rows) {
21867
+ if (Math.max(0, Math.abs(point[v] - row.center) - row.size / 2) > radius) continue;
21868
+ const last = ranges[ranges.length - 1];
21869
+ if (last && last[1] === row.from) last[1] = row.to;
21870
+ else ranges.push([row.from, row.to]);
21871
+ }
21872
+ return ranges;
21873
+ };
21874
+ var planeDistance = (cell, thin, point) => {
21875
+ const [u, v] = planeAxes(thin);
21876
+ const du = cell.center[u] - point[u], dv = cell.center[v] - point[v];
21877
+ return Math.sqrt(du * du + dv * dv);
21878
+ };
21879
+ var cellsWithin = (cells, thin, point, radius) => {
21880
+ const inside3 = cells.filter((c) => planeDistance(c, thin, point) <= radius);
21881
+ if (inside3.length > 0 || cells.length === 0) return inside3;
21882
+ return [cells.reduce((best, c) => planeDistance(c, thin, point) < planeDistance(best, thin, point) ? c : best)];
21883
+ };
21884
+ var cellsOutside = (cells, thin, point, radius) => cells.filter((c) => planeDistance(c, thin, point) > radius);
21885
+ var MAX_MARKS_PER_FRAGMENT = 12;
21886
+ var marksInBox = (center, size, rotation2, holes) => {
21887
+ const inverse = rotation2 ? quat.conjugate(rotation2) : void 0;
21888
+ const marks = [];
21889
+ for (const hole of holes) {
21890
+ const offset = [hole.point[0] - center[0], hole.point[1] - center[1], hole.point[2] - center[2]];
21891
+ const point = inverse ? rotateVec(inverse, offset) : offset;
21892
+ const inside3 = point.every((value, k) => Math.abs(value) <= size[k] / 2 + hole.diameter / 2);
21893
+ if (!inside3) continue;
21894
+ marks.push({ point, normal: inverse ? rotateVec(inverse, hole.normal) : hole.normal, diameter: hole.diameter });
21895
+ if (marks.length >= MAX_MARKS_PER_FRAGMENT) break;
21896
+ }
21897
+ return marks;
21898
+ };
21899
+ var rowLayouts = /* @__PURE__ */ new WeakMap();
21900
+ var rowLayoutOf = (cells, thin, bottom) => {
21901
+ const known = rowLayouts.get(cells);
21902
+ if (known && known.thin === thin && known.bottom === bottom && known.count === cells.length) return known;
21903
+ const [u, v] = planeAxes(thin);
21904
+ const keys = cells.map((cell) => Math.round((cell.center[v] - cell.size[v] / 2 - bottom) * 1e4));
21905
+ const alongOrder = cells.map((_, i) => i).sort((a, b) => cells[a].center[u] - cells[b].center[u]);
21906
+ const layout = { thin, bottom, count: cells.length, keys, alongOrder };
21907
+ rowLayouts.set(cells, layout);
21908
+ return layout;
21909
+ };
21910
+ var holeInBox = (center, size, hole) => {
21911
+ for (let k = 0; k < 3; k++) if (!(Math.abs(hole.point[k] - center[k]) <= size[k] / 2 + hole.diameter / 2)) return false;
21912
+ return true;
21913
+ };
21914
+ var JOINT_GAP = 1e-4;
21915
+ var MIN_BEARING_SHARE = 0.25;
21916
+ var unsupportedCells = (cells, thin, dims, standing, bears) => {
21917
+ if (thin === 1) return unheldSlabCells(cells, dims, standing);
21918
+ const [u, v] = planeAxes(thin);
21919
+ const bottom = -dims[v] / 2;
21920
+ const layout = rowLayoutOf(cells, thin, bottom);
21921
+ const rows = /* @__PURE__ */ new Map();
21922
+ const isStanding = new Uint8Array(cells.length);
21923
+ for (let i = 0; i < cells.length; i++) {
21924
+ if (!standing(i)) continue;
21925
+ isStanding[i] = 1;
21926
+ const key2 = layout.keys[i];
21927
+ if (!rows.has(key2)) rows.set(key2, []);
21928
+ }
21929
+ for (const i of layout.alongOrder) if (isStanding[i] === 1) rows.get(layout.keys[i]).push(i);
21930
+ const rowOf = (y) => Math.round((y - bottom) * 1e4);
21931
+ const held = /* @__PURE__ */ new Set();
21932
+ const queue = [];
21933
+ for (const i of rows.get(0) ?? []) {
21934
+ if (bears && !bears(i)) continue;
21935
+ held.add(i);
21936
+ queue.push(i);
21937
+ }
21938
+ const overlap = (a, b) => Math.min(a.center[u] + a.size[u] / 2, b.center[u] + b.size[u] / 2) - Math.max(a.center[u] - a.size[u] / 2, b.center[u] - b.size[u] / 2);
21939
+ const climb = () => {
21940
+ while (queue.length > 0) {
21941
+ const cell = cells[queue.pop()];
21942
+ for (const j of rows.get(rowOf(cell.center[v] + cell.size[v] / 2)) ?? []) {
21943
+ const other = cells[j];
21944
+ if (held.has(j) || overlap(cell, other) <= Math.max(JOINT_GAP, MIN_BEARING_SHARE * Math.min(cell.size[u], other.size[u]))) continue;
21945
+ held.add(j);
21946
+ queue.push(j);
21947
+ }
21948
+ }
21949
+ };
21950
+ const touching = (a, b) => Math.abs(a.center[u] + a.size[u] / 2 - (b.center[u] - b.size[u] / 2)) <= 1e-3;
21951
+ for (let wedged = true; wedged; ) {
21952
+ climb();
21953
+ wedged = false;
21954
+ for (const row of rows.values()) {
21955
+ for (let k = 1; k < row.length - 1; k++) {
21956
+ const i = row[k];
21957
+ if (held.has(i) || !held.has(row[k - 1]) || !held.has(row[k + 1])) continue;
21958
+ if (!touching(cells[row[k - 1]], cells[i]) || !touching(cells[i], cells[row[k + 1]])) continue;
21959
+ held.add(i);
21960
+ queue.push(i);
21961
+ wedged = true;
21962
+ }
21963
+ }
21964
+ }
21965
+ const loose = [];
21966
+ for (const row of rows.values()) for (const i of row) if (!held.has(i)) loose.push(i);
21967
+ return loose;
21968
+ };
21969
+ var slabGrids = /* @__PURE__ */ new WeakMap();
21970
+ function slabGridOf(cells) {
21971
+ const known = slabGrids.get(cells);
21972
+ if (known && known.place.length === cells.length * 2) return known;
21973
+ const [u, v] = planeAxes(1);
21974
+ const round5 = (x) => Math.round(x * 1e4);
21975
+ const columns = [...new Set(cells.map((cell) => round5(cell.center[u])))].sort((a, b) => a - b);
21976
+ const rows = [...new Set(cells.map((cell) => round5(cell.center[v])))].sort((a, b) => a - b);
21977
+ const columnOf = new Map(columns.map((c, k) => [c, k])), rowOf = new Map(rows.map((r, k) => [r, k]));
21978
+ const place = new Int32Array(cells.length * 2);
21979
+ cells.forEach((cell, i) => {
21980
+ place[i * 2] = columnOf.get(round5(cell.center[u]));
21981
+ place[i * 2 + 1] = rowOf.get(round5(cell.center[v]));
21982
+ });
21983
+ const grid = { columns: columns.length, rows: rows.length, place };
21984
+ slabGrids.set(cells, grid);
21985
+ return grid;
21986
+ }
21987
+ var unheldSlabCells = (cells, dims, standing) => {
21988
+ const [u, v] = planeAxes(1);
21989
+ const edge = (cell) => cell.center[u] - cell.size[u] / 2 <= -dims[u] / 2 + JOINT_GAP || cell.center[u] + cell.size[u] / 2 >= dims[u] / 2 - JOINT_GAP || cell.center[v] - cell.size[v] / 2 <= -dims[v] / 2 + JOINT_GAP || cell.center[v] + cell.size[v] / 2 >= dims[v] / 2 - JOINT_GAP;
21990
+ const { columns, rows, place } = slabGridOf(cells);
21991
+ const at4 = /* @__PURE__ */ new Map();
21992
+ for (let i = 0; i < cells.length; i++) if (standing(i)) at4.set(place[i * 2 + 1] * columns + place[i * 2], i);
21993
+ const held = new Uint8Array(cells.length);
21994
+ const queue = [];
21995
+ for (const i of at4.values()) if (edge(cells[i])) {
21996
+ held[i] = 1;
21997
+ queue.push(i);
21998
+ }
21999
+ while (queue.length > 0) {
22000
+ const i = queue.pop();
22001
+ const c = place[i * 2], r = place[i * 2 + 1];
22002
+ for (const [nc, nr] of [[c - 1, r], [c + 1, r], [c, r - 1], [c, r + 1]]) {
22003
+ if (nc < 0 || nr < 0 || nc >= columns || nr >= rows) continue;
22004
+ const j = at4.get(nr * columns + nc);
22005
+ if (j === void 0 || held[j] === 1) continue;
22006
+ held[j] = 1;
22007
+ queue.push(j);
22008
+ }
22009
+ }
22010
+ const loose = [];
22011
+ for (const i of at4.values()) if (held[i] !== 1) loose.push(i);
22012
+ return loose.sort((a, b) => a - b);
22013
+ };
22014
+ var clumpUnits = (cells, thin, unit, cap) => {
22015
+ if (cells.length <= cap) return [...cells];
22016
+ const [u, v] = planeAxes(thin);
22017
+ let lo0 = Infinity, lo1 = Infinity;
22018
+ for (const cell of cells) {
22019
+ lo0 = Math.min(lo0, cell.center[u] - cell.size[u] / 2);
22020
+ lo1 = Math.min(lo1, cell.center[v] - cell.size[v] / 2);
22021
+ }
22022
+ let along3 = 1, up = 1;
22023
+ for (let grow2 = 0; ; grow2++) {
22024
+ const bins = /* @__PURE__ */ new Map();
22025
+ for (const cell of cells) {
22026
+ const key2 = `${Math.floor((cell.center[u] - lo0) / (along3 * unit[0]))}:${Math.floor((cell.center[v] - lo1) / (up * unit[1]))}`;
22027
+ const bin2 = bins.get(key2) ?? { lo: [Infinity, Infinity, Infinity], hi: [-Infinity, -Infinity, -Infinity] };
22028
+ for (let k = 0; k < 3; k++) {
22029
+ bin2.lo[k] = Math.min(bin2.lo[k], cell.center[k] - cell.size[k] / 2);
22030
+ bin2.hi[k] = Math.max(bin2.hi[k], cell.center[k] + cell.size[k] / 2);
22031
+ }
22032
+ bins.set(key2, bin2);
22033
+ }
22034
+ if (bins.size <= cap) {
22035
+ return [...bins.values()].map(({ lo, hi }) => ({ center: [(lo[0] + hi[0]) / 2, (lo[1] + hi[1]) / 2, (lo[2] + hi[2]) / 2], size: [hi[0] - lo[0], hi[1] - lo[1], hi[2] - lo[2]] }));
22036
+ }
22037
+ if (grow2 % 2 === 0) up++;
22038
+ else along3++;
22039
+ }
22040
+ };
22041
+ var MAX_SPALLS = 64;
22042
+ var thinAxisOf = (dims) => dims[0] <= dims[1] && dims[0] <= dims[2] ? 0 : dims[1] <= dims[2] ? 1 : 2;
22043
+ var resolveLayer = (def, index, mat) => ({ index, def, mat, energy: mat.penetration * def.thickness * 1e3 });
22044
+ var faceCode = (thin, axis2, sign2) => {
22045
+ const [u] = planeAxes(thin);
22046
+ return (sign2 >= 0 ? 1 : -1) * (axis2 === thin ? 1 : axis2 === u ? 2 : 3);
22047
+ };
22048
+ var faceAxis = (thin, face) => {
22049
+ const k = Math.abs(face);
22050
+ return k === 1 ? thin : planeAxes(thin)[k - 2];
22051
+ };
22052
+ var faceOfNormal = (layers, thin, localNormal) => {
22053
+ if (!layers.some((l) => l.def.faces === "all")) return localNormal[thin] >= 0 ? 1 : -1;
22054
+ let axis2 = thin;
22055
+ for (let k = 0; k < 3; k++) if (Math.abs(localNormal[k]) > Math.abs(localNormal[axis2])) axis2 = k;
22056
+ return faceCode(thin, axis2, localNormal[axis2]);
22057
+ };
22058
+ var onFace = (layer3, face) => {
22059
+ const faces = layer3.def.faces;
22060
+ if (faces === "all") return true;
22061
+ if (Math.abs(face) !== 1) return false;
22062
+ return faces === "both" || faces === (face > 0 ? "+" : "-");
22063
+ };
22064
+ var thinSidesOf = (def) => def.faces === "both" || def.faces === "all" ? [1, -1] : [def.faces === "+" ? 1 : -1];
22065
+ var isSpalled = (spalls, layer3, face, point) => {
22066
+ for (const s of spalls ?? []) {
22067
+ if (s[0] !== layer3 || s[1] !== face) continue;
22068
+ const dx = s[2] - point[0], dy = s[3] - point[1], dz = s[4] - point[2];
22069
+ if (dx * dx + dy * dy + dz * dz <= s[5] * s[5]) return true;
22070
+ }
22071
+ return false;
22072
+ };
22073
+ var outerLayer = (layers, spalls, face, point) => layers.find((l) => onFace(l, face) && !isSpalled(spalls, l.index, face, point));
22074
+ var layersEnergy = (layers, spalls, face, point) => {
22075
+ let sum2 = 0;
22076
+ for (const l of layers) if (onFace(l, face) && !isSpalled(spalls, l.index, face, point)) sum2 += l.energy;
22077
+ return sum2;
22078
+ };
22079
+ var layersThickness = (layers, face) => {
22080
+ let sum2 = 0;
22081
+ for (const l of layers) if (onFace(l, face)) sum2 += l.def.thickness;
22082
+ return sum2;
22083
+ };
22084
+ var tornPatchAt = (layers, spalls, face, point, radius) => {
22085
+ for (const l of layers) {
22086
+ if (!onFace(l, face)) continue;
22087
+ if (l.mat.fracture === "tear") {
22088
+ let best = -1;
22089
+ (spalls ?? []).forEach((s, i) => {
22090
+ if (s[0] !== l.index || s[1] !== face) return;
22091
+ const dx = s[2] - point[0], dy = s[3] - point[1], dz = s[4] - point[2];
22092
+ const reach2 = s[5] + radius;
22093
+ if (dx * dx + dy * dy + dz * dz <= reach2 * reach2 && (best < 0 || s[5] > spalls[best][5])) best = i;
22094
+ });
22095
+ if (best >= 0) return { layer: l, spall: best };
22096
+ }
22097
+ if (!isSpalled(spalls, l.index, face, point)) return void 0;
22098
+ }
22099
+ return void 0;
22100
+ };
22101
+ var AIR_DENSITY = 1.2;
22102
+ var DRAG_AREA_FACTOR = 1.5;
22103
+ var STEEL_DENSITY = 7850;
22104
+ var FRAGMENT_MIN_SPEED = 30;
22105
+ var GLASS_STIFFENING = 2.5;
22106
+ var PLATE_COEFFICIENT = 0.2874;
22107
+ var BEAM_COEFFICIENT = 0.75;
22108
+ var TNT_PER_JOULE = DEFAULT_BLAST_IMPULSE.tntPerJoule;
22109
+ function projectedArea(shape, toward2) {
22110
+ const [dx, dy, dz] = [Math.abs(toward2[0]), Math.abs(toward2[1]), Math.abs(toward2[2])];
22111
+ if (shape.kind === "box") return dx * shape.size[1] * shape.size[2] + dy * shape.size[0] * shape.size[2] + dz * shape.size[0] * shape.size[1];
22112
+ if (shape.kind === "cylinder") return Math.PI * shape.radius ** 2 * dy + 2 * shape.radius * shape.height * Math.sqrt(Math.max(0, 1 - dy * dy));
22113
+ return Math.PI * shape.radius ** 2;
22114
+ }
22115
+ function failureWork(input) {
22116
+ const ratio = input.thickness / Math.max(input.span, input.thickness);
22117
+ const stiffening = input.isGlass ? GLASS_STIFFENING : 1;
22118
+ const pressure = stiffening * input.failureMPa * 1e6 * ratio * ratio / (input.isBeam ? BEAM_COEFFICIENT : PLATE_COEFFICIENT);
22119
+ const deflection = input.thickness * (1 + 25 * input.ductility * input.ductility);
22120
+ return { pressure, work: (0.5 + 0.5 * input.ductility) * pressure * input.loaded * deflection };
22121
+ }
22122
+ function casingFlight(casing2) {
22123
+ const k = casing2.geometry === "cylinder" ? 0.5 : 0.6;
22124
+ return {
22125
+ mottScale: casing2.mass / (2 * Math.max(1, casing2.fragments)),
22126
+ speed: casing2.gurneyVelocity / Math.sqrt(casing2.mass / Math.max(casing2.chargeMass, 1e-6) + k)
22127
+ };
22128
+ }
22129
+ function mottMass(u, scale, fragments) {
22130
+ const lowest = 1 / Math.max(1, fragments);
22131
+ return scale * Math.log(1 / Math.max(u, lowest)) ** 2;
22132
+ }
22133
+ function fragmentCaliberMm(mass) {
22134
+ return 2e3 * Math.cbrt(3 * mass / (4 * Math.PI * STEEL_DENSITY));
22135
+ }
22136
+ function fragmentDrag(mass) {
22137
+ const sphereArea = Math.PI * Math.cbrt(3 * mass / (4 * Math.PI * STEEL_DENSITY)) ** 2;
22138
+ return AIR_DENSITY * DRAG_AREA_FACTOR * sphereArea / (2 * mass);
22139
+ }
22140
+ var BLUNT_FRAGMENT_NOSE = 0.84;
22141
+ var NDRC_CONSTANT = 38e-6;
22142
+ function concretePerforation(input) {
22143
+ const { mass, caliber, speed } = input;
22144
+ if (!(mass > 0) || !(caliber > 0) || !(speed > 0)) return { depth: 0, perforation: 0 };
22145
+ const g = NDRC_CONSTANT * (input.nose ?? BLUNT_FRAGMENT_NOSE) * mass / (caliber * Math.sqrt(input.compressiveMPa * 1e6)) * (speed / caliber) ** 1.8;
22146
+ const relative = g <= 1 ? 2 * Math.sqrt(g) : g + 1;
22147
+ const through = relative <= 1.35 ? 3.19 * relative - 0.718 * relative * relative : 1.32 + 1.24 * relative;
22148
+ return { depth: relative * caliber, perforation: through * caliber };
22149
+ }
22150
+ var FIRE_PRIME_C = 300;
22151
+ var drawChainDelay = (delay, random) => {
22152
+ if (typeof delay === "number") return delay;
22153
+ const [min2, max2] = delay;
22154
+ return min2 + random() * (max2 - min2);
22155
+ };
22156
+ var chainDelayOf = (spec, trigger) => spec.explodes?.chain?.[trigger];
22157
+ var shotDamageFractionOf = (spec) => spec.explodes?.chain?.shotDamageFraction ?? 0;
21781
22158
  var bsp = (root, count, axes, rnd2) => {
21782
22159
  const pieces = [root];
21783
22160
  const vol = (b) => axes.reduce((v, a) => v * b.s[a], 1);
@@ -22058,179 +22435,6 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
22058
22435
  const n = clamp(Math.round(dims[u] * dims[v] / (mean * mean)), 6, maxFragments);
22059
22436
  return radialPlates(inp, root, { t, u, v }, n, Math.min(inp.thickness, dims[t]), fmax * 1.5);
22060
22437
  };
22061
- var planeAxes = (thin) => thin === 1 ? [0, 2] : [thin === 0 ? 2 : 0, 1];
22062
- var unitGrid = (dims, thin, units, cap) => {
22063
- const [u, v] = planeAxes(thin);
22064
- let unitU = Math.min(units.size[0], dims[u]), unitV = Math.min(units.size[1], dims[v]);
22065
- const rowsFor = (h) => Math.ceil(dims[v] / h - 1e-9);
22066
- const colsFor = (w) => Math.ceil(dims[u] / w - 1e-9) + (units.bond === "running" ? 1 : 0);
22067
- const merge = Math.ceil(Math.sqrt(rowsFor(unitV) * colsFor(unitU) / cap));
22068
- if (merge > 1) {
22069
- unitU = Math.min(unitU * merge, dims[u]);
22070
- unitV = Math.min(unitV * merge, dims[v]);
22071
- }
22072
- const cells = [];
22073
- for (let row = 0; row < rowsFor(unitV); row++) {
22074
- const v0 = -dims[v] / 2 + row * unitV, v1 = Math.min(v0 + unitV, dims[v] / 2);
22075
- const shift = units.bond === "running" && row % 2 === 1 ? unitU / 2 : 0;
22076
- for (let col = 0; col < colsFor(unitU); col++) {
22077
- const u0 = Math.max(-dims[u] / 2 + col * unitU - shift, -dims[u] / 2), u1 = Math.min(-dims[u] / 2 + (col + 1) * unitU - shift, dims[u] / 2);
22078
- if (u1 - u0 < 0.01) continue;
22079
- const center = [0, 0, 0], size = [0, 0, 0];
22080
- center[u] = (u0 + u1) / 2;
22081
- center[v] = (v0 + v1) / 2;
22082
- size[u] = u1 - u0;
22083
- size[v] = v1 - v0;
22084
- size[thin] = dims[thin];
22085
- cells.push({ center, size });
22086
- }
22087
- }
22088
- return cells;
22089
- };
22090
- var rowsOfGrid = /* @__PURE__ */ new WeakMap();
22091
- var unitRowsWithin = (cells, thin, point, radius) => {
22092
- const [u, v] = planeAxes(thin);
22093
- if (!Number.isFinite(point[u]) || !Number.isFinite(point[v]) || !Number.isFinite(radius)) return [[0, cells.length]];
22094
- let rows = rowsOfGrid.get(cells);
22095
- if (!rows) {
22096
- const found = [];
22097
- cells.forEach((cell, i) => {
22098
- const last = found[found.length - 1];
22099
- if (last && last.center === cell.center[v] && last.size === cell.size[v]) last.to = i + 1;
22100
- else found.push({ from: i, to: i + 1, center: cell.center[v], size: cell.size[v] });
22101
- });
22102
- rowsOfGrid.set(cells, rows = found);
22103
- }
22104
- const ranges = [];
22105
- for (const row of rows) {
22106
- if (Math.max(0, Math.abs(point[v] - row.center) - row.size / 2) > radius) continue;
22107
- const last = ranges[ranges.length - 1];
22108
- if (last && last[1] === row.from) last[1] = row.to;
22109
- else ranges.push([row.from, row.to]);
22110
- }
22111
- return ranges;
22112
- };
22113
- var planeDistance = (cell, thin, point) => {
22114
- const [u, v] = planeAxes(thin);
22115
- const du = cell.center[u] - point[u], dv = cell.center[v] - point[v];
22116
- return Math.sqrt(du * du + dv * dv);
22117
- };
22118
- var cellsWithin = (cells, thin, point, radius) => {
22119
- const inside3 = cells.filter((c) => planeDistance(c, thin, point) <= radius);
22120
- if (inside3.length > 0 || cells.length === 0) return inside3;
22121
- return [cells.reduce((best, c) => planeDistance(c, thin, point) < planeDistance(best, thin, point) ? c : best)];
22122
- };
22123
- var cellsOutside = (cells, thin, point, radius) => cells.filter((c) => planeDistance(c, thin, point) > radius);
22124
- var MAX_MARKS_PER_FRAGMENT = 12;
22125
- var marksInBox = (center, size, rotation2, holes) => {
22126
- const inverse = rotation2 ? quat.conjugate(rotation2) : void 0;
22127
- const marks = [];
22128
- for (const hole of holes) {
22129
- const offset = [hole.point[0] - center[0], hole.point[1] - center[1], hole.point[2] - center[2]];
22130
- const point = inverse ? rotateVec(inverse, offset) : offset;
22131
- const inside3 = point.every((value, k) => Math.abs(value) <= size[k] / 2 + hole.diameter / 2);
22132
- if (!inside3) continue;
22133
- marks.push({ point, normal: inverse ? rotateVec(inverse, hole.normal) : hole.normal, diameter: hole.diameter });
22134
- if (marks.length >= MAX_MARKS_PER_FRAGMENT) break;
22135
- }
22136
- return marks;
22137
- };
22138
- var rowLayouts = /* @__PURE__ */ new WeakMap();
22139
- var rowLayoutOf = (cells, thin, bottom) => {
22140
- const known = rowLayouts.get(cells);
22141
- if (known && known.thin === thin && known.bottom === bottom && known.count === cells.length) return known;
22142
- const [u, v] = planeAxes(thin);
22143
- const keys = cells.map((cell) => Math.round((cell.center[v] - cell.size[v] / 2 - bottom) * 1e4));
22144
- const alongOrder = cells.map((_, i) => i).sort((a, b) => cells[a].center[u] - cells[b].center[u]);
22145
- const layout = { thin, bottom, count: cells.length, keys, alongOrder };
22146
- rowLayouts.set(cells, layout);
22147
- return layout;
22148
- };
22149
- var holeInBox = (center, size, hole) => {
22150
- for (let k = 0; k < 3; k++) if (!(Math.abs(hole.point[k] - center[k]) <= size[k] / 2 + hole.diameter / 2)) return false;
22151
- return true;
22152
- };
22153
- var JOINT_GAP = 1e-4;
22154
- var MIN_BEARING_SHARE = 0.25;
22155
- var unsupportedCells = (cells, thin, dims, standing) => {
22156
- if (thin === 1) return [];
22157
- const [u, v] = planeAxes(thin);
22158
- const bottom = -dims[v] / 2;
22159
- const layout = rowLayoutOf(cells, thin, bottom);
22160
- const rows = /* @__PURE__ */ new Map();
22161
- const isStanding = new Uint8Array(cells.length);
22162
- for (let i = 0; i < cells.length; i++) {
22163
- if (!standing(i)) continue;
22164
- isStanding[i] = 1;
22165
- const key2 = layout.keys[i];
22166
- if (!rows.has(key2)) rows.set(key2, []);
22167
- }
22168
- for (const i of layout.alongOrder) if (isStanding[i] === 1) rows.get(layout.keys[i]).push(i);
22169
- const rowOf = (y) => Math.round((y - bottom) * 1e4);
22170
- const held = /* @__PURE__ */ new Set();
22171
- const queue = [];
22172
- for (const i of rows.get(0) ?? []) {
22173
- held.add(i);
22174
- queue.push(i);
22175
- }
22176
- const overlap = (a, b) => Math.min(a.center[u] + a.size[u] / 2, b.center[u] + b.size[u] / 2) - Math.max(a.center[u] - a.size[u] / 2, b.center[u] - b.size[u] / 2);
22177
- const climb = () => {
22178
- while (queue.length > 0) {
22179
- const cell = cells[queue.pop()];
22180
- for (const j of rows.get(rowOf(cell.center[v] + cell.size[v] / 2)) ?? []) {
22181
- const other = cells[j];
22182
- if (held.has(j) || overlap(cell, other) <= Math.max(JOINT_GAP, MIN_BEARING_SHARE * Math.min(cell.size[u], other.size[u]))) continue;
22183
- held.add(j);
22184
- queue.push(j);
22185
- }
22186
- }
22187
- };
22188
- const touching = (a, b) => Math.abs(a.center[u] + a.size[u] / 2 - (b.center[u] - b.size[u] / 2)) <= 1e-3;
22189
- for (let wedged = true; wedged; ) {
22190
- climb();
22191
- wedged = false;
22192
- for (const row of rows.values()) {
22193
- for (let k = 1; k < row.length - 1; k++) {
22194
- const i = row[k];
22195
- if (held.has(i) || !held.has(row[k - 1]) || !held.has(row[k + 1])) continue;
22196
- if (!touching(cells[row[k - 1]], cells[i]) || !touching(cells[i], cells[row[k + 1]])) continue;
22197
- held.add(i);
22198
- queue.push(i);
22199
- wedged = true;
22200
- }
22201
- }
22202
- }
22203
- const loose = [];
22204
- for (const row of rows.values()) for (const i of row) if (!held.has(i)) loose.push(i);
22205
- return loose;
22206
- };
22207
- var clumpUnits = (cells, thin, unit, cap) => {
22208
- if (cells.length <= cap) return [...cells];
22209
- const [u, v] = planeAxes(thin);
22210
- let lo0 = Infinity, lo1 = Infinity;
22211
- for (const cell of cells) {
22212
- lo0 = Math.min(lo0, cell.center[u] - cell.size[u] / 2);
22213
- lo1 = Math.min(lo1, cell.center[v] - cell.size[v] / 2);
22214
- }
22215
- let along3 = 1, up = 1;
22216
- for (let grow2 = 0; ; grow2++) {
22217
- const bins = /* @__PURE__ */ new Map();
22218
- for (const cell of cells) {
22219
- const key2 = `${Math.floor((cell.center[u] - lo0) / (along3 * unit[0]))}:${Math.floor((cell.center[v] - lo1) / (up * unit[1]))}`;
22220
- const bin2 = bins.get(key2) ?? { lo: [Infinity, Infinity, Infinity], hi: [-Infinity, -Infinity, -Infinity] };
22221
- for (let k = 0; k < 3; k++) {
22222
- bin2.lo[k] = Math.min(bin2.lo[k], cell.center[k] - cell.size[k] / 2);
22223
- bin2.hi[k] = Math.max(bin2.hi[k], cell.center[k] + cell.size[k] / 2);
22224
- }
22225
- bins.set(key2, bin2);
22226
- }
22227
- if (bins.size <= cap) {
22228
- return [...bins.values()].map(({ lo, hi }) => ({ center: [(lo[0] + hi[0]) / 2, (lo[1] + hi[1]) / 2, (lo[2] + hi[2]) / 2], size: [hi[0] - lo[0], hi[1] - lo[1], hi[2] - lo[2]] }));
22229
- }
22230
- if (grow2 % 2 === 0) up++;
22231
- else along3++;
22232
- }
22233
- };
22234
22438
  function put(out, at4, value) {
22235
22439
  if (at4 < out.length) out[at4] = value;
22236
22440
  else out.push(value);
@@ -22360,66 +22564,6 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
22360
22564
  }
22361
22565
  };
22362
22566
  }
22363
- var MAX_SPALLS = 64;
22364
- var thinAxisOf = (dims) => dims[0] <= dims[1] && dims[0] <= dims[2] ? 0 : dims[1] <= dims[2] ? 1 : 2;
22365
- var resolveLayer = (def, index, mat) => ({ index, def, mat, energy: mat.penetration * def.thickness * 1e3 });
22366
- var faceCode = (thin, axis2, sign2) => {
22367
- const [u] = planeAxes(thin);
22368
- return (sign2 >= 0 ? 1 : -1) * (axis2 === thin ? 1 : axis2 === u ? 2 : 3);
22369
- };
22370
- var faceAxis = (thin, face) => {
22371
- const k = Math.abs(face);
22372
- return k === 1 ? thin : planeAxes(thin)[k - 2];
22373
- };
22374
- var faceOfNormal = (layers, thin, localNormal) => {
22375
- if (!layers.some((l) => l.def.faces === "all")) return localNormal[thin] >= 0 ? 1 : -1;
22376
- let axis2 = thin;
22377
- for (let k = 0; k < 3; k++) if (Math.abs(localNormal[k]) > Math.abs(localNormal[axis2])) axis2 = k;
22378
- return faceCode(thin, axis2, localNormal[axis2]);
22379
- };
22380
- var onFace = (layer3, face) => {
22381
- const faces = layer3.def.faces;
22382
- if (faces === "all") return true;
22383
- if (Math.abs(face) !== 1) return false;
22384
- return faces === "both" || faces === (face > 0 ? "+" : "-");
22385
- };
22386
- var thinSidesOf = (def) => def.faces === "both" || def.faces === "all" ? [1, -1] : [def.faces === "+" ? 1 : -1];
22387
- var isSpalled = (spalls, layer3, face, point) => {
22388
- for (const s of spalls ?? []) {
22389
- if (s[0] !== layer3 || s[1] !== face) continue;
22390
- const dx = s[2] - point[0], dy = s[3] - point[1], dz = s[4] - point[2];
22391
- if (dx * dx + dy * dy + dz * dz <= s[5] * s[5]) return true;
22392
- }
22393
- return false;
22394
- };
22395
- var outerLayer = (layers, spalls, face, point) => layers.find((l) => onFace(l, face) && !isSpalled(spalls, l.index, face, point));
22396
- var layersEnergy = (layers, spalls, face, point) => {
22397
- let sum2 = 0;
22398
- for (const l of layers) if (onFace(l, face) && !isSpalled(spalls, l.index, face, point)) sum2 += l.energy;
22399
- return sum2;
22400
- };
22401
- var layersThickness = (layers, face) => {
22402
- let sum2 = 0;
22403
- for (const l of layers) if (onFace(l, face)) sum2 += l.def.thickness;
22404
- return sum2;
22405
- };
22406
- var tornPatchAt = (layers, spalls, face, point, radius) => {
22407
- for (const l of layers) {
22408
- if (!onFace(l, face)) continue;
22409
- if (l.mat.fracture === "tear") {
22410
- let best = -1;
22411
- (spalls ?? []).forEach((s, i) => {
22412
- if (s[0] !== l.index || s[1] !== face) return;
22413
- const dx = s[2] - point[0], dy = s[3] - point[1], dz = s[4] - point[2];
22414
- const reach2 = s[5] + radius;
22415
- if (dx * dx + dy * dy + dz * dz <= reach2 * reach2 && (best < 0 || s[5] > spalls[best][5])) best = i;
22416
- });
22417
- if (best >= 0) return { layer: l, spall: best };
22418
- }
22419
- if (!isSpalled(spalls, l.index, face, point)) return void 0;
22420
- }
22421
- return void 0;
22422
- };
22423
22567
  var REBAR_COVER = 0.03;
22424
22568
  var COVER = REBAR_COVER;
22425
22569
  var MAX_BARS_PER_DIRECTION = 24;
@@ -22580,12 +22724,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
22580
22724
  var steelMoment = (area3, yieldMPa, d, b, compressiveMPa, options = {}) => {
22581
22725
  if (area3 <= 0 || d <= 0 || b <= 0) return 0;
22582
22726
  const T2 = area3 * yieldMPa * MPA;
22583
- const block = 0.68 * compressiveMPa * MPA * b;
22584
- const x = T2 / block;
22727
+ const block2 = 0.68 * compressiveMPa * MPA * b;
22728
+ const x = T2 / block2;
22585
22729
  const xl = (options.neutralAxisLimit ?? FLEXURE_DEFAULTS.neutralAxisLimit) * d;
22586
22730
  if (x <= xl) return T2 * (d - 0.4 * x);
22587
22731
  const top = Math.min(d / 2, (options.cover ?? FLEXURE_DEFAULTS.cover) + RATIO_BAR / 2);
22588
- return block * xl * (d - 0.4 * xl) + (T2 - block * xl) * (d - top);
22732
+ return block2 * xl * (d - 0.4 * xl) + (T2 - block2 * xl) * (d - top);
22589
22733
  };
22590
22734
  var spanStiffness = (EI, span) => 384 * EI / (5 * span ** 3);
22591
22735
  var elasticEnergy = (moment, span, EI, loadFactor = FLEXURE_DEFAULTS.loadFactor) => {
@@ -23142,19 +23286,31 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23142
23286
  var clampNumber = (v, a, b) => Math.max(a, Math.min(b, v));
23143
23287
  var settlementAt = (settlement, point) => {
23144
23288
  const d = [settlement.to[0] - settlement.from[0], settlement.to[1] - settlement.from[1], settlement.to[2] - settlement.from[2]];
23289
+ const px = point[0] - settlement.from[0];
23290
+ const py = point[1] - settlement.from[1];
23291
+ const pz = point[2] - settlement.from[2];
23145
23292
  const length2 = d[0] * d[0] + d[1] * d[1] + d[2] * d[2];
23146
- const t = length2 > 0 ? clampNumber(((point[0] - settlement.from[0]) * d[0] + (point[1] - settlement.from[1]) * d[1] + (point[2] - settlement.from[2]) * d[2]) / length2, 0, 1) : 0;
23293
+ const along3 = length2 > 0 ? (px * d[0] + py * d[1] + pz * d[2]) / length2 : 0;
23294
+ const t = clampNumber(along3, 0, 1);
23147
23295
  const drops = settlement.drop;
23148
23296
  if (drops.length === 0) return 0;
23149
23297
  const at4 = t * (drops.length - 1);
23150
23298
  const i = Math.floor(at4);
23151
23299
  const j = Math.min(drops.length - 1, i + 1);
23152
- return drops[i] + (drops[j] - drops[i]) * (at4 - i);
23300
+ const f = at4 - i;
23301
+ const drop = drops[i] + (drops[j] - drops[i]) * f;
23302
+ const turn2 = settlement.turn;
23303
+ if (!turn2 || turn2.length !== drops.length) return drop;
23304
+ const a = turn2[i];
23305
+ const b = turn2[j];
23306
+ const armX = px - d[0] * along3;
23307
+ const armZ = pz - d[2] * along3;
23308
+ return drop - ((a[2] + (b[2] - a[2]) * f) * armX - (a[0] + (b[0] - a[0]) * f) * armZ);
23153
23309
  };
23154
23310
  var mergeSettlement = (old, next) => {
23155
23311
  if (!old) return next;
23156
23312
  const same = old.from.every((v, k) => Math.abs(v - next.from[k]) < 1e-6) && old.to.every((v, k) => Math.abs(v - next.to[k]) < 1e-6);
23157
- if (same && old.drop.length === next.drop.length) return { from: old.from, to: old.to, drop: old.drop.map((v, k) => Math.max(v, next.drop[k])) };
23313
+ if (same && old.drop.length === next.drop.length && !old.turn && !next.turn) return { from: old.from, to: old.to, drop: old.drop.map((v, k) => Math.max(v, next.drop[k])) };
23158
23314
  const mean = (line) => line.drop.reduce((sum2, v) => sum2 + v, 0) / Math.max(1, line.drop.length);
23159
23315
  return mean(old) >= mean(next) ? old : next;
23160
23316
  };
@@ -23533,6 +23689,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23533
23689
  var materials_default = [
23534
23690
  {
23535
23691
  id: "steel",
23692
+ splitForm: "sheets",
23536
23693
  density: 7850,
23537
23694
  hpPerKg: 400,
23538
23695
  penetration: 110,
@@ -23656,6 +23813,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23656
23813
  },
23657
23814
  {
23658
23815
  id: "aluminium",
23816
+ splitForm: "sheets",
23659
23817
  density: 2700,
23660
23818
  hpPerKg: 250,
23661
23819
  penetration: 60,
@@ -23695,6 +23853,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23695
23853
  },
23696
23854
  {
23697
23855
  id: "copper",
23856
+ splitForm: "sheets",
23698
23857
  density: 8960,
23699
23858
  hpPerKg: 300,
23700
23859
  penetration: 70,
@@ -23883,7 +24042,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23883
24042
  tearJoules: 80
23884
24043
  }
23885
24044
  },
23886
- failureMPa: 40
24045
+ failureMPa: 40,
24046
+ elastic: {
24047
+ alongGPa: 6.96,
24048
+ shearGPa: 0.44
24049
+ }
23887
24050
  },
23888
24051
  {
23889
24052
  id: "mdf",
@@ -23930,7 +24093,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23930
24093
  tearJoules: 20
23931
24094
  }
23932
24095
  },
23933
- failureMPa: 25
24096
+ failureMPa: 25,
24097
+ elastic: {
24098
+ alongGPa: 3,
24099
+ shearGPa: 0.8
24100
+ }
23934
24101
  },
23935
24102
  {
23936
24103
  id: "glass",
@@ -24189,6 +24356,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24189
24356
  },
24190
24357
  {
24191
24358
  id: "plastic",
24359
+ splitForm: "plates",
24192
24360
  density: 1100,
24193
24361
  hpPerKg: 60,
24194
24362
  penetration: 8,
@@ -24223,6 +24391,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24223
24391
  },
24224
24392
  {
24225
24393
  id: "rubber",
24394
+ splitForm: "strips",
24226
24395
  density: 1100,
24227
24396
  hpPerKg: 80,
24228
24397
  penetration: 12,
@@ -24255,6 +24424,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24255
24424
  },
24256
24425
  {
24257
24426
  id: "fabric",
24427
+ splitForm: "strips",
24258
24428
  density: 400,
24259
24429
  hpPerKg: 20,
24260
24430
  penetration: 0.8,
@@ -24352,6 +24522,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24352
24522
  },
24353
24523
  {
24354
24524
  id: "leather",
24525
+ splitForm: "strips",
24355
24526
  density: 900,
24356
24527
  hpPerKg: 50,
24357
24528
  penetration: 4,
@@ -24388,6 +24559,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24388
24559
  },
24389
24560
  {
24390
24561
  id: "paper",
24562
+ splitForm: "strips",
24391
24563
  density: 700,
24392
24564
  hpPerKg: 8,
24393
24565
  penetration: 0.3,
@@ -25316,21 +25488,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
25316
25488
  const r = [x[0], y[0], z[0], x[1], y[1], z[1], x[2], y[2], z[2]];
25317
25489
  const half = new Float64Array(n * n);
25318
25490
  const out = new Float64Array(n * n);
25319
- for (let block = 0; block < n; block += 3) {
25491
+ for (let block2 = 0; block2 < n; block2 += 3) {
25320
25492
  for (let col = 0; col < n; col++) {
25321
25493
  for (let i = 0; i < 3; i++) {
25322
25494
  let sum2 = 0;
25323
- for (let m = 0; m < 3; m++) sum2 += r[i * 3 + m] * k[(block + m) * n + col];
25324
- half[(block + i) * n + col] = sum2;
25495
+ for (let m = 0; m < 3; m++) sum2 += r[i * 3 + m] * k[(block2 + m) * n + col];
25496
+ half[(block2 + i) * n + col] = sum2;
25325
25497
  }
25326
25498
  }
25327
25499
  }
25328
25500
  for (let row = 0; row < n; row++) {
25329
- for (let block = 0; block < n; block += 3) {
25501
+ for (let block2 = 0; block2 < n; block2 += 3) {
25330
25502
  for (let i = 0; i < 3; i++) {
25331
25503
  let sum2 = 0;
25332
- for (let m = 0; m < 3; m++) sum2 += half[row * n + block + m] * r[i * 3 + m];
25333
- out[row * n + block + i] = sum2;
25504
+ for (let m = 0; m < 3; m++) sum2 += half[row * n + block2 + m] * r[i * 3 + m];
25505
+ out[row * n + block2 + i] = sum2;
25334
25506
  }
25335
25507
  }
25336
25508
  }
@@ -25466,17 +25638,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
25466
25638
  const index = shape.placeOf(i, j);
25467
25639
  k[index] = k[index] + value;
25468
25640
  }
25469
- function halfQuadratic(shape, k, x) {
25641
+ function multiply2(shape, k, x, out) {
25470
25642
  const { n, start, rows } = shape;
25471
- let total = 0;
25643
+ for (let j = 0; j < n; j++) out[j] = k[j] * x[j];
25472
25644
  for (let j = 0; j < n; j++) {
25473
25645
  const xj = x[j];
25474
- if (xj === 0) continue;
25475
- let column = 0.5 * k[j] * xj;
25476
- for (let p = start[j]; p < start[j + 1]; p++) column += k[n + p] * x[rows[p]];
25477
- total += xj * column;
25646
+ for (let p = start[j]; p < start[j + 1]; p++) {
25647
+ const i = rows[p];
25648
+ const value = k[n + p];
25649
+ out[i] = out[i] + value * xj;
25650
+ out[j] = out[j] + value * x[i];
25651
+ }
25478
25652
  }
25479
- return total;
25480
25653
  }
25481
25654
  function factor(shape, k, from, to) {
25482
25655
  const { n, start, rows, beforeStart, before } = shape;
@@ -25530,7 +25703,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
25530
25703
  placeOf: (i, j) => placeOf(shape, i, j),
25531
25704
  factor: (k, from, to) => factor(shape, k, from, to),
25532
25705
  substitute: (k, f) => substitute(shape, k, f),
25533
- halfQuadratic: (k, x) => halfQuadratic(shape, k, x)
25706
+ multiply: (k, x, out) => multiply2(shape, k, x, out)
25534
25707
  };
25535
25708
  };
25536
25709
  function hullOf(points) {
@@ -25718,7 +25891,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
25718
25891
  const delta = new Float64Array(n);
25719
25892
  for (let i = 0; i < n; i++) delta[i] = after2.u[i] - before.u[i];
25720
25893
  for (const beam of beams.values()) if (!after2.standing.has(beam.part.id)) for (const node of beam.nodes) for (const dof of dofsOf(node)) delta[dof] = 0;
25721
- released = frame2.shape.halfQuadratic(after2.k, delta);
25894
+ const d = new Float64Array(n);
25895
+ for (let i = 0; i < n; i++) d[i] = -delta[i];
25896
+ const kd = new Float64Array(n);
25897
+ frame2.shape.multiply(after2.structure, d, kd);
25898
+ const ku = new Float64Array(n);
25899
+ frame2.shape.multiply(after2.structure, after2.u, ku);
25900
+ let change = 0;
25901
+ for (let i = 0; i < n; i++) change += d[i] * (0.5 * kd[i] + (ku[i] - after2.load[i]));
25902
+ released = Math.max(0, change);
25722
25903
  spin = spinOf({ frame: frame2, after: after2, delta, released, centre: allCentre, mass: all, floor: floor2, g });
25723
25904
  }
25724
25905
  return {
@@ -25742,12 +25923,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
25742
25923
  const from = vec.madd(beam.part.position, beam.axis, -beam.length / 2);
25743
25924
  const to = vec.madd(beam.part.position, beam.axis, beam.length / 2);
25744
25925
  const drop = [];
25926
+ const turn2 = [];
25745
25927
  for (let i = 0; i < SAG_STATIONS; i++) {
25746
25928
  const point = vec.madd(from, beam.axis, beam.length * i / (SAG_STATIONS - 1));
25747
25929
  const node = carrier ? carrier.node : nearest(beam, point);
25748
25930
  drop.push(-moved(after2, { part: id, node, arm: vec.sub(point, nodes[node].at), mass: 0 })[1]);
25931
+ const base2 = order2[node] * 6;
25932
+ turn2.push([after2.u[base2 + 3], after2.u[base2 + 4], after2.u[base2 + 5]]);
25749
25933
  }
25750
- return { from, to, drop };
25934
+ return { from, to, drop, turn: turn2 };
25751
25935
  }
25752
25936
  };
25753
25937
  }
@@ -25941,8 +26125,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
25941
26125
  if (worst > MECHANISM) return null;
25942
26126
  const holding = feet.filter((_, index) => holds3[index]);
25943
26127
  if (holding.length < 3) return null;
25944
- build(structure);
25945
- return { u: u.slice(), k: k.slice(), holding, masses, standing };
26128
+ return { u: u.slice(), structure, load: f, holding, masses, standing };
25946
26129
  }
25947
26130
  return null;
25948
26131
  }
@@ -26171,7 +26354,6 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
26171
26354
  var TEAR_JOULES = 150;
26172
26355
  var STRIP_THICKNESS = 15e-4;
26173
26356
  var UNIT_FRAGMENT_FACTOR = 4;
26174
- var BREACH_GRID_CAP = 4096;
26175
26357
  var MASONRY_CRUMBLE_SPEED = 0.6;
26176
26358
  var MASONRY_TOPPLE = 0.4;
26177
26359
  var MASONRY_TOPPLE_MIN_HEIGHT = 0.5;
@@ -27948,6 +28130,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27948
28130
  } else emit2({ ...base2(o, src), type: "stage", part: p.spec.id, stage: 2, opening: { center: worldCenter, radius: hole.radius }, fragments });
27949
28131
  debris2(o, p, p.mat.breakDebris, worldCenter, [0, 1, 0], 14, 2, src);
27950
28132
  if (p.spec.reinforcement) exposeRebar(o, p, src);
28133
+ dropOverOpening(o, p, src);
27951
28134
  };
27952
28135
  const distort = (o, q, beta, at4, toward2, src) => {
27953
28136
  const prior = q.rt.distortion ?? 0;
@@ -29189,7 +29372,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29189
29372
  const faceArea = (cell) => cell.size[u] * cell.size[v];
29190
29373
  const total = cells.reduce((sum2, cell) => sum2 + faceArea(cell), 0) || 1;
29191
29374
  const shape = p.spec.units ? "chunk" : FRAGMENT_SHAPE[p.mat.fracture] ?? "chunk";
29192
- const laid = !!p.spec.units && p.spec.units.mortar !== p.spec.material;
29375
+ const laid2 = !!p.spec.units && p.spec.units.mortar !== p.spec.material;
29193
29376
  const pieces = shape === "shard" && bondedPlate(o, p) ? cells.flatMap((cell) => shardsOfCell(cell, u, v)) : cells;
29194
29377
  return pieces.map((cell, i) => {
29195
29378
  const cw = toWorld(c, q, cell.center);
@@ -29198,7 +29381,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29198
29381
  const k = speed * (0.6 + 0.8 * rnd2());
29199
29382
  const marks = marksInBox(cell.center, cell.size, void 0, holes);
29200
29383
  const size = [cell.size[0], cell.size[1], cell.size[2]];
29201
- if (laid) for (const a of [u, v]) size[a] = Math.max(size[a] * MIN_UNIT_SHARE, size[a] - MORTAR_JOINT);
29384
+ if (laid2) for (const a of [u, v]) size[a] = Math.max(size[a] * MIN_UNIT_SHARE, size[a] - MORTAR_JOINT);
29202
29385
  return {
29203
29386
  id: `${p.spec.id}#${tag}${i}`,
29204
29387
  part: p.spec.id,
@@ -29211,7 +29394,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29211
29394
  angularVelocity: bornSpin(cell.size, 8, rnd2),
29212
29395
  mass: mass * faceArea(cell) / total,
29213
29396
  ...marks.length > 0 ? { marks } : {},
29214
- ...inner && laid ? { unit: true } : inner ? { inner } : {}
29397
+ ...inner && laid2 ? { unit: true } : inner ? { inner } : {}
29215
29398
  };
29216
29399
  });
29217
29400
  };
@@ -29622,7 +29805,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29622
29805
  if (p.st.stripped) bars = [...bars, ...stirrups];
29623
29806
  else for (const box5 of [...p.st.chipped ?? [], ...p.rt.bared ?? []]) bars.push(...clipBarsToVolume(stirrups, box5.center, box5.size));
29624
29807
  }
29625
- emit2({ ...base2(o, src), type: "expose", part: p.spec.id, bars: worldBars(o, p, bars) });
29808
+ emit2({ ...base2(o, src), type: "expose", part: p.spec.id, bars: worldBars(o, p, belowCut(p, bars)) });
29809
+ };
29810
+ const belowCut = (p, bars) => {
29811
+ const cut = p.rt.cutThrough;
29812
+ if (cut === void 0) return bars.map(([a, b]) => [a, b]);
29813
+ const height = (x) => p.pos[1] + rotateVec(p.q, x)[1];
29814
+ return bars.flatMap(([a, b]) => {
29815
+ const ha = height(a) - cut, hb = height(b) - cut;
29816
+ if (ha <= 0 && hb <= 0) return [[a, b]];
29817
+ if (ha > 0 && hb > 0) return [];
29818
+ const at4 = vec.add(a, vec.scale(vec.sub(b, a), ha / (ha - hb)));
29819
+ return [ha <= 0 ? [a, at4] : [at4, b]];
29820
+ });
29626
29821
  };
29627
29822
  const openBreach = (o, p, center, total, energy, dir, src) => {
29628
29823
  const [u, v] = planeAxes(p.thin);
@@ -29651,6 +29846,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29651
29846
  setStage(o, p, 2, { opening: { center: worldCenter, radius }, fragments }, src);
29652
29847
  debris2(o, p, p.mat.breakDebris, worldCenter, vec.scale(dir ?? [0, 1, 0], -1), 14, 3, src);
29653
29848
  dropUnsupported(o, p, src);
29849
+ dropOverOpening(o, p, src);
29654
29850
  const reinforcement = p.spec.reinforcement;
29655
29851
  if (reinforcement) exposeRebar(o, p, src);
29656
29852
  if (p.structural) solveStructure(o);
@@ -29789,7 +29985,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29789
29985
  for (const i of out) worn[i] = -1;
29790
29986
  return knockOutUnits(o, p, point, energy, out, src);
29791
29987
  };
29792
- const knockOutUnits = (o, p, wp, energy, out, src, d, drive = CHIP_DRIVE) => {
29988
+ const knockOutUnits = (o, p, wp, energy, out, src, d, drive = CHIP_DRIVE, severed) => {
29793
29989
  var _a, _b;
29794
29990
  const [u, v] = planeAxes(p.thin);
29795
29991
  const op = p.st.opening ? toLocal(p.pos, p.q, p.st.opening.center) : null;
@@ -29834,7 +30030,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29834
30030
  setStage(o, p, 1, {}, src);
29835
30031
  const center = toWorld(c, q, [(lo[0] + hi[0]) / 2, (lo[1] + hi[1]) / 2, (lo[2] + hi[2]) / 2]);
29836
30032
  const units = cells.map((cell) => ({ center: toWorld(c, q, cell.center), size: [cell.size[0], cell.size[1], cell.size[2]] }));
29837
- 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 });
30033
+ 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, ...severed ? { severed } : {} });
29838
30034
  debris2(o, p, p.mat.breakDebris, center, vec.normalize(vec.sub(center, wp), [0, 1, 0]), 14, 3, src);
29839
30035
  const cut = wornLocally(p) && cutBandsGone(o, p, cells, d ?? vec.normalize(vec.sub(partXf(o, p).c, wp), [1, 0, 0]), src);
29840
30036
  if (p.spec.reinforcement && !cut) exposeRebar(o, p, src);
@@ -29854,15 +30050,50 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29854
30050
  const grid = gridOf(p);
29855
30051
  const gone = p.rt.chips ?? {};
29856
30052
  const worn = (_a = p.rt).bands ?? (_a.bands = {});
30053
+ const [u, v] = [0, 1, 2].filter((k) => k !== along3);
30054
+ const standing = (band) => grid.filter((cell, i) => gone[i] !== -1 && bandOf2(cell.center[along3]) === band);
30055
+ const bearOn = (a, b) => Math.abs(a.center[u] - b.center[u]) < (a.size[u] + b.size[u]) / 2 - 1e-6 && Math.abs(a.center[v] - b.center[v]) < (a.size[v] + b.size[v]) / 2 - 1e-6;
29857
30056
  for (const band of new Set(cells.map((cell) => bandOf2(cell.center[along3])))) {
29858
30057
  if ((worn[band] ?? 0) >= 1) continue;
30058
+ const left = standing(band);
29859
30059
  const center = -p.dims[along3] / 2 + (band + 0.5) * height;
29860
- if (!grid.every((cell, i) => gone[i] === -1 || Math.abs(cell.center[along3] - center) > height / 2 + 1e-6)) continue;
29861
- worn[band] = 1;
29862
- return giveAtCut(o, p, src, { at: alongAt(along3, center), d });
30060
+ if (left.length === 0) {
30061
+ worn[band] = 1;
30062
+ return giveAtCut(o, p, src, { at: alongAt(along3, center), d });
30063
+ }
30064
+ for (const next of [band - 1, band + 1]) {
30065
+ if (next < 0 || next >= bands || (worn[next] ?? 0) >= 1) continue;
30066
+ const beyond = standing(next);
30067
+ if (beyond.length === 0 || left.some((a) => beyond.some((b) => bearOn(a, b)))) continue;
30068
+ worn[band] = 1;
30069
+ worn[next] = 1;
30070
+ return giveAtCut(o, p, src, { at: alongAt(along3, (center + (-p.dims[along3] / 2 + (next + 0.5) * height)) / 2), d });
30071
+ }
29863
30072
  }
29864
30073
  return false;
29865
30074
  };
30075
+ const bedOverHoles = (o, p, grid) => {
30076
+ const bases = (o.byPart.get(p.spec.id) ?? []).filter((j) => j.bears === "a_on_b" && j.spec.a === p.spec.id && !j.st.open).map((j) => o.parts[j.ib]).filter((q) => !!q.st.opening);
30077
+ if (bases.length === 0) return void 0;
30078
+ const [, v] = planeAxes(p.thin);
30079
+ const bed = [0, 0, 0];
30080
+ return (i) => {
30081
+ const cell = grid[i];
30082
+ bed[0] = cell.center[0];
30083
+ bed[1] = cell.center[1];
30084
+ bed[2] = cell.center[2];
30085
+ bed[v] = cell.center[v] - cell.size[v] / 2;
30086
+ const at4 = toWorld(p.pos, p.q, bed);
30087
+ return !bases.some((q) => insideOpening(o, q, at4));
30088
+ };
30089
+ };
30090
+ const dropOverOpening = (o, q, src) => {
30091
+ for (const j of o.byPart.get(q.spec.id) ?? []) {
30092
+ if (j.bears !== "a_on_b" || j.spec.b !== q.spec.id || j.st.open) continue;
30093
+ const p = o.parts[j.ia];
30094
+ if (p.spec.units && !isLost(p)) dropUnsupported(o, p, src);
30095
+ }
30096
+ };
29866
30097
  const dropUnsupported = (o, p, src) => {
29867
30098
  var _a, _b;
29868
30099
  if (!p.spec.units || p.spec.units.mortar === p.spec.material || p.st.stripped || isLost(p)) return 0;
@@ -29872,7 +30103,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29872
30103
  const op = p.st.opening ? toLocal(p.pos, p.q, p.st.opening.center) : null;
29873
30104
  const opened = (cell) => !!op && !!p.st.opening && Math.hypot(cell.center[u] - op[u], cell.center[v] - op[v]) <= p.st.opening.radius;
29874
30105
  const castHere = castCells(p);
29875
- const loose = wedgedUnder(o, p, unsupportedCells(grid, p.thin, p.dims, (i) => worn[i] !== -1 && !opened(grid[i]))).filter((i) => !castHere.has(i));
30106
+ const loose = wedgedUnder(o, p, unsupportedCells(grid, p.thin, p.dims, (i) => worn[i] !== -1 && !opened(grid[i]), bedOverHoles(o, p, grid))).filter((i) => !castHere.has(i));
29876
30107
  if (loose.length === 0) return 0;
29877
30108
  for (const i of loose) worn[i] = -1;
29878
30109
  const fallen = loose.map((i) => grid[i]);
@@ -30022,7 +30253,26 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30022
30253
  const at4 = vec.madd(origin, d, s * vec.length(d));
30023
30254
  debris2(o, p, "sparks", at4, vec.scale(d, -1), 6, 3, src);
30024
30255
  });
30025
- if (severed > 0) reyield(o, p, barsMoment(p), src);
30256
+ if (severed === 0) return;
30257
+ reyield(o, p, barsMoment(p), src);
30258
+ if (barsMoment(p) <= 0) dropAboveCut(o, p, origin, src);
30259
+ };
30260
+ const dropAboveCut = (o, p, wp, src) => {
30261
+ const cut = p.rt.hinges?.reduce((low, h) => Math.min(low, h.point[1]), Infinity) ?? Infinity;
30262
+ if (!Number.isFinite(cut)) return;
30263
+ const gone = p.rt.chips ?? {};
30264
+ const grid = gridOf(p);
30265
+ const above2 = grid.flatMap((cell, i) => gone[i] !== -1 && vec.add(p.pos, rotateVec(p.q, cell.center))[1] > cut ? [i] : []);
30266
+ if (above2.length === 0) return;
30267
+ const ax = [rotateVec(p.q, [1, 0, 0])[1], rotateVec(p.q, [0, 1, 0])[1], rotateVec(p.q, [0, 0, 1])[1]];
30268
+ const floor2 = Math.min(...above2.map((i) => {
30269
+ const cell = grid[i];
30270
+ return vec.add(p.pos, rotateVec(p.q, cell.center))[1] - (Math.abs(ax[0]) * cell.size[0] + Math.abs(ax[1]) * cell.size[1] + Math.abs(ax[2]) * cell.size[2]) / 2;
30271
+ }));
30272
+ p.rt.cutThrough = floor2;
30273
+ const severed = { point: toWorld(o.st.position, o.st.rotation, [p.pos[0], floor2, p.pos[2]]), normal: rotateVec(o.st.rotation, [0, 1, 0]) };
30274
+ knockOutUnits(o, p, wp, 0, above2, src, [0, -1, 0], 0, severed);
30275
+ exposeRebar(o, p, src);
30026
30276
  };
30027
30277
  const giveAtCut = (o, p, src, cut) => {
30028
30278
  if (!p.spec.reinforcement || !p.spec.units || !p.st.chipped?.length || sectionLoss(p) <= 0) return false;
@@ -30116,7 +30366,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30116
30366
  const unitPlan = p.spec.units ? unitFragmentPlan(p, maxFragments * UNIT_FRAGMENT_FACTOR) : [];
30117
30367
  const axis2 = style === "splinter" || style === "snap" ? severAxis(p) : -1;
30118
30368
  const cutAt3 = axis2 < 0 ? void 0 : p.rt.cutAt ?? (origin ? hitLocal[axis2] : void 0);
30119
- const planRnd = p.mat.splitForm ? splitStream(o.id, p.spec.id, hitLocal) : rnd2;
30369
+ const woodForm = p.mat.splitForm === "slivers" || p.mat.splitForm === "plies" || p.mat.splitForm === "granules" ? p.mat.splitForm : void 0;
30370
+ const planRnd = woodForm ? splitStream(o.id, p.spec.id, hitLocal) : rnd2;
30120
30371
  const plan = unitPlan.length > 0 ? unitPlan : planFragments({
30121
30372
  style,
30122
30373
  dims: p.dims,
@@ -30127,7 +30378,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30127
30378
  maxFragments,
30128
30379
  rnd: planRnd,
30129
30380
  sheet: p.mat.sheet,
30130
- ...p.mat.splitForm ? { form: p.mat.splitForm } : {},
30381
+ ...woodForm ? { form: woodForm } : {},
30131
30382
  ...cutAt3 !== void 0 ? { cut: { at: cutAt3, gap: SEVER_BAND } } : {},
30132
30383
  ...p.spec.solids ? { solids: p.spec.solids } : {}
30133
30384
  });
@@ -30611,18 +30862,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30611
30862
  const confinementOf = (conf, point, radius) => {
30612
30863
  if (conf === null) return 1;
30613
30864
  if (typeof conf === "number") return conf;
30614
- let hits = 0;
30865
+ let hits2 = 0;
30615
30866
  let sum2 = 0;
30616
30867
  for (const d of raysOf(Math.max(1, Math.round(conf.rays)))) {
30617
30868
  const h = raycastInternal(point, d, radius * conf.reach, void 0, true);
30618
30869
  if (h) {
30619
- hits++;
30870
+ hits2++;
30620
30871
  sum2 += h.distance;
30621
30872
  }
30622
30873
  }
30623
- if (hits === 0) return 1;
30624
- const closed = hits / Math.max(1, Math.round(conf.rays));
30625
- const ratio = clamp2(radius / Math.max(sum2 / hits, 1e-3), 0, 2);
30874
+ if (hits2 === 0) return 1;
30875
+ const closed = hits2 / Math.max(1, Math.round(conf.rays));
30876
+ const ratio = clamp2(radius / Math.max(sum2 / hits2, 1e-3), 0, 2);
30626
30877
  return Math.min(Math.max(1, conf.max), 1 + conf.gain * closed ** conf.power * ratio);
30627
30878
  };
30628
30879
  const FLAG_LOST = 1;
@@ -33368,6 +33619,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
33368
33619
  else slab.y0 = round2(slab.y1 - thickness);
33369
33620
  slab.mass = Math.max(1, Math.round((slab.aabb[2] - slab.aabb[0]) * (slab.aabb[3] - slab.aabb[1]) * (slab.y1 - slab.y0) * densityOf(slab.material)));
33370
33621
  };
33622
+ function footprintWithin(leaf, footprint) {
33623
+ const out = [];
33624
+ for (const r of footprint) {
33625
+ const cut = [Math.max(leaf[0], r[0]), Math.max(leaf[1], r[1]), Math.min(leaf[2], r[2]), Math.min(leaf[3], r[3])];
33626
+ if (cut[2] - cut[0] > 1e-6 && cut[3] - cut[1] > 1e-6) out.push(cut);
33627
+ }
33628
+ return out;
33629
+ }
33371
33630
  function cutSlab(context, slab, wallBoxes) {
33372
33631
  const { options } = context;
33373
33632
  const roof = slab.cover === true;
@@ -33396,7 +33655,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
33396
33655
  floor: slab.floor,
33397
33656
  ...slab.cover ? { cover: true } : {},
33398
33657
  slab: slab.id,
33399
- ...slab.footprint ? { footprint: slab.footprint } : {}
33658
+ ...slab.footprint ? { footprint: footprintWithin(leaf, slab.footprint) } : {}
33400
33659
  })
33401
33660
  );
33402
33661
  context.parts.splice(context.parts.indexOf(slab), 1, ...panels);
@@ -33881,7 +34140,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
33881
34140
  return spec;
33882
34141
  };
33883
34142
  var MEMBER_CAGE = { spacing: 0.1, diameter: 0.01, unit: 0.1 };
33884
- var CAGED_ROLES = /* @__PURE__ */ new Set(["beam", "column"]);
34143
+ var CAGED_ROLES = /* @__PURE__ */ new Set(["beam", "column", "slab"]);
33885
34144
  var CAGE_COVER = 0.03;
33886
34145
  var CAGE_BUCKLING_SHARE = 0.5;
33887
34146
  var DEFAULT_RESIDUAL = 0.15;
@@ -46339,7 +46598,20 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
46339
46598
  stack: 6,
46340
46599
  shape: "cup",
46341
46600
  color: 14215408,
46342
- rarity: "common"
46601
+ rarity: "common",
46602
+ parts: [
46603
+ {
46604
+ id: "body",
46605
+ material: "glass",
46606
+ thickness: 3e-3
46607
+ }
46608
+ ],
46609
+ container: {
46610
+ capacityLiters: 0.3
46611
+ },
46612
+ estimated: [
46613
+ "container"
46614
+ ]
46343
46615
  },
46344
46616
  {
46345
46617
  id: "cutlery",
@@ -46590,8 +46862,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
46590
46862
  }
46591
46863
  ],
46592
46864
  estimated: [
46593
- "parts"
46594
- ]
46865
+ "parts",
46866
+ "consumable"
46867
+ ],
46868
+ consumable: {
46869
+ form: "liquid",
46870
+ unit: "ml",
46871
+ amount: 450,
46872
+ dose: 5,
46873
+ emptyKg: 0.03,
46874
+ density: 1.03
46875
+ }
46595
46876
  },
46596
46877
  {
46597
46878
  id: "bleach",
@@ -48081,8 +48362,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
48081
48362
  thickness: 2e-3
48082
48363
  }
48083
48364
  ],
48365
+ container: {
48366
+ capacityLiters: 0.35
48367
+ },
48084
48368
  estimated: [
48085
- "parts"
48369
+ "parts",
48370
+ "container"
48086
48371
  ]
48087
48372
  },
48088
48373
  {
@@ -48229,6 +48514,41 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
48229
48514
  },
48230
48515
  weapon: "brass_knuckles",
48231
48516
  model: "brass_knuckles"
48517
+ },
48518
+ {
48519
+ id: "plunger",
48520
+ category: "tools",
48521
+ kind: "tool",
48522
+ tags: [
48523
+ "cleaning"
48524
+ ],
48525
+ tools: [
48526
+ "plunger"
48527
+ ],
48528
+ size: [
48529
+ 0.14,
48530
+ 0.55,
48531
+ 0.14
48532
+ ],
48533
+ weight: 0.45,
48534
+ stack: 1,
48535
+ shape: "tool",
48536
+ color: 11545120,
48537
+ rarity: "common",
48538
+ finds: {
48539
+ places: [
48540
+ "house",
48541
+ "apartment"
48542
+ ]
48543
+ },
48544
+ parts: [
48545
+ {
48546
+ id: "body",
48547
+ material: "rubber",
48548
+ thickness: 4e-3
48549
+ }
48550
+ ],
48551
+ model: "plunger"
48232
48552
  }
48233
48553
  ];
48234
48554
  var kinds_default = [
@@ -49912,6 +50232,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
49912
50232
  "alicate"
49913
50233
  ]
49914
50234
  },
50235
+ plunger: {
50236
+ created: true,
50237
+ idSource: "decision",
50238
+ sizeSource: "REF",
50239
+ vc3: [
50240
+ "desentupidor"
50241
+ ]
50242
+ },
49915
50243
  adjustable_wrench: {
49916
50244
  ite: "chave_inglesa",
49917
50245
  idSource: "decision",
@@ -53038,14 +53366,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53038
53366
  var ITEM_CONTRACTS = createItemContracts();
53039
53367
  var createGoodsKinds = (options = {}) => defineCategories(GOODS_KINDS, options);
53040
53368
  var KINDS2 = createGoodsKinds();
53041
- var withSeal = (item) => {
53369
+ var withKind = (item) => {
53042
53370
  const kind = item.kind;
53043
- const seal = kind && KINDS2.has(kind) ? KINDS2.defaults(kind).seal : void 0;
53044
- return seal ? { ...item, seal: { ...seal, ...item.seal } } : item;
53371
+ if (!kind || !KINDS2.has(kind)) return item;
53372
+ const defaults = KINDS2.defaults(kind);
53373
+ const seal = defaults.seal;
53374
+ const parts2 = defaults.parts;
53375
+ const own = item.parts;
53376
+ return { ...item, ...seal ? { seal: { ...seal, ...item.seal } } : {}, ...!own && parts2 ? { parts: parts2 } : {} };
53045
53377
  };
53046
53378
  var goodsPack = {
53047
53379
  id: "goods",
53048
- items: GOODS_ITEMS.map(withSeal),
53380
+ items: GOODS_ITEMS.map(withKind),
53049
53381
  categories: GOODS_CATEGORIES,
53050
53382
  places: GOODS_PLACES,
53051
53383
  containers: GOODS_CONTAINERS,
@@ -53327,6 +53659,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53327
53659
  "item.toothbrush": "Toothbrush",
53328
53660
  "item.deodorant": "Deodorant",
53329
53661
  "item.toilet_paper": "Toilet paper",
53662
+ "item.plunger": "Toilet plunger",
53330
53663
  "item.towel": "Towel",
53331
53664
  "item.detergent": "Detergent",
53332
53665
  "item.bleach": "Bleach",
@@ -53835,6 +54168,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53835
54168
  "item.toothbrush": "Escova de dente",
53836
54169
  "item.deodorant": "Desodorante",
53837
54170
  "item.toilet_paper": "Papel higi\xEAnico",
54171
+ "item.plunger": "Desentupidor",
53838
54172
  "item.towel": "Toalha",
53839
54173
  "item.detergent": "Detergente",
53840
54174
  "item.bleach": "\xC1gua sanit\xE1ria",
@@ -54135,7 +54469,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54135
54469
  },
54136
54470
  toilet: {
54137
54471
  body: { material: "ceramic", joint: "bolt" },
54138
- parts: [["lid", door("plastic", "hinge", "lid")], ["flush_button", { material: "plastic", joint: "clip", piece: "button" }]]
54472
+ parts: [["lid", door("plastic", "hinge", "lid")], ["seat_ring", door("plastic", "hinge", "lid")], ["flush_button", { material: "plastic", joint: "clip", piece: "button" }]]
54139
54473
  },
54140
54474
  wall_socket: { body: { material: "plastic", joint: "screw" }, parts: [] },
54141
54475
  wall_switch: { body: { material: "plastic", joint: "screw" }, parts: [["rocker", { material: "plastic", joint: "clip", piece: "rocker" }]] },
@@ -54304,6 +54638,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54304
54638
  "prompt.toilet_lid": "Toilet lid",
54305
54639
  "prompt.toilet_lid.open": "Close the lid",
54306
54640
  "prompt.toilet_lid.closed": "Lift the lid",
54641
+ "prompt.toilet_seat": "Toilet seat",
54642
+ "prompt.toilet_seat.open": "Lower the seat",
54643
+ "prompt.toilet_seat.closed": "Lift the seat",
54307
54644
  "prompt.switch": "Light switch",
54308
54645
  "prompt.switch.on": "Switch off",
54309
54646
  "prompt.switch.on.verb": "Switch off",
@@ -54562,6 +54899,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54562
54899
  "prompt.toilet_lid": "Tampa do vaso",
54563
54900
  "prompt.toilet_lid.open": "Fechar a tampa",
54564
54901
  "prompt.toilet_lid.closed": "Levantar a tampa",
54902
+ "prompt.toilet_seat": "Assento do vaso",
54903
+ "prompt.toilet_seat.open": "Abaixar o assento",
54904
+ "prompt.toilet_seat.closed": "Levantar o assento",
54565
54905
  "prompt.switch": "Interruptor",
54566
54906
  "prompt.switch.on": "Desligar a luz",
54567
54907
  "prompt.switch.on.verb": "Desligar",
@@ -55382,6 +55722,25 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55382
55722
  }
55383
55723
  ];
55384
55724
  var WALL_PLATE = { width: 0.075, height: 0.12, thickness: 0.012, sink: 5e-3 };
55725
+ var DIRTY_PLATE = 0.8;
55726
+ var DIRTY_CUP = 0.5;
55727
+ var DIRTY_CUTLERY = 0.6;
55728
+ function goodsSize(id) {
55729
+ const item = GOODS_ITEMS.find((candidate) => candidate.id === id);
55730
+ if (!item) throw new Error(`game-interactables-household: the sinks lay "${id}", which the goods catalogue does not have`);
55731
+ return [item.size[0], item.size[1], item.size[2]];
55732
+ }
55733
+ var laid = (type, data) => ({ stack: { type, qty: 1, ...data ? { data } : {} }, size: goodsSize(type) });
55734
+ var DIRTY_DISHES = [
55735
+ laid("plate", { dirt: DIRTY_PLATE }),
55736
+ laid("cup", { dirt: DIRTY_CUP }),
55737
+ laid("cutlery", { dirt: DIRTY_CUTLERY })
55738
+ ];
55739
+ var WASHING_THINGS = [
55740
+ laid("detergent"),
55741
+ laid("sponge"),
55742
+ laid("cup")
55743
+ ];
55385
55744
  var DEFS2 = types_default;
55386
55745
  var HOUSEHOLD_ITEMS = GOODS_ITEMS.filter((item) => GOODS_PROVENANCE[item.id]?.household !== void 0);
55387
55746
  var itemTexts = (locale) => Object.fromEntries(HOUSEHOLD_ITEMS.map((item) => [`item.${item.id}`, GOODS_STRINGS[locale][`item.${item.id}`] ?? item.id]));
@@ -56649,7 +57008,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56649
57008
  worlds.set(world, info);
56650
57009
  return world;
56651
57010
  }
56652
- function pointOf2(world, fixtureId) {
57011
+ function pointOf3(world, fixtureId) {
56653
57012
  const info = worlds.get(world);
56654
57013
  return info ? info.points.get(fixtureId) : void 0;
56655
57014
  }
@@ -56790,7 +57149,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56790
57149
  if (info) for (const f of planned.fixtures) info.points.set(f.global, f.point);
56791
57150
  return out;
56792
57151
  }
56793
- return { version: ADAPTER_VERSION, household: hh, plan, createWorld, add: add2, blockedOf, pointOf: pointOf2, ownSpec, registries: { typeMap, contentMap, contentByGroup, chairTables, fixturesOfPoint, substitutes, preference, ownTypes } };
57152
+ return { version: ADAPTER_VERSION, household: hh, plan, createWorld, add: add2, blockedOf, pointOf: pointOf3, ownSpec, registries: { typeMap, contentMap, contentByGroup, chairTables, fixturesOfPoint, substitutes, preference, ownTypes } };
56794
57153
  }
56795
57154
  var FloorplanInteractables = { version: ADAPTER_VERSION, create: create2, TYPE_MAP, CONTENT_MAP, CONTENT_BY_GROUP, CHAIR_TABLES, PREFERENCE, mergeRegistry };
56796
57155
 
@@ -56870,21 +57229,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56870
57229
  { type: "buffet", category: "buffet", w: 1.6, d: 0.5, h: 0.9, opening: 0.45 },
56871
57230
  { type: "china_cabinet", category: "china_cabinet", w: 1.2, d: 0.45, h: 2, opening: 0.45 },
56872
57231
  { type: "stairs", category: "stairs", w: 1, d: 3.2, h: 2.8 },
56873
- { type: "planter_bed", category: "planter_bed", w: 3, d: 0.7, h: 0.4, color: { role: "dirt" } },
56874
- { type: "planter_bed_small", category: "planter_bed", w: 1.8, d: 0.6, h: 0.4, color: { role: "dirt" } },
57232
+ { type: "planter_bed", category: "planter_bed", w: 3, d: 0.7, h: 0.4, color: { role: "dirt" }, material: "concrete" },
57233
+ { type: "planter_bed_small", category: "planter_bed", w: 1.8, d: 0.6, h: 0.4, color: { role: "dirt" }, material: "concrete" },
56875
57234
  { type: "tree_small", category: "tree", w: 1.2, d: 1.2, h: 3, color: { role: "lawn" } },
56876
57235
  { type: "tree_large", category: "tree_large", w: 3, d: 3, h: 6, color: { role: "lawn" } },
56877
- { type: "shrub", category: "shrub", w: 0.8, d: 0.8, h: 0.9, color: { role: "lawn" } },
56878
- { type: "outdoor_pot", category: "outdoor_pot", w: 0.5, d: 0.5, h: 0.7 },
56879
- { type: "fountain", category: "fountain", w: 2, d: 2, h: 1.2 },
57236
+ { type: "shrub", category: "shrub", w: 0.8, d: 0.8, h: 0.9, color: { role: "lawn" }, material: "foliage" },
57237
+ { type: "outdoor_pot", category: "outdoor_pot", w: 0.5, d: 0.5, h: 0.7, material: "ceramic" },
57238
+ { type: "fountain", category: "fountain", w: 2, d: 2, h: 1.2, material: "concrete" },
56880
57239
  { type: "garden_bench", category: "garden_bench", w: 1.5, d: 0.5, h: 0.5 },
56881
57240
  { type: "clothesline", category: "clothesline", w: 3.6, d: 0.4, h: 2 },
56882
57241
  { type: "bbq_grill", category: "bbq_grill", w: 1, d: 0.7, h: 1.4 },
56883
57242
  { type: "outbuilding", category: "outbuilding", w: 3.2, d: 3, h: 2.6 },
56884
57243
  { type: "doghouse", category: "doghouse", w: 0.6, d: 0.8, h: 0.7 },
56885
57244
  { type: "water_tank", category: "water_tank", w: 1, d: 1, h: 1.8 },
56886
- { type: "pool", category: "pool", w: 7, d: 3.5, h: 0, rim: 1.2, color: { role: "water" } },
56887
- { type: "pool_large", category: "pool", w: 9, d: 4.5, h: 0, rim: 1.2, color: { role: "water" } },
57245
+ { type: "pool", category: "pool", w: 7, d: 3.5, h: 0, rim: 1.2, color: { role: "water" }, material: "concrete" },
57246
+ { type: "pool_large", category: "pool", w: 9, d: 4.5, h: 0, rim: 1.2, color: { role: "water" }, material: "concrete" },
56888
57247
  { type: "sun_lounger", category: "sun_lounger", w: 0.7, d: 2, h: 0.4, deck: true },
56889
57248
  { type: "outdoor_table", category: "outdoor_table", w: 1.6, d: 1, h: 0.75, deck: true },
56890
57249
  { type: "gas_cylinder", category: "gas_cylinder", w: 0.35, d: 0.35, h: 0.6 },
@@ -56894,12 +57253,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56894
57253
  { type: "track_spot", category: "ceiling_light", w: 0.6, d: 0.1, h: 0.12, decor: true, mount: "ceiling", color: { role: "metal" } },
56895
57254
  { type: "chandelier", category: "ceiling_light", w: 0.7, d: 0.7, h: 0.6, decor: true, mount: "ceiling", color: { role: "metal" } },
56896
57255
  { type: "wall_ac", category: "air_conditioner", w: 0.9, d: 0.25, h: 0.28, decor: true, mount: "wall", color: { role: "ceiling" } },
56897
- { type: "ac_condenser", category: "ac_condenser", w: 0.8, d: 0.35, h: 0.6, decor: true, mount: "floor", color: { role: "ceiling" } },
57256
+ { type: "ac_condenser", category: "ac_condenser", w: 0.8, d: 0.35, h: 0.6, decor: true, mount: "floor", color: { role: "ceiling" }, material: "steel" },
56898
57257
  { type: "picture_small", category: "picture", w: 0.4, d: 0.03, h: 0.5, decor: true, mount: "wall", color: { role: "picture_accent" } },
56899
57258
  { type: "picture_large", category: "picture", w: 0.9, d: 0.03, h: 0.6, decor: true, mount: "wall", color: { role: "picture_accent" } },
56900
- { type: "mirror", category: "picture", w: 0.6, d: 0.03, h: 0.9, decor: true, mount: "wall", color: { role: "metal" } },
56901
- { type: "floor_plant", category: "plant", w: 0.4, d: 0.4, h: 0.9, decor: true, mount: "floor", color: { role: "lawn" } },
56902
- { type: "table_plant", category: "plant", w: 0.2, d: 0.2, h: 0.3, decor: true, mount: "support", color: { role: "lawn" } },
57259
+ { type: "mirror", category: "picture", w: 0.6, d: 0.03, h: 0.9, decor: true, mount: "wall", color: { role: "metal" }, material: "glass" },
57260
+ { type: "floor_plant", category: "plant", w: 0.4, d: 0.4, h: 0.9, decor: true, mount: "floor", color: { role: "lawn" }, material: "ceramic" },
57261
+ { type: "table_plant", category: "plant", w: 0.2, d: 0.2, h: 0.3, decor: true, mount: "support", color: { role: "lawn" }, material: "ceramic" },
56903
57262
  { type: "mailbox", category: "mailbox", w: 0.35, d: 0.3, h: 0.3, decor: true, mount: "wall_top", color: { role: "metal" } },
56904
57263
  { type: "table_lamp", category: "table_light", w: 0.36, d: 0.36, h: 0.5, decor: true, mount: "support", powered: true },
56905
57264
  { type: "hanging_plant", category: "plant", w: 0.3, d: 0.3, h: 0.7, decor: true, mount: "ceiling", color: { role: "lawn" } },
@@ -56914,11 +57273,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56914
57273
  { type: "gourmet_counter_small", category: "gourmet", w: 1.8, d: 0.65, h: 1, window: true, equip: ["bbq_grill", "kitchen_cabinet"] },
56915
57274
  { type: "gourmet_table", category: "gourmet", w: 2.8, d: 0.9, h: 0.78 },
56916
57275
  { type: "gourmet_table_small", category: "gourmet", w: 1.2, d: 0.9, h: 0.78 },
56917
- { type: "pool_small", category: "pool", w: 5, d: 2.6, h: 0, rim: 1.2, color: { role: "water" } },
56918
- { type: "pool_medium", category: "pool", w: 6, d: 3, h: 0, rim: 1.2, color: { role: "water" } },
57276
+ { type: "pool_small", category: "pool", w: 5, d: 2.6, h: 0, rim: 1.2, color: { role: "water" }, material: "concrete" },
57277
+ { type: "pool_medium", category: "pool", w: 6, d: 3, h: 0, rim: 1.2, color: { role: "water" }, material: "concrete" },
56919
57278
  { type: "deck", category: "deck", w: 3, d: 2, h: 0.15, flat: true, deck: true, color: { role: "deck_floor" } },
56920
- { type: "garden_bed", category: "garden_bed", w: 2, d: 0.8, h: 0.3, color: { role: "dirt" } },
56921
- { type: "fruit_tree", category: "tree", w: 2.2, d: 2.2, h: 3.5, color: { role: "lawn" } },
57279
+ { type: "garden_bed", category: "garden_bed", w: 2, d: 0.8, h: 0.3, color: { role: "dirt" }, material: "concrete" },
57280
+ { type: "fruit_tree", category: "tree", w: 2.2, d: 2.2, h: 3.5, color: { role: "lawn" }, material: "foliage" },
56922
57281
  { type: "palm_tree", category: "tree", w: 1.2, d: 1.2, h: 4, color: { role: "lawn" } },
56923
57282
  { type: "pergola", category: "pergola", w: 3.6, d: 3.2, h: 2.4, flat: true, mount: "roof", color: { role: "deck_floor" } },
56924
57283
  { type: "bbq_simple", category: "bbq_simple", w: 0.8, d: 0.6, h: 1.2 },
@@ -57985,7 +58344,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57985
58344
  }
57986
58345
  var residentialTower = residentialTowerTemplate();
57987
58346
 
57988
- // ../game-floorplan-three/dist/chunk-RW7ZTU76.js
58347
+ // ../game-floorplan-three/dist/chunk-KOJFBQRC.js
57989
58348
  var __defProp4 = Object.defineProperty;
57990
58349
  var __defNormalProp2 = (obj, key2, value) => key2 in obj ? __defProp4(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
57991
58350
  var __publicField2 = (obj, key2, value) => __defNormalProp2(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
@@ -57995,6 +58354,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57995
58354
  "prompt.lockedDoor": "E: locked door",
57996
58355
  "prompt.lightOn": "E: turn on the light",
57997
58356
  "prompt.lightOff": "E: turn off the light",
58357
+ "prompt.sit": "E: sit",
58358
+ "prompt.lie": "E: lie down",
57998
58359
  "what.door": "the door",
57999
58360
  "what.curtain": "the curtain",
58000
58361
  "what.mailbox": "the mailbox",
@@ -58021,6 +58382,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58021
58382
  "prompt.lockedDoor": "E: porta trancada",
58022
58383
  "prompt.lightOn": "E: acender a luz",
58023
58384
  "prompt.lightOff": "E: apagar a luz",
58385
+ "prompt.sit": "E: sentar",
58386
+ "prompt.lie": "E: deitar",
58024
58387
  "what.door": "a porta",
58025
58388
  "what.curtain": "a cortina",
58026
58389
  "what.mailbox": "a caixa de correio",
@@ -58075,13 +58438,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58075
58438
  return out;
58076
58439
  }
58077
58440
  function exclusiveBoxes(solids2) {
58078
- const laid = [];
58441
+ const laid2 = [];
58079
58442
  for (const solid2 of solids2) {
58080
58443
  let pieces = [solid2.box];
58081
- for (const before of laid) pieces = pieces.flatMap((piece22) => subtractBox(piece22, before.box));
58082
- for (const box5 of pieces) laid.push({ ...solid2, box: box5 });
58444
+ for (const before of laid2) pieces = pieces.flatMap((piece22) => subtractBox(piece22, before.box));
58445
+ for (const box5 of pieces) laid2.push({ ...solid2, box: box5 });
58083
58446
  }
58084
- return laid;
58447
+ return laid2;
58085
58448
  }
58086
58449
  function outsideBoxes(box5, taken) {
58087
58450
  let pieces = [box5];
@@ -61779,7 +62142,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
61779
62142
  function addSpoil(THREE, parent, trenches, material, site) {
61780
62143
  const heap = new BoxBatch();
61781
62144
  const rects = trenches.map((t) => t.rect);
61782
- const laid = [];
62145
+ const laid2 = [];
61783
62146
  trenches.forEach(({ rect: r }, i) => {
61784
62147
  const others = rects.filter((_, k) => k !== i);
61785
62148
  for (const e of openEdges(r, others, site.solids)) {
@@ -61788,10 +62151,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
61788
62151
  const w = TRENCH.berm.width;
61789
62152
  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];
61790
62153
  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);
61791
- 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])) {
62154
+ 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]), ...laid2])) {
61792
62155
  if (Math.min(piece22[2] - piece22[0], piece22[3] - piece22[1]) < TRENCH.berm.crest * 2) continue;
61793
62156
  addHumps(heap, piece22);
61794
- laid.push(piece22);
62157
+ laid2.push(piece22);
61795
62158
  }
61796
62159
  }
61797
62160
  });
@@ -62633,8 +62996,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62633
62996
  const isBlock = part.assembly === "concrete_block_wall" || part.material === "concrete";
62634
62997
  const coreTh = coreWidthOf(th, unitId);
62635
62998
  for (const r of slivers) chased(batches.mortar, r.a0 + SLIVER_CLEAR, r.y0 + SLIVER_CLEAR, r.a1 - SLIVER_CLEAR, r.y1 - SLIVER_CLEAR, coreTh * 0.98, MORTAR_CHASE_INSET);
62636
- const laid = coursingOf(unitId, getAssembly(part.assembly ?? (isBlock ? "concrete_block_wall" : "brick_wall_plastered"))?.units);
62637
- const coursing = { courseH: laid.courseHeight, unitLen: laid.unitLength, joint: 0.012, courseBase };
62999
+ const laid2 = coursingOf(unitId, getAssembly(part.assembly ?? (isBlock ? "concrete_block_wall" : "brick_wall_plastered"))?.units);
63000
+ const coursing = { courseH: laid2.courseHeight, unitLen: laid2.unitLength, joint: 0.012, courseBase };
62638
63001
  const unit = isBlock ? batches.block : batches.brick;
62639
63002
  for (const r of pieces) {
62640
63003
  unitEnds.length = 0;
@@ -62893,10 +63256,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62893
63256
  const walled = applyPanels(slabbed, rawStructure, "panels", slabOptions && rawStructure.construction.frame.rebar ? (span) => beamDepthFor(span, slabOptions) : void 0);
62894
63257
  return (slabOptions ? deepenBondBeams(walled, rawStructure, slabOptions) : walled).parts;
62895
63258
  }
62896
- function addFrameBox(THREE, parent, box5, mat, id, block) {
62897
- for (const b of block.length ? outsideBoxes(box5, block) : [box5]) addStageBox(THREE, parent, b[0], b[1], b[2], b[3], b[4], b[5], mat, id);
63259
+ function addFrameBox(THREE, parent, box5, mat, id, block2) {
63260
+ for (const b of block2.length ? outsideBoxes(box5, block2) : [box5]) addStageBox(THREE, parent, b[0], b[1], b[2], b[3], b[4], b[5], mat, id);
62898
63261
  }
62899
- function buildStructuralStageGroups(THREE, rawStructure, outbuildings, runs = [], block = []) {
63262
+ function buildStructuralStageGroups(THREE, rawStructure, outbuildings, runs = [], block2 = []) {
62900
63263
  const foundation = new THREE.Group();
62901
63264
  foundation.name = "stage:1:foundation";
62902
63265
  const frame2 = new THREE.Group();
@@ -62937,15 +63300,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62937
63300
  seatSlabs(slabs.filter((s) => !s.id.startsWith("tank_")), [...beams, ...columns.filter((c) => !c.tank)], beams);
62938
63301
  for (const c of columns) {
62939
63302
  const mat = c.material === "wood_soft" || c.material === "wood_hard" ? mats.wood : c.material === "steel" ? mats.sheet : mats.concrete;
62940
- addFrameBox(THREE, frame2, [c.aabb[0], c.y0, c.aabb[1], c.aabb[2], c.y1, c.aabb[3]], mat, c.id, block);
63303
+ addFrameBox(THREE, frame2, [c.aabb[0], c.y0, c.aabb[1], c.aabb[2], c.y1, c.aabb[3]], mat, c.id, block2);
62941
63304
  if (c.tank || c.y0 > 0.1 || c.material !== "concrete") continue;
62942
63305
  if (c.floor === 0) addRebarCage(THREE, starterBars, c.aabb, 0, 0.42, mats.rebar);
62943
63306
  }
62944
63307
  for (const b of beams) {
62945
63308
  const p = beamParts.find((x) => x.id === b.id);
62946
- addFrameBox(THREE, frame2, [b.aabb[0], b.y0, b.aabb[1], b.aabb[2], b.y1, b.aabb[3]], p && (p.material === "wood_soft" || p.material === "wood_hard") ? mats.wood : mats.concrete, b.id, block);
63309
+ addFrameBox(THREE, frame2, [b.aabb[0], b.y0, b.aabb[1], b.aabb[2], b.y1, b.aabb[3]], p && (p.material === "wood_soft" || p.material === "wood_hard") ? mats.wood : mats.concrete, b.id, block2);
62947
63310
  }
62948
- for (const s of slabs) addFrameBox(THREE, frame2, [s.aabb[0], s.y0, s.aabb[1], s.aabb[2], s.y1, s.aabb[3]], mats.concrete, s.id, block);
63311
+ for (const s of slabs) addFrameBox(THREE, frame2, [s.aabb[0], s.y0, s.aabb[1], s.aabb[2], s.y1, s.aabb[3]], mats.concrete, s.id, block2);
62949
63312
  const wallCores = wallParts.filter(isMasonry).map((w) => {
62950
63313
  const line = wallLineOf(w.aabb), width = coreWidthOf(line.thickness, unit), centre = coreLineOf(line, w, columns, width);
62951
63314
  return { ...solidOf(w), aabb: line.alongU ? [w.aabb[0], centre - width / 2, w.aabb[2], centre + width / 2] : [centre - width / 2, w.aabb[1], centre + width / 2, w.aabb[3]] };
@@ -62953,13 +63316,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62953
63316
  const lintels = beamParts.filter((p) => isLintel(p.id)).map(solidOf).map(toCoreWidth).map(inWall).map((l) => fitLintel(l, beams, columns, wallCores.filter((w) => wallLineOf(w.aabb).alongU !== wallLineOf(l.aabb).alongU))).filter((l) => l !== null);
62954
63317
  for (const l of lintels) addStageBox(THREE, masonry, l.aabb[0], l.y0, l.aabb[1], l.aabb[2], l.y1, l.aabb[3], mats.lintel, l.id);
62955
63318
  const batches = createMasonryBatches();
62956
- const laid = [];
63319
+ const laid2 = [];
62957
63320
  const solids2 = [...foundations, ...columns, ...beams, ...slabs, ...lintels];
62958
63321
  for (const run of wallRuns(wallParts)) {
62959
63322
  const p = run.part;
62960
63323
  const wall = wallLineOf(p.aabb);
62961
63324
  const cuts = [...run.gaps];
62962
- for (const s of [...solids2, ...laid]) {
63325
+ for (const s of [...solids2, ...laid2]) {
62963
63326
  const top = columns.includes(s) ? s.y1 + 0.3 : s.y1;
62964
63327
  const cut = cutOf(wall, s.aabb, s.y0, top);
62965
63328
  if (cut) cuts.push(cut);
@@ -62972,7 +63335,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62972
63335
  const coreLine = coreLineOf(wall, p, columns, coreWidth);
62973
63336
  const filled = buildMasonryPanel(batches, p, { cuts, courseBase: (p.floor ?? 0) === 0 ? FOUNDATION_TOP : p.y0, unitId: unit, coreLine, chases: chasesIn(wall, { line: coreLine, width: coreWidth, y0: p.y0, y1: p.y1 }, runs) });
62974
63337
  const half = coreWidth / 2;
62975
- for (const r of filled) laid.push({ id: p.id, aabb: wall.alongU ? [r.a0, coreLine - half, r.a1, coreLine + half] : [coreLine - half, r.a0, coreLine + half, r.a1], y0: r.y0, y1: r.y1, floor: p.floor ?? 0 });
63338
+ for (const r of filled) laid2.push({ id: p.id, aabb: wall.alongU ? [r.a0, coreLine - half, r.a1, coreLine + half] : [coreLine - half, r.a0, coreLine + half, r.a1], y0: r.y0, y1: r.y1, floor: p.floor ?? 0 });
62976
63339
  }
62977
63340
  for (const mesh3 of masonryMeshes(THREE, batches, mats, "masonry")) masonry.add(mesh3);
62978
63341
  return groups;
@@ -63329,7 +63692,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
63329
63692
  }
63330
63693
  return 0;
63331
63694
  };
63332
- const boundsOf = (roomId, x, z) => {
63695
+ const boundsOf2 = (roomId, x, z) => {
63333
63696
  const rects = shared3.ctx.roomById[roomId ?? ""]?.parts ?? [], rect = rects.find((r) => r[0] <= x && x <= r[2] && r[1] <= z && z <= r[3]) ?? rects[0];
63334
63697
  return rect ? [rect[0] + WALL_HALF, rect[1] + WALL_HALF, rect[2] - WALL_HALF, rect[3] - WALL_HALF] : [-Infinity, -Infinity, Infinity, Infinity];
63335
63698
  };
@@ -63355,7 +63718,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
63355
63718
  const fittings = [
63356
63719
  ...lights.map((it) => {
63357
63720
  const ceiling = ceilingOf(it), kind = lampOf.get(it.id) ?? DEFAULT_LAMP_TYPE, lamp = kind === "sconce" ? DEFAULT_LAMP_TYPE : kind;
63358
- const layout = lamp === "tube_t8" ? tubeLayoutOf(it.x, it.z, boundsOf(it.room, it.x, it.z)) : { alongU: true, span: SOCKET_SIZE.t8.spans[0] }, params = { lamp, x: it.x, z: it.z, ...layout };
63721
+ const layout = lamp === "tube_t8" ? tubeLayoutOf(it.x, it.z, boundsOf2(it.room, it.x, it.z)) : { alongU: true, span: SOCKET_SIZE.t8.spans[0] }, params = { lamp, x: it.x, z: it.z, ...layout };
63359
63722
  return { id: it.id, lamp: kind, rough: ceilingSocketParts({ ...params, mountY: undersideAt(it.x, it.z, ceiling) }), finished: ceilingSocketParts({ ...params, mountY: ceiling }) };
63360
63723
  }),
63361
63724
  ...sconces.map((lampPoint) => {
@@ -63421,7 +63784,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
63421
63784
  };
63422
63785
  for (const A of ws) for (const [side, sd] of [[A.w.sides[0], -1], [A.w.sides[1], 1]]) {
63423
63786
  if (!sideOf(side, false).exterior) continue;
63424
- const strip = (k, y1, y2, o0, o1, mat, c, piece22, laid = BASEBOARD_TILES) => {
63787
+ const strip = (k, y1, y2, o0, o1, mat, c, piece22, laid2 = BASEBOARD_TILES) => {
63425
63788
  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;
63426
63789
  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);
63427
63790
  if (s1 - s0 < 1e-3) return;
@@ -63431,14 +63794,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
63431
63794
  if (!shared3.ctx.visorScene) (mat === "sidewalk" ? shared3.ctx.paving : shared3.ctx.baseboards)?.push(p);
63432
63795
  }
63433
63796
  };
63434
- const tag = laid === BASEBOARD_TILES ? "baseboard" : "sidewalk";
63797
+ const tag = laid2 === BASEBOARD_TILES ? "baseboard" : "sidewalk";
63435
63798
  const tile = (id, a, b) => {
63436
- cursor.pc = pieceRecord(id, laid.material, null, { floor: 0, mass: Math.round((b - a) * (y2 - y1) * (hi - lo) * laid.density * 100) / 100, tags: [tag] });
63799
+ cursor.pc = pieceRecord(id, laid2.material, null, { floor: 0, mass: Math.round((b - a) * (y2 - y1) * (hi - lo) * laid2.density * 100) / 100, tags: [tag] });
63437
63800
  box5(a, b);
63438
63801
  };
63439
63802
  const runs = [];
63440
63803
  let from = s0;
63441
- if (laid === BASEBOARD_TILES) for (const d of doorsInWall(R.doors, A.w, A.L, A.a, A.b).sort((p, q) => p.at - q.at)) {
63804
+ if (laid2 === BASEBOARD_TILES) for (const d of doorsInWall(R.doors, A.w, A.L, A.a, A.b).sort((p, q) => p.at - q.at)) {
63442
63805
  runs.push([from, d.at - d.width / 2]);
63443
63806
  from = d.at + d.width / 2;
63444
63807
  }
@@ -63449,7 +63812,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
63449
63812
  if (!id) box5(r0, r1);
63450
63813
  else if (shared3.ctx.baseboardBand) tile(id, r0, r1);
63451
63814
  else {
63452
- const n = Math.max(1, Math.round((r1 - r0) / laid.length)), w = (r1 - r0) / n, j = laid.joint / 2;
63815
+ const n = Math.max(1, Math.round((r1 - r0) / laid2.length)), w = (r1 - r0) / n, j = laid2.joint / 2;
63453
63816
  for (let i = 0; i < n; i++) tile(`${id}:${i}`, r0 + i * w + (i > 0 ? j : 0), r0 + (i + 1) * w - (i < n - 1 ? j : 0));
63454
63817
  }
63455
63818
  });
@@ -64564,8 +64927,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
64564
64927
  }
64565
64928
  var BLOB_LEANS = [[0.06, 0], [-0.06, 0], [0, 0.06], [0, -0.06], [0.06, 0.06], [-0.06, -0.06], [0.06, -0.06], [-0.06, 0.06], [0.12, 0], [0, 0.12]];
64566
64929
  var BLOB_CROSSING = Math.cos(20 * Math.PI / 180);
64567
- function grazes(laid, x, y, z, r) {
64568
- return laid.some(([x0, y0, z0, r0]) => {
64930
+ function grazes(laid2, x, y, z, r) {
64931
+ return laid2.some(([x0, y0, z0, r0]) => {
64569
64932
  const d = Math.hypot(x - x0, y - y0, z - z0);
64570
64933
  if (d <= Math.abs(r - r0) || d >= r + r0) return false;
64571
64934
  return (r * r + r0 * r0 - d * d) / (2 * r * r0) > BLOB_CROSSING;
@@ -64578,14 +64941,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
64578
64941
  const GREENS2 = [4160058, 3107376, 5212738, 5936200, 3832396];
64579
64942
  const FLOWERS = [14700682, 15909424, 16118506, 14168874, 9067216, 15764026];
64580
64943
  function blobs(K2, cx, cy, cz, R, n, green2, rnd2, o = {}) {
64581
- const laid = [];
64944
+ const laid2 = [];
64582
64945
  for (let i = 0; i < n; i++) {
64583
64946
  const a = rnd2() * 6.283, u = Math.sqrt(rnd2()), ph = (rnd2() - 0.2) * 1.2, dx = Math.cos(a) * u * R * 0.75, dz = Math.sin(a) * u * R * 0.75, dy = (o.flatten ? 0.35 : 0.55) * R * (Math.sin(ph) * 0.5 + 0.5) * 1.5 - R * 0.15;
64584
64947
  const r = R * (0.34 + rnd2() * 0.22) * (1 - u * 0.25), alt = r * 2 * (o.flatten ? 0.75 : 0.95), f = 0.72 + Math.min(1, (dy + R * 0.2) / (R * 1.2)) * 0.32 + rnd2() * 0.12;
64585
- const shown2 = shared3.ctx.visorScene || !grazes(laid, cx + dx, cy + dy + r * 0.5, cz + dz, r);
64948
+ const shown2 = shared3.ctx.visorScene || !grazes(laid2, cx + dx, cy + dy + r * 0.5, cz + dz, r);
64586
64949
  if (shared3.ctx.visorScene) K2.e("plant", cx + dx, cy + dy + r * 0.5, cz + dz, r, alt, sh(green2, f));
64587
64950
  else if (shown2) {
64588
- laid.push([cx + dx, cy + dy + r * 0.5, cz + dz, r]);
64951
+ laid2.push([cx + dx, cy + dy + r * 0.5, cz + dz, r]);
64589
64952
  const [wx, , wz] = K2.W(cx + dx, 0, cz + dz), lean = BLOB_LEANS[i % BLOB_LEANS.length];
64590
64953
  K2.A.cylinder({ ...K2.M, x: wx, z: wz, ry: K2.M.ry + i / n * (Math.PI / 5) }, "plant", 0, K2.y0 + cy + dy + r * 0.5, 0, r, alt, sh(green2, f), lean[0], lean[1], "sphere");
64591
64954
  }
@@ -65739,6 +66102,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
65739
66102
  const defined = { NO_COLLIDE, registerCollision, objectDistance, collideObject, collideAt, walkInSolids, kitCollides };
65740
66103
  Object.assign(K, defined);
65741
66104
  }
66105
+ var PELVIS_FROM_HEAD = 0.95;
66106
+ var SWING_SEAT = 0.45;
66107
+ var SAUNA_BENCH = 0.45;
66108
+ var TUB_FLOOR = 0.12;
66109
+ var PLAN_FURNITURE_SEATS = {
66110
+ sun_lounger: ({ w, d, h }) => [{ id: "lie", pose: "lie", pos: [0, h, -d / 2 + PELVIS_FROM_HEAD], ry: 0, eye: 0.2, exit: [w / 2 + 0.5, 0, 0] }],
66111
+ swing: ({ d }) => [{ id: "seat", pose: "sit", pos: [0, SWING_SEAT, 0], ry: 0, exit: [0, 0, d / 2 + 0.6] }],
66112
+ soaking_tub: ({ d }) => [{ id: "seat", pose: "sit", pos: [0, TUB_FLOOR, -d / 6], ry: 0, exit: [0, 0, d / 2 + 0.5] }],
66113
+ sauna: ({ d }) => [{ id: "bench", pose: "sit", pos: [0, SAUNA_BENCH, -d / 4], ry: 0, exit: [0, 0, d / 2 + 0.5] }]
66114
+ };
66115
+ var planFurnitureSeats = (type, size) => PLAN_FURNITURE_SEATS[type]?.(size) ?? [];
65742
66116
  function installInteractionItems(K, shared3) {
65743
66117
  const { t, LIGHTS, cursor, definePiece, localOf, registerCollision, togglePiece } = K;
65744
66118
  const DOOR_ITEM = /^(tv_unit|tv_unit_small|tv_unit_large|sideboard|china_cabinet|filing_cabinet|pantry|laundry_cabinet|wardrobe|wardrobe_small|wardrobe_large|closet_wardrobe|kitchen_cabinet|kitchen_cabinet_large|kitchen_cabinet_small|fridge|fridge_large|display_fridge_medium|display_fridge)$/;
@@ -65758,11 +66132,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
65758
66132
  function buildItem2(m, M, ent, api, parent) {
65759
66133
  registerCollision(m, M);
65760
66134
  const type = m.type;
66135
+ seatItem(m, M);
65761
66136
  if (LIGHT_TYPES.has(type)) return lightItem(m, M, ent, api, parent);
65762
66137
  if (type === "curtain") return curtainItem(m, M, ent, api, parent);
65763
66138
  if (DOOR_ITEM.test(type) || DRAWER_ITEM.test(type)) return furnitureItem(m, M, ent, api, parent, DRAWER_ITEM.test(type));
65764
66139
  ent.f(M, api);
65765
66140
  }
66141
+ function seatItem(m, M) {
66142
+ const seats = planFurnitureSeats(m.type, { w: M.w, d: M.d, h: M.h });
66143
+ const first = seats[0];
66144
+ if (!first) return;
66145
+ const base2 = M.base + (M.y || 0), [ax, az] = localOf(M, first.pos[0], first.pos[2]);
66146
+ I().items.push({ type: "seat", id: m.id, floor: M.floor, anchor: [ax, base2 + first.pos[1], az], range: 1.6, angle: 1.1, pieces: [], seats, mount: { x: M.x, y: base2, z: M.z, ry: M.ry }, text: () => t(first.pose === "lie" ? "prompt.lie" : "prompt.sit"), action: () => void 0 });
66147
+ }
65766
66148
  function lightItem(m, M, ent, api, parent) {
65767
66149
  M.on = M.light = M.lit = true;
65768
66150
  const n0 = LIGHTS.length, name = shared3.quality === "game" ? "ix:light:" + m.room + "@" + parent : "ix:light:" + m.id;
@@ -67597,7 +67979,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
67597
67979
  const bars = def && def.reinforcement ? pc.role === "column" || pc.role === "beam" ? { ...def.reinforcement, diameter: Math.max(def.reinforcement.diameter, MEMBER_CAGE.diameter) } : def.reinforcement : null;
67598
67980
  const cage = bars ? pc.role === "column" && sp.shape.kind === "box" ? { ...bars, residualCapacity: cageResidualCapacity(sp.shape.size, bars, sp.structure?.capacity) } : { ...bars } : null;
67599
67981
  const out = cage && !sp.reinforcement ? { ...sp, reinforcement: cage } : sp;
67600
- if (out.reinforcement && !out.units && pc.material === "concrete" && (pc.role === "beam" || pc.role === "column") && sp.shape.kind === "box") {
67982
+ if (out.reinforcement && !out.units && pc.material === "concrete" && CAGED_ROLES.has(pc.role) && sp.shape.kind === "box") {
67601
67983
  return { ...out, units: { size: [MEMBER_CAGE.unit, MEMBER_CAGE.unit, Math.min(...sp.shape.size)], bond: "stack", mortar: "concrete" } };
67602
67984
  }
67603
67985
  return out;
@@ -67660,6 +68042,25 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
67660
68042
  if (distance4 <= -depth) return true;
67661
68043
  return distance4 <= -depth * noise3();
67662
68044
  }
68045
+ var WALL_ALONG_U = { along: 0, up: 1, across: 2 };
68046
+ var WALL_ALONG_V = { along: 2, up: 1, across: 0 };
68047
+ var LYING = { along: 0, up: 2, across: 1 };
68048
+ function extentOf(part, axis2) {
68049
+ if (axis2 === 1) return [part.y0, part.y1];
68050
+ return axis2 === 0 ? [part.aabb[0], part.aabb[2]] : [part.aabb[1], part.aabb[3]];
68051
+ }
68052
+ function planeAxesOf(part) {
68053
+ const [u0, v0, u1, v1] = part.aabb;
68054
+ if (thinAxisOf([u1 - u0, part.y1 - part.y0, v1 - v0]) === 1) return LYING;
68055
+ return u1 - u0 >= v1 - v0 ? WALL_ALONG_U : WALL_ALONG_V;
68056
+ }
68057
+ function pointOf2(axes, along22, up, across2) {
68058
+ const out = [0, 0, 0];
68059
+ out[axes.along] = along22;
68060
+ out[axes.up] = up;
68061
+ out[axes.across] = across2;
68062
+ return out;
68063
+ }
67663
68064
  var JOINT_SHARE = 0.5;
67664
68065
  var EPSILON22 = 1e-4;
67665
68066
  function carve(boxes, grid) {
@@ -67769,11 +68170,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
67769
68170
  const boxes = part.gone?.length ? subtract2(mergeSpans(part.spans), part.gone) : mergeSpans(part.spans);
67770
68171
  for (const s of line.open ? mergeSpans(carve(boxes, line.open), 0) : boxes) {
67771
68172
  const along22 = line.start + (s.a + s.b) / 2;
67772
- point.set(line.alongU ? along22 : part.mid, (s.y0 + s.y1) / 2, line.alongU ? part.mid : along22).applyMatrix4(toMesh);
67773
- const length2 = (s.b - s.a) / 2, up = (s.y1 - s.y0) / 2, across2 = part.thick / 2;
68173
+ point.set(...pointOf2(line.axes, along22, (s.y0 + s.y1) / 2, part.mid)).applyMatrix4(toMesh);
68174
+ const [hx, hy, hz2] = pointOf2(line.axes, (s.b - s.a) / 2, (s.y1 - s.y0) / 2, part.thick / 2);
67774
68175
  out.push({
67775
68176
  center: [point.x, point.y, point.z],
67776
- half: [(line.alongU ? length2 : across2) * scale.x, up * scale.y, (line.alongU ? across2 : length2) * scale.z],
68177
+ half: [hx * scale.x, hy * scale.y, hz2 * scale.z],
67777
68178
  rotation: [turn2.x, turn2.y, turn2.z, turn2.w],
67778
68179
  kind: "box"
67779
68180
  });
@@ -67831,6 +68232,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
67831
68232
  var SPALL_MIN = 0.025;
67832
68233
  var SPALL_RAGGED = 0.045;
67833
68234
  var PLASTER_REACH = { least: SPALL_MIN, band: SPALL_RAGGED };
68235
+ var CAST_GAP = 2e-3;
67834
68236
  var COVER2 = 0.015;
67835
68237
  var LUMP_BAR_INSET = 0.035;
67836
68238
  var LUMPS_PER_BAR = 1;
@@ -67849,6 +68251,28 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
67849
68251
  if (hi[0] - lo[0] <= 1e-4 || hi[1] - lo[1] <= 1e-4 || hi[2] - lo[2] <= 1e-4) return null;
67850
68252
  return { x: (lo[0] + hi[0]) / 2, y: (lo[1] + hi[1]) / 2, z: (lo[2] + hi[2]) / 2, sx: hi[0] - lo[0], sy: hi[1] - lo[1], sz: hi[2] - lo[2], colour: unit.colour };
67851
68253
  }
68254
+ var axisVector = (axis2) => [axis2 === 0 ? 1 : 0, axis2 === 1 ? 1 : 0, axis2 === 2 ? 1 : 0];
68255
+ function isSliver(unit, size) {
68256
+ return Math.min(unit.sx, unit.sy, unit.sz) < 0.5 * Math.min(...size);
68257
+ }
68258
+ function overlapsStone(a, b) {
68259
+ const reach2 = 0.62 * (Math.max(a.sx, a.sy, a.sz) + Math.max(b.sx, b.sy, b.sz));
68260
+ return Math.hypot(a.x - b.x, a.y - b.y, a.z - b.z) < reach2;
68261
+ }
68262
+ function unitBoxOf(axes, centre, size, colour) {
68263
+ const [x, y, z] = pointOf2(axes, centre[0], centre[1], centre[2]), [sx, sy, sz] = pointOf2(axes, size[0], size[1], size[2]);
68264
+ return { x, y, z, sx, sy, sz, colour };
68265
+ }
68266
+ function coatedInside(bounds2, axes) {
68267
+ const inner = [...bounds2];
68268
+ inner[axes.along] = bounds2[axes.along] + COVER2;
68269
+ inner[axes.along + 3] = bounds2[axes.along + 3] - COVER2;
68270
+ inner[axes.up + 3] = bounds2[axes.up + 3] - COVER2;
68271
+ if (axes.up !== 1) inner[axes.up] = bounds2[axes.up] + COVER2;
68272
+ inner[axes.across] = bounds2[axes.across] + COVER2;
68273
+ inner[axes.across + 3] = bounds2[axes.across + 3] - COVER2;
68274
+ return inner;
68275
+ }
67852
68276
  function installDestructionBreach(K, _shared) {
67853
68277
  const { THREE, fragmentMaterial, invalidate, invalidateShadow } = K;
67854
68278
  const paintState = { attached: false };
@@ -68017,13 +68441,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
68017
68441
  hasStrike = true;
68018
68442
  };
68019
68443
  function cells(part, units, mask) {
68020
- const [u0, v0, u1, v1] = part.aabb;
68021
- const alongU = mask.alongU;
68022
- const len = alongU ? u1 - u0 : v1 - v0;
68023
- const offset = (alongU ? u0 : v0) - mask.start;
68024
- const [ul, uh] = units.size;
68025
- const rows = Math.max(1, Math.round((part.y1 - part.y0) / uh));
68026
- const rowH = (part.y1 - part.y0) / rows;
68444
+ const [a0, a1] = extentOf(part, mask.axes.along), [up0, up1] = extentOf(part, mask.axes.up);
68445
+ const len = a1 - a0;
68446
+ const offset = a0 - mask.start;
68447
+ const merge = Math.max(1, Math.ceil(Math.sqrt(Math.max(1, Math.round((up1 - up0) / units.size[1])) * Math.max(1, Math.round(len / units.size[0])) / BREACH_GRID_CAP)));
68448
+ const ul = units.size[0] * merge, uh = units.size[1] * merge;
68449
+ const rows = Math.max(1, Math.round((up1 - up0) / uh));
68450
+ const rowH = (up1 - up0) / rows;
68027
68451
  const per = Math.max(1, Math.round(len / ul));
68028
68452
  const w = len / per;
68029
68453
  const out = [];
@@ -68031,7 +68455,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
68031
68455
  const shift = units.bond === "running" && r & 1 ? w / 2 : 0;
68032
68456
  for (let i = 0; i < per + (shift ? 1 : 0); i++) {
68033
68457
  const a = Math.max(0, i * w - shift), b = Math.min(len, i * w - shift + w);
68034
- if (b - a > 1e-3) out.push({ a: offset + a, b: offset + b, y0: part.y0 + r * rowH, y1: part.y0 + (r + 1) * rowH, r, i });
68458
+ if (b - a > 1e-3) out.push({ a: offset + a, b: offset + b, y0: up0 + r * rowH, y1: up0 + (r + 1) * rowH, r, i });
68035
68459
  }
68036
68460
  }
68037
68461
  return out;
@@ -68099,8 +68523,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
68099
68523
  return [...first, ...other];
68100
68524
  }
68101
68525
  const pillarSpans = (view) => structure.parts.filter((q) => q.role === "column" && wallsAround(q).includes(view.host)).map((q) => {
68102
- const a = (view.mask.alongU ? q.aabb[0] : q.aabb[1]) - view.mask.start, b = (view.mask.alongU ? q.aabb[2] : q.aabb[3]) - view.mask.start;
68103
- return { a, b, y0: q.y0, y1: q.y1 };
68526
+ const [from, to] = extentOf(q, view.mask.axes.along), [y0, y1] = extentOf(q, view.mask.axes.up);
68527
+ return { a: from - view.mask.start, b: to - view.mask.start, y0, y1 };
68104
68528
  });
68105
68529
  const windowGaps = (view) => (structure.openings ?? []).filter((o) => o.kind === "window" && o.wall === view.host).map((o) => ({ a: Math.min(o.from, o.to) - view.mask.start, b: Math.max(o.from, o.to) - view.mask.start, y0: o.y0, y1: o.y1 }));
68106
68530
  function outsideGaps(c, gaps) {
@@ -68149,9 +68573,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
68149
68573
  sh.uniforms.uToHouse = toHouse;
68150
68574
  sh.uniforms.uMask = { value: mask.texture };
68151
68575
  sh.uniforms.uMaskRect = { value: mask.rect };
68152
- sh.uniforms.uMaskAlongX = { value: mask.alongU ? 1 : 0 };
68576
+ sh.uniforms.uMaskAlong = { value: axisVector(mask.axes.along) };
68577
+ sh.uniforms.uMaskUp = { value: axisVector(mask.axes.up) };
68153
68578
  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;");
68154
- 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;");
68579
+ sh.fragmentShader = sh.fragmentShader.replace("void main() {", "uniform sampler2D uMask;\nuniform vec4 uMaskRect;\nuniform vec3 uMaskAlong;\nuniform vec3 uMaskUp;\nvarying vec3 vHousePos;\nvoid main() {\n vec2 mUv = vec2((dot(vHousePos, uMaskAlong) - uMaskRect.x) / uMaskRect.z, (dot(vHousePos, uMaskUp) - 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;");
68155
68580
  };
68156
68581
  material.customProgramCacheKey = () => "breachMask" + (base2.customProgramCacheKey?.() ?? "");
68157
68582
  const mesh3 = new THREE.Mesh(g, material);
@@ -68159,7 +68584,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
68159
68584
  mesh3.userData.breachMask = mask;
68160
68585
  mesh3.userData.cutAt = (p) => {
68161
68586
  const v = local2([p.x, p.y, p.z]);
68162
- const i = Math.floor(((mask.alongU ? v[0] : v[2]) - mask.start) / mask.len * mask.w), j = Math.floor((v[1] - mask.y0) / mask.height * mask.h);
68587
+ const i = Math.floor((v[mask.axes.along] - mask.start) / mask.len * mask.w), j = Math.floor((v[mask.axes.up] - mask.y0) / mask.height * mask.h);
68163
68588
  return i >= 0 && i < mask.w && j >= 0 && j < mask.h && mask.data[j * mask.w + i] > 127;
68164
68589
  };
68165
68590
  mesh3.position.copy(it.mesh.position);
@@ -68186,9 +68611,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
68186
68611
  material.onBeforeCompile = (sh) => {
68187
68612
  sh.uniforms.uCore = { value: core.texture };
68188
68613
  sh.uniforms.uCoreRect = { value: core.rect };
68189
- sh.uniforms.uCoreAlongX = { value: core.alongU ? 1 : 0 };
68614
+ sh.uniforms.uCoreAlong = { value: axisVector(core.axes.along) };
68615
+ sh.uniforms.uCoreUp = { value: axisVector(core.axes.up) };
68190
68616
  sh.vertexShader = sh.vertexShader.replace("void main() {", "varying vec3 vHousePos;\nvoid main() {").replace("#include <begin_vertex>", "#include <begin_vertex>\n#ifdef USE_INSTANCING\nvHousePos = (instanceMatrix * vec4(transformed, 1.0)).xyz;\n#else\nvHousePos = transformed;\n#endif");
68191
- sh.fragmentShader = sh.fragmentShader.replace("void main() {", "uniform sampler2D uCore;\nuniform vec4 uCoreRect;\nuniform float uCoreAlongX;\nvarying vec3 vHousePos;\nvoid main() {\n vec2 cUv = vec2(((uCoreAlongX > 0.5 ? vHousePos.x : vHousePos.z) - uCoreRect.x) / uCoreRect.z, (vHousePos.y - uCoreRect.y) / uCoreRect.w);\n if (cUv.x >= 0.0 && cUv.x <= 1.0 && cUv.y >= 0.0 && cUv.y <= 1.0 && texture2D(uCore, cUv).r > 0.5) discard;").replace("#include <color_fragment>", "#include <color_fragment>\nif (!gl_FrontFacing) diffuseColor.rgb *= 0.55;");
68617
+ sh.fragmentShader = sh.fragmentShader.replace("void main() {", "uniform sampler2D uCore;\nuniform vec4 uCoreRect;\nuniform vec3 uCoreAlong;\nuniform vec3 uCoreUp;\nvarying vec3 vHousePos;\nvoid main() {\n vec2 cUv = vec2((dot(vHousePos, uCoreAlong) - uCoreRect.x) / uCoreRect.z, (dot(vHousePos, uCoreUp) - uCoreRect.y) / uCoreRect.w);\n if (cUv.x >= 0.0 && cUv.x <= 1.0 && cUv.y >= 0.0 && cUv.y <= 1.0 && texture2D(uCore, cUv).r > 0.5) discard;").replace("#include <color_fragment>", "#include <color_fragment>\nif (!gl_FrontFacing) diffuseColor.rgb *= 0.55;");
68192
68618
  };
68193
68619
  material.customProgramCacheKey = () => "breachCore";
68194
68620
  material.userData.breachCore = core;
@@ -68207,17 +68633,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
68207
68633
  }
68208
68634
  function maskOf(hostId, parts2) {
68209
68635
  const host = structure.byId.get(hostId);
68210
- const [u0, v0, u1, v1] = host.aabb;
68211
- const alongU = u1 - u0 >= v1 - v0;
68212
- const y0 = Math.min(...parts2.map((id) => structure.byId.get(id).y0)), y1 = Math.max(...parts2.map((id) => structure.byId.get(id).y1));
68213
- const len = alongU ? u1 - u0 : v1 - v0;
68636
+ const axes = planeAxesOf(host);
68637
+ const [start, end3] = extentOf(host, axes.along);
68638
+ const y0 = Math.min(...parts2.map((id) => extentOf(structure.byId.get(id), axes.up)[0])), y1 = Math.max(...parts2.map((id) => extentOf(structure.byId.get(id), axes.up)[1]));
68639
+ const len = end3 - start;
68214
68640
  const w = Math.max(2, Math.min(2048, Math.ceil(len / MASK_TEXEL))), h = Math.max(2, Math.min(1024, Math.ceil((y1 - y0) / MASK_TEXEL)));
68215
68641
  const data = new Uint8Array(w * h);
68216
68642
  const texture = new THREE.DataTexture(data, w, h, THREE.RedFormat);
68217
68643
  texture.magFilter = THREE.LinearFilter;
68218
68644
  texture.minFilter = THREE.LinearFilter;
68219
68645
  texture.needsUpdate = true;
68220
- return { data, texture, w, h, alongU, start: alongU ? u0 : v0, len, y0, height: y1 - y0, rect: new THREE.Vector4(alongU ? u0 : v0, y0, len, y1 - y0) };
68646
+ return { data, texture, w, h, axes, start, len, y0, height: y1 - y0, rect: new THREE.Vector4(start, y0, len, y1 - y0) };
68221
68647
  }
68222
68648
  function besidePillars(c, pillars) {
68223
68649
  let { a, b } = c;
@@ -68246,13 +68672,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
68246
68672
  }
68247
68673
  function splitUnits(view, id, around) {
68248
68674
  const { mask } = view;
68249
- const along22 = (p) => (mask.alongU ? p[0] : p[2]) - mask.start;
68675
+ const along22 = (p) => p[mask.axes.along] - mask.start;
68676
+ const upOf = (p) => p[mask.axes.up];
68250
68677
  const part = structure.byId.get(id), units = specOf(id).units, chips2 = view.chips.get(id), opening = view.openings.get(id);
68251
68678
  const own = cells(part, units, mask);
68252
68679
  const all = (id === view.host ? own.flatMap((c) => besidePillars(c, around.pillars)) : own).flatMap((c) => outsideGaps(c, around.gaps));
68253
68680
  const holes = [], kept = [];
68254
68681
  if (view.fallen.has(id)) return { all, kept, holes: all, boxes: [] };
68255
- const boxes = chips2.map((k) => ({ s0: along22(k.center) - k.along, s1: along22(k.center) + k.along, y0: k.center[1] - k.up, y1: k.center[1] + k.up }));
68682
+ const boxes = chips2.map((k) => ({ s0: along22(k.center) - k.along, s1: along22(k.center) + k.along, y0: upOf(k.center) - k.up, y1: upOf(k.center) + k.up }));
68256
68683
  const gone = (c) => {
68257
68684
  const over = boxes.filter((k) => k.s1 > c.a && k.s0 < c.b && k.y1 > c.y0 && k.y0 < c.y1);
68258
68685
  const share = covered(c, over);
@@ -68260,7 +68687,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
68260
68687
  const s = (c.a + c.b) / 2, y = (c.y0 + c.y1) / 2;
68261
68688
  return share >= 0.5 && over.some((k) => s >= k.s0 && s <= k.s1 && y >= k.y0 && y <= k.y1);
68262
68689
  };
68263
- const open = (c) => gone(c) || opening !== void 0 && Math.hypot((c.a + c.b) / 2 - along22(opening.center), (c.y0 + c.y1) / 2 - opening.center[1]) < opening.radius;
68690
+ const open = (c) => gone(c) || opening !== void 0 && Math.hypot((c.a + c.b) / 2 - along22(opening.center), (c.y0 + c.y1) / 2 - upOf(opening.center)) < opening.radius;
68264
68691
  for (const c of all) (open(c) ? holes : kept).push(c);
68265
68692
  return { all, kept, holes, boxes };
68266
68693
  }
@@ -68273,20 +68700,22 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
68273
68700
  function publishStanding(view) {
68274
68701
  if (!view.saved) return;
68275
68702
  const { mask } = view;
68276
- const along22 = (p) => (mask.alongU ? p[0] : p[2]) - mask.start;
68703
+ const along22 = (p) => p[mask.axes.along] - mask.start;
68704
+ const upOf = (p) => p[mask.axes.up];
68277
68705
  const parts2 = view.parts.map((id) => {
68278
68706
  const part = structure.byId.get(id);
68279
- const thick = mask.alongU ? part.aabb[3] - part.aabb[1] : part.aabb[2] - part.aabb[0];
68280
- const mid = mask.alongU ? (part.aabb[1] + part.aabb[3]) / 2 : (part.aabb[0] + part.aabb[2]) / 2;
68281
- const gone = (view.chips.get(id) ?? []).map((k) => ({ a: along22(k.center) - k.along, b: along22(k.center) + k.along, y0: k.center[1] - k.up, y1: k.center[1] + k.up }));
68707
+ const [across0, across1] = extentOf(part, mask.axes.across);
68708
+ const thick = across1 - across0, mid = (across0 + across1) / 2;
68709
+ const gone = (view.chips.get(id) ?? []).map((k) => ({ a: along22(k.center) - k.along, b: along22(k.center) + k.along, y0: upOf(k.center) - k.up, y1: upOf(k.center) + k.up }));
68282
68710
  return { spans: view.kept.get(id) ?? [], gone, thick, mid };
68283
68711
  });
68284
- const line = { alongU: mask.alongU, start: mask.start, open: view.core };
68712
+ const line = { axes: mask.axes, start: mask.start, open: view.core };
68285
68713
  view.items.forEach((it, k) => publishSolids(it.mesh, it.v0, it.v1, k === 0 ? standingSolids(THREE, house, it.mesh, line, parts2) : []));
68286
68714
  }
68287
68715
  function paint2(view) {
68288
68716
  const { mask, core } = view;
68289
- const along22 = (p) => (mask.alongU ? p[0] : p[2]) - mask.start;
68717
+ const along22 = (p) => p[mask.axes.along] - mask.start;
68718
+ const upOf = (p) => p[mask.axes.up];
68290
68719
  const holes = [];
68291
68720
  const pits = [];
68292
68721
  const discs = [];
@@ -68302,10 +68731,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
68302
68731
  view.kept.set(id, []);
68303
68732
  continue;
68304
68733
  }
68305
- const thick = mask.alongU ? part.aabb[3] - part.aabb[1] : part.aabb[2] - part.aabb[0];
68306
- const mid = mask.alongU ? (part.aabb[1] + part.aabb[3]) / 2 : (part.aabb[0] + part.aabb[2]) / 2;
68307
- if (opening) discs.push({ s: along22(opening.center), y: opening.center[1], r: opening.radius });
68308
- for (const k of spalls) flakes.push({ s: along22(k.center), y: k.center[1], r: k.radius });
68734
+ const [across0, across1] = extentOf(part, mask.axes.across);
68735
+ const thick = across1 - across0, mid = (across0 + across1) / 2;
68736
+ if (opening) discs.push({ s: along22(opening.center), y: upOf(opening.center), r: opening.radius });
68737
+ for (const k of spalls) flakes.push({ s: along22(k.center), y: upOf(k.center), r: k.radius });
68309
68738
  holes.push(...lost);
68310
68739
  view.kept.set(id, kept);
68311
68740
  if (units2.mortar === part.material) {
@@ -68361,18 +68790,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
68361
68790
  const list2 = [];
68362
68791
  const tone = (hex2, k) => tmp.c.setHex(hex2).multiplyScalar(k).getHex();
68363
68792
  const b = view.bounds;
68364
- const inner = mask.alongU ? [b[0] + COVER2, b[1], b[2], b[3] - COVER2, b[4] - COVER2, b[5]] : [b[0], b[1], b[2] + COVER2, b[3], b[4] - COVER2, b[5] - COVER2];
68793
+ const inner = coatedInside(b, mask.axes);
68365
68794
  for (const { c, part, units: units2, thick, mid } of shown2) {
68366
68795
  if (!near(c)) continue;
68367
68796
  const centre = mask.start + (c.a + c.b) / 2, y = (c.y0 + c.y1) / 2, len = c.b - c.a, h = c.y1 - c.y0;
68368
68797
  const at4 = (s, dy, d, colour) => {
68369
- 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);
68370
- 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);
68798
+ const unit = clipToBox(unitBoxOf(mask.axes, [centre, y, mid], [s, dy, d], colour), inner);
68799
+ if (unit && !discs.some((k) => {
68800
+ const p = [unit.x, unit.y, unit.z];
68801
+ return Math.hypot(p[mask.axes.along] - mask.start - k.s, p[mask.axes.up] - k.y) < k.r;
68802
+ })) list2.push(unit);
68371
68803
  };
68372
68804
  const base2 = fragmentMaterial(part.material).color.getHex();
68373
68805
  const n = noise2(centre * 3.1, y * 2.7, 0.07);
68374
68806
  if (units2.mortar === "concrete") {
68375
- at4(len, h, thick - 2 * COVER2, tone(base2, 0.9 + 0.04 * n));
68807
+ at4(len - CAST_GAP, h - CAST_GAP, thick - 2 * COVER2, tone(base2, 0.9 + 0.04 * n));
68376
68808
  } else {
68377
68809
  at4(len, h, thick - 2 * COVER2 - 0.012, 10327948);
68378
68810
  at4(len - 0.012, h - 0.012, thick - 2 * COVER2, tone(base2, 0.8 + 0.35 * n));
@@ -68401,14 +68833,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
68401
68833
  view.flakes = flakes.length;
68402
68834
  publishStanding(view);
68403
68835
  }
68404
- function chipBox(chip, alongU) {
68836
+ function chipBox(chip, axes) {
68405
68837
  house.updateWorldMatrix(true, false);
68406
68838
  const q = tmp.q.set(chip.rotation[0], chip.rotation[1], chip.rotation[2], chip.rotation[3]).premultiply(house.getWorldQuaternion(new THREE.Quaternion()).invert());
68407
68839
  let a = 0, u = 0;
68408
68840
  for (let k = 0; k < 3; k++) {
68409
68841
  const axis2 = tmp.p.set(k === 0 ? 1 : 0, k === 1 ? 1 : 0, k === 2 ? 1 : 0).applyQuaternion(q);
68410
- a += Math.abs(alongU ? axis2.x : axis2.z) * chip.size[k] / 2;
68411
- u += Math.abs(axis2.y) * chip.size[k] / 2;
68842
+ a += Math.abs(axis2.getComponent(axes.along)) * chip.size[k] / 2;
68843
+ u += Math.abs(axis2.getComponent(axes.up)) * chip.size[k] / 2;
68412
68844
  }
68413
68845
  return { center: local2(chip.center), along: a, up: u };
68414
68846
  }
@@ -68444,12 +68876,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
68444
68876
  const grey = fragmentMaterial("concrete").color.getHex();
68445
68877
  const stone = (s, y, d, size, r) => {
68446
68878
  const centre = mask.start + s;
68447
- const unit = clipToBox({ x: mask.alongU ? centre : d, y, z: mask.alongU ? d : centre, sx: mask.alongU ? size[0] : size[2], sy: size[1], sz: mask.alongU ? size[2] : size[0], colour: tmp.c.setHex(grey).multiplyScalar(0.85 + 0.2 * r(7)).getHex() }, bounds2);
68448
- if (unit) out.push(unit);
68879
+ const unit = clipToBox(unitBoxOf(mask.axes, [centre, y, d], size, tmp.c.setHex(grey).multiplyScalar(0.85 + 0.2 * r(7)).getHex()), bounds2);
68880
+ if (unit && !isSliver(unit, size) && !out.some((k) => overlapsStone(k, unit))) out.push(unit);
68449
68881
  };
68450
68882
  for (const { c, part, thick, mid } of gone) {
68451
- const p0 = (mask.alongU ? part.aabb[0] : part.aabb[1]) - mask.start, p1 = (mask.alongU ? part.aabb[2] : part.aabb[3]) - mask.start;
68452
- const lying = p1 - p0 > part.y1 - part.y0;
68883
+ const [from, to] = extentOf(part, mask.axes.along), [up0, up1] = extentOf(part, mask.axes.up);
68884
+ const p0 = from - mask.start, p1 = to - mask.start;
68885
+ const lying = p1 - p0 > up1 - up0;
68453
68886
  const random = (seed) => (n) => {
68454
68887
  const x = Math.sin(seed + n * 3.3) * 43758.5453;
68455
68888
  return x - Math.floor(x);
@@ -68467,7 +68900,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
68467
68900
  stone(s, y, d, [size, size * (0.6 + 0.5 * r(4)), size], r);
68468
68901
  }
68469
68902
  }
68470
- const bars = lying ? [part.y0 + LUMP_BAR_INSET, part.y1 - LUMP_BAR_INSET].filter((y) => y >= c.y0 - 1e-6 && y <= c.y1 + 1e-6) : [p0 + LUMP_BAR_INSET, p1 - LUMP_BAR_INSET].filter((s) => s >= c.a - 1e-6 && s <= c.b + 1e-6);
68903
+ const bars = lying ? [up0 + LUMP_BAR_INSET, up1 - LUMP_BAR_INSET].filter((y) => y >= c.y0 - 1e-6 && y <= c.y1 + 1e-6) : [p0 + LUMP_BAR_INSET, p1 - LUMP_BAR_INSET].filter((s) => s >= c.a - 1e-6 && s <= c.b + 1e-6);
68471
68904
  for (const bar2 of bars) {
68472
68905
  for (const side of [-1, 1]) {
68473
68906
  const d = mid + side * (thick / 2 - LUMP_BAR_INSET);
@@ -68527,8 +68960,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
68527
68960
  if (view.openings.has(partId)) return false;
68528
68961
  view.openings.set(partId, { center: local2(change.opening.center), radius: change.opening.radius });
68529
68962
  }
68530
- if (change.chip) view.chips.get(partId).push(chipBox(change.chip, view.mask.alongU));
68531
- for (const chip of change.chips ?? []) view.chips.get(partId).push(chipBox(chip, view.mask.alongU));
68963
+ if (change.chip) view.chips.get(partId).push(chipBox(change.chip, view.mask.axes));
68964
+ for (const chip of change.chips ?? []) view.chips.get(partId).push(chipBox(chip, view.mask.axes));
68532
68965
  if (change.spall) {
68533
68966
  const list2 = view.spalls.get(partId);
68534
68967
  list2.push({ center: local2(change.spall.center), radius: change.spall.radius });
@@ -68629,13 +69062,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
68629
69062
  },
68630
69063
  /**
68631
69064
  * What still stands of the units of `partId` once its wall is cut, as drawn: spans along the wall from `start` (in the house's space, along u when
68632
- * `alongU`) and up. Null while the wall is whole (all of the part stands).
69065
+ * `axes.along`) and up `axes.up`. Null while the wall is whole (all of the part stands).
68633
69066
  */
68634
69067
  standing(partId) {
68635
69068
  const hostId = hostOf(partId), view = hostId ? views.get(hostId) : void 0;
68636
69069
  if (view?.keptStale) refreshKept(view);
68637
69070
  const spans = view?.saved ? view.kept.get(partId) : void 0;
68638
- return view && spans ? { spans, alongU: view.mask.alongU, start: view.mask.start } : null;
69071
+ return view && spans ? { spans, axes: view.mask.axes, start: view.mask.start } : null;
68639
69072
  },
68640
69073
  /** Handles a `stage` event of the house's object. Returns true when the wall was cut. */
68641
69074
  stage(event) {
@@ -69090,8 +69523,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
69090
69523
  if (du * du + dv * dv >= radius * radius) continue;
69091
69524
  const left = breach.standing(part.id);
69092
69525
  if (!left) return true;
69093
- const s0 = (left.alongU ? lx : lz) - left.start;
69094
- const low1 = Math.min(ly0, ly1), high1 = Math.max(ly0, ly1);
69526
+ const s0 = (left.axes.along === 0 ? lx : lz) - left.start;
69527
+ const flat2 = left.axes.up !== 1, t0 = left.axes.up === 0 ? lx : lz;
69528
+ const low1 = flat2 ? t0 - radius : Math.min(ly0, ly1), high1 = flat2 ? t0 + radius : Math.max(ly0, ly1);
69095
69529
  for (const c of left.spans) if (c.b > s0 - radius && c.a < s0 + radius && c.y1 > low1 && c.y0 < high1) return true;
69096
69530
  }
69097
69531
  return false;
@@ -70927,13 +71361,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
70927
71361
  function seatStructure(L, c, seats, options) {
70928
71362
  return [...base(L, c, seats, options.plinth), ...back(L, c), ...arms(L, c, options.boardBack)];
70929
71363
  }
70930
- function cushion(block, id) {
70931
- return { ...block, id, material: "foam", layers: CLOTH_COVER };
71364
+ function cushion(block2, id) {
71365
+ return { ...block2, id, material: "foam", layers: CLOTH_COVER };
70932
71366
  }
70933
71367
  var SOFAS = /^sofa_/;
70934
71368
  var ARMCHAIRS = /^armchair/;
70935
71369
  var BEDS = /^(double_bed|queen_bed|king_bed|single_bed|mattress)$/;
70936
- var seatsOf = (cushions) => cushions.map((block, k) => ({ x: block.position[0], ...cushions[k + 1] ? { seam: (block.position[0] + cushions[k + 1].position[0]) / 2 } : {} }));
71370
+ var seatsOf = (cushions) => cushions.map((block2, k) => ({ x: block2.position[0], ...cushions[k + 1] ? { seam: (block2.position[0] + cushions[k + 1].position[0]) / 2 } : {} }));
70937
71371
  function sofaParts(drawn) {
70938
71372
  const woods = drawn.filter((p) => p.key === "wood");
70939
71373
  const cloth2 = drawn.filter((p) => p.key === "fabric");
@@ -70975,7 +71409,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
70975
71409
  };
70976
71410
  const colours = { wood: feet[0].color, skirt: skirt.color, back: back2.color, arm: armLeft.color };
70977
71411
  const structure = seatStructure(layout, colours, seatsOf(seatCushions), { plinth: false, boardBack: layout.backFrame });
70978
- const cushions = [...seatCushions.map((block, k) => cushion(block, `seat_cushion_${k}`)), ...backCushions.map((block, k) => cushion(block, `back_cushion_${k}`)), cushion(pillow, "accent_pillow")];
71412
+ const cushions = [...seatCushions.map((block2, k) => cushion(block2, `seat_cushion_${k}`)), ...backCushions.map((block2, k) => cushion(block2, `back_cushion_${k}`)), cushion(pillow, "accent_pillow")];
70979
71413
  return [...structure, ...cushions];
70980
71414
  }
70981
71415
  var ARMCHAIR_SUPPORT = 0.28;
@@ -71348,18 +71782,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
71348
71782
  };
71349
71783
  return { spec, build, top, fixed: fixed2 };
71350
71784
  }
71785
+ var furnitureCatalogEntry = (type, catalog) => (catalog ?? residentialItems).find((i) => i.type === type);
71351
71786
  function furnitureSpec(THREE, type, opts = {}) {
71352
71787
  const renderer = rendererOf(THREE, opts.document);
71353
71788
  const ent = renderer.types[type];
71354
71789
  if (!ent) throw new Error(`game-floorplan-three: no builder for the furniture type "${type}"`);
71355
- const entry2 = (opts.catalog ?? residentialItems).find((i) => i.type === type);
71790
+ const entry2 = furnitureCatalogEntry(type, opts.catalog);
71356
71791
  const w = opts.w ?? entry2?.w;
71357
71792
  const d = opts.d ?? entry2?.d;
71358
71793
  const h = opts.h ?? entry2?.h;
71359
71794
  if (w === void 0 || d === void 0 || h === void 0) throw new Error(`game-floorplan-three: furniture type "${type}" is not in the catalogue, so give w, d and h`);
71360
71795
  const o = opts.options ?? {};
71361
71796
  const seed = Math.round(opts.seed ?? 1);
71362
- const plain2 = SHELVING.test(type) ? "paper" : "plastic";
71797
+ const plain2 = entry2?.material ?? (SHELVING.test(type) ? "paper" : "plastic");
71363
71798
  const root = { x: seed, z: 0, ry: 0, w, d, h, y: 0, base: 0, palette: o.palette, seed: `furniture_${type}_${seed}` };
71364
71799
  const { K, shared: shared3 } = renderer.internals;
71365
71800
  const before = K.PARTS.length;
@@ -73395,7 +73830,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
73395
73830
  hgFrac: 0.9,
73396
73831
  rail: 1,
73397
73832
  scope: 1,
73398
- rpm: 1100
73833
+ rpm: 1100,
73834
+ eject: "down"
73399
73835
  }
73400
73836
  },
73401
73837
  thompson_m1a1: {
@@ -73546,7 +73982,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
73546
73982
  length: 660,
73547
73983
  barrel: 470,
73548
73984
  options: {
73549
- shot: 1
73985
+ shot: 1,
73986
+ eject: "down"
73550
73987
  }
73551
73988
  },
73552
73989
  saiga_12: {
@@ -74736,7 +75173,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
74736
75173
  fore: 0.55,
74737
75174
  gas: 1,
74738
75175
  charge: 1,
74739
- bayo: 1
75176
+ bayo: 1,
75177
+ eject: "up"
74740
75178
  },
74741
75179
  variantOf: "sks"
74742
75180
  },
@@ -74924,7 +75362,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
74924
75362
  fore: 0,
74925
75363
  bands: 1,
74926
75364
  br: 0.012,
74927
- m1887: 1
75365
+ m1887: 1,
75366
+ eject: "up"
74928
75367
  },
74929
75368
  variantOf: "winchester_1894"
74930
75369
  },
@@ -75845,6 +76284,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
75845
76284
  kit.torus(lever, ring3, M.metal, 0, 0, 0);
75846
76285
  parts2.muzzle = kit.mark(group, length2 + 0.01, 0, 0);
75847
76286
  parts2.eject = kit.mark(group, middle + 0.02, 0.012, 0.01);
76287
+ if (options.eject) parts2.ejectSide = options.eject;
75848
76288
  parts2.loadPort = kit.mark(group, middle + 0.03, -0.035, 0.02);
75849
76289
  parts2.topLoad = parts2.eject;
75850
76290
  parts2.frames = {
@@ -76093,7 +76533,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
76093
76533
  const ejectX = receiverEnd - (options.ejectBack || 0.07);
76094
76534
  const ejectY = options.ar ? receiverHeight * 0.2 : by;
76095
76535
  parts2.muzzle = kit.mark(group, length2 + 0.01, by, 0);
76096
- parts2.eject = kit.mark(group, ejectX, ejectY, wR / 2 + 6e-3);
76536
+ const ejectsDown = options.eject === "down";
76537
+ if (ejectsDown) kit.box(group, 0.05, 2e-3, wR * 0.5, M.hole, ejectX, -receiverHeight / 2 - 1e-3, 0);
76538
+ parts2.eject = ejectsDown ? kit.mark(group, ejectX, -receiverHeight / 2 - 4e-3, 0) : kit.mark(group, ejectX, ejectY, wR / 2 + 6e-3);
76539
+ if (options.eject) parts2.ejectSide = options.eject;
76097
76540
  parts2.loadPort = kit.mark(group, receiverEnd - 0.05, -receiverHeight / 2 - 4e-3, 0);
76098
76541
  parts2.topLoad = kit.mark(group, ejectX, receiverHeight / 2 + 4e-3, 0);
76099
76542
  parts2.family = familyOf(options);
@@ -76364,7 +76807,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
76364
76807
  box5(group, 0.026, 0.075, 0.026, body, bodyLength + 0.05, -0.05, 0, 0.1);
76365
76808
  }
76366
76809
  parts2.muzzle = kit.mark(group, L + 0.01, 0.012, 0);
76367
- parts2.eject = kit.mark(group, bodyLength * 0.25, 5e-3, 0.03);
76810
+ if (options.eject === "down") {
76811
+ box5(group, 0.05, 2e-3, 0.024, M.hole, bodyLength * 0.25, -0.0385, 0);
76812
+ parts2.eject = kit.mark(group, bodyLength * 0.25, -0.042, 0);
76813
+ parts2.ejectSide = "down";
76814
+ } else parts2.eject = kit.mark(group, bodyLength * 0.25, 5e-3, 0.03);
76368
76815
  return { group, parts: parts2 };
76369
76816
  }
76370
76817
 
@@ -76375,14 +76822,30 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
76375
76822
  const tube2 = new THREE.Mesh(new THREE.TubeGeometry(curve, 40, radius, 8, false), material);
76376
76823
  tube2.castShadow = tube2.receiveShadow = true;
76377
76824
  group.add(tube2);
76825
+ return tube2;
76826
+ };
76827
+ var fuelPack = (kit, target) => {
76828
+ const { M, box: box5, cylinderY, sphere: sphere2 } = kit;
76829
+ for (const z of [-0.1, 0.1]) {
76830
+ cylinderY(target, 0.085, 0.5, M.olive, -0.3, -0.05, z, 20);
76831
+ sphere2(target, 0.085, M.olive, -0.3, 0.2, z, 2).scale.y = 0.45;
76832
+ sphere2(target, 0.085, M.olive, -0.3, -0.3, z, 2).scale.y = 0.45;
76833
+ cylinderY(target, 0.03, 0.03, M.metal, -0.3, 0.24, z, 12);
76834
+ }
76835
+ sphere2(target, 0.075, M.olive, -0.3, 0.1, 0, 2).position.x = -0.39;
76836
+ box5(target, 0.03, 0.6, 0.24, M.dark, -0.4, -0.05, 0);
76837
+ cylinderY(target, 0.03, 0.012, M.metal, -0.39, 0.18, 0, 14);
76838
+ const gauge = kit.pivot(target, -0.39, 0.18, 3e-3);
76839
+ box5(gauge, 2e-3, 0.022, 2e-3, M.red, 0, 8e-3, 0.012);
76840
+ return gauge;
76378
76841
  };
76379
76842
  var pilot = (kit, group, x, y) => {
76380
76843
  const { M, cylinderX } = kit;
76381
76844
  cylinderX(group, 6e-3, 0.03, M.fire2, x + 0.015, y, 0, 6, 0).userData.flame = 1;
76382
76845
  cylinderX(group, 4e-3, 0.022, M.fire, x + 0.012, y, 0, 6, 0).userData.flame = 1;
76383
76846
  };
76384
- function buildFlamethrower(kit, group, parts2) {
76385
- const { M, box: box5, cylinderX, cylinderY, sphere: sphere2 } = kit;
76847
+ function buildFlamethrower(kit, group, parts2, separate = false) {
76848
+ const { M, box: box5, cylinderX } = kit;
76386
76849
  parts2.kick = 0.15;
76387
76850
  heatify(parts2.glow, cylinderX(group, 0.016, 0.62, M.steel, 0.42, 0, 0, 14));
76388
76851
  cylinderX(group, 0.022, 0.1, M.dark, 0.78, 0, 0, 14);
@@ -76400,19 +76863,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
76400
76863
  box5(rearGrip, 0.03, 0.1, 0.03, M.wood, 0, -0.05, 0);
76401
76864
  box5(group, 0.05, 4e-3, 0.012, M.metal, 0.2, -0.035, 0);
76402
76865
  cylinderX(group, 0.02, 0.04, M.metal, 0.1, 0, 0, 12);
76403
- hose(kit, group, [[0.08, 0, 0], [0, -0.04, 0], [-0.08, -0.2, 0.05], [-0.18, -0.32, 0.08], [-0.25, -0.33, 0.08]], 0.011, M.rubber);
76404
- for (const z of [-0.1, 0.1]) {
76405
- cylinderY(group, 0.085, 0.5, M.olive, -0.3, -0.05, z, 20);
76406
- sphere2(group, 0.085, M.olive, -0.3, 0.2, z, 2).scale.y = 0.45;
76407
- sphere2(group, 0.085, M.olive, -0.3, -0.3, z, 2).scale.y = 0.45;
76408
- cylinderY(group, 0.03, 0.03, M.metal, -0.3, 0.24, z, 12);
76409
- }
76410
- sphere2(group, 0.075, M.olive, -0.3, 0.1, 0, 2).position.x = -0.39;
76411
- box5(group, 0.03, 0.6, 0.24, M.dark, -0.4, -0.05, 0);
76412
- cylinderY(group, 0.03, 0.012, M.metal, -0.39, 0.18, 0, 14);
76413
- const gauge = kit.pivot(group, -0.39, 0.18, 3e-3);
76414
- parts2.gauge = gauge;
76415
- box5(gauge, 2e-3, 0.022, 2e-3, M.red, 0, 8e-3, 0.012);
76866
+ if (separate) {
76867
+ const pack2 = kit.group();
76868
+ parts2.gauge = fuelPack(kit, pack2);
76869
+ hose(kit, group, [[0.08, 0, 0], [0, -0.04, 0], [-0.08, -0.2, 0.05]], 0.011, M.rubber);
76870
+ parts2.worn = { root: pack2, mount: kit.pivot(pack2, -0.415, -0.05, 0), port: kit.pivot(pack2, -0.25, -0.33, 0.08), wandEnd: kit.pivot(group, -0.08, -0.2, 0.05), hoseMaterial: M.rubber };
76871
+ } else {
76872
+ hose(kit, group, [[0.08, 0, 0], [0, -0.04, 0], [-0.08, -0.2, 0.05], [-0.18, -0.32, 0.08], [-0.25, -0.33, 0.08]], 0.011, M.rubber);
76873
+ parts2.gauge = fuelPack(kit, group);
76874
+ }
76416
76875
  parts2.muzzle = kit.pivot(group, 0.94, 0, 0);
76417
76876
  parts2.rear = kit.pivot(group, 0.1, 0, 0);
76418
76877
  }
@@ -76603,7 +77062,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
76603
77062
  const type = options.lt ?? "";
76604
77063
  const isFlame = type === "flame" || type === "flameDIY";
76605
77064
  const parts2 = { family: isFlame ? "flame" : "rocket", launcherType: type, glow: [] };
76606
- if (type === "flame") buildFlamethrower(kit, group, parts2);
77065
+ if (type === "flame") buildFlamethrower(kit, group, parts2, options.separateWorn === true);
76607
77066
  else if (type === "flameDIY") buildImprovisedFlamethrower(kit, group, parts2);
76608
77067
  else ROCKET_BUILDERS[type]?.(kit, group, parts2);
76609
77068
  parts2.eject = parts2.muzzle;
@@ -76806,6 +77265,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
76806
77265
  };
76807
77266
  parts2.muzzle = kit.mark(group, BARREL_END + 0.01, 0, 0);
76808
77267
  parts2.eject = kit.mark(group, 0.3, -0.07, 0.08);
77268
+ parts2.ejectSide = "down";
76809
77269
  return { group, parts: parts2 };
76810
77270
  }
76811
77271
 
@@ -76843,6 +77303,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
76843
77303
  box5(tripod, 0.012, 0.62, 0.012, M.metal, 0.22, -0.25, -0.16, -0.75, 0, -0.3);
76844
77304
  parts2.muzzle = kit.mark(group, 1.72, 0.01, 0);
76845
77305
  parts2.eject = kit.mark(group, 0.3, -0.07, 0);
77306
+ parts2.ejectSide = "down";
76846
77307
  return { group, parts: parts2 };
76847
77308
  }
76848
77309
 
@@ -76967,6 +77428,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
76967
77428
  parts2.trigger = box5(group, 4e-3, 0.016, 4e-3, M.dark, 0.24, -0.045, 0);
76968
77429
  parts2.muzzle = kit.mark(group, 0.48, 0, 0);
76969
77430
  parts2.eject = kit.mark(group, 0.2, -0.07, 0);
77431
+ parts2.ejectSide = "down";
76970
77432
  return { group, parts: parts2 };
76971
77433
  }
76972
77434
 
@@ -77077,6 +77539,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
77077
77539
  };
77078
77540
  parts2.muzzle = kit.mark(group, length2, 0, 0);
77079
77541
  parts2.eject = kit.mark(group, 0.12, -0.092, 0);
77542
+ parts2.ejectSide = "down";
77080
77543
  return { group, parts: parts2 };
77081
77544
  }
77082
77545
 
@@ -77202,6 +77665,87 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
77202
77665
  return (y) => frontTopX + (frontTopY - y) * Math.tan(angle);
77203
77666
  }
77204
77667
 
77668
+ // src/models/sight.ts
77669
+ var SIGHT_SINK = 5e-4;
77670
+ var FOOTPRINT_INSET = 0.15;
77671
+ var RAY_CLEARANCE = 0.05;
77672
+ var measured = /* @__PURE__ */ new WeakMap();
77673
+ var boundsOf = (THREE, geometry) => {
77674
+ const known = measured.get(geometry);
77675
+ if (known) return known;
77676
+ const position = geometry.getAttribute("position");
77677
+ const box5 = new THREE.Box3().setFromBufferAttribute(position);
77678
+ const bounds = { box: box5, sphere: box5.getBoundingSphere(new THREE.Sphere()) };
77679
+ measured.set(geometry, bounds);
77680
+ return bounds;
77681
+ };
77682
+ var hits = /* @__PURE__ */ new WeakMap();
77683
+ var KEY_DIGITS = 6;
77684
+ function hitOn(THREE, mesh3, origin) {
77685
+ const geometry = mesh3.geometry;
77686
+ const ray = new THREE.Ray(origin.clone(), new THREE.Vector3(0, -1, 0)).applyMatrix4(new THREE.Matrix4().copy(mesh3.matrixWorld).invert());
77687
+ const from = ray.origin;
77688
+ const along3 = ray.direction;
77689
+ const key2 = [...from.toArray(), ...along3.toArray()].map((value) => value.toFixed(KEY_DIGITS)).join(",");
77690
+ const known = hits.get(geometry) ?? /* @__PURE__ */ new Map();
77691
+ hits.set(geometry, known);
77692
+ if (!known.has(key2)) {
77693
+ const before = { box: geometry.boundingBox, sphere: geometry.boundingSphere };
77694
+ const bounds = boundsOf(THREE, geometry);
77695
+ geometry.boundingBox = bounds.box;
77696
+ geometry.boundingSphere = bounds.sphere;
77697
+ const probe2 = new THREE.Mesh(geometry, mesh3.material);
77698
+ const found = new THREE.Raycaster(from, along3).intersectObject(probe2, false)[0];
77699
+ geometry.boundingBox = before.box;
77700
+ geometry.boundingSphere = before.sphere;
77701
+ known.set(key2, found ? found.point.clone() : null);
77702
+ }
77703
+ const local2 = known.get(key2);
77704
+ return local2 ? local2.clone().applyMatrix4(mesh3.matrixWorld) : null;
77705
+ }
77706
+ function surfaceUnder(kit, support, parent, spec) {
77707
+ const { THREE } = kit;
77708
+ let root = support;
77709
+ while (root.parent) root = root.parent;
77710
+ root.updateMatrixWorld(true);
77711
+ const reachX = spec.length / 2 * (1 - 2 * FOOTPRINT_INSET);
77712
+ const reachZ = spec.width / 2 * (1 - 2 * FOOTPRINT_INSET);
77713
+ const corners = [[0, 0], [-reachX, -reachZ], [-reachX, reachZ], [reachX, -reachZ], [reachX, reachZ]].map(([dx, dz]) => parent.localToWorld(new THREE.Vector3(spec.x + dx, 0, dz)));
77714
+ const footprint = new THREE.Box3().setFromPoints(corners);
77715
+ const under = [];
77716
+ const world = new THREE.Box3();
77717
+ const whole = new THREE.Box3();
77718
+ support.traverse((child) => {
77719
+ const mesh3 = child;
77720
+ if (!mesh3.isMesh) return;
77721
+ world.copy(boundsOf(THREE, mesh3.geometry).box).applyMatrix4(mesh3.matrixWorld);
77722
+ whole.union(world);
77723
+ if (mesh3.userData["sight"] === true) return;
77724
+ if (world.max.x < footprint.min.x || world.min.x > footprint.max.x || world.max.z < footprint.min.z || world.min.z > footprint.max.z) return;
77725
+ under.push(mesh3);
77726
+ });
77727
+ const top = whole.max.y;
77728
+ if (under.length === 0) throw new Error("a sight with nothing under it");
77729
+ let highest = -Infinity;
77730
+ for (const origin of corners) {
77731
+ origin.y = top + RAY_CLEARANCE;
77732
+ for (const mesh3 of under) {
77733
+ const hit = hitOn(THREE, mesh3, origin);
77734
+ if (hit) highest = Math.max(highest, parent.worldToLocal(hit).y);
77735
+ }
77736
+ }
77737
+ if (highest === -Infinity) throw new Error("a sight with nothing under it");
77738
+ return highest;
77739
+ }
77740
+ function placeSight(kit, parent, support, spec) {
77741
+ const tilt = spec.tilt ?? 0;
77742
+ const halfHeight = spec.height / 2 * Math.cos(tilt) + spec.length / 2 * Math.abs(Math.sin(tilt));
77743
+ const bottom = surfaceUnder(kit, support, parent, spec) - SIGHT_SINK;
77744
+ const mesh3 = kit.box(parent, spec.length, spec.height, spec.width, spec.material, spec.x, bottom + halfHeight, 0, tilt);
77745
+ mesh3.userData["sight"] = true;
77746
+ return { mesh: mesh3, bottom };
77747
+ }
77748
+
77205
77749
  // src/models/pistol-design-slide.ts
77206
77750
  function buildDesignSlide(kit, slide2, parts2, name, design, length2) {
77207
77751
  const { M, box: box5, cylinderX } = kit;
@@ -77228,14 +77772,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
77228
77772
  }
77229
77773
  heatify(parts2.glow, cylinderX(slide2, 62e-4, 4e-3, M.dark, length2 + 15e-4, 2e-3, 0, 18));
77230
77774
  cylinderX(slide2, 34e-4, 5e-3, M.hole, length2 + 25e-4, 2e-3, 0, 12);
77231
- const top = sh / 2;
77232
- box5(slide2, 4e-3, 7e-3, 4e-3, M.dark, length2 - 8e-3, top + 35e-4, 0);
77233
- box5(slide2, 22e-4, 22e-4, 46e-4, M.white, length2 - 8e-3, top + 58e-4, 0);
77234
- box5(slide2, 8e-3, 7e-3, 0.016, M.dark, 9e-3, top + 35e-4, 0);
77235
- box5(slide2, 22e-4, 22e-4, 0.0166, M.white, 9e-3, top + 58e-4, 0);
77775
+ const front = placeSight(kit, slide2, slide2, { length: 4e-3, height: 7e-3, width: 4e-3, material: M.dark, x: length2 - 8e-3 });
77776
+ const rear = placeSight(kit, slide2, slide2, { length: 8e-3, height: 7e-3, width: 0.016, material: M.dark, x: 9e-3 });
77777
+ parts2.sights = [front.mesh, rear.mesh];
77778
+ box5(slide2, 22e-4, 22e-4, 46e-4, M.white, length2 - 8e-3, front.bottom + 58e-4, 0);
77779
+ box5(slide2, 22e-4, 22e-4, 0.0166, M.white, 9e-3, rear.bottom + 58e-4, 0);
77236
77780
  }
77237
77781
 
77238
77782
  // src/models/pistol-design.ts
77783
+ var PORT_RISE = 5e-3;
77239
77784
  function buildDesignedPistol(kit, options, name) {
77240
77785
  const { M, box: box5 } = kit;
77241
77786
  const design = PISTOL_DESIGNS[name];
@@ -77284,7 +77829,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
77284
77829
  box5(hammer2, 0.01, 6e-3, 0.012, M.dark, -0.011, 8e-3, 0, 0.5);
77285
77830
  }
77286
77831
  parts2.muzzle = kit.mark(group, length2 + 6e-3, 2e-3, 0);
77287
- parts2.eject = kit.mark(group, length2 * 0.6, sh / 2, sw * 0.25);
77832
+ parts2.eject = kit.mark(group, length2 * 0.6, sh / 2 + PORT_RISE, sw * 0.25);
77288
77833
  return { group, parts: parts2 };
77289
77834
  }
77290
77835
 
@@ -77323,11 +77868,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
77323
77868
  box5(group, 24e-4, SLIDE_HEIGHT * 0.9, WIDTH2 + 4e-4, M.dark, slideLength, 0, 0);
77324
77869
  for (let i = 0; i < 9; i++) box5(slide2, 22e-4, SLIDE_HEIGHT * 0.66, WIDTH2 + 12e-4, M.dark, 8e-3 + i * 48e-4, -3e-3, 0);
77325
77870
  box5(slide2, length2 * 0.08, 3e-3, WIDTH2 * 0.5, M.hole, length2 * 0.42, SLIDE_HEIGHT / 2, WIDTH2 * 0.12);
77326
- box5(slide2, 7e-3, 6e-3, 0.014, M.dark, 8e-3, SLIDE_HEIGHT / 2 + 3e-3, 0);
77327
- box5(slide2, 3e-3, 2e-3, 4e-3, M.hole, 8e-3, SLIDE_HEIGHT / 2 + 5e-3, 0);
77871
+ const rearSight = placeSight(kit, slide2, slide2, { length: 7e-3, height: 6e-3, width: 0.014, material: M.dark, x: 8e-3 });
77872
+ box5(slide2, 3e-3, 2e-3, 4e-3, M.hole, 8e-3, rearSight.bottom + 5e-3, 0);
77328
77873
  box5(group, barrelLength * 0.9, 4e-3, WIDTH2 * 0.42, metal2, slideLength + barrelLength * 0.5, SLIDE_HEIGHT / 2 + 2e-3, 0);
77329
77874
  for (let i = 0; i < 7; i++) box5(group, 4e-3, 15e-4, WIDTH2 * 0.43, M.hole, slideLength + 0.01 + i * 0.013, SLIDE_HEIGHT / 2 + 4e-3, 0);
77330
- box5(group, 4e-3, 6e-3, 4e-3, M.dark, length2 - 6e-3, SLIDE_HEIGHT / 2 + 6e-3, 0);
77875
+ parts2.sights = [rearSight.mesh, placeSight(kit, group, group, { length: 4e-3, height: 6e-3, width: 4e-3, material: M.dark, x: length2 - 6e-3 }).mesh];
77331
77876
  const nose = plate(kit, group, [[-WIDTH2 / 2, -SLIDE_HEIGHT / 2 + 2e-3], [WIDTH2 / 2, -SLIDE_HEIGHT / 2 + 2e-3], [WIDTH2 * 0.16, SLIDE_HEIGHT / 2 - 2e-3], [-WIDTH2 * 0.16, SLIDE_HEIGHT / 2 - 2e-3]], null, 3e-3, metal2);
77332
77877
  nose.rotation.y = Math.PI / 2;
77333
77878
  nose.position.set(length2 + 15e-4, 0, 0);
@@ -77461,16 +78006,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
77461
78006
  const muzzleY = style.tri ? slideHeight * 0.08 : 2e-3;
77462
78007
  heatify(parts2.glow, cylinderX(slide2, style.tri ? 72e-4 : 62e-4, 4e-3, M.dark, L + 15e-4, muzzleY, 0, 18));
77463
78008
  cylinderX(slide2, 34e-4, 5e-3, M.hole, L + 25e-4, muzzleY, 0, 12);
77464
- const top = slideHeight / 2;
78009
+ const seat2 = (spec) => placeSight(kit, slide2, slide2, spec);
77465
78010
  if (style.sight === "u" || style.sight === "3dot") {
77466
- box5(slide2, 4e-3, 7e-3, 4e-3, M.dark, L - 8e-3, top + 35e-4, 0);
77467
- box5(slide2, 22e-4, 22e-4, 46e-4, M.white, L - 8e-3, top + 58e-4, 0);
77468
- box5(slide2, 8e-3, 7e-3, 0.016, M.dark, 9e-3, top + 35e-4, 0);
77469
- if (style.sight === "u") box5(slide2, 4e-3, 2e-3, 0.0122, M.white, 9e-3, top + 6e-3, 0);
77470
- else box5(slide2, 22e-4, 22e-4, 0.0166, M.white, 9e-3, top + 58e-4, 0);
78011
+ const front = seat2({ length: 4e-3, height: 7e-3, width: 4e-3, material: M.dark, x: L - 8e-3 });
78012
+ const rear = seat2({ length: 8e-3, height: 7e-3, width: 0.016, material: M.dark, x: 9e-3 });
78013
+ parts2.sights = [front.mesh, rear.mesh];
78014
+ box5(slide2, 22e-4, 22e-4, 46e-4, M.white, L - 8e-3, front.bottom + 58e-4, 0);
78015
+ if (style.sight === "u") box5(slide2, 4e-3, 2e-3, 0.0122, M.white, 9e-3, rear.bottom + 6e-3, 0);
78016
+ else box5(slide2, 22e-4, 22e-4, 0.0166, M.white, 9e-3, rear.bottom + 58e-4, 0);
77471
78017
  } else {
77472
- box5(slide2, 6e-3, 4e-3, 3e-3, M.dark, L - 6e-3, top + 2e-3, 0);
77473
- box5(slide2, 6e-3, 4e-3, 0.012, M.dark, 8e-3, top + 2e-3, 0);
78018
+ parts2.sights = [seat2({ length: 6e-3, height: 4e-3, width: 3e-3, material: M.dark, x: L - 6e-3 }).mesh, seat2({ length: 6e-3, height: 4e-3, width: 0.012, material: M.dark, x: 8e-3 }).mesh];
77474
78019
  }
77475
78020
  if (style.decock === "slide") {
77476
78021
  box5(slide2, 0.012, 8e-3, 4e-3, M.dark, 0.02, slideHeight * 0.15, slideWidth / 2 + 2e-3, 0.3);
@@ -77628,8 +78173,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
77628
78173
  box5(group, barrel * 0.96, 58e-4, 88e-4, M.metal, start + barrel * 0.48, 0.0218, 0);
77629
78174
  for (let i = 0; i < 2; i++) box5(group, barrel * 0.2, 62e-4, 92e-4, M.hole, start + barrel * (0.26 + i * 0.36), 0.0218, 0);
77630
78175
  box5(group, 0.012, 36e-4, 4e-3, M.dark, start + barrel * 0.4, -4e-3, 94e-4);
77631
- box5(group, 9e-3, 0.01, 34e-4, M.metal, start + barrel - 7e-3, 0.0285, 0, -0.35);
77632
- box5(group, 35e-4, 5e-3, 36e-4, M.red, start + barrel - 45e-4, 0.0288, 0, -0.35);
78176
+ const front = placeSight(kit, group, group, { length: 9e-3, height: 0.01, width: 34e-4, material: M.metal, x: start + barrel - 7e-3, tilt: -0.35 });
78177
+ parts2.sights = [...parts2.sights ?? [], front.mesh];
78178
+ box5(group, 35e-4, 5e-3, 36e-4, M.red, start + barrel - 45e-4, front.mesh.position.y + 3e-4, 0, -0.35);
77633
78179
  cylinderX(group, 42e-4, 5e-3, M.hole, start + barrel + 15e-4, 9e-3, 0, 12);
77634
78180
  }
77635
78181
  function buildPythonGrip(kit, parts2, group) {
@@ -77659,8 +78205,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
77659
78205
  box5(group, 0.085, 0.056, 0.026, M.metal, 0.07, -4e-3, 0);
77660
78206
  kit.roundness = null;
77661
78207
  box5(group, 0.056, 8e-3, 0.02, M.metal, 0.075, 0.025, 0);
77662
- box5(group, 0.016, 0.01, 0.016, M.metal, 0.044, 0.034, 0);
77663
- box5(group, 4e-3, 8e-3, 0.012, M.dark, 0.044, 0.04, 0);
78208
+ const rear = placeSight(kit, group, group, { length: 0.016, height: 0.01, width: 0.016, material: M.metal, x: 0.044 });
78209
+ parts2.sights = [rear.mesh];
78210
+ box5(group, 4e-3, 8e-3, 0.012, M.dark, 0.044, rear.bottom + 0.011, 0);
77664
78211
  box5(group, 0.024, 0.012, 4e-3, M.dark, 0.055, 4e-3, -0.013);
77665
78212
  box5(group, 0.016, 0.018, 0.0255, M.metal, 0.099, -0.014, 0);
77666
78213
  const crane = kit.pivot(group, 0.077, -0.026, 0);
@@ -77724,8 +78271,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
77724
78271
  heatify(parts2.glow, cylinderX(group, 88e-4, barrel, metal2, 0.112 + barrel / 2, 9e-3, 0, 18));
77725
78272
  box5(group, barrel * 0.92, 0.015, 0.013, metal2, 0.112 + barrel * 0.46, -5e-3, 0);
77726
78273
  cylinderX(group, 4e-3, 5e-3, M.hole, 0.112 + barrel + 15e-4, 9e-3, 0, 12);
77727
- box5(group, 0.012, 9e-3, 4e-3, M.dark, 0.112 + barrel - 8e-3, 0.021, 0, -0.3);
77728
- box5(group, 0.012, 6e-3, 0.012, M.dark, 0.105, 0.031, 0);
78274
+ parts2.sights = [
78275
+ placeSight(kit, group, group, { length: 0.012, height: 9e-3, width: 4e-3, material: M.dark, x: 0.112 + barrel - 8e-3, tilt: -0.3 }).mesh,
78276
+ placeSight(kit, group, group, { length: 0.012, height: 6e-3, width: 0.012, material: M.dark, x: 0.105 }).mesh
78277
+ ];
77729
78278
  const hammer2 = kit.pivot(group, 0.036, 0.018, 0);
77730
78279
  box5(hammer2, 0.01, 0.02, 8e-3, M.dark, -4e-3, 8e-3, 0, 0.45);
77731
78280
  parts2.hammer = hammer2;
@@ -78230,13 +78779,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
78230
78779
  return root;
78231
78780
  };
78232
78781
  var hasWeaponModel = (id) => id in MODEL_ENTRIES || id in ARCHETYPE_MODELS;
78233
- function buildWeaponModelById(THREE, id) {
78782
+ function buildWeaponModelById(THREE, id, options = {}) {
78234
78783
  const entry2 = MODEL_ENTRIES[ARCHETYPE_MODELS[id] ?? id];
78235
78784
  if (!entry2) return void 0;
78236
78785
  const kit = modelKit(THREE);
78237
- const options = { L: entry2.length, B: entry2.barrel, cal: entry2.caliber, ...entry2.options };
78238
- if (id in ARCHETYPE_MODELS) delete options.chambers;
78239
- const built2 = BUILDERS[entry2.builder](kit, options);
78786
+ const modelOptions = { L: entry2.length, B: entry2.barrel, cal: entry2.caliber, ...entry2.options };
78787
+ if (id in ARCHETYPE_MODELS) delete modelOptions.chambers;
78788
+ if (options.worn === "separate") modelOptions.separateWorn = true;
78789
+ const built2 = BUILDERS[entry2.builder](kit, modelOptions);
78240
78790
  nameParts(built2.parts);
78241
78791
  let root;
78242
78792
  if (entry2.builder === "launcher") {
@@ -79231,9 +79781,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
79231
79781
  if (hit.thickness <= 0) return 0;
79232
79782
  return Math.max(0, entry2.lossDb + MASS_LAW_DB_PER_DOUBLING * Math.log2(hit.thickness / entry2.thickness));
79233
79783
  }
79234
- function totalLossDb(hits, setup = {}) {
79784
+ function totalLossDb(hits2, setup = {}) {
79235
79785
  let total = 0;
79236
- for (const hit of hits) total += hitLossDb(hit, setup);
79786
+ for (const hit of hits2) total += hitLossDb(hit, setup);
79237
79787
  return Math.min(total, setup.maxLossDb ?? OCCLUSION_DEFAULTS.maxLossDb);
79238
79788
  }
79239
79789
  function occlusionState(lossDb, setup = {}) {
@@ -84790,6 +85340,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
84790
85340
  // src/fx/layers.ts
84791
85341
  var createLayers = () => ({ casings: true, magazines: true, muzzleFlash: true, attachments: true, beams: true });
84792
85342
 
85343
+ // src/models/eject-port.ts
85344
+ var EJECT_SIDES = {
85345
+ right: [-0.25, 0.55, 0.8],
85346
+ up: [-0.1, 0.97, 0.2],
85347
+ down: [0, -1, 0.05],
85348
+ back: [-1, -0.1, 0],
85349
+ backUp: [-1, 0.9, 0]
85350
+ };
85351
+ var EJECT_SCATTER = 0.12;
85352
+ var ejectDirection = (THREE, side) => new THREE.Vector3(...EJECT_SIDES[side]).normalize();
85353
+
84793
85354
  // src/laser-raycast.ts
84794
85355
  var VIEWMODEL_NODE_NAME = "weapon-viewmodel";
84795
85356
  var IN_HAND_NODE_NAME = "weapon-in-hand";
@@ -84856,7 +85417,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
84856
85417
  /** A shouldered gun's bore runs this far above the shoulder pocket (the cheek on the comb). */
84857
85418
  boreAbove: 0.05,
84858
85419
  /** A handgun's (or a short two-hand gun's) grip: toward the middle of the chest, a little low, at the reach of bent arms. */
84859
- handgunGrip: [-0.15, -0.04, -0.42],
85420
+ handgunGrip: [-0.13, -0.05, -0.4],
84860
85421
  /** A one-hand tool's grip: low in front of the body, the elbow bent. */
84861
85422
  toolGrip: [0.02, -0.34, -0.3],
84862
85423
  /** A gun in each hand: each grip ahead of its own shoulder, a little in and low, the arms out at the aim (the left one is the mirror, in the left shoulder's frame). */
@@ -84872,7 +85433,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
84872
85433
  /** The farthest apart two hands hold a long gun (a support hand past it slides back along the gun, toward the grip). */
84873
85434
  supportSpan: 0.5,
84874
85435
  /** A gun carried at the hip (`carry: 'hip'`): its rear grip low at the right hip, a little ahead of it. */
84875
- hipGrip: [0.25, -0.5, -0.24],
85436
+ hipGrip: [0.2, -0.4, -0.24],
84876
85437
  /**
84877
85438
  * A tool put away against the body to free its hand (a magazine changed with a tool in each hand): tucked in the front of the belt on its own side, muzzle down and grip forward, its
84878
85439
  * grip here in the frame of the shoulder pocket (the left one mirrored).
@@ -84984,6 +85545,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
84984
85545
  // the lens of the long guns and the tools: a gun beside a blade in the other hand is drawn through the same one
84985
85546
  dual: { grip: [0.19, -0.2, -0.4], fov: 84, sights: { distance: 0.42, fromRear: 0.02 } }
84986
85547
  };
85548
+ var viewKindOf = (parts2, oneHand) => oneHand ? "dual" : parts2.carry === "hip" ? "hip" : parts2.family === "pistol" || parts2.family === "revolver" ? "handgun" : parts2.family === "rocket" ? "launcher" : "long";
84987
85549
  var NO_GRIP_REAR = [0.2, -0.24, -0.12];
84988
85550
  var SIGHT_UNDER_EYE = 0.02;
84989
85551
  var scratch2 = { grip: null, hip: null, aimed: null, tilt: null };
@@ -85232,8 +85794,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
85232
85794
  var SHOVEL_SWING = {
85233
85795
  keys: [
85234
85796
  { at: 0, ...HOLD },
85235
- { at: 0.3, offset: [0.11, 0.06, 0.06], turn: [0.05, 0.45, 0.1] },
85236
- { at: 0.47, offset: [-0.025, 0, -0.16], turn: [0, -0.15, 0] },
85797
+ { at: 0.3, offset: [0.17, 0.04, 0.06], turn: [0.05, 0.2, 0.1] },
85798
+ { at: 0.47, offset: [-0.025, 0, -0.08], turn: [0, -0.15, 0] },
85237
85799
  { at: 0.67, offset: [-0.16, -0.03, -0.1], turn: [0, -0.5, -0.075] },
85238
85800
  { at: 1, ...HOLD }
85239
85801
  ]
@@ -85262,7 +85824,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
85262
85824
  pivot: "grip",
85263
85825
  keys: [
85264
85826
  { at: 0, ...HOLD },
85265
- { at: 0.29, offset: [0.12, 0.12, 0.1], turn: [1.9, -0.6, 0] },
85827
+ { at: 0.14, offset: [0.14, 0.03, 0.05], turn: [0.7, -0.9, 0] },
85828
+ { at: 0.29, offset: [0.24, 0.04, 0.1], turn: [1.9, -0.6, 0] },
85266
85829
  { at: 0.43, offset: [-0.1, 0.04, -0.07], turn: [-0.3, 1.2, 0] },
85267
85830
  { at: 0.64, offset: [-0.28, 0.1, 0], turn: [2, 1, 0] },
85268
85831
  { at: 0.8, offset: [-0.2, 0.06, 0.02], turn: [1.8, 0.8, 0] },
@@ -85373,7 +85936,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
85373
85936
  return group;
85374
85937
  }
85375
85938
 
85376
- // ../game-items-three/dist/chunk-64JEKMFT.js
85939
+ // ../game-items-three/dist/chunk-FCEKW7F6.js
85377
85940
  var destruction_default = {
85378
85941
  families: {
85379
85942
  drink_can: {
@@ -85637,6 +86200,235 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
85637
86200
  mesh3.userData.destructionMaterial = materialOf2.get(part);
85638
86201
  });
85639
86202
  }
86203
+ var DEFAULT_COLOR = 9080724;
86204
+ var PI13 = Math.PI;
86205
+ function shade2(color2, factor2) {
86206
+ const channel = (shift) => Math.max(0, Math.min(255, Math.round((color2 >> shift & 255) * factor2)));
86207
+ return channel(16) << 16 | channel(8) << 8 | channel(0);
86208
+ }
86209
+ var PROUD = 2e-3;
86210
+ var seg = (c, n) => Math.max(5, Math.round(n * c.detail));
86211
+ function canonicalFrame(size) {
86212
+ const [w, h, d] = size;
86213
+ if (h >= w && h >= d) return { axis: 1, L: h, a: w, b: d };
86214
+ if (d >= w && d >= h) return { axis: 2, L: d, a: h, b: w };
86215
+ return { axis: 0, L: w, a: h, b: d };
86216
+ }
86217
+ function orient(c, group, axis2) {
86218
+ if (axis2 === 0) return group;
86219
+ const holder = c.k.G(group);
86220
+ if (axis2 === 1) holder.rotation.z = PI13 / 2;
86221
+ else holder.rotation.y = -PI13 / 2;
86222
+ return holder;
86223
+ }
86224
+ var alongLong = (draw2) => (c) => {
86225
+ const { axis: axis2, L, a, b } = canonicalFrame([c.w, c.h, c.d]);
86226
+ return orient(c, draw2(c, L, a, b), axis2);
86227
+ };
86228
+ var across = (c, group) => {
86229
+ group.scale.set(c.w, 1, c.d);
86230
+ return c.k.G(group);
86231
+ };
86232
+ var can = (c) => {
86233
+ const { k, h } = c;
86234
+ const body = k.metal(9277590);
86235
+ const r = 0.5 - PROUD / Math.min(c.w, c.d);
86236
+ return across(c, k.G(k.mesh(k.cyl(r, r, h * 0.94, seg(c, 14)), body), k.mesh(k.cyl(0.5, 0.5, h * 0.5, seg(c, 14)), k.food(c.color)), k.mesh(k.cyl(0.5, 0.5, h * 0.03, seg(c, 14)), body, [0, h * 0.485, 0]), k.mesh(k.cyl(0.5, 0.5, h * 0.03, seg(c, 14)), body, [0, -h * 0.485, 0])));
86237
+ };
86238
+ var bottle = (c) => {
86239
+ const { k, h } = c;
86240
+ const r = 0.5;
86241
+ const profile = [[0, -h / 2], [r, -h / 2], [r, h * 0.12], [r * 0.45, h * 0.3], [r * 0.4, h * 0.4], [0, h * 0.4]];
86242
+ return across(c, k.G(k.mesh(k.lathe(profile, seg(c, 14)), k.glass(c.color, 0.6)), k.mesh(k.cyl(r * 0.42, r * 0.42, h * 0.1, seg(c, 10)), k.plastic(shade2(c.color, 0.5)), [0, h * 0.45, 0])));
86243
+ };
86244
+ var jar = (c) => {
86245
+ const { k, h } = c;
86246
+ return across(c, k.G(k.mesh(k.cyl(0.5, 0.5, h * 0.82, seg(c, 14)), k.glass(c.color, 0.55), [0, -h * 0.09, 0]), k.mesh(k.cyl(0.5, 0.5, h * 0.18, seg(c, 14)), k.metal(12095802), [0, h * 0.41, 0])));
86247
+ };
86248
+ var bag = (c) => {
86249
+ const { k, w, h, d } = c;
86250
+ return k.G(k.mesh(k.bx(w, h * 0.88, d - 2 * PROUD), k.paper(c.color), [0, -h * 0.06, 0]), k.mesh(k.bx(w * 1, h * 0.12, d * 0.5), k.paper(shade2(c.color, 0.85)), [0, h * 0.44, 0]), k.mesh(k.bx(w * 0.7, h * 0.3, d), k.paper(shade2(c.color, 1.2)), [0, 0, 0]));
86251
+ };
86252
+ var box4 = (c) => {
86253
+ const { k, w, h, d } = c;
86254
+ return k.G(k.mesh(k.bx(w - 2 * PROUD, h - PROUD, d - 2 * PROUD), k.paper(c.color), [0, -PROUD / 2, 0]), k.mesh(k.bx(w, h * 0.12, d), k.paper(shade2(c.color, 0.8)), [0, h * 0.44, 0]), k.mesh(k.bx(w * 0.62, h * 0.4, d), k.paper(shade2(c.color, 1.25)), [0, -h * 0.02, 0]));
86255
+ };
86256
+ var cloth = (c) => {
86257
+ const { k, w, h, d } = c;
86258
+ const material = k.cloth(c.color);
86259
+ return k.G(k.mesh(k.bx(w, h * 0.55, d), material, [0, -h * 0.225, 0]), k.mesh(k.bx(w * 0.96, h * 0.45, d * 0.96), k.cloth(shade2(c.color, 0.9)), [0, h * 0.275, 0]));
86260
+ };
86261
+ var paper = (c) => {
86262
+ const { k, w, h, d } = c;
86263
+ const sheet = k.paper(c.color);
86264
+ return k.G(k.mesh(k.bx(w, h / 3, d), sheet, [0, -h / 3, 0]), k.mesh(k.bx(w * 0.98, h / 3, d * 0.98), k.paper(shade2(c.color, 0.95)), [0, 0, 0]), k.mesh(k.bx(w, h / 3, d), sheet, [0, h / 3, 0]));
86265
+ };
86266
+ var fruit = (c) => {
86267
+ const { k, w, h, d } = c;
86268
+ const sphere2 = new k.T.SphereGeometry(0.5, seg(c, 12), seg(c, 8));
86269
+ return k.G(k.mesh(sphere2, k.food(c.color), [0, -h * 0.04, 0], [0, 0, 0], [w, h * 0.92, d]), k.mesh(k.cyl(h * 0.02, h * 0.02, h * 0.1, 6), k.wood(5913122), [0, h * 0.45, 0]));
86270
+ };
86271
+ var dish = (c) => {
86272
+ const { k, w, h, d } = c;
86273
+ return k.G(k.mesh(k.cyl(0.5, 0.35, h, seg(c, 16)), k.plastic(c.color), [0, 0, 0], [0, 0, 0], [w, 1, d]));
86274
+ };
86275
+ var CUP_FLOOR_SHARE = 0.06;
86276
+ var cup = (c) => {
86277
+ const { k, w, h, d } = c;
86278
+ const floor2 = -h / 2 + h * CUP_FLOOR_SHARE;
86279
+ const profile = [[0, -h / 2], [0.38, -h / 2], [0.5, h / 2], [0.44, h / 2], [0.33, floor2], [0, floor2]];
86280
+ return k.G(k.mesh(k.lathe(profile, seg(c, 14)), k.plastic(c.color), [0, 0, 0], [0, 0, 0], [w, 1, d]));
86281
+ };
86282
+ var tube = (c) => {
86283
+ const { k, h } = c;
86284
+ const material = k.plastic(c.color);
86285
+ return across(c, k.G(k.mesh(k.cyl(0.5, 0.42, h * 0.86, seg(c, 12)), material, [0, -h * 0.04, 0]), k.mesh(k.cyl(0.35, 0.35, h * 0.12, seg(c, 12)), k.plastic(shade2(c.color, 0.6)), [0, h * 0.44, 0]), k.mesh(k.bx(1, h * 0.06, 0.25), material, [0, -h * 0.47, 0])));
86286
+ };
86287
+ var roll = (c) => {
86288
+ const { k, w, h, d } = c;
86289
+ const body = k.G(k.mesh(k.cyl(0.5, 0.5, 1, seg(c, 18)), k.paper(c.color)), k.mesh(k.cyl(0.18, 0.18, 0.98, seg(c, 12)), k.paper(11902328)));
86290
+ if (h <= w && h <= d) body.scale.set(w, h, d);
86291
+ else if (w <= d) {
86292
+ body.rotation.z = PI13 / 2;
86293
+ body.scale.set(h, w, d);
86294
+ } else {
86295
+ body.rotation.x = PI13 / 2;
86296
+ body.scale.set(w, d, h);
86297
+ }
86298
+ return k.G(body);
86299
+ };
86300
+ var shoe = (c) => {
86301
+ const { k, w, h, d } = c;
86302
+ const upper = k.cloth(c.color);
86303
+ return k.G(k.mesh(k.bx(w, h * 0.22, d), k.plastic(2237727), [0, -h * 0.39, 0]), k.mesh(k.bx(w * 0.42, h * 0.78, d * 0.96), upper, [-w * 0.29, h * 0.11, 0]), k.mesh(k.bx(w * 0.5, h * 0.5, d * 0.96), upper, [w * 0.25, -h * 0.03, 0]));
86304
+ };
86305
+ var tool = alongLong((c, L, a, b) => {
86306
+ const { k } = c;
86307
+ const radius = Math.max(4e-3, Math.min(a, b) / 2);
86308
+ return k.G(k.mesh(k.cyl(radius, radius, L * 0.74, seg(c, 10)), k.wood(9069628), [-L * 0.13, 0, 0], [0, 0, PI13 / 2]), k.mesh(k.bx(L * 0.26, a, b), k.metal(shade2(c.color, 1)), [L * 0.37, 0, 0]));
86309
+ });
86310
+ var longTool = alongLong((c, L, a, b) => {
86311
+ const { k } = c;
86312
+ const radius = Math.max(4e-3, Math.min(a, b) / 2) * 0.55;
86313
+ return k.G(k.mesh(k.cyl(radius, radius, L * 0.94, seg(c, 10)), k.wood(10122312), [0, 0, 0], [0, 0, PI13 / 2]), k.mesh(k.bx(L * 0.12, a, b), k.metal(c.color), [L * 0.44, 0, 0]));
86314
+ });
86315
+ var blade = alongLong((c, L, a, b) => {
86316
+ const { k } = c;
86317
+ const edge = Math.min(2e-4, b * 0.05);
86318
+ const steel = k.extrude([[0, 0], [L * 0.66, 0], [L * 0.68, a * 0.4], [0, a]], Math.max(5e-4, b * 0.4 - 2 * edge), edge);
86319
+ return k.G(k.mesh(steel, k.metal(11120048), [-L * 0.18, -a / 2, -b * 0.2 + edge]), k.mesh(k.bx(L * 0.34, a * 0.6, b), k.wood(3877408), [-L * 0.33, 0, 0]));
86320
+ });
86321
+ var garment = (c) => {
86322
+ const { k, w, h, d } = c;
86323
+ const material = k.cloth(c.color);
86324
+ return k.G(k.mesh(k.bx(w * 0.56, h, d), material), k.mesh(k.bx(w * 0.22, h * 0.42, d * 0.9), material, [-w * 0.39, h * 0.29, 0]), k.mesh(k.bx(w * 0.22, h * 0.42, d * 0.9), material, [w * 0.39, h * 0.29, 0]));
86325
+ };
86326
+ var backpack = (c) => {
86327
+ const { k, w, h, d } = c;
86328
+ const material = k.cloth(c.color);
86329
+ const dome = new k.T.SphereGeometry(0.5, seg(c, 12), seg(c, 6), 0, PI13 * 2, 0, PI13 / 2);
86330
+ const strap = k.cloth(shade2(c.color, 0.6));
86331
+ return k.G(k.mesh(k.bx(w, h * 0.78, d * 0.68), material, [0, -h * 0.11, -d * 0.14]), k.mesh(dome, material, [0, h * 0.28, -d * 0.14], [0, 0, 0], [w, h * 0.44, d * 0.68]), k.mesh(k.bx(w * 0.7, h * 0.4, d * 0.3), k.cloth(shade2(c.color, 0.75)), [0, -h * 0.18, d * 0.35]), k.mesh(k.bx(w * 0.1, h * 0.7, d * 0.04), strap, [-w * 0.25, -h * 0.05, -d * 0.48]), k.mesh(k.bx(w * 0.1, h * 0.7, d * 0.04), strap, [w * 0.25, -h * 0.05, -d * 0.48]));
86332
+ };
86333
+ var jerrycan = (c) => {
86334
+ const { k, w, h, d } = c;
86335
+ const material = k.plastic(c.color);
86336
+ return k.G(k.mesh(k.bx(w, h * 0.86, d), material, [0, -h * 0.07, 0]), k.mesh(k.bx(w * 0.4, h * 0.1, d * 0.5), material, [-w * 0.2, h * 0.45, 0]), k.mesh(k.cyl(d * 0.14, d * 0.18, h * 0.12, seg(c, 10)), k.plastic(14263361), [w * 0.3, h * 0.44, 0]));
86337
+ };
86338
+ var tank = (c) => {
86339
+ const { k, h } = c;
86340
+ const r = 0.5;
86341
+ const profile = [[0, -h / 2], [r * 0.9, -h / 2], [r, -h * 0.4], [r, h * 0.22], [r * 0.6, h * 0.36], [r * 0.2, h * 0.4], [0, h * 0.4]];
86342
+ const metal2 = k.metal(c.color);
86343
+ return across(c, k.G(k.mesh(k.lathe(profile, seg(c, 14)), metal2), k.mesh(k.cyl(r * 0.62, r * 0.62, h * 0.05, seg(c, 14)), metal2, [0, h * 0.3, 0]), k.mesh(k.cyl(r * 0.18, r * 0.18, h * 0.12, seg(c, 8)), k.metal(12095802), [0, h * 0.44, 0])));
86344
+ };
86345
+ var book = (c) => {
86346
+ const { k, w, h, d } = c;
86347
+ const cover = k.paper(c.color);
86348
+ return k.G(k.mesh(k.bx(w - PROUD, h - 2 * PROUD, d * 0.14), cover, [PROUD / 2, 0, d * 0.43 - PROUD]), k.mesh(k.bx(w - PROUD, h - 2 * PROUD, d * 0.14), cover, [PROUD / 2, 0, -d * 0.43 + PROUD]), k.mesh(k.bx(w * 0.94, h * 0.96, d * 0.72), k.paper(15327692), [w * 0.02, 0, 0]), k.mesh(k.bx(w * 0.08, h, d), k.paper(shade2(c.color, 0.8)), [-w * 0.46, 0, 0]));
86349
+ };
86350
+ var key = alongLong((c, L, a, b) => {
86351
+ const { k } = c;
86352
+ const metal2 = k.metal(12095802);
86353
+ const ring3 = a * 0.5;
86354
+ const tube2 = Math.min(b * 0.4, ring3 * 0.2);
86355
+ return k.G(k.mesh(new c.k.T.TorusGeometry(ring3 * 0.8, tube2, 5, seg(c, 10)), k.metal(10132896), [-L / 2 + ring3 * 0.8 + tube2, 0, 0]), k.mesh(k.bx(L * 0.62, a * 0.28, b), metal2, [L * 0.12, 0, 0]), k.mesh(k.bx(L * 0.08, a * 0.17, b), metal2, [L * 0.36, -a * 0.225, 0]), k.mesh(k.bx(L * 0.06, a * 0.17, b), metal2, [L * 0.2, -a * 0.225, 0]));
86356
+ });
86357
+ var battery2 = alongLong((c, L, a, b) => {
86358
+ const { k } = c;
86359
+ const r = Math.min(a, b) / 2;
86360
+ return k.G(k.mesh(k.cyl(r, r, L * 0.94, seg(c, 14)), k.metal(c.color), [0, 0, 0], [0, 0, PI13 / 2]), k.mesh(k.cyl(r * 0.36, r * 0.36, L * 0.06, seg(c, 8)), k.metal(12172736), [L * 0.47, 0, 0], [0, 0, PI13 / 2]));
86361
+ });
86362
+ var plank = alongLong((c, L, a, b) => {
86363
+ const { k } = c;
86364
+ const nail = k.metal(8225158);
86365
+ return k.G(k.mesh(k.bx(L, a, b), k.wood(11043929)), k.mesh(k.cyl(Math.min(a, b) * 0.1, Math.min(a, b) * 0.1, b * 0.98, 6), nail, [-L * 0.4, 0, 0], [PI13 / 2, 0, 0]), k.mesh(k.cyl(Math.min(a, b) * 0.1, Math.min(a, b) * 0.1, b * 0.98, 6), nail, [L * 0.4, 0, 0], [PI13 / 2, 0, 0]));
86366
+ });
86367
+ var device = (c) => {
86368
+ const { k, w, h, d } = c;
86369
+ const screen2 = k.M(10469258, "glass", { emissive: 3099170, emissiveIntensity: 0.6, roughness: 0.2 });
86370
+ return k.G(k.mesh(k.bx(w, h, d * 0.96), k.plastic(c.color), [0, 0, -d * 0.02]), k.mesh(k.bx(w * 0.7, h * 0.32, d * 0.06), screen2, [0, h * 0.22, d * 0.47]), k.mesh(k.cyl(Math.min(w, h) * 0.08, Math.min(w, h) * 0.08, d * 0.1, seg(c, 8)), k.metal(12172736), [w * 0.25, -h * 0.18, d * 0.45], [PI13 / 2, 0, 0]));
86371
+ };
86372
+ var DRAWERS = {
86373
+ can,
86374
+ bag,
86375
+ box: box4,
86376
+ bottle,
86377
+ tool,
86378
+ roll,
86379
+ dish,
86380
+ cloth,
86381
+ shoe,
86382
+ jar,
86383
+ paper,
86384
+ fruit,
86385
+ cup,
86386
+ tube,
86387
+ blade,
86388
+ long_tool: longTool,
86389
+ garment,
86390
+ backpack,
86391
+ jerrycan,
86392
+ tank,
86393
+ book,
86394
+ key,
86395
+ battery: battery2,
86396
+ plank,
86397
+ device
86398
+ };
86399
+ var isShape = (value) => value !== void 0 && value in DRAWERS;
86400
+ function shapeOf(subject) {
86401
+ const hint = subject.shape;
86402
+ if (!isShape(hint)) return "box";
86403
+ const [w, h, d] = subject.size;
86404
+ const { L, a, b } = canonicalFrame(subject.size);
86405
+ const long = L / Math.max(a, b, 1e-6) >= 4;
86406
+ const flat2 = Math.min(w, h, d) / Math.max(w, h, d) <= 0.2;
86407
+ switch (hint) {
86408
+ case "tool":
86409
+ if (subject.category === "keys") return "key";
86410
+ if (subject.category === "electronics") return "device";
86411
+ if (long) return subject.category === "melee" && Math.min(a, b) / L <= 0.1 && flat2 ? "blade" : "long_tool";
86412
+ return hint;
86413
+ case "cloth":
86414
+ return subject.category === "clothing" ? "garment" : hint;
86415
+ case "bag":
86416
+ return subject.category === "bags" ? "backpack" : hint;
86417
+ case "box":
86418
+ if (subject.category === "electronics") return "device";
86419
+ if (subject.category === "books") return "book";
86420
+ if (subject.category === "keys") return "key";
86421
+ return hint;
86422
+ case "paper":
86423
+ return subject.category === "books" ? "book" : hint;
86424
+ default:
86425
+ return hint;
86426
+ }
86427
+ }
86428
+ function drawShape(k, shape, size, options = {}) {
86429
+ const [w, h, d] = size;
86430
+ return DRAWERS[shape]({ k, w, h, d, color: options.color ?? DEFAULT_COLOR, detail: options.detail ?? 1 });
86431
+ }
85640
86432
  var DESTRUCTION_MATERIAL_BY_TAG = {
85641
86433
  metal: "steel",
85642
86434
  wood: "wood_soft",
@@ -85644,6 +86436,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
85644
86436
  paper: "paper",
85645
86437
  plastic: "plastic",
85646
86438
  cloth: "fabric",
86439
+ rubber: "rubber",
85647
86440
  food: "flesh_fruit"
85648
86441
  };
85649
86442
  var FAMILIES = destruction_default.families;
@@ -85770,6 +86563,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
85770
86563
  return;
85771
86564
  }
85772
86565
  const rule = modelId !== void 0 ? itemDestruction(modelId) : shapeId !== void 0 ? shapeDestruction(shapeId) : void 0;
86566
+ const body = options.parts?.length === 1 ? options.parts[0] : void 0;
85773
86567
  if (rule?.tessellate) tessellateShapes(root, rule.tessellate, three);
85774
86568
  const solid2 = [];
85775
86569
  root.traverse((object2) => {
@@ -85783,6 +86577,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
85783
86577
  mesh3.userData.destructionSkin = true;
85784
86578
  return;
85785
86579
  }
86580
+ if (body) {
86581
+ mesh3.userData.destructionMaterial = body.material;
86582
+ if (body.thickness !== void 0) mesh3.userData.destructionThickness = body.thickness;
86583
+ }
85786
86584
  if (rule?.hollow) mesh3.userData.hollow = true;
85787
86585
  if (powder) mesh3.userData.destructionPowder = { color: powder.color };
85788
86586
  solid2.push(mesh3);
@@ -85816,6 +86614,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
85816
86614
  return object2;
85817
86615
  };
85818
86616
  return {
86617
+ carryHandle: (part) => {
86618
+ part.userData[CARRY_HANDLE_TAG] = true;
86619
+ return part;
86620
+ },
85819
86621
  T: T2,
85820
86622
  materials,
85821
86623
  M,
@@ -88333,6 +89135,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
88333
89135
  0.553
88334
89136
  ],
88335
89137
  scale: 0.092308
89138
+ },
89139
+ {
89140
+ id: "plunger",
89141
+ teamId: "desentupidor",
89142
+ teamBox: [
89143
+ 1.4,
89144
+ 5.5,
89145
+ 1.4
89146
+ ],
89147
+ scale: 0.1
88336
89148
  }
88337
89149
  ];
88338
89150
  var cannedBeans = ({ mesh: mesh3, cyl, torus: torus2, G, metal: metal2, paper: paper2, food }) => {
@@ -89198,6 +90010,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
89198
90010
  const nozzle = mesh3(cyl(0.04, 0.07, 0.08, 8), plastic(14211288), [0, 0.96, 0]);
89199
90011
  return G(bottle2, label, stripe, cap, nozzle);
89200
90012
  };
90013
+ var plunger = ({ mesh: mesh3, cyl, G, M, wood }) => {
90014
+ const rubber = M(11545120, "rubber", { roughness: 0.75 });
90015
+ const cup2 = mesh3(cyl(0.3, 0.7, 0.75, 16), rubber, [0, 0.455, 0]);
90016
+ const lip = mesh3(cyl(0.7, 0.7, 0.08, 16), M(9314841, "rubber", { roughness: 0.8 }), [0, 0.04, 0]);
90017
+ const neck = mesh3(cyl(0.2, 0.3, 0.3, 12), rubber, [0, 0.98, 0]);
90018
+ const handle = mesh3(cyl(0.15, 0.15, 4.4, 10), wood(10122312), [0, 3.3, 0]);
90019
+ return G(cup2, lip, neck, handle);
90020
+ };
89201
90021
  var canOpener = ({ mesh: mesh3, bx, cyl, G, metal: metal2, plastic }) => {
89202
90022
  const steel = metal2(11120050);
89203
90023
  const grip = plastic(3104138);
@@ -89242,7 +90062,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
89242
90062
  mesh3(bx(14, 5.5, 3), metal2(7304056), [23, 0, -6])
89243
90063
  );
89244
90064
  };
89245
- var bucket = ({ mesh: mesh3, bx, cyl, G, plastic, metal: metal2 }) => {
90065
+ var bucket = ({ mesh: mesh3, bx, cyl, G, plastic, metal: metal2, carryHandle }) => {
89246
90066
  const body = plastic(2908062);
89247
90067
  const wire = metal2(9080209);
89248
90068
  return G(
@@ -89251,7 +90071,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
89251
90071
  mesh3(cyl(11.8, 11.8, 1, 16), plastic(2313602), [0, -13, 0]),
89252
90072
  mesh3(bx(0.6, 3.7, 0.6), wire, [13, 11.35, 0]),
89253
90073
  mesh3(bx(0.6, 3.7, 0.6), wire, [-13, 11.35, 0]),
89254
- mesh3(bx(27.2, 0.5, 1.1), wire, [0, 13.25, 0])
90074
+ carryHandle(mesh3(bx(27.2, 0.5, 1.1), wire, [0, 13.25, 0]))
89255
90075
  );
89256
90076
  };
89257
90077
  var binoculars = ({ mesh: mesh3, bx, cyl, G, M, plastic, metal: metal2 }) => {
@@ -90136,7 +90956,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
90136
90956
  mesh3(bx(0.05, 0.081, 0.05), tan, [0, 0.0445, 0.13])
90137
90957
  );
90138
90958
  };
90139
- var backpack = ({ mesh: mesh3, bx, G, cloth: cloth2, plastic }) => {
90959
+ var backpack2 = ({ mesh: mesh3, bx, G, cloth: cloth2, plastic }) => {
90140
90960
  const main = cloth2(3099243);
90141
90961
  const trim = cloth2(1976890);
90142
90962
  return G(
@@ -91474,7 +92294,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
91474
92294
  rebar,
91475
92295
  lubricant_spray: lubricantSpray,
91476
92296
  army_camouflage_uniform: armyCamouflageUniform,
91477
- backpack,
92297
+ backpack: backpack2,
91478
92298
  ballistic_vest: ballisticVest,
91479
92299
  battery_9v: battery9V,
91480
92300
  bean_seeds: beanSeeds,
@@ -91561,7 +92381,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
91561
92381
  tshirt,
91562
92382
  watering_can: wateringCan,
91563
92383
  wheelbarrow,
91564
- windup_alarm_clock: windupAlarmClock
92384
+ windup_alarm_clock: windupAlarmClock,
92385
+ plunger
91565
92386
  };
91566
92387
  var SHIPPED_MODELS = models_default2.map((entry2) => {
91567
92388
  const builder = BUILDERS3[entry2.id];
@@ -91585,234 +92406,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
91585
92406
  var defaultRegistry;
91586
92407
  var defaultItemModels = () => defaultRegistry ?? (defaultRegistry = registryOver(new Map(SHIPPED_MODELS.map(({ entry: entry2 }) => [entry2.id, entry2])), new Map(SHIPPED_MODELS.map(({ entry: entry2, builder }) => [entry2.id, builder]))));
91587
92408
  var hasItemModel = (id) => defaultItemModels().has(id);
91588
- var DEFAULT_COLOR = 9080724;
91589
- var PI13 = Math.PI;
91590
- function shade2(color2, factor2) {
91591
- const channel = (shift) => Math.max(0, Math.min(255, Math.round((color2 >> shift & 255) * factor2)));
91592
- return channel(16) << 16 | channel(8) << 8 | channel(0);
91593
- }
91594
- var PROUD = 2e-3;
91595
- var seg = (c, n) => Math.max(5, Math.round(n * c.detail));
91596
- function canonicalFrame(size) {
91597
- const [w, h, d] = size;
91598
- if (h >= w && h >= d) return { axis: 1, L: h, a: w, b: d };
91599
- if (d >= w && d >= h) return { axis: 2, L: d, a: h, b: w };
91600
- return { axis: 0, L: w, a: h, b: d };
91601
- }
91602
- function orient(c, group, axis2) {
91603
- if (axis2 === 0) return group;
91604
- const holder = c.k.G(group);
91605
- if (axis2 === 1) holder.rotation.z = PI13 / 2;
91606
- else holder.rotation.y = -PI13 / 2;
91607
- return holder;
91608
- }
91609
- var alongLong = (draw2) => (c) => {
91610
- const { axis: axis2, L, a, b } = canonicalFrame([c.w, c.h, c.d]);
91611
- return orient(c, draw2(c, L, a, b), axis2);
91612
- };
91613
- var across = (c, group) => {
91614
- group.scale.set(c.w, 1, c.d);
91615
- return c.k.G(group);
91616
- };
91617
- var can = (c) => {
91618
- const { k, h } = c;
91619
- const body = k.metal(9277590);
91620
- const r = 0.5 - PROUD / Math.min(c.w, c.d);
91621
- return across(c, k.G(k.mesh(k.cyl(r, r, h * 0.94, seg(c, 14)), body), k.mesh(k.cyl(0.5, 0.5, h * 0.5, seg(c, 14)), k.food(c.color)), k.mesh(k.cyl(0.5, 0.5, h * 0.03, seg(c, 14)), body, [0, h * 0.485, 0]), k.mesh(k.cyl(0.5, 0.5, h * 0.03, seg(c, 14)), body, [0, -h * 0.485, 0])));
91622
- };
91623
- var bottle = (c) => {
91624
- const { k, h } = c;
91625
- const r = 0.5;
91626
- const profile = [[0, -h / 2], [r, -h / 2], [r, h * 0.12], [r * 0.45, h * 0.3], [r * 0.4, h * 0.4], [0, h * 0.4]];
91627
- return across(c, k.G(k.mesh(k.lathe(profile, seg(c, 14)), k.glass(c.color, 0.6)), k.mesh(k.cyl(r * 0.42, r * 0.42, h * 0.1, seg(c, 10)), k.plastic(shade2(c.color, 0.5)), [0, h * 0.45, 0])));
91628
- };
91629
- var jar = (c) => {
91630
- const { k, h } = c;
91631
- return across(c, k.G(k.mesh(k.cyl(0.5, 0.5, h * 0.82, seg(c, 14)), k.glass(c.color, 0.55), [0, -h * 0.09, 0]), k.mesh(k.cyl(0.5, 0.5, h * 0.18, seg(c, 14)), k.metal(12095802), [0, h * 0.41, 0])));
91632
- };
91633
- var bag = (c) => {
91634
- const { k, w, h, d } = c;
91635
- return k.G(k.mesh(k.bx(w, h * 0.88, d - 2 * PROUD), k.paper(c.color), [0, -h * 0.06, 0]), k.mesh(k.bx(w * 1, h * 0.12, d * 0.5), k.paper(shade2(c.color, 0.85)), [0, h * 0.44, 0]), k.mesh(k.bx(w * 0.7, h * 0.3, d), k.paper(shade2(c.color, 1.2)), [0, 0, 0]));
91636
- };
91637
- var box4 = (c) => {
91638
- const { k, w, h, d } = c;
91639
- return k.G(k.mesh(k.bx(w - 2 * PROUD, h - PROUD, d - 2 * PROUD), k.paper(c.color), [0, -PROUD / 2, 0]), k.mesh(k.bx(w, h * 0.12, d), k.paper(shade2(c.color, 0.8)), [0, h * 0.44, 0]), k.mesh(k.bx(w * 0.62, h * 0.4, d), k.paper(shade2(c.color, 1.25)), [0, -h * 0.02, 0]));
91640
- };
91641
- var cloth = (c) => {
91642
- const { k, w, h, d } = c;
91643
- const material = k.cloth(c.color);
91644
- return k.G(k.mesh(k.bx(w, h * 0.55, d), material, [0, -h * 0.225, 0]), k.mesh(k.bx(w * 0.96, h * 0.45, d * 0.96), k.cloth(shade2(c.color, 0.9)), [0, h * 0.275, 0]));
91645
- };
91646
- var paper = (c) => {
91647
- const { k, w, h, d } = c;
91648
- const sheet = k.paper(c.color);
91649
- return k.G(k.mesh(k.bx(w, h / 3, d), sheet, [0, -h / 3, 0]), k.mesh(k.bx(w * 0.98, h / 3, d * 0.98), k.paper(shade2(c.color, 0.95)), [0, 0, 0]), k.mesh(k.bx(w, h / 3, d), sheet, [0, h / 3, 0]));
91650
- };
91651
- var fruit = (c) => {
91652
- const { k, w, h, d } = c;
91653
- const sphere2 = new k.T.SphereGeometry(0.5, seg(c, 12), seg(c, 8));
91654
- return k.G(k.mesh(sphere2, k.food(c.color), [0, -h * 0.04, 0], [0, 0, 0], [w, h * 0.92, d]), k.mesh(k.cyl(h * 0.02, h * 0.02, h * 0.1, 6), k.wood(5913122), [0, h * 0.45, 0]));
91655
- };
91656
- var dish = (c) => {
91657
- const { k, w, h, d } = c;
91658
- return k.G(k.mesh(k.cyl(0.5, 0.35, h, seg(c, 16)), k.plastic(c.color), [0, 0, 0], [0, 0, 0], [w, 1, d]));
91659
- };
91660
- var cup = (c) => {
91661
- const { k, w, h, d } = c;
91662
- const profile = [[0, -h / 2], [0.38, -h / 2], [0.5, h / 2], [0.44, h / 2], [0.33, -h / 2 + h * 0.06], [0, -h / 2 + h * 0.06]];
91663
- return k.G(k.mesh(k.lathe(profile, seg(c, 14)), k.plastic(c.color), [0, 0, 0], [0, 0, 0], [w, 1, d]));
91664
- };
91665
- var tube = (c) => {
91666
- const { k, h } = c;
91667
- const material = k.plastic(c.color);
91668
- return across(c, k.G(k.mesh(k.cyl(0.5, 0.42, h * 0.86, seg(c, 12)), material, [0, -h * 0.04, 0]), k.mesh(k.cyl(0.35, 0.35, h * 0.12, seg(c, 12)), k.plastic(shade2(c.color, 0.6)), [0, h * 0.44, 0]), k.mesh(k.bx(1, h * 0.06, 0.25), material, [0, -h * 0.47, 0])));
91669
- };
91670
- var roll = (c) => {
91671
- const { k, w, h, d } = c;
91672
- const body = k.G(k.mesh(k.cyl(0.5, 0.5, 1, seg(c, 18)), k.paper(c.color)), k.mesh(k.cyl(0.18, 0.18, 0.98, seg(c, 12)), k.paper(11902328)));
91673
- if (h <= w && h <= d) body.scale.set(w, h, d);
91674
- else if (w <= d) {
91675
- body.rotation.z = PI13 / 2;
91676
- body.scale.set(h, w, d);
91677
- } else {
91678
- body.rotation.x = PI13 / 2;
91679
- body.scale.set(w, d, h);
91680
- }
91681
- return k.G(body);
91682
- };
91683
- var shoe = (c) => {
91684
- const { k, w, h, d } = c;
91685
- const upper = k.cloth(c.color);
91686
- return k.G(k.mesh(k.bx(w, h * 0.22, d), k.plastic(2237727), [0, -h * 0.39, 0]), k.mesh(k.bx(w * 0.42, h * 0.78, d * 0.96), upper, [-w * 0.29, h * 0.11, 0]), k.mesh(k.bx(w * 0.5, h * 0.5, d * 0.96), upper, [w * 0.25, -h * 0.03, 0]));
91687
- };
91688
- var tool = alongLong((c, L, a, b) => {
91689
- const { k } = c;
91690
- const radius = Math.max(4e-3, Math.min(a, b) / 2);
91691
- return k.G(k.mesh(k.cyl(radius, radius, L * 0.74, seg(c, 10)), k.wood(9069628), [-L * 0.13, 0, 0], [0, 0, PI13 / 2]), k.mesh(k.bx(L * 0.26, a, b), k.metal(shade2(c.color, 1)), [L * 0.37, 0, 0]));
91692
- });
91693
- var longTool = alongLong((c, L, a, b) => {
91694
- const { k } = c;
91695
- const radius = Math.max(4e-3, Math.min(a, b) / 2) * 0.55;
91696
- return k.G(k.mesh(k.cyl(radius, radius, L * 0.94, seg(c, 10)), k.wood(10122312), [0, 0, 0], [0, 0, PI13 / 2]), k.mesh(k.bx(L * 0.12, a, b), k.metal(c.color), [L * 0.44, 0, 0]));
91697
- });
91698
- var blade = alongLong((c, L, a, b) => {
91699
- const { k } = c;
91700
- const edge = Math.min(2e-4, b * 0.05);
91701
- const steel = k.extrude([[0, 0], [L * 0.66, 0], [L * 0.68, a * 0.4], [0, a]], Math.max(5e-4, b * 0.4 - 2 * edge), edge);
91702
- return k.G(k.mesh(steel, k.metal(11120048), [-L * 0.18, -a / 2, -b * 0.2 + edge]), k.mesh(k.bx(L * 0.34, a * 0.6, b), k.wood(3877408), [-L * 0.33, 0, 0]));
91703
- });
91704
- var garment = (c) => {
91705
- const { k, w, h, d } = c;
91706
- const material = k.cloth(c.color);
91707
- return k.G(k.mesh(k.bx(w * 0.56, h, d), material), k.mesh(k.bx(w * 0.22, h * 0.42, d * 0.9), material, [-w * 0.39, h * 0.29, 0]), k.mesh(k.bx(w * 0.22, h * 0.42, d * 0.9), material, [w * 0.39, h * 0.29, 0]));
91708
- };
91709
- var backpack2 = (c) => {
91710
- const { k, w, h, d } = c;
91711
- const material = k.cloth(c.color);
91712
- const dome = new k.T.SphereGeometry(0.5, seg(c, 12), seg(c, 6), 0, PI13 * 2, 0, PI13 / 2);
91713
- const strap = k.cloth(shade2(c.color, 0.6));
91714
- return k.G(k.mesh(k.bx(w, h * 0.78, d * 0.68), material, [0, -h * 0.11, -d * 0.14]), k.mesh(dome, material, [0, h * 0.28, -d * 0.14], [0, 0, 0], [w, h * 0.44, d * 0.68]), k.mesh(k.bx(w * 0.7, h * 0.4, d * 0.3), k.cloth(shade2(c.color, 0.75)), [0, -h * 0.18, d * 0.35]), k.mesh(k.bx(w * 0.1, h * 0.7, d * 0.04), strap, [-w * 0.25, -h * 0.05, -d * 0.48]), k.mesh(k.bx(w * 0.1, h * 0.7, d * 0.04), strap, [w * 0.25, -h * 0.05, -d * 0.48]));
91715
- };
91716
- var jerrycan = (c) => {
91717
- const { k, w, h, d } = c;
91718
- const material = k.plastic(c.color);
91719
- return k.G(k.mesh(k.bx(w, h * 0.86, d), material, [0, -h * 0.07, 0]), k.mesh(k.bx(w * 0.4, h * 0.1, d * 0.5), material, [-w * 0.2, h * 0.45, 0]), k.mesh(k.cyl(d * 0.14, d * 0.18, h * 0.12, seg(c, 10)), k.plastic(14263361), [w * 0.3, h * 0.44, 0]));
91720
- };
91721
- var tank = (c) => {
91722
- const { k, h } = c;
91723
- const r = 0.5;
91724
- const profile = [[0, -h / 2], [r * 0.9, -h / 2], [r, -h * 0.4], [r, h * 0.22], [r * 0.6, h * 0.36], [r * 0.2, h * 0.4], [0, h * 0.4]];
91725
- const metal2 = k.metal(c.color);
91726
- return across(c, k.G(k.mesh(k.lathe(profile, seg(c, 14)), metal2), k.mesh(k.cyl(r * 0.62, r * 0.62, h * 0.05, seg(c, 14)), metal2, [0, h * 0.3, 0]), k.mesh(k.cyl(r * 0.18, r * 0.18, h * 0.12, seg(c, 8)), k.metal(12095802), [0, h * 0.44, 0])));
91727
- };
91728
- var book = (c) => {
91729
- const { k, w, h, d } = c;
91730
- const cover = k.paper(c.color);
91731
- return k.G(k.mesh(k.bx(w - PROUD, h - 2 * PROUD, d * 0.14), cover, [PROUD / 2, 0, d * 0.43 - PROUD]), k.mesh(k.bx(w - PROUD, h - 2 * PROUD, d * 0.14), cover, [PROUD / 2, 0, -d * 0.43 + PROUD]), k.mesh(k.bx(w * 0.94, h * 0.96, d * 0.72), k.paper(15327692), [w * 0.02, 0, 0]), k.mesh(k.bx(w * 0.08, h, d), k.paper(shade2(c.color, 0.8)), [-w * 0.46, 0, 0]));
91732
- };
91733
- var key = alongLong((c, L, a, b) => {
91734
- const { k } = c;
91735
- const metal2 = k.metal(12095802);
91736
- const ring3 = a * 0.5;
91737
- const tube2 = Math.min(b * 0.4, ring3 * 0.2);
91738
- return k.G(k.mesh(new c.k.T.TorusGeometry(ring3 * 0.8, tube2, 5, seg(c, 10)), k.metal(10132896), [-L / 2 + ring3 * 0.8 + tube2, 0, 0]), k.mesh(k.bx(L * 0.62, a * 0.28, b), metal2, [L * 0.12, 0, 0]), k.mesh(k.bx(L * 0.08, a * 0.17, b), metal2, [L * 0.36, -a * 0.225, 0]), k.mesh(k.bx(L * 0.06, a * 0.17, b), metal2, [L * 0.2, -a * 0.225, 0]));
91739
- });
91740
- var battery2 = alongLong((c, L, a, b) => {
91741
- const { k } = c;
91742
- const r = Math.min(a, b) / 2;
91743
- return k.G(k.mesh(k.cyl(r, r, L * 0.94, seg(c, 14)), k.metal(c.color), [0, 0, 0], [0, 0, PI13 / 2]), k.mesh(k.cyl(r * 0.36, r * 0.36, L * 0.06, seg(c, 8)), k.metal(12172736), [L * 0.47, 0, 0], [0, 0, PI13 / 2]));
91744
- });
91745
- var plank = alongLong((c, L, a, b) => {
91746
- const { k } = c;
91747
- const nail = k.metal(8225158);
91748
- return k.G(k.mesh(k.bx(L, a, b), k.wood(11043929)), k.mesh(k.cyl(Math.min(a, b) * 0.1, Math.min(a, b) * 0.1, b * 0.98, 6), nail, [-L * 0.4, 0, 0], [PI13 / 2, 0, 0]), k.mesh(k.cyl(Math.min(a, b) * 0.1, Math.min(a, b) * 0.1, b * 0.98, 6), nail, [L * 0.4, 0, 0], [PI13 / 2, 0, 0]));
91749
- });
91750
- var device = (c) => {
91751
- const { k, w, h, d } = c;
91752
- const screen2 = k.M(10469258, "glass", { emissive: 3099170, emissiveIntensity: 0.6, roughness: 0.2 });
91753
- return k.G(k.mesh(k.bx(w, h, d * 0.96), k.plastic(c.color), [0, 0, -d * 0.02]), k.mesh(k.bx(w * 0.7, h * 0.32, d * 0.06), screen2, [0, h * 0.22, d * 0.47]), k.mesh(k.cyl(Math.min(w, h) * 0.08, Math.min(w, h) * 0.08, d * 0.1, seg(c, 8)), k.metal(12172736), [w * 0.25, -h * 0.18, d * 0.45], [PI13 / 2, 0, 0]));
91754
- };
91755
- var DRAWERS = {
91756
- can,
91757
- bag,
91758
- box: box4,
91759
- bottle,
91760
- tool,
91761
- roll,
91762
- dish,
91763
- cloth,
91764
- shoe,
91765
- jar,
91766
- paper,
91767
- fruit,
91768
- cup,
91769
- tube,
91770
- blade,
91771
- long_tool: longTool,
91772
- garment,
91773
- backpack: backpack2,
91774
- jerrycan,
91775
- tank,
91776
- book,
91777
- key,
91778
- battery: battery2,
91779
- plank,
91780
- device
91781
- };
91782
- var isShape = (value) => value !== void 0 && value in DRAWERS;
91783
- function shapeOf(subject) {
91784
- const hint = subject.shape;
91785
- if (!isShape(hint)) return "box";
91786
- const [w, h, d] = subject.size;
91787
- const { L, a, b } = canonicalFrame(subject.size);
91788
- const long = L / Math.max(a, b, 1e-6) >= 4;
91789
- const flat2 = Math.min(w, h, d) / Math.max(w, h, d) <= 0.2;
91790
- switch (hint) {
91791
- case "tool":
91792
- if (subject.category === "keys") return "key";
91793
- if (subject.category === "electronics") return "device";
91794
- if (long) return subject.category === "melee" && Math.min(a, b) / L <= 0.1 && flat2 ? "blade" : "long_tool";
91795
- return hint;
91796
- case "cloth":
91797
- return subject.category === "clothing" ? "garment" : hint;
91798
- case "bag":
91799
- return subject.category === "bags" ? "backpack" : hint;
91800
- case "box":
91801
- if (subject.category === "electronics") return "device";
91802
- if (subject.category === "books") return "book";
91803
- if (subject.category === "keys") return "key";
91804
- return hint;
91805
- case "paper":
91806
- return subject.category === "books" ? "book" : hint;
91807
- default:
91808
- return hint;
91809
- }
91810
- }
91811
- function drawShape(k, shape, size, options = {}) {
91812
- const [w, h, d] = size;
91813
- return DRAWERS[shape]({ k, w, h, d, color: options.color ?? DEFAULT_COLOR, detail: options.detail ?? 1 });
91814
- }
91815
- var WEAR_TARGET = { food: 6122286, metal: 8011293, wood: 4141862, cloth: 4866099, plastic: 7038294, paper: 9075282, glass: 5591098 };
92409
+ var WEAR_TARGET = { food: 6122286, metal: 8011293, wood: 4141862, cloth: 4866099, plastic: 7038294, paper: 9075282, glass: 5591098, rubber: 4860452 };
91816
92410
  var WEAR_AMOUNT = [0, 0.3, 0.62];
91817
92411
  var hexToRgb = (hex2) => [(hex2 >> 16 & 255) / 255, (hex2 >> 8 & 255) / 255, (hex2 & 255) / 255];
91818
92412
  var dataOf = (material) => {
@@ -91876,7 +92470,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
91876
92470
  const materials = kit.materials.slice(first);
91877
92471
  if (options.wear) setWear(materials, options.wear);
91878
92472
  root.userData.wear = options.wear ?? 0;
91879
- if (options.destructible) tagForDestruction(root, { ...kind === "model" && item.model !== void 0 ? { modelId: item.model } : {}, ...shape === void 0 ? {} : { shapeId: shape }, ...item.weight === void 0 ? {} : { weight: item.weight }, size: item.size, ...item.powder ? { powder: item.powder } : {}, three: T2 });
92473
+ if (options.destructible) tagForDestruction(root, { ...kind === "model" && item.model !== void 0 ? { modelId: item.model } : {}, ...shape === void 0 ? {} : { shapeId: shape }, ...item.weight === void 0 ? {} : { weight: item.weight }, size: item.size, ...item.powder ? { powder: item.powder } : {}, ...item.parts ? { parts: item.parts } : {}, three: T2 });
91880
92474
  markKitOrigin(root, { owner: "game-items-three", kind: "item", id: item.id, ...kind === "shape" ? { standIn: true } : {} });
91881
92475
  return { root, kind, ...shape ? { shape } : {}, size: item.size, materials };
91882
92476
  }
@@ -91930,10 +92524,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
91930
92524
  }
91931
92525
  function restOnFloor({ THREE, group, root }, grips) {
91932
92526
  group.updateMatrixWorld(true);
91933
- const laid = new THREE.Box3().setFromObject(root);
91934
- const centre = laid.getCenter(new THREE.Vector3());
91935
- root.position.sub(new THREE.Vector3(centre.x, laid.min.y, centre.z));
91936
- const length2 = laid.max.x - laid.min.x;
92527
+ const laid2 = new THREE.Box3().setFromObject(root);
92528
+ const centre = laid2.getCenter(new THREE.Vector3());
92529
+ root.position.sub(new THREE.Vector3(centre.x, laid2.min.y, centre.z));
92530
+ const length2 = laid2.max.x - laid2.min.x;
91937
92531
  const handle = new THREE.Object3D();
91938
92532
  handle.name = "handle";
91939
92533
  handle.position.set(grips.handleAt ? grips.handleAt[0] : length2 * grips.handle, grips.handleAt ? grips.handleAt[1] : 0, 0);
@@ -92092,7 +92686,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
92092
92686
  ["nail_bat", { grips: { handle: -0.3, support: -0.41 } }],
92093
92687
  ["iron_pipe", { grips: { handle: -0.29, support: -0.41 } }],
92094
92688
  ["crowbar", { grips: { handle: -0.3, support: -0.42 } }],
92095
- ["sledgehammer", { grips: { handle: -0.22, support: -0.42 } }]
92689
+ ["sledgehammer", { grips: { handle: -0.22, support: -0.42 } }],
92690
+ // an axe and a pickaxe are swung with both hands as the shovel is (the `two_hand_swing` family): the right at the end of the haft, the left up it toward the head
92691
+ ["axe", { grips: { handle: -0.44, support: -0.2 } }],
92692
+ ["pickaxe", { grips: { handle: -0.44, support: -0.2 } }],
92693
+ // a spear is thrust with both hands on the shaft, a forearm apart
92694
+ ["improvised_spear", { grips: { handle: -0.35, support: -0.12 } }]
92096
92695
  ];
92097
92696
  var hasThrowableModel = (def) => def.action?.kind === "throwable" && def.action.explosive !== void 0 && hasExplosiveModel(def.action.explosive);
92098
92697
  var buildThrowableModel = (THREE, def) => def.action?.kind === "throwable" && def.action.explosive !== void 0 ? buildExplosiveModel(THREE, def.action.explosive) : void 0;
@@ -92124,6 +92723,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
92124
92723
 
92125
92724
  // src/box-fx.ts
92126
92725
  var TOOL_REACH = 0.47;
92726
+ var RIGID_IN_HAND = /* @__PURE__ */ new Set(["melee", "tool"]);
92727
+ var SEAT_STILL = { distance: 1e-4, angle: 1e-4 };
92127
92728
  var EJECTS_ON_SHOT = /* @__PURE__ */ new Set(["pistol", "smg", "carbine", "rifle", "sniper", "shotgun"]);
92128
92729
  var SPOUTS = /* @__PURE__ */ new Set(["firearm", "flame", "heat", "extinguisher"]);
92129
92730
  var DROPS_MAGAZINE = /* @__PURE__ */ new Set(["pistol", "smg", "carbine", "rifle", "sniper"]);
@@ -92149,7 +92750,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
92149
92750
  let inHand = null;
92150
92751
  let def = null;
92151
92752
  let hold = null;
92152
- let kick = 0;
92753
+ let kick2 = 0;
92153
92754
  let motion = null;
92154
92755
  const applyMotion = (frame2) => {
92155
92756
  if (!motion) return;
@@ -92190,6 +92791,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
92190
92791
  const q = new THREE.Quaternion();
92191
92792
  const bodyFrame = new THREE.Quaternion();
92192
92793
  const q2 = new THREE.Quaternion();
92794
+ const seatTurn = new THREE.Quaternion();
92795
+ const seatAsked = new THREE.Quaternion();
92193
92796
  const pointForward = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 1, 0), Math.PI / 2);
92194
92797
  const frontOf = new THREE.Vector3();
92195
92798
  const restBox2 = new THREE.Box3();
@@ -92255,15 +92858,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
92255
92858
  scene.add(mesh3);
92256
92859
  bodies.push({ mesh: mesh3, velocity: velocity2, spin: new THREE.Vector3(random() * 20 - 10, random() * 30 - 15, random() * 20 - 10), radius, age: 0, resting: false, bounces: 0, kind });
92257
92860
  };
92258
- const ejectCasing = (caliberMm, isShell, downward) => {
92861
+ const ejectCasing = (caliberMm, isShell) => {
92862
+ if (!model) return;
92259
92863
  const radius = isShell ? 0.0105 : Math.max(3e-3, caliberMm / 1e3 * 0.6);
92260
92864
  const length2 = isShell ? 0.068 : Math.min(0.07, Math.max(0.015, caliberMm / 1e3 * 2.6));
92261
92865
  const mesh3 = new THREE.Mesh(new THREE.CylinderGeometry(radius, radius, length2, 8), isShell ? shell : brass);
92262
92866
  mesh3.name = "casing";
92263
- const from = handPoint(0.03, 0.03, 0.05, new THREE.Vector3());
92264
- const right = new THREE.Vector3(1, 0, 0).applyQuaternion(camera2.quaternion);
92265
- const up = new THREE.Vector3(0, 1, 0);
92266
- const velocity2 = downward ? up.clone().multiplyScalar(-0.5).addScaledVector(right, (random() - 0.5) * 0.4) : right.multiplyScalar(1.6 + random() * 0.8).addScaledVector(up, 1.4 + random() * 0.8);
92867
+ hand.updateMatrixWorld(true);
92868
+ const from = model.localToWorld(new THREE.Vector3(frontOf.x - lengthMetres * 0.4, frontOf.y + 0.02, 0.015));
92869
+ if (inLens) toWorldLens(camera2, from, camera2.fov ?? 72, VIEW_HOLD.tool.fov);
92870
+ const scatter2 = new THREE.Vector3(random() - 0.5, random() - 0.5, random() - 0.5).multiplyScalar(2 * EJECT_SCATTER);
92871
+ const velocity2 = ejectDirection(THREE, "right").add(scatter2).normalize().multiplyScalar(1.5 + random() * 0.6).applyQuaternion(model.getWorldQuaternion(q2));
92267
92872
  throwBody("casing", mesh3, from, velocity2, radius);
92268
92873
  };
92269
92874
  const dropMagazine = (category) => {
@@ -92285,20 +92890,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
92285
92890
  bodies.splice(bodies.indexOf(body), 1);
92286
92891
  }
92287
92892
  const onShot = (weapon2) => {
92288
- kick = 1;
92893
+ kick2 = 1;
92289
92894
  const caliber = weapon2.action.kind === "firearm" ? arsenal.calibers.get(weapon2.action.caliber) : void 0;
92290
92895
  const energy = caliber ? muzzleEnergy(caliber) * (caliber.pellets ?? 1) : FALLBACK_ENERGY;
92291
92896
  audio?.shot(energy, weapon2.category, { ...caliber ? { caliber } : {}, distance: options.soundDistance?.() ?? 0, space: options.soundSpace?.() ?? "outdoor" });
92292
92897
  if (CYCLES.has(weapon2.id)) audio?.cycle();
92293
- if (EJECTS_ON_SHOT.has(weapon2.category) && weapon2.id !== "shotgun_double_12") ejectCasing(caliberOf2(weapon2), weapon2.category === "shotgun", false);
92898
+ if (EJECTS_ON_SHOT.has(weapon2.category) && weapon2.id !== "shotgun_double_12") ejectCasing(caliberOf2(weapon2), weapon2.category === "shotgun");
92294
92899
  };
92295
- const onReloadStart = (weapon2, tool2) => {
92900
+ const onReloadStart = (weapon2) => {
92296
92901
  if (DROPS_MAGAZINE.has(weapon2.category)) dropMagazine(weapon2.category);
92297
92902
  else audio?.reloadStart(weapon2.category);
92298
- if (weapon2.category === "revolver" || weapon2.id === "shotgun_double_12") {
92299
- const spent = Math.max(1, tool2.capacity - tool2.ammo);
92300
- for (let i = 0; i < spent; i++) ejectCasing(caliberOf2(weapon2), weapon2.category === "shotgun", true);
92301
- }
92302
92903
  };
92303
92904
  const stepBody = (body, dt) => {
92304
92905
  body.age += dt;
@@ -92351,6 +92952,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
92351
92952
  hand.updateMatrixWorld(true);
92352
92953
  return targetsOf(THREE, held, model.getWorldQuaternion(q2), 0);
92353
92954
  },
92955
+ seat(reached) {
92956
+ const held = heldHold();
92957
+ const got = reached[side];
92958
+ if (!model || !def || !held || !got || !RIGID_IN_HAND.has(def.action.kind)) return false;
92959
+ hand.updateMatrixWorld(true);
92960
+ const asked = targetsOf(THREE, held, model.getWorldQuaternion(q2), 0)[side];
92961
+ if (!asked) return false;
92962
+ seatTurn.set(...got.quaternion).multiply(seatAsked.set(...asked.quaternion).invert());
92963
+ const off = Math.hypot(got.position[0] - asked.position[0], got.position[1] - asked.position[1], got.position[2] - asked.position[2]);
92964
+ if (off < SEAT_STILL.distance && 2 * Math.acos(Math.min(1, Math.abs(seatTurn.w))) < SEAT_STILL.angle) return false;
92965
+ hand.position.sub(v.set(...asked.position)).applyQuaternion(seatTurn).add(v.set(...got.position));
92966
+ hand.quaternion.premultiply(seatTurn);
92967
+ hand.updateMatrixWorld(true);
92968
+ return true;
92969
+ },
92354
92970
  handle(event, tool2) {
92355
92971
  if (event.type === "explosion" || event.type === "player" || event.type === "footfall") return;
92356
92972
  const weapon2 = arsenal.weapons.get(event.weapon);
@@ -92365,12 +92981,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
92365
92981
  }
92366
92982
  if (event.type === "shot") onShot(weapon2);
92367
92983
  else if (event.type === "empty") audio?.click();
92368
- else if (event.type === "reload" && event.phase === "start") onReloadStart(weapon2, tool2);
92984
+ else if (event.type === "reload" && event.phase === "start") onReloadStart(weapon2);
92369
92985
  else if (event.type === "reload" && event.phase === "end") audio?.reloadEnd(weapon2.category);
92370
92986
  reloading = tool2.reloading;
92371
92987
  },
92372
92988
  update(dt) {
92373
- kick *= Math.exp(-dt * 14);
92989
+ kick2 *= Math.exp(-dt * 14);
92374
92990
  if (motion) {
92375
92991
  motion.elapsed += dt;
92376
92992
  if (motion.elapsed >= motion.duration) motion = null;
@@ -92381,7 +92997,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
92381
92997
  const held = heldHold();
92382
92998
  const kind = isOneHand() && def?.action.kind === "firearm" ? "dual" : "tool";
92383
92999
  placeInView({ THREE, hand, holder: model, camera: camera2, right: heldAnchor(held), box: restBox2, kind, aim: 0, offset: noMotion, ...side === "L" ? { mirror: true } : {} });
92384
- hand.position.add(v.set(0, -0.12 * dip, 0.05 * kick).applyQuaternion(camera2.quaternion));
93000
+ hand.position.add(v.set(0, -0.12 * dip, 0.05 * kick2).applyQuaternion(camera2.quaternion));
92385
93001
  applyMotion(camera2.quaternion);
92386
93002
  hand.updateMatrixWorld(true);
92387
93003
  } else if (inHand && model) {
@@ -92392,8 +93008,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
92392
93008
  const grip = def?.action.kind === "firearm" ? BODY_HOLD.dualGrip : BODY_HOLD.toolGrip;
92393
93009
  placeOnBody({ THREE, hand, holder: model, frame: options.bodyHold?.() ?? eyeFrame(), rear, lengthMetres, handgun: true, right: heldAnchor(held), left: null, grip, ...side === "L" ? { mirror: true } : {} });
92394
93010
  } else placeOnBody({ THREE, hand, holder: model, frame: options.bodyHold?.() ?? eyeFrame(), rear, lengthMetres, handgun, right: hold?.right ?? null, left: hold?.left ?? null });
92395
- hand.position.add(v.set(0, -0.12 * dip, 0.05 * kick).applyQuaternion(camera2.quaternion));
92396
- q.setFromEuler(new THREE.Euler(0.14 * kick - 0.25 * dip, 0, 0.6 * dip));
93011
+ hand.position.add(v.set(0, -0.12 * dip, 0.05 * kick2).applyQuaternion(camera2.quaternion));
93012
+ q.setFromEuler(new THREE.Euler(0.14 * kick2 - 0.25 * dip, 0, 0.6 * dip));
92397
93013
  hand.quaternion.multiply(q);
92398
93014
  const body = options.bodyHold?.() ?? eyeFrame();
92399
93015
  applyMotion(bodyFrame.set(body.quaternion[0], body.quaternion[1], body.quaternion[2], body.quaternion[3]));
@@ -92567,9 +93183,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
92567
93183
  }
92568
93184
  function cycleClip(context) {
92569
93185
  const { parts: parts2, family } = context;
92570
- if (family === "pump" && parts2.pump) return composeClip("cycle", [move("pump", "x", 0.22, 0.11, 0, PUMP_TRAVEL), move("pump", "x", 0.36, 0.11, PUMP_TRAVEL, 0)], [cue(0.3, "eject_casing", { down: false })], 0.5);
92571
- if ((family === "bolt" || family === "boltmag") && parts2.bolt && parts2.boltHandle) return composeClip("cycle", boltStroke(0.3), [cue(0.5, "eject_casing", { down: false })], 0.82);
92572
- if (family === "lever" && parts2.lever) return composeClip("cycle", [turn("lever", "z", 0.22, 0.13, 0, LEVER_TURN), turn("lever", "z", 0.38, 0.13, LEVER_TURN, 0)], [cue(0.3, "eject_casing", { down: false })], 0.55);
93186
+ if (family === "pump" && parts2.pump) return composeClip("cycle", [move("pump", "x", 0.22, 0.11, 0, PUMP_TRAVEL), move("pump", "x", 0.36, 0.11, PUMP_TRAVEL, 0)], [cue(0.3, "eject_casing")], 0.5);
93187
+ if ((family === "bolt" || family === "boltmag") && parts2.bolt && parts2.boltHandle) return composeClip("cycle", boltStroke(0.3), [cue(0.5, "eject_casing")], 0.82);
93188
+ if (family === "lever" && parts2.lever) return composeClip("cycle", [turn("lever", "z", 0.22, 0.13, 0, LEVER_TURN), turn("lever", "z", 0.38, 0.13, LEVER_TURN, 0)], [cue(0.3, "eject_casing")], 0.55);
92573
93189
  return void 0;
92574
93190
  }
92575
93191
  var STUCK_AT = { stovepipe: 0.35, double_feed: 0.6, misfire: 0, failure_to_extract: 0 };
@@ -92644,7 +93260,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
92644
93260
  return draft;
92645
93261
  }
92646
93262
  function revolverReload(kind) {
92647
- const events = [sound2(0, "cylinder_open"), cue(0.32, "eject_casing", { from: "chambers", down: false }), sound2(0.32, "cylinder_eject"), sound2(1.2, "cylinder_close")];
93263
+ const events = [sound2(0, "cylinder_open"), cue(0.32, "eject_casing", { from: "chambers" }), sound2(0.32, "cylinder_eject"), sound2(1.2, "cylinder_close")];
92648
93264
  if (kind !== "one_by_one") events.push(cue(0.7, "move_in", { from: "chambers" }), sound2(0.7, "speedloader"));
92649
93265
  return { tweens: [turn("crane", "x", 0, 0.22, 0, -1.25), turn("crane", "x", 1.05, 0.2, -1.25, 0)], events, end: 1.3 };
92650
93266
  }
@@ -92652,7 +93268,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
92652
93268
  tweens: [turn("barrels", "z", 0, 0.2, 0, -0.5), turn("barrels", "z", 1, 0.15, -0.5, 0)],
92653
93269
  events: [
92654
93270
  sound2(0, "barrels_open"),
92655
- cue(0.25, "eject_casing", { from: "breech", down: false }),
93271
+ cue(0.25, "eject_casing", { from: "breech" }),
92656
93272
  sound2(0.25, "casings_eject"),
92657
93273
  cue(0.65, "move_in", { from: "breech" }),
92658
93274
  sound2(0.65, "shell_insert"),
@@ -92765,12 +93381,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
92765
93381
  var FAULT_SLIDE_BACK = { stovepipe: 0.35, double_feed: 0.6 };
92766
93382
  var pullTrigger = (context) => context.parts.trigger ? [turn("trigger", "z", 0, 0.04, 0, 0.35), turn("trigger", "z", 0.06, 0.08, 0.35, 0)] : [];
92767
93383
  var recoil = (context) => {
92768
- const kick = kickOf(context);
93384
+ const kick2 = kickOf(context);
92769
93385
  return [
92770
- move(ROOT2, "x", 0, 0.03, 0, -0.014 * kick),
92771
- turn(ROOT2, "z", 0, 0.03, 0, 0.045 * kick),
92772
- move(ROOT2, "x", 0.03, 0.18, -0.014 * kick, 0),
92773
- turn(ROOT2, "z", 0.03, 0.18, 0.045 * kick, 0)
93386
+ move(ROOT2, "x", 0, 0.03, 0, -0.014 * kick2),
93387
+ turn(ROOT2, "z", 0, 0.03, 0, 0.045 * kick2),
93388
+ move(ROOT2, "x", 0.03, 0.18, -0.014 * kick2, 0),
93389
+ turn(ROOT2, "z", 0.03, 0.18, 0.045 * kick2, 0)
92774
93390
  ];
92775
93391
  };
92776
93392
  var spinBarrels = (context) => context.parts.barrels && context.family === "belt" ? [turn("barrels", "x", 0, 0.03, 0, Math.PI / 3)] : [];
@@ -92786,7 +93402,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
92786
93402
  tweens.push(move(part, "x", 0, 0.025, 0, travel));
92787
93403
  if (!locked) tweens.push(move(part, "x", 0.025, 0.045, travel, 0));
92788
93404
  }
92789
- events.push(cue(0.012, "eject_casing", { down: family === "p90" || family === "belt" }));
93405
+ events.push(cue(0.012, "eject_casing"));
92790
93406
  } else if (REVOLVING.has(family) && parts2.cylinder && parts2.hammer) {
92791
93407
  tweens.push(turn("cylinder", "x", 0, 0.05, 0, Math.PI / 3), turn("hammer", "z", 0, 0.05, 0, 0.5), turn("hammer", "z", 0.05, 0.03, 0.5, -0.5), turn("hammer", "z", 0.12, 0.08, -0.5, 0));
92792
93408
  }
@@ -97827,11 +98443,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
97827
98443
  const { x, y, scale } = args;
97828
98444
  let best;
97829
98445
  let bestDistance = 9;
97830
- for (const block of blocks) {
97831
- const distance4 = Math.hypot(block.x - x, block.y - y);
98446
+ for (const block2 of blocks) {
98447
+ const distance4 = Math.hypot(block2.x - x, block2.y - y);
97832
98448
  if (distance4 < bestDistance) {
97833
98449
  bestDistance = distance4;
97834
- best = block;
98450
+ best = block2;
97835
98451
  }
97836
98452
  }
97837
98453
  if (!best) return;
@@ -97845,10 +98461,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
97845
98461
  impact2(host.engine, "concrete", [ORIGIN4[0] + x, y, ORIGIN4[2] + 0.13], [0, 0, 1], 0.8);
97846
98462
  } else if (action === "collapse") {
97847
98463
  const { x, y } = args;
97848
- for (const block of blocks) {
97849
- const dx = block.x - x;
97850
- const dy = block.y - y;
97851
- block.motion = {
98464
+ for (const block2 of blocks) {
98465
+ const dx = block2.x - x;
98466
+ const dy = block2.y - y;
98467
+ block2.motion = {
97852
98468
  vx: dx * random.between(0.8, 2),
97853
98469
  vy: random.between(0.5, 2.5) + dy * 0.5,
97854
98470
  vz: random.between(-2.2, -0.4),
@@ -97865,17 +98481,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
97865
98481
  throw new Error(`blocks: unknown query ${name}`);
97866
98482
  },
97867
98483
  update(_host, dt) {
97868
- for (const block of blocks) {
97869
- const motion = block.motion;
98484
+ for (const block2 of blocks) {
98485
+ const motion = block2.motion;
97870
98486
  if (!motion || motion.rest) continue;
97871
98487
  motion.vy -= 9.8 * dt;
97872
- block.x += motion.vx * dt;
97873
- block.y += motion.vy * dt;
97874
- block.rotation[0] += motion.wx * dt;
97875
- block.rotation[1] += motion.wy * dt;
97876
- block.rotation[2] += motion.wz * dt;
97877
- if (block.y < FLOOR2) {
97878
- block.y = FLOOR2;
98488
+ block2.x += motion.vx * dt;
98489
+ block2.y += motion.vy * dt;
98490
+ block2.rotation[0] += motion.wx * dt;
98491
+ block2.rotation[1] += motion.wy * dt;
98492
+ block2.rotation[2] += motion.wz * dt;
98493
+ if (block2.y < FLOOR2) {
98494
+ block2.y = FLOOR2;
97879
98495
  motion.vy *= -0.25;
97880
98496
  motion.vx *= 0.5;
97881
98497
  motion.vz *= 0.5;
@@ -97884,8 +98500,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
97884
98500
  motion.wz *= 0.5;
97885
98501
  if (Math.abs(motion.vy) < 0.4 && Math.hypot(motion.vx, motion.vz) < 0.3) {
97886
98502
  motion.rest = true;
97887
- block.rotation[0] = Math.round(block.rotation[0] / QUARTER_TURN) * QUARTER_TURN;
97888
- block.rotation[2] = Math.round(block.rotation[2] / QUARTER_TURN) * QUARTER_TURN;
98503
+ block2.rotation[0] = Math.round(block2.rotation[0] / QUARTER_TURN) * QUARTER_TURN;
98504
+ block2.rotation[2] = Math.round(block2.rotation[2] / QUARTER_TURN) * QUARTER_TURN;
97889
98505
  }
97890
98506
  }
97891
98507
  }
@@ -100785,7 +101401,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
100785
101401
  }
100786
101402
  var CAPACITY3 = 400;
100787
101403
  var IDENTITY3 = [0, 0, 0, 1];
100788
- function multiply2(a, b) {
101404
+ function multiply3(a, b) {
100789
101405
  const [ax, ay, az, aw] = a;
100790
101406
  const [bx, by, bz, bw] = b;
100791
101407
  return [aw * bx + ax * bw + ay * bz - az * by, aw * by - ax * bz + ay * bw + az * bx, aw * bz + ax * by - ay * bx + az * bw, aw * bw - ax * bx - ay * by - az * bz];
@@ -100816,7 +101432,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
100816
101432
  x: options.p[0],
100817
101433
  y: options.p[1],
100818
101434
  z: options.p[2],
100819
- frame: options.roll ? multiply2(frame2, aboutX(options.roll)) : frame2,
101435
+ frame: options.roll ? multiply3(frame2, aboutX(options.roll)) : frame2,
100820
101436
  roll: options.roll ? aboutX(options.roll) : void 0,
100821
101437
  carried,
100822
101438
  drift: [0, 0, 0],
@@ -100898,7 +101514,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
100898
101514
  particle.y = y + drift[1];
100899
101515
  particle.z = z + drift[2];
100900
101516
  const turn2 = carried.carrier.orientation;
100901
- if (turn2) particle.frame = particle.roll ? multiply2(turn2, particle.roll) : turn2;
101517
+ if (turn2) particle.frame = particle.roll ? multiply3(turn2, particle.roll) : turn2;
100902
101518
  }
100903
101519
  };
100904
101520
  var DEFAULT_FADE_IN = 0.1;
@@ -103547,6 +104163,45 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
103547
104163
  };
103548
104164
  }
103549
104165
 
104166
+ // src/fx/worn-pack-rig.ts
104167
+ var MOUNT_TURN = Math.PI / 2;
104168
+ var HOSE_SAG = 0.18;
104169
+ var HOSE_RADIUS = 0.011;
104170
+ var HOSE_SEGMENTS = 28;
104171
+ var createWornPackRig = (THREE, scene, pack2) => {
104172
+ const turn2 = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 1, 0), MOUNT_TURN);
104173
+ const cord = createHangingCord(THREE, { segments: HOSE_SEGMENTS, radius: HOSE_RADIUS, material: pack2.hoseMaterial });
104174
+ const hose2 = cord.mesh;
104175
+ const from = new THREE.Vector3();
104176
+ const to = new THREE.Vector3();
104177
+ const rotation2 = new THREE.Quaternion();
104178
+ const offset = new THREE.Vector3();
104179
+ pack2.root.visible = false;
104180
+ hose2.visible = false;
104181
+ scene.add(pack2.root, hose2);
104182
+ return {
104183
+ update(slot) {
104184
+ const shown = slot !== null;
104185
+ pack2.root.visible = shown;
104186
+ hose2.visible = shown;
104187
+ if (!slot) return;
104188
+ rotation2.set(...slot.quaternion).multiply(turn2);
104189
+ pack2.root.quaternion.copy(rotation2);
104190
+ pack2.root.position.set(...slot.position).sub(offset.copy(pack2.mount.position).applyQuaternion(rotation2));
104191
+ pack2.root.updateMatrixWorld(true);
104192
+ pack2.wandEnd.getWorldPosition(from);
104193
+ pack2.port.getWorldPosition(to);
104194
+ cord.hang(from, to, HOSE_SAG);
104195
+ },
104196
+ dispose() {
104197
+ hose2.removeFromParent();
104198
+ hose2.geometry.dispose();
104199
+ pack2.root.removeFromParent();
104200
+ discardObject3D(pack2.root);
104201
+ }
104202
+ };
104203
+ };
104204
+
103550
104205
  // src/fx/heavy.ts
103551
104206
  var PI17 = Math.PI;
103552
104207
  var ROCKET_LIGHT_NAME = "rocket-light";
@@ -103958,6 +104613,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
103958
104613
 
103959
104614
  // src/fx/viewmodel-events.ts
103960
104615
  var PI18 = Math.PI;
104616
+ var DROP_SPEED = 0.4;
103961
104617
  var UGL_FLASH = 1.6;
103962
104618
  var restFlat = (object2) => {
103963
104619
  object2.rotation.x = 0;
@@ -103978,10 +104634,16 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
103978
104634
  if (session.cartridge.caseType) casing2.group.userData["caseType"] = session.cartridge.caseType;
103979
104635
  particles.spawn(casing2.group, velocity2, { kind: "casing", life: 25, radius: casing2.radius, bounce: 0.35, spin, onRest: restFlat, ownsGeometry: true, collider: casingCollider(casing2.radius, casing2.length) });
103980
104636
  };
103981
- const ejectFromPort = (down2) => {
104637
+ const scattered = (side, speed) => {
104638
+ const direction = ejectDirection(THREE, side);
104639
+ const jitter = vector2(random() - 0.5, random() - 0.5, random() - 0.5).multiplyScalar(2 * EJECT_SCATTER);
104640
+ return direction.add(jitter).normalize().multiplyScalar(speed);
104641
+ };
104642
+ const ejectFromPort = () => {
103982
104643
  if (!parts2.eject) return;
103983
- const local2 = down2 ? vector2((random() - 0.5) * 0.3, -0.4, (random() - 0.5) * 0.3) : vector2(-0.2 - random() * 0.4, (0.9 + random() * 0.5) * reach2, (1 + random() * 0.6) * reach2);
103984
- throwCase(parts2.eject, toWorld3(session, local2), vector2(random() * 30, random() * 30, random() * 30));
104644
+ const side = parts2.ejectSide ?? "right";
104645
+ const speed = side === "down" ? DROP_SPEED : (1.5 + random() * 0.6) * reach2;
104646
+ throwCase(parts2.eject, toWorld3(session, scattered(side, speed)), vector2(random() * 30, random() * 30, random() * 30));
103985
104647
  };
103986
104648
  const ejectAll = (marks, spent) => {
103987
104649
  marks?.forEach((mark, index) => {
@@ -104055,7 +104717,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
104055
104717
  const round5 = buildRound(kit, session.cartridge.dims, session.cartridge.shape);
104056
104718
  round5.group.position.copy(positionOf3(parts2.eject));
104057
104719
  particles.spawn(round5.group, toWorld3(session, vector2(-0.2, 1.1, 1.2)), { kind: "round", life: 25, radius: round5.radius, bounce: 0.3, spin: vector2(8, 12, 6), onRest: restFlat, ownsGeometry: true });
104058
- } else ejectFromPort(false);
104720
+ } else ejectFromPort();
104059
104721
  };
104060
104722
  const trackOf = (mark) => () => root.parent ? { position: positionOf3(mark), orientation: root.getWorldQuaternion(new THREE.Quaternion()) } : null;
104061
104723
  return (event) => {
@@ -104073,9 +104735,9 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
104073
104735
  }
104074
104736
  break;
104075
104737
  case "eject_casing":
104076
- if (data.from === "chambers") ejectAll(parts2.chambers, () => ({ velocity: vector2(-0.5 - random() * 0.3, -0.1 + random() * 0.3, (random() - 0.5) * 0.25), spin: vector2(10, 20, 5), tilt: 0 }));
104077
- else if (data.from === "breech") ejectAll(parts2.breech, () => ({ velocity: vector2(-1, 0.9, (random() - 0.5) * 0.2), spin: vector2(3, 8, 12), tilt: -0.5 }));
104078
- else ejectFromPort(data.down === true);
104738
+ if (data.from === "chambers") ejectAll(parts2.chambers, () => ({ velocity: scattered("back", 0.5 + random() * 0.3), spin: vector2(10, 20, 5), tilt: 0 }));
104739
+ else if (data.from === "breech") ejectAll(parts2.breech, () => ({ velocity: scattered("backUp", 1.3), spin: vector2(3, 8, 12), tilt: -0.5 }));
104740
+ else ejectFromPort();
104079
104741
  break;
104080
104742
  case "drop_magazine":
104081
104743
  dropMagazine(data.up === true);
@@ -104679,6 +105341,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
104679
105341
  hand.add(holder);
104680
105342
  let tasks = [];
104681
105343
  let stockRig = null;
105344
+ let wornRig = null;
104682
105345
  let stockFolded = false;
104683
105346
  let session = null;
104684
105347
  let player = null;
@@ -104722,6 +105385,8 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
104722
105385
  lens2 = null;
104723
105386
  lensLayer = -1;
104724
105387
  session.attachments?.dispose();
105388
+ wornRig?.dispose();
105389
+ wornRig = null;
104725
105390
  discardObject3D(session.model.root);
104726
105391
  player = null;
104727
105392
  session = null;
@@ -104747,7 +105412,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
104747
105412
  });
104748
105413
  const equip = (weapon2) => {
104749
105414
  const def = arsenal.weapons.get(weapon2);
104750
- const model = def ? buildWeaponModelById(THREE, weapon2) : void 0;
105415
+ const model = def ? buildWeaponModelById(THREE, weapon2, { worn: "separate" }) : void 0;
104751
105416
  if (!def || !model) return false;
104752
105417
  release();
104753
105418
  hold = null;
@@ -104758,6 +105423,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
104758
105423
  lift = 0;
104759
105424
  rigStock(THREE, model, def);
104760
105425
  rigUnderbarrel(THREE, model, def);
105426
+ wornRig = model.parts.worn ? createWornPackRig(THREE, scene, model.parts.worn) : null;
104761
105427
  const modelBox = new THREE.Box3().setFromObject(model.root);
104762
105428
  const length2 = modelBox.getSize(new THREE.Vector3()).x;
104763
105429
  modelRear = modelBox.min.x;
@@ -104928,7 +105594,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
104928
105594
  const oneHand = isOneHand();
104929
105595
  const held = heldHold();
104930
105596
  if (options.firstPerson?.()) {
104931
- const kind = oneHand ? "dual" : session.model.parts.carry === "hip" ? "hip" : family === "pistol" || family === "revolver" ? "handgun" : family === "rocket" ? "launcher" : "long";
105597
+ const kind = viewKindOf(session.model.parts, oneHand);
104932
105598
  const aim = oneHand || kind === "hip" ? 0 : options.aim?.() ?? 0;
104933
105599
  placeInView({ THREE, hand, holder, camera: camera2, right: heldAnchor(held), box: restBox2, kind, aim, offset: viewMotion(dt, aim), ...side === "L" ? { mirror: true } : {} });
104934
105600
  setLens(kind);
@@ -105023,6 +105689,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
105023
105689
  clock += dt;
105024
105690
  if (session) {
105025
105691
  place(dt);
105692
+ wornRig?.update(options.firstPerson?.() ? null : options.bodySlot?.("back") ?? null);
105026
105693
  player?.update(dt);
105027
105694
  if (posed.length) {
105028
105695
  hand.updateMatrixWorld(true);
@@ -105152,6 +105819,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
105152
105819
  ...options.physics ? { physics: options.physics } : {},
105153
105820
  ...options.contact ? { contact: options.contact } : {},
105154
105821
  ...options.bodyHold ? { bodyHold: options.bodyHold } : {},
105822
+ ...options.bodySlot ? { bodySlot: options.bodySlot } : {},
105155
105823
  ...options.firstPerson ? { firstPerson: options.firstPerson } : {},
105156
105824
  ...options.viewmodelFov ? { viewmodelFov: options.viewmodelFov } : {},
105157
105825
  ...options.aim ? { aim: options.aim } : {},
@@ -105239,6 +105907,11 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
105239
105907
  if (supportR > 0.5) delete merged2.fingers;
105240
105908
  return merged2;
105241
105909
  },
105910
+ seat: (reached) => {
105911
+ const moved = model.inHand === null && box5.seat(reached);
105912
+ const movedLeft = left !== null && leftHeld() && left.model.inHand === null && left.box.seat(reached);
105913
+ return moved || movedLeft;
105914
+ },
105242
105915
  muzzle: (hand) => {
105243
105916
  const pair = hand === "L" ? left : right;
105244
105917
  if (!pair) return null;
@@ -105775,6 +106448,10 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
105775
106448
  source: "generated",
105776
106449
  file: "generated/famas.svg"
105777
106450
  },
106451
+ fists: {
106452
+ source: "generated",
106453
+ file: "generated/fists.svg"
106454
+ },
105778
106455
  flamethrower: {
105779
106456
  source: "generated",
105780
106457
  file: "generated/flamethrower.svg"
@@ -105871,6 +106548,10 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
105871
106548
  source: "generated",
105872
106549
  file: "generated/hammer.svg"
105873
106550
  },
106551
+ hand: {
106552
+ source: "generated",
106553
+ file: "generated/hand.svg"
106554
+ },
105874
106555
  hatchet: {
105875
106556
  source: "generated",
105876
106557
  file: "generated/hatchet.svg"
@@ -105971,6 +106652,10 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
105971
106652
  source: "generated",
105972
106653
  file: "generated/kel_tec_ksg.svg"
105973
106654
  },
106655
+ kick: {
106656
+ source: "generated",
106657
+ file: "generated/kick.svg"
106658
+ },
105974
106659
  knife: {
105975
106660
  source: "generated",
105976
106661
  file: "generated/knife.svg"
@@ -106223,6 +106908,10 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
106223
106908
  source: "generated",
106224
106909
  file: "generated/shotgun_semi_12.svg"
106225
106910
  },
106911
+ shove: {
106912
+ source: "generated",
106913
+ file: "generated/shove.svg"
106914
+ },
106226
106915
  shovel: {
106227
106916
  source: "generated",
106228
106917
  file: "generated/shovel.svg"
@@ -106395,7 +107084,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
106395
107084
  var P13_VALVE_MESH = "valve";
106396
107085
  var P13_VALVE_COLOR = 12095802;
106397
107086
  var P13_WALL = 25e-4;
106398
- var SHAPES3 = {
107087
+ var SHAPES4 = {
106399
107088
  fuel_barrel: { shape: { kind: "cylinder", radius: 0.3, height: 0.9 }, position: [0, 0.45, 0], color: 3104666 },
106400
107089
  propane_p13: {
106401
107090
  shape: { kind: "cylinder", radius: 0.176, height: 0.49 },
@@ -106406,7 +107095,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
106406
107095
  },
106407
107096
  car_fuel_tank: { shape: { kind: "box", size: [0.9, 0.25, 0.5] }, position: [0, 0.4, 0], color: 4935509 }
106408
107097
  };
106409
- var WORLD_EXPLOSIVE_IDS = Object.keys(SHAPES3);
107098
+ var WORLD_EXPLOSIVE_IDS = Object.keys(SHAPES4);
106410
107099
  var SHELL = { thickness: 1e-3, fill: 0.03 };
106411
107100
  var explosivePart = (def, shape, scale) => ({
106412
107101
  id: "tank",
@@ -106452,7 +107141,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
106452
107141
  return [centre.x, centre.y, centre.z];
106453
107142
  };
106454
107143
  var worldExplosiveShell = (THREE, defId, items) => {
106455
- const shape = SHAPES3[defId];
107144
+ const shape = SHAPES4[defId];
106456
107145
  const model = shape ? modelOf(THREE, shape, items, 2) : void 0;
106457
107146
  if (!model) return void 0;
106458
107147
  model.traverse((node) => {
@@ -106484,7 +107173,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
106484
107173
  };
106485
107174
  };
106486
107175
  var worldExplosiveItem = (def, name, options = {}) => {
106487
- const shape = SHAPES3[def.id];
107176
+ const shape = SHAPES4[def.id];
106488
107177
  if (!shape) return void 0;
106489
107178
  const scale = () => options.scale?.() ?? 1;
106490
107179
  const spec = () => ({ name, parts: [explosivePart(def, shape, scale())], joints: [], tags: ["explosive"] });
@@ -106883,6 +107572,16 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
106883
107572
  get fx() {
106884
107573
  return fx;
106885
107574
  },
107575
+ // every tool of the arsenal has its picture: the hotbar shows it for the ones no item stands for too (the generic guns, the hand and the fists)
107576
+ toolThumbnails: () => {
107577
+ const urls = {};
107578
+ if (thumbnailBase === false) return urls;
107579
+ for (const id of arsenal.weapons.keys()) {
107580
+ const url2 = weaponThumbnailUrl(id, thumbnailBase);
107581
+ if (url2) urls[id] = url2;
107582
+ }
107583
+ return urls;
107584
+ },
106886
107585
  items: () => [
106887
107586
  ...weaponDefs.map((def) => withThumbnail(weaponItem(def, arsenal.name(def.id), options.items, options.props), def.id)),
106888
107587
  counterItem(text.counter),
@@ -106970,6 +107669,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
106970
107669
  // the weapon against a wall asks as often as the laser, on the clock of the simulation (so a fast-forwarded room measures as often per frame)
106971
107670
  contact: createLaserRaycast(lent.THREE, lent.scene, lent.camera, { now: () => simulatedMs }),
106972
107671
  ...lent.holdFrame ? { bodyHold: () => lent.holdFrame?.() ?? null, leftBodyHold: () => lent.holdFrame?.("L") ?? null } : {},
107672
+ ...lent.bodySlot ? { bodySlot: (slot) => lent.bodySlot?.(slot) ?? null } : {},
106973
107673
  firstPerson: () => lent.player().cameraMode === "first",
106974
107674
  // the lens of the gun in first person, how far it is brought to the eye (the right button) and how the body moves (the bob and the sway follow it)
106975
107675
  ...lent.setViewmodelFov ? { viewmodelFov: (degrees) => lent.setViewmodelFov?.(degrees) } : {},
@@ -107037,7 +107737,10 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
107037
107737
  created.update(dt);
107038
107738
  holstered?.update(dt);
107039
107739
  });
107040
- const offHands = lent.setHandTargets?.(() => holstered?.handTargets() ?? created.handTargets());
107740
+ const offHands = lent.setHandTargets?.(
107741
+ () => holstered?.handTargets() ?? created.handTargets(),
107742
+ (reached) => !holstered?.handTargets() && created.seat(reached)
107743
+ );
107041
107744
  const offMuzzle = lent.setMuzzleSource?.((hand) => created.muzzle(hand));
107042
107745
  const offClear = lent.onClear?.(() => created.clearLoose());
107043
107746
  created.handle({ type: "tool", weapon: lent.tool().weapon }, lent.tool());
@@ -107359,7 +108062,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
107359
108062
  if (by === "shot") say(fillText2(log.jet_lit, { seconds: num2(now() - (vessel.leakAt ?? now()), 1), rest: num2(rest2, 1) }), { phase: "torch", objectId: vessel.objectId, seconds: now() - (vessel.leakAt ?? now()), rest: rest2 });
107360
108063
  else say(fillText2(log.lighter_lit, {}), { phase: "torch", objectId: vessel.objectId, by });
107361
108064
  };
107362
- const shove = (vessel) => {
108065
+ const shove2 = (vessel) => {
107363
108066
  const leak = vessel.leaks[vessel.leaks.length - 1];
107364
108067
  if (!room || !leak) return;
107365
108068
  const [dx, dy, dz] = leak.direction;
@@ -107535,7 +108238,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
107535
108238
  continue;
107536
108239
  }
107537
108240
  if (vessel.leakAt !== void 0) {
107538
- if (t - vessel.leakAt <= hissSeconds && leaking(vessel)) shove(vessel);
108241
+ if (t - vessel.leakAt <= hissSeconds && leaking(vessel)) shove2(vessel);
107539
108242
  if (vessel.cause === "shot" && !vessel.lit && t - vessel.leakAt >= igniteDelay && leaking(vessel)) ignite(vessel, "shot");
107540
108243
  }
107541
108244
  if (vessel.lit) {
@@ -108131,6 +108834,51 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
108131
108834
  return { model: holder, axis: [0, 1, 0], ...body ? { body } : {} };
108132
108835
  }
108133
108836
 
108837
+ // src/body-action-models.ts
108838
+ var SKIN3 = 14263420;
108839
+ var CLOTH = 3099514;
108840
+ var SOLE = 8947848;
108841
+ var block = (THREE, group, [width, height, depth, x, y, z = 0, turn2 = 0], color2, metalness = 0) => {
108842
+ const mesh3 = new THREE.Mesh(new THREE.BoxGeometry(width, height, depth), new THREE.MeshStandardMaterial({ color: color2, metalness }));
108843
+ mesh3.position.set(x, y, z);
108844
+ mesh3.rotation.z = turn2;
108845
+ group.add(mesh3);
108846
+ };
108847
+ var forearm = (THREE, group, y) => block(THREE, group, [0.34, 0.075, 0.07, -0.17, y], CLOTH);
108848
+ var openHand = (THREE, group) => {
108849
+ forearm(THREE, group, 0);
108850
+ block(THREE, group, [0.1, 0.09, 0.03, 0.05, 0], SKIN3);
108851
+ for (const [index, y] of [-0.033, -0.011, 0.011, 0.033].entries()) block(THREE, group, [0.085 - (index === 0 || index === 3 ? 0.012 : 0), 0.019, 0.025, 0.145, y + (index - 1.5) * 4e-3, 0, (index - 1.5) * 0.09], SKIN3);
108852
+ block(THREE, group, [0.06, 0.022, 0.025, 0.07, 0.07, 0, 0.7], SKIN3);
108853
+ };
108854
+ var fists = (THREE, group) => {
108855
+ for (const y of [-0.075, 0.075]) {
108856
+ forearm(THREE, group, y);
108857
+ block(THREE, group, [0.095, 0.085, 0.08, 0.05, y], SKIN3);
108858
+ for (const step of [-1.5, -0.5, 0.5, 1.5]) block(THREE, group, [0.025, 0.018, 0.02, 0.105, y + step * 0.02], SKIN3);
108859
+ }
108860
+ };
108861
+ var shove = (THREE, group) => {
108862
+ forearm(THREE, group, 0);
108863
+ block(THREE, group, [0.035, 0.16, 0.11, 0.05, 0.04], SKIN3);
108864
+ block(THREE, group, [0.05, 0.03, 0.03, 0.02, -0.06, 0, 0.5], SKIN3);
108865
+ };
108866
+ var kick = (THREE, group) => {
108867
+ block(THREE, group, [0.5, 0.11, 0.11, -0.25, 0], CLOTH);
108868
+ block(THREE, group, [0.07, 0.3, 0.12, 0.035, 0.04], CLOTH);
108869
+ block(THREE, group, [0.03, 0.3, 0.125, 0.085, 0.04], SOLE, 0.8);
108870
+ block(THREE, group, [0.07, 0.07, 0.12, 0.05, 0.2, 0, 0.3], CLOTH);
108871
+ };
108872
+ var BUILDERS5 = { hand: openHand, fists, shove, kick };
108873
+ function buildBodyActionModel(THREE, id) {
108874
+ const draw2 = BUILDERS5[id];
108875
+ if (!draw2) return void 0;
108876
+ const group = new THREE.Group();
108877
+ group.name = id;
108878
+ draw2(THREE, group);
108879
+ return group;
108880
+ }
108881
+
108134
108882
  // src/weapon-props.ts
108135
108883
  function createWeaponProps(options = {}) {
108136
108884
  const entryOf = ([id, model]) => ({ id, model: model ?? { item: "" } });