@adatechnology/game-weapons-three 0.29.6 → 0.29.7

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.
@@ -18175,12 +18175,12 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
18175
18175
  }
18176
18176
  return pack("TorusGeometry", parameters, { vertices, normals, uvs, indices, groups: [] });
18177
18177
  }
18178
- function difference(size, subtract2) {
18178
+ function difference(size, subtract3) {
18179
18179
  const [w, h, d] = size;
18180
18180
  const hw = w / 2;
18181
18181
  const hh = h / 2;
18182
18182
  const hd = d / 2;
18183
- const holes = subtract2.map((hole) => ({ x0: Math.max(-hw, Math.min(hole.min[0], hole.max[0])), x1: Math.min(hw, Math.max(hole.min[0], hole.max[0])), y0: Math.max(-hh, Math.min(hole.min[1], hole.max[1])), y1: Math.min(hh, Math.max(hole.min[1], hole.max[1])) })).filter((hole) => hole.x1 > hole.x0 && hole.y1 > hole.y0);
18183
+ const holes = subtract3.map((hole) => ({ x0: Math.max(-hw, Math.min(hole.min[0], hole.max[0])), x1: Math.min(hw, Math.max(hole.min[0], hole.max[0])), y0: Math.max(-hh, Math.min(hole.min[1], hole.max[1])), y1: Math.min(hh, Math.max(hole.min[1], hole.max[1])) })).filter((hole) => hole.x1 > hole.x0 && hole.y1 > hole.y0);
18184
18184
  const cuts = (lo, hi, values) => [.../* @__PURE__ */ new Set([lo, hi, ...values.filter((v) => v > lo && v < hi)])].sort((a, b) => a - b);
18185
18185
  const xs = cuts(-hw, hw, holes.flatMap((hole) => [hole.x0, hole.x1]));
18186
18186
  const ys = cuts(-hh, hh, holes.flatMap((hole) => [hole.y0, hole.y1]));
@@ -23986,6 +23986,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23986
23986
  heatCapacity: 1.5,
23987
23987
  thermalShockC: 200
23988
23988
  },
23989
+ visual: {
23990
+ innerColor: 13148794
23991
+ },
23989
23992
  tags: [
23990
23993
  "ceramic",
23991
23994
  "brittle"
@@ -24283,7 +24286,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24283
24286
  },
24284
24287
  visual: {
24285
24288
  charColor: 855309,
24286
- innerColor: 15254346
24289
+ innerColor: 14271631
24287
24290
  },
24288
24291
  tags: [
24289
24292
  "fabric",
@@ -25112,6 +25115,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
25112
25115
  return { ...base2, mesh: { vertices, indices: piece3.mesh.indices } };
25113
25116
  };
25114
25117
  var THIN_SHEET_DISHING = 5e-3;
25118
+ var TEAR_CALIBERS = 1.1;
25115
25119
  var SHELL_YIELD_SHARE = 0.5;
25116
25120
  var STEEL_YIELD_MPA = 250;
25117
25121
  var SWEEP_BACK = 0.01;
@@ -25204,7 +25208,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
25204
25208
  var MAX_PLASTER_FLAKES = 24;
25205
25209
  var CHIP_ENERGY = 200;
25206
25210
  var CHIP_SPLASH = 0.5;
25211
+ var MORTAR_JOINT = 0.01;
25212
+ var MIN_UNIT_SHARE = 0.8;
25213
+ var CHIP_DRIVE = 0.6;
25214
+ var BLAST_DRIVE = 2.5;
25207
25215
  var CRATER_SPENT = 0.6;
25216
+ var BONDING_JOINTS = /* @__PURE__ */ new Set(["glue", "mortar", "nail", "screw"]);
25217
+ var PLATE_ASPECT = 0.25;
25218
+ var PLATE_BACK_SHARE = 0.5;
25219
+ var BONDED_REMNANT = 0.25;
25208
25220
  var EDGE_REACH = 1.5;
25209
25221
  var BAR_BOW = 0.08;
25210
25222
  var BULLET_JOINT_SPAN = 0.3;
@@ -27713,6 +27725,38 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27713
27725
  };
27714
27726
  const isTrim = (p) => (p.spec.structure?.role ?? "none") === "none";
27715
27727
  const fixesTrim = (o, j) => isTrim(o.parts[j.ia]) !== isTrim(o.parts[j.ib]);
27728
+ const bondedPlate = (o, p) => isPlateTrim(p) && (o.byPart.get(p.spec.id) ?? []).some((j) => !j.st.open && bondsPlate(o, j));
27729
+ const isPlateTrim = (p) => {
27730
+ if (!isTrim(p) || p.spec.units || p.spec.reinforcement || p.mat.ductility >= 0.5 || p.mat.fracture === "none" || p.mat.tags?.includes("glass") === true || p.spec.shape.kind !== "box") return false;
27731
+ const [u, v] = planeAxes(p.thin);
27732
+ return p.dims[p.thin] <= PLATE_ASPECT * Math.min(p.dims[u], p.dims[v]) && gridOf(p).length >= 2;
27733
+ };
27734
+ const bondsPlate = (o, j) => {
27735
+ if (!BONDING_JOINTS.has(j.spec.kind)) return false;
27736
+ const a = o.parts[j.ia], b = o.parts[j.ib];
27737
+ return isPlateTrim(a) && !isTrim(b) && backOn(a, b) || isPlateTrim(b) && !isTrim(a) && backOn(b, a);
27738
+ };
27739
+ const backOn = (plate2, carrier) => {
27740
+ const A = aabbOf(plate2.spec.shape, plate2.spec.position, plate2.q);
27741
+ const B = aabbOf(carrier.spec.shape, carrier.spec.position, carrier.q);
27742
+ const face = (k) => (Math.min(A.max[k], B.max[k]) - Math.max(A.min[k], B.min[k])) / Math.max(A.max[k] - A.min[k], 1e-9);
27743
+ const sides = [0, 1, 2].sort((x, y) => A.max[y] - A.min[y] - (A.max[x] - A.min[x])).slice(0, 2);
27744
+ return sides.every((k) => face(k) >= PLATE_BACK_SHARE);
27745
+ };
27746
+ const bondCarriers = (o, p) => {
27747
+ if (!bondedPlate(o, p)) return [];
27748
+ return (o.byPart.get(p.spec.id) ?? []).filter((j) => !j.st.open && bondsPlate(o, j)).map((j) => o.parts[j.ia] === p ? o.parts[j.ib] : o.parts[j.ia]).filter((q) => !isLost(q));
27749
+ };
27750
+ const bondedShareLeft = (p) => {
27751
+ const whole2 = p.st.mass + (p.rt.removed ?? 0);
27752
+ return whole2 > 0 ? p.st.mass / whole2 : 0;
27753
+ };
27754
+ const settleBonded = (o, p, origin, dir, src) => {
27755
+ if (isLost(p)) return;
27756
+ const share = bondedShareLeft(p);
27757
+ p.st.hp = Math.max(1, Math.min(p.st.hp, p.st.maxHp * share));
27758
+ if (share < BONDED_REMNANT) failPart(o, p, origin, dir, 0, 4, src);
27759
+ };
27716
27760
  const holdsEmbedded = (o, j) => {
27717
27761
  const a = o.parts[j.ia], b = o.parts[j.ib];
27718
27762
  return a.embedded === true && a.spec.hostedIn === b.spec.id && a.st.exposed !== true || b.embedded === true && b.spec.hostedIn === a.spec.id && b.st.exposed !== true;
@@ -27730,6 +27774,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27730
27774
  if (j.st.open) continue;
27731
27775
  if (j.spec.kind === "rebar" && (isReinforced(o.parts[j.ia].spec) || isReinforced(o.parts[j.ib].spec))) continue;
27732
27776
  if (holdsEmbedded(o, j)) continue;
27777
+ if (bondsPlate(o, j)) continue;
27733
27778
  if (near && jointReach(o, j, near) > Math.max(radius, jointReachLimit(o, j))) continue;
27734
27779
  if (blast && fixesTrim(o, j) && jointReach(o, j, blast.point) > Math.max(blast.reach, jointReachLimit(o, j))) continue;
27735
27780
  j.st.hp -= span === void 0 ? amount : Math.min(amount, j.st.maxHp) * Math.min(1, span / Math.max(jointLength(o, j), 1e-6));
@@ -27769,19 +27814,20 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27769
27814
  emit2({ ...base2(o, src), type: "spall", part: p.spec.id, layer: torn.layer.index, point: centre, area: Math.PI * r * r, ...spallNormal(o, p, s[1]) });
27770
27815
  debris2(o, p, torn.layer.mat.hitDebris, toWorld(o.st.position, o.st.rotation, lp), normal, 5, 2, src, torn.layer.mat.id);
27771
27816
  };
27772
- const spallOuter = (o, p, wp, face, normal, radius, src) => {
27817
+ const spallOuter = (o, p, wp, face, normal, radius, src, tearRadius = radius) => {
27773
27818
  var _a;
27774
27819
  if (p.layers.length === 0) return;
27775
27820
  const lp = objLocal(o, wp);
27776
27821
  const torn = tornPatchAt(p.layers, p.rt.spalls, face, lp, radius);
27777
- if (torn) return widenTear(o, p, torn, lp, normal, radius, src);
27822
+ if (torn) return widenTear(o, p, torn, lp, normal, tearRadius, src);
27778
27823
  const layer3 = outerLayer(p.layers, p.rt.spalls, face, lp);
27779
27824
  if (!layer3) return;
27825
+ const patch = layer3.mat.fracture === "tear" ? tearRadius : radius;
27780
27826
  const spalls = (_a = p.rt).spalls ?? (_a.spalls = []);
27781
- spalls.push([layer3.index, face, lp[0], lp[1], lp[2], radius]);
27827
+ spalls.push([layer3.index, face, lp[0], lp[1], lp[2], patch]);
27782
27828
  if (spalls.length > MAX_SPALLS) spalls.shift();
27783
27829
  markDamaged(p);
27784
- emit2({ ...base2(o, src), type: "spall", part: p.spec.id, layer: layer3.index, point: wp, area: Math.PI * radius * radius, ...spallNormal(o, p, face) });
27830
+ emit2({ ...base2(o, src), type: "spall", part: p.spec.id, layer: layer3.index, point: wp, area: Math.PI * patch * patch, ...spallNormal(o, p, face) });
27785
27831
  debris2(o, p, layer3.mat.hitDebris, wp, normal, 5, 2, src, layer3.mat.id);
27786
27832
  setStage(o, p, 1, {}, src);
27787
27833
  };
@@ -27821,7 +27867,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27821
27867
  return first && first.size[u] > size[0] + 1e-6 ? [first.size[u], first.size[v]] : [Math.min(size[0], p.dims[u]), Math.min(size[1], p.dims[v])];
27822
27868
  };
27823
27869
  const FRAGMENT_SHAPE = { shatter: "shard", splinter: "splinter", tear: "scrap" };
27824
- const cellFragments = (o, p, cells, hitW, dir, speed, mass, tag, inner = false, knownHoles) => {
27870
+ const cellFragments = (o, p, cells, hitW, dir, speed, mass, tag, inner = false, knownHoles, drive = CHIP_DRIVE) => {
27825
27871
  const { c, q } = partXf(o, p);
27826
27872
  const holes = knownHoles ?? (p.st.holes.length > 0 ? localHolesOf(p) : []);
27827
27873
  const [u, v] = planeAxes(p.thin);
@@ -27832,16 +27878,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27832
27878
  return cells.map((cell, i) => {
27833
27879
  const cw = toWorld(c, q, cell.center);
27834
27880
  const out = vec.normalize(vec.sub(cw, hitW), [0, 1, 0]);
27835
- const dv = dir ? vec.normalize(vec.madd(out, dir, 0.6)) : out;
27881
+ const dv = dir ? vec.normalize(vec.madd(out, dir, drive)) : out;
27836
27882
  const k = speed * (0.6 + 0.8 * rnd2());
27837
27883
  const marks = marksInBox(cell.center, cell.size, void 0, holes);
27884
+ const size = [cell.size[0], cell.size[1], cell.size[2]];
27885
+ if (laid) for (const a of [u, v]) size[a] = Math.max(size[a] * MIN_UNIT_SHARE, size[a] - MORTAR_JOINT);
27838
27886
  return {
27839
27887
  id: `${p.spec.id}#${tag}${i}`,
27840
27888
  part: p.spec.id,
27841
27889
  material: p.spec.material,
27842
27890
  shape,
27843
27891
  center: cw,
27844
- size: [cell.size[0], cell.size[1], cell.size[2]],
27892
+ size,
27845
27893
  rotation: q,
27846
27894
  velocity: [dv[0] * k, dv[1] * k + 0.5 * rnd2(), dv[2] * k],
27847
27895
  angularVelocity: bornSpin(cell.size, 8, rnd2),
@@ -28092,7 +28140,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28092
28140
  };
28093
28141
  const chipUnits = (o, p, kind, wp, hitEnergy, dir, radius, src) => {
28094
28142
  var _a, _b, _c;
28095
- if (!p.spec.units || !p.staged || chipEnergy <= 0 || p.st.stripped || isLost(p) || (p.st.stage ?? 0) >= 2) return;
28143
+ const bonded = bondedPlate(o, p);
28144
+ if (!bonded && (!p.spec.units || !p.staged) || chipEnergy <= 0 || p.st.stripped || isLost(p) || (p.st.stage ?? 0) >= 2) return;
28096
28145
  const rule = p.mat.hits?.[kind];
28097
28146
  const perKg = rule?.unitJoules ?? chipEnergy;
28098
28147
  const energy = hitEnergy - (rule?.floor ?? 0);
@@ -28166,6 +28215,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28166
28215
  if (Object.values(worn).filter((w) => w === -1).length > wholeBefore) dropUnsupported(o, p, src);
28167
28216
  if (p.spec.reinforcement) exposeRebar(o, p, src);
28168
28217
  for (const cell of out) addBreach(o, p, toWorld(c, q, cell.center), cell.size[u] * cell.size[v], energy, dir, src);
28218
+ if (bonded) settleBonded(o, p, wp, dir, src);
28169
28219
  if (p.structural && !isLost(p)) {
28170
28220
  solveStructure(o);
28171
28221
  collapseCheck(o, src);
@@ -28280,15 +28330,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28280
28330
  if (reinforcement) exposeRebar(o, p, src);
28281
28331
  if (p.structural) solveStructure(o);
28282
28332
  };
28283
- const blastReachOf = (p, energy) => {
28284
- const perKg = p.mat.hits?.blunt?.unitJoules ?? chipEnergy;
28285
- const resistance = Math.max(1, perKg * p.mat.density * p.thickness);
28333
+ const blastReachOf = (o, p, energy) => {
28334
+ const resistance = Math.max(1, ...[p, ...bondCarriers(o, p)].map((q) => (q.mat.hits?.blunt?.unitJoules ?? chipEnergy) * q.mat.density * q.thickness));
28286
28335
  return BREACH_BLAST_REACH * Math.cbrt(Math.max(0, energy) / 1e3) * clamp2(Math.cbrt(BLAST_REFERENCE_RESISTANCE / resistance), 0.3, 2);
28287
28336
  };
28288
- const blastUnits = (o, p, wp, energy, dist2, src) => {
28337
+ const blastUnits = (o, p, wp, energy, dist2, src, from) => {
28289
28338
  var _a;
28290
- if (!p.staged || p.st.stripped || isLost(p) || chipEnergy <= 0) return false;
28291
- const reach2 = blastReachOf(p, energy);
28339
+ if (!p.staged && !bondedPlate(o, p) || p.st.stripped || isLost(p) || chipEnergy <= 0) return false;
28340
+ const reach2 = blastReachOf(o, p, energy);
28292
28341
  if (dist2 >= reach2) return false;
28293
28342
  const radius = Math.sqrt(reach2 * reach2 - dist2 * dist2);
28294
28343
  const [u, v] = planeAxes(p.thin);
@@ -28316,7 +28365,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28316
28365
  }
28317
28366
  }
28318
28367
  if (out.length === 0) return false;
28319
- return knockOutUnits(o, p, wp, energy, out, src);
28368
+ return knockOutUnits(o, p, wp, energy, out, src, from ? awayFromCharge(o, p, from) : void 0, BLAST_DRIVE);
28369
+ };
28370
+ const awayFromCharge = (o, p, charge2) => {
28371
+ const axis2 = [0, 0, 0];
28372
+ axis2[p.thin] = toLocal(p.pos, p.q, objLocal(o, charge2))[p.thin] >= 0 ? -1 : 1;
28373
+ return rotateVec(partXf(o, p).q, axis2);
28320
28374
  };
28321
28375
  const wedgedUnder = (o, p, loose) => {
28322
28376
  if (loose.length === 0) return loose;
@@ -28408,7 +28462,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28408
28462
  for (const i of out) worn[i] = -1;
28409
28463
  return knockOutUnits(o, p, point, energy, out, src);
28410
28464
  };
28411
- const knockOutUnits = (o, p, wp, energy, out, src, d) => {
28465
+ const knockOutUnits = (o, p, wp, energy, out, src, d, drive = CHIP_DRIVE) => {
28412
28466
  var _a, _b;
28413
28467
  const [u, v] = planeAxes(p.thin);
28414
28468
  const op = p.st.opening ? toLocal(p.pos, p.q, p.st.opening.center) : null;
@@ -28418,7 +28472,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28418
28472
  out = out.filter((i) => !castHere.has(i));
28419
28473
  if (out.length === 0) return false;
28420
28474
  for (const i of out) worn[i] = -1;
28421
- const cast = p.spec.units?.mortar === p.spec.material;
28475
+ const bonded = bondedPlate(o, p);
28476
+ const cast = p.spec.units?.mortar === p.spec.material || bonded;
28422
28477
  const loose = cast ? [] : wedgedUnder(o, p, unsupportedCells(grid, p.thin, p.dims, (i) => worn[i] !== -1 && !(op && p.st.opening && Math.hypot(grid[i].center[u] - op[u], grid[i].center[v] - op[v]) <= p.st.opening.radius))).filter((i) => !castHere.has(i));
28423
28478
  for (const i of loose) worn[i] = -1;
28424
28479
  const blown = out.map((i) => grid[i]), fallen = loose.map((i) => grid[i]);
@@ -28431,7 +28486,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28431
28486
  const tag = `x${chipped.length}_`;
28432
28487
  const holes = localHolesOf(p);
28433
28488
  const fragments = [
28434
- ...cellFragments(o, p, clumpUnits(blown, p.thin, unitSpan(p), unitClumps), wp, null, speed, blownMass, tag, true, holes),
28489
+ ...cellFragments(o, p, clumpUnits(blown, p.thin, unitSpan(p), unitClumps), wp, d ?? null, speed, blownMass, tag, true, holes, drive),
28435
28490
  ...fallen.length > 0 ? cellFragments(o, p, clumpUnits(fallen, p.thin, unitSpan(p), fallenClumps), wp, null, 0.3, fallenMass, `${tag}f`, true, holes) : [],
28436
28491
  ...plasterFlakes(o, p, blown, wp, speed, `${tag}p`)
28437
28492
  ];
@@ -28456,6 +28511,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28456
28511
  debris2(o, p, p.mat.breakDebris, center, vec.normalize(vec.sub(center, wp), [0, 1, 0]), 14, 3, src);
28457
28512
  const cut = wornLocally(p) && cutBandsGone(o, p, cells, d ?? vec.normalize(vec.sub(partXf(o, p).c, wp), [1, 0, 0]), src);
28458
28513
  if (p.spec.reinforcement && !cut) exposeRebar(o, p, src);
28514
+ if (bonded) settleBonded(o, p, wp, d ?? null, src);
28459
28515
  if (p.structural && !isLost(p)) {
28460
28516
  solveStructure(o);
28461
28517
  collapseCheck(o, src);
@@ -28798,6 +28854,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28798
28854
  if (chained && p.st.hp <= 0 && p.rt.chainDue === void 0) p.st.hp = Math.min(prev, 1);
28799
28855
  if (p.st.hp <= 0 && p.mat.fracture === "none" && !p.spec.explodes) p.st.hp = Math.min(prev, 1);
28800
28856
  if (p.st.hp <= 0 && type === "ballistic" && wornLocally(p)) p.st.hp = Math.min(prev, 1);
28857
+ if (p.st.hp <= 0 && type !== "fire" && type !== "heat" && bondedPlate(o, p)) p.st.hp = Math.min(prev, 1);
28801
28858
  const done = prev - p.st.hp;
28802
28859
  if (done > 0) emit2({ ...base2(o, src), type: "damage", part: p.spec.id, amount: done, hp: Math.max(0, p.st.hp), damageType: type });
28803
28860
  if (p.st.hp <= 0) failPart(o, p, origin, dir, fragEnergy * weight, cap, src);
@@ -28906,7 +28963,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28906
28963
  const dmg2 = applyDamage(o, p, E * DMG_PER_J * scale * 0.2, "ballistic", entry2, d, E * 0.1, 12, src, weight);
28907
28964
  return { penetrated: false, exitEnergy: 0, damage: dmg2 };
28908
28965
  }
28909
- if (p.layers.length > 0) spallOuter(o, p, entry2, face, n, Math.max(0.03, caliber / 1e3 * 4), src);
28966
+ if (p.layers.length > 0) spallOuter(o, p, entry2, face, n, Math.max(0.03, caliber / 1e3 * 4), src, caliber / 1e3 * TEAR_CALIBERS);
28910
28967
  else if (mat.hits?.ballistic?.crater) crater(o, p, entry2, n, clamp2(0.02 + Math.sqrt(E) * 15e-4, 0.02, 0.15), src);
28911
28968
  const brittle = mat.ductility < 0.3;
28912
28969
  const ratio = Ep / Math.max(thr, 1e-6);
@@ -28919,7 +28976,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28919
28976
  exitPoint = vec.madd(entry2, d, exitDist);
28920
28977
  const hole = addHole(o, p, entry2, n, holeWidth, true, exitPoint, src);
28921
28978
  shellShare = wearsShell(p, hole.diameter * 2);
28922
- if (p.layers.length > 0) spallOuter(o, p, exitPoint, -face, vec.scale(n, -1), Math.max(0.03, caliber / 1e3 * 4), src);
28979
+ if (p.layers.length > 0) spallOuter(o, p, exitPoint, -face, vec.scale(n, -1), Math.max(0.03, caliber / 1e3 * 4), src, caliber / 1e3 * TEAR_CALIBERS);
28923
28980
  addBreach(o, p, entry2, Math.PI * (hole.diameter / 2) * (hole.diameter / 2), E, d, src);
28924
28981
  if (mat.ductility >= 0.5 && p.thickness <= THIN_SHEET_DISHING) addDent(o, p, entry2, n, Math.max(caliber * 3 / 1e3, 0.012), clamp2(E * 2e-5, 1e-3, 0.03), src);
28925
28982
  if (brittle && mat.fracture === "shatter") addCrack(o, p, entry2, n, crackLen, src);
@@ -29091,13 +29148,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29091
29148
  const breachReach = BREACH_BLAST_REACH * Math.cbrt(Math.max(0, energy) / 1e3);
29092
29149
  const caged2 = Boolean(p.spec.reinforcement && p.spec.units);
29093
29150
  const member = caged2 && (isMember(p.dims, p.spec.structure?.role) || dist2 > MEMBER_CUT_REACH * breachReach);
29094
- const dealt = member ? applyDamage(o, p, Math.min(amount, Math.max(0, p.st.hp - p.st.maxHp * FAR_MEMBER_HP_FLOOR)), "explosive", null, null, Ein * 0.3, 40, src) : applyDamage(o, p, amount, "explosive", point, null, Ein * 0.3, 40, src);
29151
+ const bonded = bondedPlate(o, p);
29152
+ const dealt = bonded ? applyDamage(o, p, Math.min(amount, Math.max(0, p.st.hp - 1)), "explosive", null, null, Ein * 0.3, 40, src) : member ? applyDamage(o, p, Math.min(amount, Math.max(0, p.st.hp - p.st.maxHp * FAR_MEMBER_HP_FLOOR)), "explosive", null, null, Ein * 0.3, 40, src) : applyDamage(o, p, amount, "explosive", point, null, Ein * 0.3, 40, src);
29095
29153
  res.damage += dealt;
29096
29154
  if (p.bend && flexure.enabled) bendByBlast(o, p, point, energy, radius, reach2, src);
29097
29155
  if (p.spec.units && p.spec.units.mortar !== p.spec.material) {
29098
29156
  blastPanel(o, p, point, energy, src);
29099
- if (!isLost(p)) blastUnits(o, p, wp, energy, dist2, src);
29100
- } else if (member) blastUnits(o, p, wp, energy, dist2, src);
29157
+ if (!isLost(p)) blastUnits(o, p, wp, energy, dist2, src, point);
29158
+ } else if (member || bonded) blastUnits(o, p, wp, energy, dist2, src, point);
29101
29159
  else if (dist2 <= breachReach) addBreach(o, p, wp, breachAreaOf(p, dealt, true), Ein, null, src);
29102
29160
  return reach2;
29103
29161
  };
@@ -30635,6 +30693,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30635
30693
  }).events;
30636
30694
  },
30637
30695
  state: (id) => objects.get(id)?.st ?? impls.get(id)?.impl.state() ?? null,
30696
+ layers: (id, partId) => objects.get(id)?.byId.get(partId)?.spec.layers ?? [],
30638
30697
  anchoredParts: (id) => objects.get(id)?.parts.filter((p) => p.anchored && !isLost(p)).map((p) => p.spec.id) ?? [],
30639
30698
  fixedInPlace: (id) => {
30640
30699
  const o = objects.get(id);
@@ -31186,7 +31245,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
31186
31245
  var MIN_PILLAR_AREA = 0.036;
31187
31246
  var BEAM_DEPTH_RATIO = 10;
31188
31247
  var PLASTER_PER_FACE = 0.015;
31189
- var MORTAR_JOINT = 0.01;
31248
+ var MORTAR_JOINT2 = 0.01;
31190
31249
  var SECTION_STEP = 0.05;
31191
31250
  var ceilTo = (value, step) => Math.ceil(value / step - 1e-9) * step;
31192
31251
  var round22 = (value) => Math.round(value * 100) / 100;
@@ -31200,7 +31259,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
31200
31259
  function coursingOf(unitId, assemblyUnits) {
31201
31260
  if (unitId !== void 0) {
31202
31261
  const unit = getMasonryUnit(unitId);
31203
- return { courseHeight: round22(unit.height + MORTAR_JOINT), unitLength: round22(unit.length + MORTAR_JOINT) };
31262
+ return { courseHeight: round22(unit.height + MORTAR_JOINT2), unitLength: round22(unit.length + MORTAR_JOINT2) };
31204
31263
  }
31205
31264
  return assemblyUnits ? { courseHeight: assemblyUnits.size[1], unitLength: assemblyUnits.size[0] } : void 0;
31206
31265
  }
@@ -56480,7 +56539,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56480
56539
  }
56481
56540
  var residentialTower = residentialTowerTemplate();
56482
56541
 
56483
- // ../game-floorplan-three/dist/chunk-XI3CKQAV.js
56542
+ // ../game-floorplan-three/dist/chunk-Y7TCDFDL.js
56484
56543
  var __defProp4 = Object.defineProperty;
56485
56544
  var __defNormalProp2 = (obj, key2, value) => key2 in obj ? __defProp4(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
56486
56545
  var __publicField2 = (obj, key2, value) => __defNormalProp2(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
@@ -66192,6 +66251,25 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
66192
66251
  }
66193
66252
  return [...groups.values()];
66194
66253
  };
66254
+ function subtract2(boxes, cuts) {
66255
+ let out = [...boxes];
66256
+ for (const k of cuts) {
66257
+ const next = [];
66258
+ for (const b of out) {
66259
+ if (k.a >= b.b - EPSILON22 || k.b <= b.a + EPSILON22 || k.y0 >= b.y1 - EPSILON22 || k.y1 <= b.y0 + EPSILON22) {
66260
+ next.push(b);
66261
+ continue;
66262
+ }
66263
+ const y0 = Math.max(b.y0, k.y0), y1 = Math.min(b.y1, k.y1);
66264
+ if (y0 - b.y0 > EPSILON22) next.push({ a: b.a, b: b.b, y0: b.y0, y1: y0 });
66265
+ if (b.y1 - y1 > EPSILON22) next.push({ a: b.a, b: b.b, y0: y1, y1: b.y1 });
66266
+ if (k.a - b.a > EPSILON22) next.push({ a: b.a, b: k.a, y0, y1 });
66267
+ if (b.b - k.b > EPSILON22) next.push({ a: k.b, b: b.b, y0, y1 });
66268
+ }
66269
+ out = next;
66270
+ }
66271
+ return out;
66272
+ }
66195
66273
  function mergeSpans(spans, share = JOINT_SHARE) {
66196
66274
  const runs = [];
66197
66275
  const unitLengths = /* @__PURE__ */ new Map();
@@ -66242,7 +66320,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
66242
66320
  const point = new THREE.Vector3();
66243
66321
  const out = [];
66244
66322
  for (const part of parts2) {
66245
- const boxes = mergeSpans(part.spans);
66323
+ const boxes = part.gone?.length ? subtract2(mergeSpans(part.spans), part.gone) : mergeSpans(part.spans);
66246
66324
  for (const s of line.open ? mergeSpans(carve(boxes, line.open), 0) : boxes) {
66247
66325
  const along2 = line.start + (s.a + s.b) / 2;
66248
66326
  point.set(line.alongU ? along2 : part.mid, (s.y0 + s.y1) / 2, line.alongU ? part.mid : along2).applyMatrix4(toMesh);
@@ -66748,11 +66826,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
66748
66826
  function publishStanding(view) {
66749
66827
  if (!view.saved) return;
66750
66828
  const { mask } = view;
66829
+ const along2 = (p) => (mask.alongU ? p[0] : p[2]) - mask.start;
66751
66830
  const parts2 = view.parts.map((id) => {
66752
66831
  const part = structure.byId.get(id);
66753
66832
  const thick = mask.alongU ? part.aabb[3] - part.aabb[1] : part.aabb[2] - part.aabb[0];
66754
66833
  const mid = mask.alongU ? (part.aabb[1] + part.aabb[3]) / 2 : (part.aabb[0] + part.aabb[2]) / 2;
66755
- return { spans: view.kept.get(id) ?? [], thick, mid };
66834
+ const gone = (view.chips.get(id) ?? []).map((k) => ({ a: along2(k.center) - k.along, b: along2(k.center) + k.along, y0: k.center[1] - k.up, y1: k.center[1] + k.up }));
66835
+ return { spans: view.kept.get(id) ?? [], gone, thick, mid };
66756
66836
  });
66757
66837
  const line = { alongU: mask.alongU, start: mask.start, open: view.core };
66758
66838
  view.items.forEach((it, k) => publishSolids(it.mesh, it.v0, it.v1, k === 0 ? standingSolids(THREE, house, it.mesh, line, parts2) : []));
@@ -93771,6 +93851,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
93771
93851
  y: 0,
93772
93852
  z: 0,
93773
93853
  r: 0.6,
93854
+ h: 0,
93774
93855
  r0: 0.6,
93775
93856
  grow: 0,
93776
93857
  life: 6,
@@ -93796,6 +93877,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
93796
93877
  fire.y = init.y ?? 0;
93797
93878
  fire.z = init.z ?? 0;
93798
93879
  fire.r = init.r ?? 0.6;
93880
+ fire.h = init.h ?? 0;
93799
93881
  fire.r0 = init.startRadius ?? fire.r;
93800
93882
  fire.grow = init.grow ?? 0;
93801
93883
  fire.life = init.life ?? 6;
@@ -93820,19 +93902,23 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
93820
93902
  core.trace?.fire?.(fire);
93821
93903
  return fire;
93822
93904
  }
93905
+ var FLAMES_PER_HEIGHT = 1.5;
93906
+ var SMOKE_PER_HEIGHT = 2;
93823
93907
  function positionOf(follow) {
93824
93908
  return "position" in follow ? follow.position : follow;
93825
93909
  }
93910
+ var heightOf = (fire) => fire.h > 0 ? fire.rng.next() * fire.h : 0;
93911
+ var isBody = (follow) => "radius" in follow && "height" in follow;
93826
93912
  function emitFlames(core, fire, radius, dt) {
93827
93913
  const random = fire.rng;
93828
- fire.acc += dt * fire.rate * (0.5 + radius * 0.9) * fire.fade * core.clock.lod;
93914
+ fire.acc += dt * fire.rate * (0.5 + radius * 0.9) * (1 + fire.h * FLAMES_PER_HEIGHT) * fire.fade * core.clock.lod;
93829
93915
  while (fire.acc >= 1) {
93830
93916
  fire.acc -= 1;
93831
93917
  const angle = random.next() * Math.PI * 2;
93832
93918
  const distance4 = Math.sqrt(random.next()) * radius;
93833
93919
  addPuff(core, random, {
93834
93920
  x: fire.x + Math.cos(angle) * distance4,
93835
- y: fire.y + 0.05,
93921
+ y: fire.y + 0.05 + heightOf(fire),
93836
93922
  z: fire.z + Math.sin(angle) * distance4,
93837
93923
  vx: random.between(-0.2, 0.2),
93838
93924
  vy: random.between(0.6, 1.4),
@@ -93854,12 +93940,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
93854
93940
  }
93855
93941
  function emitSmoke(core, fire, radius, dt) {
93856
93942
  const random = fire.rng;
93857
- fire.smokeAcc += dt * fire.smoke * (1 + radius * 0.8) * fire.fade * core.clock.lod;
93943
+ fire.smokeAcc += dt * fire.smoke * (1 + radius * 0.8) * (1 + fire.h * SMOKE_PER_HEIGHT) * fire.fade * core.clock.lod;
93858
93944
  while (fire.smokeAcc >= 1 && core.layers.smoke) {
93859
93945
  fire.smokeAcc -= 1;
93860
93946
  addPuff(core, random, {
93861
93947
  x: fire.x + random.between(-radius, radius) * 0.5,
93862
- y: fire.y + 0.6 + radius * 0.3,
93948
+ y: fire.y + fire.h + 0.6 + radius * 0.3,
93863
93949
  z: fire.z + random.between(-radius, radius) * 0.5,
93864
93950
  vy: random.between(0.8, 1.5),
93865
93951
  s0: 0.25,
@@ -93881,7 +93967,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
93881
93967
  if (!(random.next() < dt * 6 * fire.fade && core.layers.shrapnel)) return;
93882
93968
  addSpark(core, {
93883
93969
  x: fire.x + random.between(-radius, radius) * 0.6,
93884
- y: fire.y + 0.4,
93970
+ y: fire.y + 0.4 + heightOf(fire),
93885
93971
  z: fire.z + random.between(-radius, radius) * 0.6,
93886
93972
  vx: random.between(-0.4, 0.4),
93887
93973
  vy: random.between(1.5, 3.2),
@@ -93905,6 +93991,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
93905
93991
  fire.x = point.x + fire.fx;
93906
93992
  fire.y = point.y + fire.fy;
93907
93993
  fire.z = point.z + fire.fz;
93994
+ if (isBody(fire.follow)) {
93995
+ fire.r = fire.follow.radius;
93996
+ fire.h = fire.follow.height;
93997
+ }
93908
93998
  }
93909
93999
  const radius = fire.grow ? lerp2(fire.r0, fire.r, Math.min(1, fire.t / fire.grow)) : fire.r;
93910
94000
  fire.fade = fire.t < fire.life - 1.5 ? Math.min(1, fire.t * 3) : Math.max(0, (fire.life - fire.t) / 1.5);
@@ -99784,10 +99874,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
99784
99874
  },
99785
99875
  fire(fireOptions) {
99786
99876
  const handle = ++handles.next;
99787
- const { point, offset, seed, radius, smokeColor, ...rest2 } = fireOptions;
99877
+ const { point, offset, seed, radius, height, smokeColor, ...rest2 } = fireOptions;
99788
99878
  addFire(core, streamOf(seed), {
99789
99879
  ...rest2,
99790
99880
  r: radius,
99881
+ ...height !== void 0 ? { h: height } : {},
99791
99882
  x: point[0],
99792
99883
  y: point[1],
99793
99884
  z: point[2],
@@ -99922,7 +100013,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
99922
100013
  }
99923
100014
  var DEGREES = 180 / Math.PI;
99924
100015
 
99925
- // ../game-vfx-three/dist/chunk-ACY6ZQC5.js
100016
+ // ../game-vfx-three/dist/chunk-BLUUVMCE.js
99926
100017
  var GLOW_VERTEX = `attribute vec4 aP;attribute vec4 aC;varying vec2 vU;varying vec4 vC;
99927
100018
  void main(){vec3 R=vec3(viewMatrix[0][0],viewMatrix[1][0],viewMatrix[2][0]);vec3 Up=vec3(viewMatrix[0][1],viewMatrix[1][1],viewMatrix[2][1]);
99928
100019
  vec3 wp=aP.xyz+(R*position.x+Up*position.y)*aP.w;vU=position.xy;vC=aC;gl_Position=projectionMatrix*viewMatrix*vec4(wp,1.);}`;
@@ -99938,6 +100029,59 @@ float vn(vec3 x){vec3 i=floor(x),f=fract(x);f=f*f*(3.-2.*f);
99938
100029
  `;
99939
100030
  var PUFF_VERTEX = `${GL_NOISE}
99940
100031
  attribute vec4 aP;attribute vec4 aD;attribute vec3 aC;
100032
+ varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;
100033
+ void main(){
100034
+ vec3 p=position;
100035
+ float s=aD.z;
100036
+ float n=vn(p*1.6+vec3(s*11.0,s*7.0,s*3.0));
100037
+ p*=0.78+0.5*n;
100038
+ float a=s*6.2831;float c=cos(a),si=sin(a);p.xz=mat2(c,-si,si,c)*p.xz;
100039
+ vL=p;
100040
+ vec3 wp=aP.xyz+p*aP.w;
100041
+ vWP=wp;vD=aD;vC=aC;
100042
+ gl_Position=projectionMatrix*viewMatrix*vec4(wp,1.0);
100043
+ }`;
100044
+ var PUFF_FRAGMENT = `${GL_NOISE}
100045
+ uniform vec3 uLight;uniform vec3 uSky;uniform vec3 uGround;uniform vec3 uGlowPos;uniform vec3 uGlowCol;uniform float uGlowI;
100046
+ varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;
100047
+ vec3 L(vec3 c){return pow(c,vec3(2.2));}
100048
+ vec3 ramp(float h){
100049
+ vec3 c0=L(vec3(.36,.07,.03)),c1=L(vec3(.76,.21,.1)),c2=L(vec3(1.,.54,.16)),c3=L(vec3(1.,.83,.42)),c4=L(vec3(1.,.96,.84));
100050
+ if(h<.25)return mix(c0,c1,h/.25);
100051
+ if(h<.5)return mix(c1,c2,(h-.25)/.25);
100052
+ if(h<.8)return mix(c2,c3,(h-.5)/.3);
100053
+ return mix(c3,c4,clamp((h-.8)/.4,0.,1.));
100054
+ }
100055
+ void main(){
100056
+ vec3 N=normalize(cross(dFdx(vWP),dFdy(vWP)));
100057
+ float age=vD.x,heat=vD.y,kind=vD.w;
100058
+ float n=vn(vL*2.4+vD.z*13.0);
100059
+ float diss=smoothstep(.5,1.,age);
100060
+ if(n<diss*1.08-.04)discard;
100061
+ float lam=max(dot(N,uLight),0.);
100062
+ float band=lam>.55?1.:lam>.15?.68:.42;
100063
+ // soot: a dark smoke still scatters some light, so it never goes flat black, and its rim takes the sky so its volume reads (only the dark puffs; the rest as the Lab)
100064
+ float dark=1.-smoothstep(.02,.12,dot(vC,vec3(.2126,.7152,.0722)));
100065
+ vec3 alb=max(vC,vec3(.055)*dark);
100066
+ vec3 col=alb*(vec3(.5,.56,.7)*band*1.05+vec3(.2,.19,.18)+uGround*(.4-.4*N.y));
100067
+ float rim=pow(1.-clamp(abs(dot(N,normalize(cameraPosition-vWP))),0.,1.),2.);
100068
+ col+=dark*rim*(uSky*.9+alb);
100069
+ vec3 tg=uGlowPos-vWP;float dg=length(tg)+.001;
100070
+ float gi=uGlowI/(1.+dg*dg*.05)*(.3+.7*max(dot(N,tg/dg),0.));
100071
+ col+=uGlowCol*gi*alb*1.6;
100072
+ float h=heat*(.72+.56*n)+heat*(-N.y)*.18;
100073
+ if(h>.05){
100074
+ float hq=floor(h*5.+.5)/5.;
100075
+ vec3 fc=ramp(clamp(hq,0.,1.2))*(1.1+3.1*hq);
100076
+ col=mix(col,fc,smoothstep(.04,.2,h));
100077
+ }
100078
+ if(kind>2.5&&kind<3.5){col+=vec3(.02,.025,.03);}
100079
+ gl_FragColor=vec4(col,1.);
100080
+ #include <tonemapping_fragment>
100081
+ #include <colorspace_fragment>
100082
+ }`;
100083
+ var SOFT_PUFF_VERTEX = `${GL_NOISE}
100084
+ attribute vec4 aP;attribute vec4 aD;attribute vec3 aC;
99941
100085
  varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;varying vec3 vN;
99942
100086
  void main(){
99943
100087
  vec3 p=position;
@@ -99951,7 +100095,7 @@ void main(){
99951
100095
  vWP=wp;vD=aD;vC=aC;
99952
100096
  gl_Position=projectionMatrix*viewMatrix*vec4(wp,1.0);
99953
100097
  }`;
99954
- var PUFF_FRAGMENT = `${GL_NOISE}
100098
+ var SOFT_PUFF_FRAGMENT = `${GL_NOISE}
99955
100099
  uniform vec3 uLight;uniform vec3 uSky;uniform vec3 uGround;uniform vec3 uGlowPos;uniform vec3 uGlowCol;uniform float uGlowI;
99956
100100
  varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;varying vec3 vN;
99957
100101
  vec3 L(vec3 c){return pow(c,vec3(2.2));}
@@ -100026,11 +100170,11 @@ void main(){
100026
100170
  function dynamic(THREE, array, size) {
100027
100171
  return new THREE.InstancedBufferAttribute(array, size).setUsage(THREE.DynamicDrawUsage);
100028
100172
  }
100029
- var PUFF_DETAIL = 2;
100030
- function createPuffLayer(THREE, pool, uniforms) {
100173
+ var PUFF_DETAIL = { faceted: 1, soft: 2 };
100174
+ function createPuffLayer(THREE, pool, uniforms, style = "faceted") {
100031
100175
  const capacity = pool.capacity;
100032
100176
  const geometry = new THREE.InstancedBufferGeometry();
100033
- geometry.setAttribute("position", new THREE.IcosahedronGeometry(1, PUFF_DETAIL).getAttribute("position"));
100177
+ geometry.setAttribute("position", new THREE.IcosahedronGeometry(1, PUFF_DETAIL[style]).getAttribute("position"));
100034
100178
  const a = new Float32Array(capacity * 4);
100035
100179
  const d = new Float32Array(capacity * 4);
100036
100180
  const c = new Float32Array(capacity * 3);
@@ -100039,7 +100183,7 @@ void main(){
100039
100183
  geometry.setAttribute("aD", attributes[1]);
100040
100184
  geometry.setAttribute("aC", attributes[2]);
100041
100185
  geometry.instanceCount = 0;
100042
- const material = new THREE.ShaderMaterial({ uniforms, vertexShader: PUFF_VERTEX, fragmentShader: PUFF_FRAGMENT, transparent: true, depthWrite: false });
100186
+ const material = style === "faceted" ? new THREE.ShaderMaterial({ uniforms, vertexShader: PUFF_VERTEX, fragmentShader: PUFF_FRAGMENT }) : new THREE.ShaderMaterial({ uniforms, vertexShader: SOFT_PUFF_VERTEX, fragmentShader: SOFT_PUFF_FRAGMENT, transparent: true, depthWrite: false });
100043
100187
  const mesh3 = new THREE.Mesh(geometry, material);
100044
100188
  mesh3.name = "vfx-puffs";
100045
100189
  mesh3.frustumCulled = false;
@@ -101361,7 +101505,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
101361
101505
  uGlowI: { value: 0 },
101362
101506
  uTime: { value: 0 }
101363
101507
  };
101364
- const puffs = createPuffLayer(THREE, pools.puffs, uniforms);
101508
+ const puffs = createPuffLayer(THREE, pools.puffs, uniforms, options.puffStyle ?? "faceted");
101365
101509
  const sparks2 = createSparkLayer(THREE, pools.sparks);
101366
101510
  const glows = createGlowLayer(THREE, pools.glows);
101367
101511
  const rockGeometry = new THREE.DodecahedronGeometry(0.5, 0);