@adatechnology/game-weapons-three 0.29.7 → 0.29.8

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.
@@ -20506,7 +20506,7 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
20506
20506
  if (isOpen) for (const s of [-1, 1]) K.box("fabric", s * (w / 2 - pw * 0.25), y + h * 0.4, 0.04, pw * 0.5, 0.05, 0.02, shade(color2, 0.7));
20507
20507
  };
20508
20508
  B.blinds = (M, a) => {
20509
- const K = kit(M, a), { w, h } = K.dim("blinds"), y = M.y || 1, retract = M.retracted != null ? M.retracted : 0.15, isWood = M.variant === "wood", color2 = isWood ? K.wood(10123858) : K.color("wall_living", 15262420), mat = isWood ? "wood" : "plain", yb = y + h * retract, n = Math.floor((y + h - yb) / 0.055);
20509
+ const K = kit(M, a), { w, h } = K.dim("blinds"), y = M.y || 1, retract = M.retracted != null ? M.retracted : 0.15, isWood2 = M.variant === "wood", color2 = isWood2 ? K.wood(10123858) : K.color("wall_living", 15262420), mat = isWood2 ? "wood" : "plain", yb = y + h * retract, n = Math.floor((y + h - yb) / 0.055);
20510
20510
  K.box("plain", 0, y + h - 0.05, 0, w, 0.05, 0.06, 14473424);
20511
20511
  for (let i = 0; i < n; i++) K.box(mat, 0, y + h - 0.06 - (i + 1) * 0.055, 0, w - 0.05, 0.01, 0.035, color2, 0, 0.3);
20512
20512
  for (const s of [-1, 1]) K.box("plain", s * (w / 2 - 0.05), yb, 0.02, 8e-3, y + h - 0.05 - yb, 8e-3, 12104876);
@@ -23554,6 +23554,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23554
23554
  tension: {
23555
23555
  elasticGPa: 200,
23556
23556
  ultimateMPa: 400
23557
+ },
23558
+ elastic: {
23559
+ alongGPa: 200,
23560
+ shearGPa: 77
23557
23561
  }
23558
23562
  },
23559
23563
  {
@@ -23592,7 +23596,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23592
23596
  elasticGPa: 200,
23593
23597
  absorbed: 0.2
23594
23598
  },
23595
- failureMPa: 1400
23599
+ failureMPa: 1400,
23600
+ elastic: {
23601
+ alongGPa: 200,
23602
+ shearGPa: 77
23603
+ }
23596
23604
  },
23597
23605
  {
23598
23606
  id: "cast_iron",
@@ -23663,6 +23671,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23663
23671
  tension: {
23664
23672
  elasticGPa: 69,
23665
23673
  ultimateMPa: 170
23674
+ },
23675
+ elastic: {
23676
+ alongGPa: 69,
23677
+ shearGPa: 26
23666
23678
  }
23667
23679
  },
23668
23680
  {
@@ -23745,7 +23757,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23745
23757
  tearJoules: 60
23746
23758
  }
23747
23759
  },
23748
- failureMPa: 40
23760
+ failureMPa: 40,
23761
+ elastic: {
23762
+ alongGPa: 12.3,
23763
+ acrossGPa: 1.17,
23764
+ shearGPa: 1
23765
+ }
23749
23766
  },
23750
23767
  {
23751
23768
  id: "wood_hard",
@@ -23796,7 +23813,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23796
23813
  elasticGPa: 12,
23797
23814
  absorbed: 0.3
23798
23815
  },
23799
- failureMPa: 80
23816
+ failureMPa: 80,
23817
+ elastic: {
23818
+ alongGPa: 12,
23819
+ acrossGPa: 1.42,
23820
+ shearGPa: 1.02
23821
+ }
23800
23822
  },
23801
23823
  {
23802
23824
  id: "plywood",
@@ -23928,7 +23950,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23928
23950
  "brittle"
23929
23951
  ],
23930
23952
  compressive: 1e5,
23931
- failureMPa: 45
23953
+ failureMPa: 45,
23954
+ elastic: {
23955
+ alongGPa: 70,
23956
+ shearGPa: 29
23957
+ }
23932
23958
  },
23933
23959
  {
23934
23960
  id: "tempered_glass",
@@ -23963,7 +23989,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23963
23989
  damageScale: {
23964
23990
  shelter: 3
23965
23991
  },
23966
- failureMPa: 120
23992
+ failureMPa: 120,
23993
+ elastic: {
23994
+ alongGPa: 70,
23995
+ shearGPa: 29
23996
+ }
23967
23997
  },
23968
23998
  {
23969
23999
  id: "ceramic",
@@ -25019,6 +25049,828 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
25019
25049
  if (ductility >= 0.3) return 1;
25020
25050
  return (1 + 4 * (0.3 - ductility) / 0.3) * Math.min(25, Math.max(1, (0.02 / Math.max(thickness, 1e-4)) ** 2));
25021
25051
  };
25052
+ var EPS22 = 1e-9;
25053
+ var rotateVecInto = (q, v, out) => {
25054
+ const qx = q[0], qy = q[1], qz = q[2], qw = q[3];
25055
+ const tx = 2 * (qy * v[2] - qz * v[1]);
25056
+ const ty = 2 * (qz * v[0] - qx * v[2]);
25057
+ const tz = 2 * (qx * v[1] - qy * v[0]);
25058
+ const x = v[0] + qw * tx + (qy * tz - qz * ty);
25059
+ const y = v[1] + qw * ty + (qz * tx - qx * tz);
25060
+ const z = v[2] + qw * tz + (qx * ty - qy * tx);
25061
+ out[0] = x;
25062
+ out[1] = y;
25063
+ out[2] = z;
25064
+ return out;
25065
+ };
25066
+ var normalizeInto = (x, y, z, out, fx, fy, fz) => {
25067
+ const l = Math.sqrt(x * x + y * y + z * z);
25068
+ if (l < EPS22) {
25069
+ out[0] = fx;
25070
+ out[1] = fy;
25071
+ out[2] = fz;
25072
+ return;
25073
+ }
25074
+ out[0] = x / l;
25075
+ out[1] = y / l;
25076
+ out[2] = z / l;
25077
+ };
25078
+ var boxInto = (size, o, d, out) => {
25079
+ let tmin = -Infinity, tmax = Infinity;
25080
+ let a0 = 0, s0 = 1;
25081
+ for (let i = 0; i < 3; i++) {
25082
+ const h = size[i] / 2;
25083
+ if (Math.abs(d[i]) < EPS22) {
25084
+ if (Math.abs(o[i]) > h) return false;
25085
+ continue;
25086
+ }
25087
+ let ta = (-h - o[i]) / d[i];
25088
+ let tb = (h - o[i]) / d[i];
25089
+ let sa = -1;
25090
+ if (ta > tb) {
25091
+ const t = ta;
25092
+ ta = tb;
25093
+ tb = t;
25094
+ sa = 1;
25095
+ }
25096
+ if (ta > tmin) {
25097
+ tmin = ta;
25098
+ a0 = i;
25099
+ s0 = sa;
25100
+ }
25101
+ if (tb < tmax) tmax = tb;
25102
+ if (tmin > tmax) return false;
25103
+ }
25104
+ if (tmax < 0 || !Number.isFinite(tmin) || !Number.isFinite(tmax)) return false;
25105
+ out.t0 = tmin;
25106
+ out.t1 = tmax;
25107
+ out.n0[0] = 0;
25108
+ out.n0[1] = 0;
25109
+ out.n0[2] = 0;
25110
+ out.n0[a0] = s0;
25111
+ return true;
25112
+ };
25113
+ var sphereInto = (radius, o, d, out) => {
25114
+ const b = o[0] * d[0] + o[1] * d[1] + o[2] * d[2];
25115
+ const a = d[0] * d[0] + d[1] * d[1] + d[2] * d[2];
25116
+ const c = o[0] * o[0] + o[1] * o[1] + o[2] * o[2] - radius * radius;
25117
+ const disc = b * b - a * c;
25118
+ if (disc < 0) return false;
25119
+ const sq = Math.sqrt(disc);
25120
+ const t0 = (-b - sq) / a;
25121
+ const t1 = (-b + sq) / a;
25122
+ if (t1 < 0) return false;
25123
+ out.t0 = t0;
25124
+ out.t1 = t1;
25125
+ normalizeInto(o[0] + d[0] * t0, o[1] + d[1] * t0, o[2] + d[2] * t0, out.n0, 0, 1, 0);
25126
+ return true;
25127
+ };
25128
+ var cylinderInto = (radius, height, o, d, out) => {
25129
+ const hh = height / 2;
25130
+ const a = d[0] * d[0] + d[2] * d[2];
25131
+ const c = o[0] * o[0] + o[2] * o[2] - radius * radius;
25132
+ let tA = -Infinity, tB = Infinity;
25133
+ if (a > EPS22) {
25134
+ const b = o[0] * d[0] + o[2] * d[2];
25135
+ const disc = b * b - a * c;
25136
+ if (disc < 0) return false;
25137
+ const sq = Math.sqrt(disc);
25138
+ tA = (-b - sq) / a;
25139
+ tB = (-b + sq) / a;
25140
+ } else if (c > 0) return false;
25141
+ let yA = -Infinity, yB = Infinity;
25142
+ if (Math.abs(d[1]) > EPS22) {
25143
+ yA = (-hh - o[1]) / d[1];
25144
+ yB = (hh - o[1]) / d[1];
25145
+ if (yA > yB) {
25146
+ const t = yA;
25147
+ yA = yB;
25148
+ yB = t;
25149
+ }
25150
+ } else if (Math.abs(o[1]) > hh) return false;
25151
+ const t0 = Math.max(tA, yA);
25152
+ const t1 = Math.min(tB, yB);
25153
+ if (t0 > t1 || t1 < 0 || !Number.isFinite(t0) || !Number.isFinite(t1)) return false;
25154
+ out.t0 = t0;
25155
+ out.t1 = t1;
25156
+ if (tA >= yA) normalizeInto(o[0] + d[0] * t0, 0, o[2] + d[2] * t0, out.n0, 1, 0, 0);
25157
+ else {
25158
+ out.n0[0] = 0;
25159
+ out.n0[1] = d[1] > 0 ? -1 : 1;
25160
+ out.n0[2] = 0;
25161
+ }
25162
+ return true;
25163
+ };
25164
+ var rayShapeInto = (s, o, d, out) => {
25165
+ if (s.kind === "box") return boxInto(s.size, o, d, out);
25166
+ if (s.kind === "sphere") return sphereInto(s.radius, o, d, out);
25167
+ return cylinderInto(s.radius, s.height, o, d, out);
25168
+ };
25169
+ var JOINT_FASTENERS = {
25170
+ screw: { diameterMm: 4.5, lateral: "predrilled", spacing: 0.2 },
25171
+ bolt: { diameterMm: 8, lateral: "predrilled", spacing: 0.2 },
25172
+ nail: { diameterMm: 3, lateral: "driven", spacing: 0.15 }
25173
+ };
25174
+ var RIGID_KINDS = /* @__PURE__ */ new Set(["glue", "weld", "fused", "mortar", "rebar"]);
25175
+ var RIGID_PUSH = 1e10;
25176
+ var RIGID_TURN = 1e8;
25177
+ var TOUCH = 0.01;
25178
+ var FOOT_BAND = 0.03;
25179
+ var SEAM_STATIONS = 5;
25180
+ var BEAM_PIECES = 4;
25181
+ var SLENDER = 4;
25182
+ var MAX_DOF = 1500;
25183
+ var MECHANISM = 0.5;
25184
+ var FOOT_FRICTION = 0.4;
25185
+ var UPRIGHT = 0.9;
25186
+ var SOFT = 1e-11;
25187
+ var GRAVITY2 = 9.81;
25188
+ var EDGE_D = 4;
25189
+ var ROW_D = 5;
25190
+ var END_D = 10;
25191
+ var THREAD_D = 6;
25192
+ var isWood = (m) => !!m.tags && m.tags.includes("wood");
25193
+ function fastenerStiffness(kind, a, b) {
25194
+ const f = JOINT_FASTENERS[kind];
25195
+ if (!f) return null;
25196
+ const woods = [a, b].filter(isWood);
25197
+ if (woods.length === 0) return null;
25198
+ const density = woods.length === 2 ? Math.sqrt(a.density * b.density) : woods[0].density;
25199
+ const d = f.diameterMm;
25200
+ const perMm = f.lateral === "predrilled" ? density ** 1.5 * d / 23 : density ** 1.5 * d ** 0.8 / 30;
25201
+ const lateral = perMm * 1e3 * (woods.length === 1 ? 2 : 1);
25202
+ const axial = kind === "screw" ? 234 * (density * d) ** 0.2 * (THREAD_D * d) ** 0.4 * 1e3 : lateral;
25203
+ return { lateral, axial, diameter: d / 1e3, spacing: f.spacing };
25204
+ }
25205
+ function torsionConstant(side, other) {
25206
+ const b = Math.max(side, other);
25207
+ const t = Math.min(side, other);
25208
+ if (b <= 0) return 0;
25209
+ const r = t / b;
25210
+ return b * t ** 3 * (1 / 3 - 0.21 * r * (1 - r ** 4 / 12));
25211
+ }
25212
+ var AXES = [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
25213
+ function beamOf(part) {
25214
+ const d = part.dims;
25215
+ let a = 0;
25216
+ if (d[1] > d[a]) a = 1;
25217
+ if (d[2] > d[a]) a = 2;
25218
+ const ui = (a + 1) % 3;
25219
+ const vi = (a + 2) % 3;
25220
+ const axis2 = rotateVec(part.rotation, AXES[a]);
25221
+ const u = rotateVec(part.rotation, AXES[ui]);
25222
+ const v = rotateVec(part.rotation, AXES[vi]);
25223
+ const min2 = [Infinity, Infinity, Infinity];
25224
+ const max2 = [-Infinity, -Infinity, -Infinity];
25225
+ for (let i = 0; i < 8; i++) {
25226
+ const c = cornerOf(part, i);
25227
+ for (let k = 0; k < 3; k++) {
25228
+ min2[k] = Math.min(min2[k], c[k]);
25229
+ max2[k] = Math.max(max2[k], c[k]);
25230
+ }
25231
+ }
25232
+ return { part, axis: axis2, u, v, length: d[a], stations: [], nodes: [], min: min2, max: max2 };
25233
+ }
25234
+ function cornerOf(part, i) {
25235
+ const d = part.dims;
25236
+ const local2 = [(i & 1 ? 0.5 : -0.5) * d[0], (i & 2 ? 0.5 : -0.5) * d[1], (i & 4 ? 0.5 : -0.5) * d[2]];
25237
+ return vec.add(part.position, rotateVec(part.rotation, local2));
25238
+ }
25239
+ function sectionOf2(beam) {
25240
+ const elastic = beam.part.material.elastic;
25241
+ if (!elastic) return null;
25242
+ const d = beam.part.dims;
25243
+ let a = 0;
25244
+ if (d[1] > d[a]) a = 1;
25245
+ if (d[2] > d[a]) a = 2;
25246
+ const du = d[(a + 1) % 3];
25247
+ const dv = d[(a + 2) % 3];
25248
+ const along2 = beam.part.grain === void 0 || beam.part.grain === a;
25249
+ const e = (along2 ? elastic.alongGPa : elastic.acrossGPa ?? elastic.alongGPa) * 1e9;
25250
+ const g = elastic.shearGPa * 1e9;
25251
+ if (beam.part.round && a === 1) {
25252
+ const r = du / 2;
25253
+ const i = Math.PI * r ** 4 / 4;
25254
+ return { area: Math.PI * r * r, iu: i, iv: i, j: 2 * i, e, g };
25255
+ }
25256
+ return { area: du * dv, iu: du * dv ** 3 / 12, iv: dv * du ** 3 / 12, j: torsionConstant(du, dv), e, g };
25257
+ }
25258
+ function beamLocal(s, length2) {
25259
+ const k = new Float64Array(144);
25260
+ const set2 = (i, j, value) => {
25261
+ k[i * 12 + j] = value;
25262
+ k[j * 12 + i] = value;
25263
+ };
25264
+ const L = length2;
25265
+ const ea = s.e * s.area / L;
25266
+ const gj = s.g * s.j / L;
25267
+ const z = s.e * s.iv;
25268
+ const y = s.e * s.iu;
25269
+ set2(0, 0, ea);
25270
+ set2(0, 6, -ea);
25271
+ set2(6, 6, ea);
25272
+ set2(3, 3, gj);
25273
+ set2(3, 9, -gj);
25274
+ set2(9, 9, gj);
25275
+ set2(1, 1, 12 * z / L ** 3);
25276
+ set2(1, 5, 6 * z / L ** 2);
25277
+ set2(1, 7, -12 * z / L ** 3);
25278
+ set2(1, 11, 6 * z / L ** 2);
25279
+ set2(5, 5, 4 * z / L);
25280
+ set2(5, 7, -6 * z / L ** 2);
25281
+ set2(5, 11, 2 * z / L);
25282
+ set2(7, 7, 12 * z / L ** 3);
25283
+ set2(7, 11, -6 * z / L ** 2);
25284
+ set2(11, 11, 4 * z / L);
25285
+ set2(2, 2, 12 * y / L ** 3);
25286
+ set2(2, 4, -6 * y / L ** 2);
25287
+ set2(2, 8, -12 * y / L ** 3);
25288
+ set2(2, 10, -6 * y / L ** 2);
25289
+ set2(4, 4, 4 * y / L);
25290
+ set2(4, 8, 6 * y / L ** 2);
25291
+ set2(4, 10, 2 * y / L);
25292
+ set2(8, 8, 12 * y / L ** 3);
25293
+ set2(8, 10, 6 * y / L ** 2);
25294
+ set2(10, 10, 4 * y / L);
25295
+ return k;
25296
+ }
25297
+ function toObjectFrame(k, n, x, y, z) {
25298
+ const r = [x[0], y[0], z[0], x[1], y[1], z[1], x[2], y[2], z[2]];
25299
+ const half = new Float64Array(n * n);
25300
+ const out = new Float64Array(n * n);
25301
+ for (let block = 0; block < n; block += 3) {
25302
+ for (let col = 0; col < n; col++) {
25303
+ for (let i = 0; i < 3; i++) {
25304
+ let sum2 = 0;
25305
+ for (let m = 0; m < 3; m++) sum2 += r[i * 3 + m] * k[(block + m) * n + col];
25306
+ half[(block + i) * n + col] = sum2;
25307
+ }
25308
+ }
25309
+ }
25310
+ for (let row = 0; row < n; row++) {
25311
+ for (let block = 0; block < n; block += 3) {
25312
+ for (let i = 0; i < 3; i++) {
25313
+ let sum2 = 0;
25314
+ for (let m = 0; m < 3; m++) sum2 += half[row * n + block + m] * r[i * 3 + m];
25315
+ out[row * n + block + i] = sum2;
25316
+ }
25317
+ }
25318
+ }
25319
+ return out;
25320
+ }
25321
+ function armRows(arm) {
25322
+ const [x, y, z] = arm;
25323
+ return [
25324
+ [1, 0, 0, 0, z, -y],
25325
+ [0, 1, 0, -z, 0, x],
25326
+ [0, 0, 1, y, -x, 0]
25327
+ ];
25328
+ }
25329
+ function stationsOf(joint2, a, b) {
25330
+ const lo = [0, 0, 0];
25331
+ const hi = [0, 0, 0];
25332
+ let touching = true;
25333
+ for (let k = 0; k < 3; k++) {
25334
+ lo[k] = Math.max(a.min[k], b.min[k]);
25335
+ hi[k] = Math.min(a.max[k], b.max[k]);
25336
+ if (hi[k] < lo[k] - TOUCH) touching = false;
25337
+ }
25338
+ const rigid = RIGID_KINDS.has(joint2.kind);
25339
+ const fastener = rigid ? null : fastenerStiffness(joint2.kind, a.part.material, b.part.material);
25340
+ const stiff = rigid || !fastener && JOINT_FASTENERS[joint2.kind] !== void 0;
25341
+ if (!stiff && !fastener) return [];
25342
+ if (!touching) {
25343
+ const frame3 = [[0, 1, 0], [1, 0, 0], [0, 0, 1]];
25344
+ if (stiff || !fastener) return [{ at: joint2.position, frame: frame3, push: [RIGID_PUSH, RIGID_PUSH, RIGID_PUSH], turn: [RIGID_TURN, RIGID_TURN, RIGID_TURN] }];
25345
+ return [{ at: joint2.position, frame: frame3, push: [fastener.axial, fastener.lateral, fastener.lateral], turn: [0, 0, 0] }];
25346
+ }
25347
+ const size = [Math.max(0, hi[0] - lo[0]), Math.max(0, hi[1] - lo[1]), Math.max(0, hi[2] - lo[2])];
25348
+ const middle = [(lo[0] + hi[0]) / 2, (lo[1] + hi[1]) / 2, (lo[2] + hi[2]) / 2];
25349
+ let n = 0;
25350
+ if (size[1] < size[n]) n = 1;
25351
+ if (size[2] < size[n]) n = 2;
25352
+ let w = (n + 1) % 3;
25353
+ let c = (n + 2) % 3;
25354
+ if (size[c] > size[w]) [w, c] = [c, w];
25355
+ const frame2 = [AXES[n], AXES[w], AXES[c]];
25356
+ const along2 = size[w];
25357
+ const across2 = size[c];
25358
+ const d = fastener?.diameter ?? 5e-3;
25359
+ const spacing = fastener?.spacing ?? 0.2;
25360
+ const end3 = END_D * d;
25361
+ const count = along2 > 2 * end3 ? 1 + Math.ceil((along2 - 2 * end3) / spacing) : 1;
25362
+ const stations = Math.min(count, SEAM_STATIONS);
25363
+ const each = count / stations;
25364
+ const out = [];
25365
+ for (let s = 0; s < stations; s++) {
25366
+ const t = stations === 1 ? 0 : -along2 / 2 + end3 + (along2 - 2 * end3) * s / (stations - 1);
25367
+ const at4 = [middle[0], middle[1], middle[2]];
25368
+ at4[w] = middle[w] + t;
25369
+ if (stiff || !fastener) {
25370
+ out.push({ at: at4, frame: frame2, push: [RIGID_PUSH, RIGID_PUSH, RIGID_PUSH], turn: [RIGID_TURN, RIGID_TURN, RIGID_TURN] });
25371
+ continue;
25372
+ }
25373
+ const rows = across2 >= (2 * EDGE_D + ROW_D) * d ? [EDGE_D * d, across2 - EDGE_D * d] : [across2 / 2];
25374
+ const pry = rows.reduce((sum2, r) => sum2 + r * r, 0) * fastener.axial * each;
25375
+ const lone = stations === 1;
25376
+ const pryAlong = lone ? (along2 / 2) ** 2 * fastener.axial * rows.length : 0;
25377
+ const twist = lone && rows.length > 1 ? rows.reduce((sum2, r) => sum2 + (r - across2 / 2) ** 2, 0) * fastener.lateral : 0;
25378
+ out.push({ at: at4, frame: frame2, push: [fastener.axial * rows.length * each, fastener.lateral * rows.length * each, fastener.lateral * rows.length * each], turn: [twist, pry, pryAlong] });
25379
+ }
25380
+ return out;
25381
+ }
25382
+ function solve(k, f, n) {
25383
+ const first = new Int32Array(n);
25384
+ for (let i = 0; i < n; i++) {
25385
+ let j = 0;
25386
+ while (j < i && k[i * n + j] === 0) j++;
25387
+ first[i] = j;
25388
+ }
25389
+ for (let i = 0; i < n; i++) {
25390
+ const fi = first[i];
25391
+ for (let j = fi; j <= i; j++) {
25392
+ let sum2 = k[i * n + j];
25393
+ const from = Math.max(fi, first[j]);
25394
+ for (let m = from; m < j; m++) sum2 -= k[i * n + m] * k[j * n + m];
25395
+ if (j === i) {
25396
+ if (!(sum2 > 0)) return false;
25397
+ k[i * n + i] = Math.sqrt(sum2);
25398
+ } else k[i * n + j] = sum2 / k[j * n + j];
25399
+ }
25400
+ }
25401
+ for (let i = 0; i < n; i++) {
25402
+ let sum2 = f[i];
25403
+ for (let m = first[i]; m < i; m++) sum2 -= k[i * n + m] * f[m];
25404
+ f[i] = sum2 / k[i * n + i];
25405
+ }
25406
+ for (let i = n - 1; i >= 0; i--) {
25407
+ const x = f[i] / k[i * n + i];
25408
+ f[i] = x;
25409
+ for (let m = first[i]; m < i; m++) f[m] = f[m] - k[i * n + m] * x;
25410
+ }
25411
+ return true;
25412
+ }
25413
+ function hullOf(points) {
25414
+ const sorted = [...points].sort((p, q) => p[0] - q[0] || p[1] - q[1]);
25415
+ const turn2 = (o, p, q) => (p[0] - o[0]) * (q[1] - o[1]) - (p[1] - o[1]) * (q[0] - o[0]);
25416
+ const lower = [];
25417
+ for (const p of sorted) {
25418
+ while (lower.length >= 2 && turn2(lower[lower.length - 2], lower[lower.length - 1], p) <= 1e-12) lower.pop();
25419
+ lower.push([p[0], p[1]]);
25420
+ }
25421
+ const upper = [];
25422
+ for (let i = sorted.length - 1; i >= 0; i--) {
25423
+ const p = sorted[i];
25424
+ while (upper.length >= 2 && turn2(upper[upper.length - 2], upper[upper.length - 1], p) <= 1e-12) upper.pop();
25425
+ upper.push([p[0], p[1]]);
25426
+ }
25427
+ lower.pop();
25428
+ upper.pop();
25429
+ return [...lower, ...upper];
25430
+ }
25431
+ function assemblyFlex(input) {
25432
+ const g = input.gravity ?? GRAVITY2;
25433
+ const lost = new Set(input.lost ?? []);
25434
+ const beams = /* @__PURE__ */ new Map();
25435
+ for (const part of input.parts) {
25436
+ if (part.mass <= 0 || Math.max(...part.dims) <= 0) continue;
25437
+ beams.set(part.id, beamOf(part));
25438
+ }
25439
+ if (beams.size === 0) return null;
25440
+ const floor2 = input.floor ?? Math.min(...[...beams.values()].map((b) => b.min[1]));
25441
+ const joints = input.joints.filter((j) => beams.has(j.a) && beams.has(j.b) && j.a !== j.b);
25442
+ const structural = (j) => RIGID_KINDS.has(j.kind) || JOINT_FASTENERS[j.kind] !== void 0;
25443
+ const stationed = /* @__PURE__ */ new Map();
25444
+ const along2 = (beam, p) => Math.max(-beam.length / 2, Math.min(beam.length / 2, vec.dot(vec.sub(p, beam.part.position), beam.axis)));
25445
+ for (const beam of beams.values()) beam.stations.push(-beam.length / 2, beam.length / 2);
25446
+ for (const joint2 of joints) {
25447
+ if (!structural(joint2)) continue;
25448
+ const a = beams.get(joint2.a);
25449
+ const b = beams.get(joint2.b);
25450
+ const stations = stationsOf(joint2, a, b);
25451
+ stationed.set(joint2, stations);
25452
+ for (const s of stations) {
25453
+ a.stations.push(along2(a, s.at));
25454
+ b.stations.push(along2(b, s.at));
25455
+ }
25456
+ }
25457
+ const footPoints = /* @__PURE__ */ new Map();
25458
+ for (const beam of beams.values()) {
25459
+ if (beam.min[1] > floor2 + FOOT_BAND) continue;
25460
+ const corners = [];
25461
+ for (let i = 0; i < 8; i++) {
25462
+ const c = cornerOf(beam.part, i);
25463
+ if (c[1] <= beam.min[1] + 5e-3) corners.push(c);
25464
+ }
25465
+ footPoints.set(beam.part.id, corners);
25466
+ for (const c of corners) beam.stations.push(along2(beam, c));
25467
+ }
25468
+ const nodes = [];
25469
+ for (const beam of beams.values()) {
25470
+ const sides = beam.part.dims.filter((d) => d !== beam.length);
25471
+ const merge = Math.max(2e-3, 0.5 * Math.min(...sides, beam.length));
25472
+ const sorted = [...beam.stations].sort((p, q) => p - q);
25473
+ const met = [];
25474
+ for (const s of sorted) if (met.length === 0 || s - met[met.length - 1] > merge) met.push(s);
25475
+ if (met.length > 1 && beam.length / 2 - met[met.length - 1] > 0) met[met.length - 1] = beam.length / 2;
25476
+ const longest = beam.length >= SLENDER * Math.max(...sides, 0) && Math.abs(beam.axis[1]) < UPRIGHT ? beam.length / BEAM_PIECES : Infinity;
25477
+ const kept = [];
25478
+ for (const [i, s] of met.entries()) {
25479
+ const from = met[i - 1];
25480
+ if (from !== void 0 && s - from > longest * 1.01) {
25481
+ const cuts = Math.ceil((s - from) / longest);
25482
+ for (let c = 1; c < cuts; c++) kept.push(from + (s - from) * c / cuts);
25483
+ }
25484
+ kept.push(s);
25485
+ }
25486
+ beam.stations = kept;
25487
+ beam.nodes = kept.map((s) => nodes.push({ at: vec.madd(beam.part.position, beam.axis, s) }) - 1);
25488
+ }
25489
+ if (nodes.length * 6 > MAX_DOF) return null;
25490
+ const lo = [Infinity, Infinity, Infinity];
25491
+ const hi = [-Infinity, -Infinity, -Infinity];
25492
+ for (const node of nodes) for (let k = 0; k < 3; k++) {
25493
+ lo[k] = Math.min(lo[k], node.at[k]);
25494
+ hi[k] = Math.max(hi[k], node.at[k]);
25495
+ }
25496
+ let main = 0;
25497
+ if (hi[1] - lo[1] > hi[main] - lo[main]) main = 1;
25498
+ if (hi[2] - lo[2] > hi[main] - lo[main]) main = 2;
25499
+ const ranked = nodes.map((_, i) => i).sort((p, q) => nodes[p].at[main] - nodes[q].at[main] || p - q);
25500
+ const order2 = new Int32Array(nodes.length);
25501
+ ranked.forEach((node, rank) => {
25502
+ order2[node] = rank;
25503
+ });
25504
+ const dofsOf = (node) => [0, 1, 2, 3, 4, 5].map((i) => order2[node] * 6 + i);
25505
+ const nearest = (beam, p) => {
25506
+ const t = along2(beam, p);
25507
+ let best = 0;
25508
+ for (let i = 1; i < beam.stations.length; i++) if (Math.abs(beam.stations[i] - t) < Math.abs(beam.stations[best] - t)) best = i;
25509
+ return beam.nodes[best];
25510
+ };
25511
+ const elements = [];
25512
+ for (const beam of beams.values()) {
25513
+ const section = sectionOf2(beam);
25514
+ if (!section) {
25515
+ const id = beam.part.id;
25516
+ if (footPoints.has(id) || joints.some((j) => structural(j) && (j.a === id || j.b === id))) return null;
25517
+ continue;
25518
+ }
25519
+ for (let i = 0; i + 1 < beam.nodes.length; i++) {
25520
+ const length2 = beam.stations[i + 1] - beam.stations[i];
25521
+ const k = toObjectFrame(beamLocal(section, length2), 12, beam.axis, beam.u, beam.v);
25522
+ elements.push({ dofs: [...dofsOf(beam.nodes[i]), ...dofsOf(beam.nodes[i + 1])], k, parts: [beam.part.id] });
25523
+ }
25524
+ }
25525
+ for (const [joint2, stations] of stationed) {
25526
+ const a = beams.get(joint2.a);
25527
+ const b = beams.get(joint2.b);
25528
+ for (const s of stations) {
25529
+ const na = nearest(a, s.at);
25530
+ const nb = nearest(b, s.at);
25531
+ const ra = armRows(vec.sub(s.at, nodes[na].at));
25532
+ const rb = armRows(vec.sub(s.at, nodes[nb].at));
25533
+ const rows = [];
25534
+ for (let i = 0; i < 3; i++) rows.push([...ra[i].map((x) => -x), ...rb[i]]);
25535
+ for (let i = 0; i < 3; i++) {
25536
+ const row = new Array(12).fill(0);
25537
+ row[3 + i] = -1;
25538
+ row[9 + i] = 1;
25539
+ rows.push(row);
25540
+ }
25541
+ const k = new Float64Array(144);
25542
+ for (let axis2 = 0; axis2 < 3; axis2++) {
25543
+ const e = s.frame[axis2];
25544
+ for (const [stiffness, base2] of [[s.push[axis2], 0], [s.turn[axis2], 3]]) {
25545
+ if (stiffness === 0) continue;
25546
+ const b12 = new Array(12).fill(0);
25547
+ for (let i = 0; i < 3; i++) for (let m = 0; m < 12; m++) b12[m] = b12[m] + e[i] * rows[base2 + i][m];
25548
+ for (let p = 0; p < 12; p++) for (let q = 0; q < 12; q++) k[p * 12 + q] = k[p * 12 + q] + stiffness * b12[p] * b12[q];
25549
+ }
25550
+ }
25551
+ elements.push({ dofs: [...dofsOf(na), ...dofsOf(nb)], k, parts: [joint2.a, joint2.b] });
25552
+ }
25553
+ }
25554
+ const supports = [];
25555
+ for (const [id, corners] of footPoints) {
25556
+ const beam = beams.get(id);
25557
+ for (const at4 of corners) {
25558
+ const node = nearest(beam, at4);
25559
+ supports.push({ part: id, node, arm: vec.sub(at4, nodes[node].at), at: at4 });
25560
+ }
25561
+ }
25562
+ const frame2 = { nodes, beams, elements, supports, order: order2 };
25563
+ const before = lost.size > 0 ? solveFrame(frame2, input, joints, structural, /* @__PURE__ */ new Set(), g, null) : null;
25564
+ const after2 = solveFrame(frame2, input, joints, structural, lost, g, before);
25565
+ if (!after2) return null;
25566
+ let mass = 0;
25567
+ const centre = [0, 0, 0];
25568
+ const shift = [0, 0, 0];
25569
+ let all = 0;
25570
+ const allCentre = [0, 0, 0];
25571
+ const moved = (s, point) => {
25572
+ const base2 = order2[point.node] * 6;
25573
+ const theta = [s.u[base2 + 3], s.u[base2 + 4], s.u[base2 + 5]];
25574
+ return vec.add([s.u[base2], s.u[base2 + 1], s.u[base2 + 2]], vec.cross(theta, point.arm));
25575
+ };
25576
+ for (const p of after2.masses) {
25577
+ const at4 = vec.add(nodes[p.node].at, p.arm);
25578
+ const by = moved(after2, p);
25579
+ all += p.mass;
25580
+ for (let k = 0; k < 3; k++) allCentre[k] = allCentre[k] + (at4[k] + by[k]) * p.mass;
25581
+ if (p.part === null) continue;
25582
+ mass += p.mass;
25583
+ for (let k = 0; k < 3; k++) {
25584
+ centre[k] = centre[k] + at4[k] * p.mass;
25585
+ shift[k] = shift[k] + by[k] * p.mass;
25586
+ }
25587
+ }
25588
+ if (mass <= 0) return null;
25589
+ for (let k = 0; k < 3; k++) {
25590
+ centre[k] = centre[k] / mass;
25591
+ shift[k] = shift[k] / mass;
25592
+ allCentre[k] = allCentre[k] / all;
25593
+ }
25594
+ const feet = after2.holding.map((s) => s.at);
25595
+ let released = 0;
25596
+ let spin = null;
25597
+ if (before) {
25598
+ const n = nodes.length * 6;
25599
+ const delta = new Float64Array(n);
25600
+ for (let i = 0; i < n; i++) delta[i] = after2.u[i] - before.u[i];
25601
+ 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;
25602
+ for (let i = 0; i < n; i++) {
25603
+ if (delta[i] === 0) continue;
25604
+ let row = 0;
25605
+ for (let j = 0; j < n; j++) row += after2.k[i * n + j] * delta[j];
25606
+ released += 0.5 * delta[i] * row;
25607
+ }
25608
+ spin = spinOf({ frame: frame2, after: after2, delta, released, centre: allCentre, mass: all, floor: floor2, g });
25609
+ }
25610
+ return {
25611
+ mass,
25612
+ centre,
25613
+ shift,
25614
+ released,
25615
+ spin,
25616
+ feet,
25617
+ deflection(id, point) {
25618
+ const beam = beams.get(id);
25619
+ if (!beam || !after2.standing.has(id)) return null;
25620
+ const node = nearest(beam, point);
25621
+ return moved(after2, { part: id, node, arm: vec.sub(point, nodes[node].at), mass: 0 });
25622
+ }
25623
+ };
25624
+ }
25625
+ function standingParts(frame2, joints, structural, gone) {
25626
+ const standing = /* @__PURE__ */ new Set();
25627
+ const queue = [];
25628
+ for (const s of frame2.supports) {
25629
+ if (gone.has(s.part) || standing.has(s.part)) continue;
25630
+ standing.add(s.part);
25631
+ queue.push(s.part);
25632
+ }
25633
+ while (queue.length > 0) {
25634
+ const id = queue.pop();
25635
+ for (const j of joints) {
25636
+ if (!structural(j) || j.a !== id && j.b !== id) continue;
25637
+ const other = j.a === id ? j.b : j.a;
25638
+ if (gone.has(other) || standing.has(other)) continue;
25639
+ standing.add(other);
25640
+ queue.push(other);
25641
+ }
25642
+ }
25643
+ return standing;
25644
+ }
25645
+ function solveFrame(frame2, input, joints, structural, gone, g, from) {
25646
+ const { nodes, beams, order: order2 } = frame2;
25647
+ const n = nodes.length * 6;
25648
+ const standing = standingParts(frame2, joints, structural, gone);
25649
+ if (standing.size === 0) return null;
25650
+ const nearestNode = (p, among) => {
25651
+ let best = -1;
25652
+ let bestDistance = Infinity;
25653
+ for (const id of among) {
25654
+ const beam = beams.get(id);
25655
+ for (const node of beam.nodes) {
25656
+ const d = vec.distance(nodes[node].at, p);
25657
+ if (d < bestDistance) {
25658
+ bestDistance = d;
25659
+ best = node;
25660
+ }
25661
+ }
25662
+ }
25663
+ return best;
25664
+ };
25665
+ const masses = [];
25666
+ for (const id of standing) {
25667
+ const beam = beams.get(id);
25668
+ const perMetre = beam.part.mass / beam.length;
25669
+ for (let i = 0; i < beam.nodes.length; i++) {
25670
+ const before = i > 0 ? beam.stations[i] - beam.stations[i - 1] : 0;
25671
+ const next = i + 1 < beam.nodes.length ? beam.stations[i + 1] - beam.stations[i] : 0;
25672
+ masses.push({ part: id, node: beam.nodes[i], arm: [0, 0, 0], mass: perMetre * (before + next) / 2 });
25673
+ }
25674
+ }
25675
+ const carried = /* @__PURE__ */ new Map();
25676
+ let grew = true;
25677
+ while (grew) {
25678
+ grew = false;
25679
+ for (const j of joints) {
25680
+ for (const [id, host] of [[j.a, j.b], [j.b, j.a]]) {
25681
+ if (gone.has(id) || gone.has(host) || standing.has(id) || carried.has(id)) continue;
25682
+ if (!standing.has(host) && !carried.has(host)) continue;
25683
+ carried.set(id, standing.has(host) ? host : carried.get(host));
25684
+ grew = true;
25685
+ }
25686
+ }
25687
+ }
25688
+ for (const [id, host] of carried) {
25689
+ const part = beams.get(id).part;
25690
+ const node = nearestNode(part.position, [host]);
25691
+ masses.push({ part: id, node, arm: vec.sub(part.position, nodes[node].at), mass: part.mass });
25692
+ }
25693
+ for (const load of input.loads ?? []) {
25694
+ if (load.mass <= 0) continue;
25695
+ const node = nearestNode(load.position, standing);
25696
+ masses.push({ part: null, node, arm: vec.sub(load.position, nodes[node].at), mass: load.mass });
25697
+ }
25698
+ const f = new Float64Array(n);
25699
+ for (const p of masses) {
25700
+ const base2 = order2[p.node] * 6;
25701
+ const weight = -p.mass * g;
25702
+ f[base2 + 1] = f[base2 + 1] + weight;
25703
+ f[base2 + 3] = f[base2 + 3] - p.arm[2] * weight;
25704
+ f[base2 + 5] = f[base2 + 5] + p.arm[0] * weight;
25705
+ }
25706
+ const structure = new Float64Array(n * n);
25707
+ let largest = 0;
25708
+ for (const element of frame2.elements) {
25709
+ if (!element.parts.every((id) => standing.has(id))) continue;
25710
+ const size = element.dofs.length;
25711
+ for (let p = 0; p < size; p++) {
25712
+ for (let q = 0; q < size; q++) structure[element.dofs[p] * n + element.dofs[q]] = structure[element.dofs[p] * n + element.dofs[q]] + element.k[p * size + q];
25713
+ }
25714
+ }
25715
+ for (let i = 0; i < n; i++) largest = Math.max(largest, structure[i * n + i]);
25716
+ if (largest <= 0) return null;
25717
+ const free = new Uint8Array(n);
25718
+ for (const id of standing) for (const node of beams.get(id).nodes) for (let i = 0; i < 6; i++) free[order2[node] * 6 + i] = 1;
25719
+ for (let i = 0; i < n; i++) {
25720
+ if (!free[i]) {
25721
+ structure[i * n + i] = largest;
25722
+ f[i] = 0;
25723
+ } else structure[i * n + i] = structure[i * n + i] + largest * SOFT;
25724
+ }
25725
+ const feet = frame2.supports.filter((s) => standing.has(s.part));
25726
+ const holds3 = feet.map((s) => !from || from.holding.includes(s));
25727
+ const footed = [...new Set(feet.map((s) => s.part))];
25728
+ const grips = new Map(footed.map((id) => [id, true]));
25729
+ const friction = input.friction ?? FOOT_FRICTION;
25730
+ const k = new Float64Array(n * n);
25731
+ const u = new Float64Array(n);
25732
+ const build = () => {
25733
+ k.set(structure);
25734
+ const held = /* @__PURE__ */ new Map();
25735
+ feet.forEach((s, index) => {
25736
+ if (!holds3[index]) return;
25737
+ const row = armRows(s.arm)[1];
25738
+ const base2 = order2[s.node] * 6;
25739
+ for (let p = 0; p < 6; p++) for (let q = 0; q < 6; q++) k[(base2 + p) * n + base2 + q] = k[(base2 + p) * n + base2 + q] + RIGID_PUSH * row[p] * row[q];
25740
+ held.set(s.part, [...held.get(s.part) ?? [], s]);
25741
+ });
25742
+ for (const [id, points] of held) {
25743
+ const { node, arm } = gripOf(points);
25744
+ const upright = order2[node] * 6 + 4;
25745
+ k[upright * n + upright] = k[upright * n + upright] + RIGID_TURN;
25746
+ if (!grips.get(id)) continue;
25747
+ const rows = armRows(arm);
25748
+ const base2 = order2[node] * 6;
25749
+ for (const row of [rows[0], rows[2]]) for (let p = 0; p < 6; p++) for (let q = 0; q < 6; q++) k[(base2 + p) * n + base2 + q] = k[(base2 + p) * n + base2 + q] + RIGID_PUSH * row[p] * row[q];
25750
+ }
25751
+ };
25752
+ const liftOf = (s) => {
25753
+ const base2 = order2[s.node] * 6;
25754
+ return u[base2 + 1] + (u[base2 + 5] * s.arm[0] - u[base2 + 3] * s.arm[2]);
25755
+ };
25756
+ const rounds = 4 * feet.length + 2 * footed.length + 4;
25757
+ for (let round5 = 0; round5 < rounds; round5++) {
25758
+ build();
25759
+ u.set(f);
25760
+ if (!solve(k, u, n)) return null;
25761
+ const pull = 1e-12;
25762
+ const sink = -1e-9;
25763
+ if (round5 === 0) {
25764
+ let any = false;
25765
+ feet.forEach((s, index) => {
25766
+ if (!holds3[index] || liftOf(s) <= pull) return;
25767
+ holds3[index] = false;
25768
+ any = true;
25769
+ });
25770
+ if (any) continue;
25771
+ }
25772
+ const worstOf = /* @__PURE__ */ new Map();
25773
+ feet.forEach((s, index) => {
25774
+ const lift = liftOf(s);
25775
+ const pulls = holds3[index] && lift > pull;
25776
+ if (!pulls && !(!holds3[index] && lift < sink)) return;
25777
+ const key2 = round5 < rounds / 2 ? s.part : "";
25778
+ const by = Math.abs(lift);
25779
+ const now = worstOf.get(key2);
25780
+ if (!now || pulls && !now.pulls || pulls === now.pulls && by > now.by) worstOf.set(key2, { index, by, pulls });
25781
+ });
25782
+ if (worstOf.size > 0) {
25783
+ for (const change of worstOf.values()) holds3[change.index] = !change.pulls;
25784
+ continue;
25785
+ }
25786
+ let slides = null;
25787
+ let over = 1;
25788
+ let gripping = 0;
25789
+ for (const id of footed) {
25790
+ const points = feet.filter((s, index) => s.part === id && holds3[index]);
25791
+ if (points.length === 0 || !grips.get(id)) continue;
25792
+ gripping++;
25793
+ let weight = 0;
25794
+ for (const s of points) weight += -RIGID_PUSH * liftOf(s);
25795
+ const { node, arm } = gripOf(points);
25796
+ const base2 = order2[node] * 6;
25797
+ const x = u[base2] + (u[base2 + 4] * arm[2] - u[base2 + 5] * arm[1]);
25798
+ const z = u[base2 + 2] + (u[base2 + 3] * arm[1] - u[base2 + 4] * arm[0]);
25799
+ const ratio = RIGID_PUSH * Math.hypot(x, z) / Math.max(friction * weight, 1e-9);
25800
+ if (ratio > over) {
25801
+ over = ratio;
25802
+ slides = id;
25803
+ }
25804
+ }
25805
+ if (slides !== null && gripping > 1) {
25806
+ grips.set(slides, false);
25807
+ continue;
25808
+ }
25809
+ let worst = 0;
25810
+ for (let i = 0; i < n; i++) if (free[i]) worst = Math.max(worst, Math.abs(u[i]));
25811
+ if (worst > MECHANISM) return null;
25812
+ const holding = feet.filter((_, index) => holds3[index]);
25813
+ if (holding.length < 3) return null;
25814
+ build();
25815
+ return { u: u.slice(), k: k.slice(), holding, masses, standing };
25816
+ }
25817
+ return null;
25818
+ }
25819
+ function gripOf(points) {
25820
+ const first = points[0];
25821
+ let arm = [0, 0, 0];
25822
+ for (const s of points) arm = vec.add(arm, vec.sub(s.at, vec.sub(first.at, first.arm)));
25823
+ return { node: first.node, arm: vec.scale(arm, 1 / points.length) };
25824
+ }
25825
+ function spinOf(input) {
25826
+ const { frame: frame2, after: after2, delta, released, centre, mass, floor: floor2, g } = input;
25827
+ if (!(released > 0)) return null;
25828
+ const { nodes, order: order2 } = frame2;
25829
+ const points = after2.masses.map((p) => {
25830
+ const base2 = order2[p.node] * 6;
25831
+ const theta = [delta[base2 + 3], delta[base2 + 4], delta[base2 + 5]];
25832
+ return { at: vec.add(nodes[p.node].at, p.arm), by: vec.add([delta[base2], delta[base2 + 1], delta[base2 + 2]], vec.cross(theta, p.arm)), mass: p.mass };
25833
+ });
25834
+ let moving = 0;
25835
+ for (const p of points) moving += p.mass * vec.dot(p.by, p.by);
25836
+ if (!(moving > 0)) return null;
25837
+ const scale = Math.sqrt(2 * released / moving);
25838
+ const hull = hullOf(after2.holding.map((s) => [s.at[0], s.at[2]]));
25839
+ if (hull.length < 3) return null;
25840
+ let best = null;
25841
+ for (let i = 0; i < hull.length; i++) {
25842
+ const p = hull[i];
25843
+ const q = hull[(i + 1) % hull.length];
25844
+ const length2 = Math.hypot(q[0] - p[0], q[1] - p[1]);
25845
+ if (length2 < 1e-9) continue;
25846
+ const point = [p[0], floor2, p[1]];
25847
+ let axis2 = [(q[0] - p[0]) / length2, 0, (q[1] - p[1]) / length2];
25848
+ const inward = [centre[0] - point[0], 0, centre[2] - point[2]];
25849
+ let out = vec.cross(axis2, [0, 1, 0]);
25850
+ if (vec.dot(out, inward) > 0) {
25851
+ axis2 = vec.scale(axis2, -1);
25852
+ out = vec.scale(out, -1);
25853
+ }
25854
+ const depth = -vec.dot(out, inward);
25855
+ let momentum = 0;
25856
+ let inertia = 0;
25857
+ for (const m of points) {
25858
+ const r = vec.sub(m.at, point);
25859
+ const off = vec.sub(r, vec.scale(axis2, vec.dot(r, axis2)));
25860
+ momentum += m.mass * vec.dot(vec.cross(r, vec.scale(m.by, scale)), axis2);
25861
+ inertia += m.mass * vec.dot(off, off);
25862
+ }
25863
+ if (!(inertia > 0)) continue;
25864
+ const rate = momentum / inertia;
25865
+ if (!(rate > 0)) continue;
25866
+ const height = centre[1] - floor2;
25867
+ const barrier = depth > 0 ? mass * g * (Math.hypot(height, depth) - height) : 0;
25868
+ const energy = 0.5 * inertia * rate * rate;
25869
+ const margin = energy - barrier;
25870
+ if (!best || margin > best.margin) best = { point, axis: axis2, rate, margin, energy, barrier };
25871
+ }
25872
+ return best ? { point: best.point, axis: best.axis, rate: best.rate, energy: best.energy, barrier: best.barrier } : null;
25873
+ }
25022
25874
  var SWEEP_BROAD_SLACK = 1e-3;
25023
25875
  var sweptBounds = (origins, direction, length2) => {
25024
25876
  if (origins.length === 0 || !Number.isFinite(length2)) return null;
@@ -25208,6 +26060,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
25208
26060
  var MAX_PLASTER_FLAKES = 24;
25209
26061
  var CHIP_ENERGY = 200;
25210
26062
  var CHIP_SPLASH = 0.5;
26063
+ var SHARD_CUT = [0.3, 0.7];
25211
26064
  var MORTAR_JOINT = 0.01;
25212
26065
  var MIN_UNIT_SHARE = 0.8;
25213
26066
  var CHIP_DRIVE = 0.6;
@@ -25247,9 +26100,31 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
25247
26100
  };
25248
26101
  var BURIED_BLAST_REACH = 0.5;
25249
26102
  var GIVE_AT_CUT_HP = 0.5;
26103
+ var lineToSegment = (o, d, a, b) => {
26104
+ const ab = vec.sub(b, a);
26105
+ const ao = vec.sub(a, o);
26106
+ const abab = vec.dot(ab, ab);
26107
+ const abd = vec.dot(ab, d);
26108
+ const denom = abab - abd * abd;
26109
+ if (abab < 1e-12) return null;
26110
+ if (denom < 1e-12) {
26111
+ const end3 = vec.dot(ao, d) <= vec.dot(vec.sub(b, o), d) ? a : b;
26112
+ return { point: end3, distance: vec.distance(end3, vec.madd(o, d, vec.dot(vec.sub(end3, o), d))) };
26113
+ }
26114
+ const s = clamp2((abd * vec.dot(ao, d) - vec.dot(ao, ab)) / denom, 0, 1);
26115
+ const point = vec.madd(a, ab, s);
26116
+ const t = vec.dot(vec.sub(point, o), d);
26117
+ return { point, distance: vec.distance(point, vec.madd(o, d, t)) };
26118
+ };
26119
+ var cageLeft = (p) => {
26120
+ const r = p.spec.reinforcement;
26121
+ if (!r) return 1;
26122
+ const total = rebarBars(p.dims, p.thin, r.spacing, p.spec.structure?.role).length;
26123
+ return total > 0 ? Math.max(0, total - (p.rt.severedBars?.length ?? 0)) / total : 1;
26124
+ };
25250
26125
  var capacityScale = (p, borne, through) => {
25251
26126
  const residual = p.spec.reinforcement?.residualCapacity ?? RESIDUAL_CAPACITY;
25252
- if (p.st.stripped) return residual;
26127
+ if (p.st.stripped) return residual * cageLeft(p);
25253
26128
  const kept = Math.min(p.rt.removed ? 1 - p.rt.removed / p.mass0 : 1, sectionKept(p, residual, borne, through));
25254
26129
  return Math.max(p.spec.reinforcement ? residual : 0.05, kept);
25255
26130
  };
@@ -25324,6 +26199,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
25324
26199
  };
25325
26200
  var HOSTED_TOLERANCE = 0.02;
25326
26201
  var HOLE_SLACK = 0.05;
26202
+ var GRAIN_AXIS = { x: 0, y: 1, z: 2 };
25327
26203
  var isLost = (p) => p.st.status === "broken" || p.st.status === "melted" || p.st.status === "ashes";
25328
26204
  var clone = (v) => structuredClone(v);
25329
26205
  var overloadRate = (stress) => Math.min(0.6, 0.12 + 0.8 * (stress - 1));
@@ -25898,7 +26774,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
25898
26774
  byKey.set(key2, span);
25899
26775
  return span;
25900
26776
  };
25901
- const sectionOf3 = (p, axis2) => {
26777
+ const sectionOf22 = (p, axis2) => {
25902
26778
  const g = p.bend;
25903
26779
  const section = { b: sectionWidth(g, axis2), h: g.dims[axis2] };
25904
26780
  const rebar2 = tensionSteel(p.spec, g.dims, section, flexure);
@@ -25913,7 +26789,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
25913
26789
  }
25914
26790
  p.restMoment = 0;
25915
26791
  if (g.gravity < 0 || p.span <= 0) return 0;
25916
- const sec = sectionOf3(p, g.gravity);
26792
+ const sec = sectionOf22(p, g.gravity);
25917
26793
  p.restMoment = spanMoment(lineLoad(g, p.bendLoad) * Math.abs(g.up[g.gravity]), p.span);
25918
26794
  const holds3 = (p.st.cracked ? sec.steel : sec.ultimate) * capacityScale(p);
25919
26795
  return p.restMoment * structureSafety / Math.max(holds3, 1);
@@ -25948,7 +26824,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
25948
26824
  const impulse = sum2 / offsets.length * cos2 * reach2 * width * L;
25949
26825
  const weight = axis2 === g.gravity ? p.bendLoad : p.st.mass;
25950
26826
  const kinetic = impulseEnergy(impulse, lineLoad(g, weight) / GRAVITY * L, flexure);
25951
- const sec = sectionOf3(p, axis2);
26827
+ const sec = sectionOf22(p, axis2);
25952
26828
  const EI = s.elasticGPa * 1e9 * sec.section.b * sec.section.h ** 3 / 12;
25953
26829
  const along2 = axis2 === g.gravity ? -Math.sign(away[axis2] * g.up[axis2]) : 0;
25954
26830
  const dynamic2 = momentOfEnergy(kinetic, L, EI, flexure.loadFactor);
@@ -26092,7 +26968,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
26092
26968
  p.bendLoad = p.st.mass + bending[i];
26093
26969
  const bent = restFlexure(o, p, lowerOf(i));
26094
26970
  p.st.flexure = bent;
26095
- p.snap = bent > 1 && !p.st.stripped && !sectionOf3(p, p.bend.gravity).reinforced;
26971
+ p.snap = bent > 1 && !p.st.stripped && !sectionOf22(p, p.bend.gravity).reinforced;
26096
26972
  if (p.spec.structure?.capacity === void 0 || bent > p.st.stress) p.st.stress = bent;
26097
26973
  }
26098
26974
  if (p.st.stress > o.maxStress) o.maxStress = p.st.stress;
@@ -27123,11 +27999,56 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27123
27999
  return r ? { t0: r.t0, t1: r.t1, n: rotateVec(q, r.n0) } : null;
27124
28000
  };
27125
28001
  const rayPart = (o, p, origin, d) => rayPartRaw(o.st.position, o.st.rotation, p.spec, p.q, origin, d, p.pos);
28002
+ const rayCentre = [0, 0, 0];
28003
+ const rayTurn = [0, 0, 0, 1];
28004
+ const rayTurnBack = [0, 0, 0, 1];
28005
+ const rayOrigin = [0, 0, 0];
28006
+ const rayDirection = [0, 0, 0];
28007
+ const rayShapeHit = { t0: 0, t1: 0, n0: [0, 0, 0] };
28008
+ const rayHitNormal = [0, 0, 0];
28009
+ const rayHit = { t0: 0, t1: 0, n: rayHitNormal };
28010
+ const rayPartInto = (pos, rot, spec, pq, origin, d, lp) => {
28011
+ rotateVecInto(rot, lp, rayCentre);
28012
+ rayCentre[0] += pos[0];
28013
+ rayCentre[1] += pos[1];
28014
+ rayCentre[2] += pos[2];
28015
+ rayTurn[0] = rot[3] * pq[0] + rot[0] * pq[3] + rot[1] * pq[2] - rot[2] * pq[1];
28016
+ rayTurn[1] = rot[3] * pq[1] - rot[0] * pq[2] + rot[1] * pq[3] + rot[2] * pq[0];
28017
+ rayTurn[2] = rot[3] * pq[2] + rot[0] * pq[1] - rot[1] * pq[0] + rot[2] * pq[3];
28018
+ rayTurn[3] = rot[3] * pq[3] - rot[0] * pq[0] - rot[1] * pq[1] - rot[2] * pq[2];
28019
+ rayTurnBack[0] = -rayTurn[0];
28020
+ rayTurnBack[1] = -rayTurn[1];
28021
+ rayTurnBack[2] = -rayTurn[2];
28022
+ rayTurnBack[3] = rayTurn[3];
28023
+ rayOrigin[0] = origin[0] - rayCentre[0];
28024
+ rayOrigin[1] = origin[1] - rayCentre[1];
28025
+ rayOrigin[2] = origin[2] - rayCentre[2];
28026
+ rotateVecInto(rayTurnBack, rayOrigin, rayOrigin);
28027
+ rotateVecInto(rayTurnBack, d, rayDirection);
28028
+ if (!rayShapeInto(spec.shape, rayOrigin, rayDirection, rayShapeHit)) return null;
28029
+ rayHit.t0 = rayShapeHit.t0;
28030
+ rayHit.t1 = rayShapeHit.t1;
28031
+ rayHit.n = rotateVecInto(rayTurn, rayShapeHit.n0, rayHitNormal);
28032
+ return rayHit;
28033
+ };
28034
+ const specTurns = /* @__PURE__ */ new WeakMap();
28035
+ const specTurnOf = (ps) => {
28036
+ let turn2 = specTurns.get(ps);
28037
+ if (!turn2) {
28038
+ turn2 = quatFromEuler2(...ps.rotation ?? [0, 0, 0]);
28039
+ specTurns.set(ps, turn2);
28040
+ }
28041
+ return turn2;
28042
+ };
28043
+ const copyOf2 = (v) => [v[0], v[1], v[2]];
28044
+ const objectTurnBack = [0, 0, 0, 1];
28045
+ const objectOrigin = [0, 0, 0];
28046
+ const objectDirection = [0, 0, 0];
27126
28047
  const PART_BOUND_SLACK = 1e-6;
27127
28048
  const raySphereMiss = (origin, d, c, r, maxDist) => {
27128
- const oc = vec.sub(origin, c);
27129
- const b = vec.dot(oc, d);
27130
- const cc = vec.dot(oc, oc) - r * r;
28049
+ const ox = origin[0] - c[0], oy = origin[1] - c[1], oz = origin[2] - c[2];
28050
+ const b = ox * d[0] + oy * d[1] + oz * d[2];
28051
+ const cc = ox * ox + oy * oy + oz * oz - r * r;
27131
28052
  if (cc > 0 && b > 0) return true;
27132
28053
  const disc = b * b - cc;
27133
28054
  if (disc < 0) return true;
@@ -27320,9 +28241,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27320
28241
  if (skip.skipLoose && o.loose || o.br < minRadius) continue;
27321
28242
  if (outside && !outside.mayMeet(o.id)) continue;
27322
28243
  if (raySphereMiss(origin, d, worldCentreOf(o), o.br, best ? Math.min(maxDist, best.distance) : maxDist)) continue;
27323
- const qi = quat.conjugate(o.st.rotation);
27324
- const lo = rotateVec(qi, vec.sub(origin, o.st.position));
27325
- const ld = rotateVec(qi, d);
28244
+ const turn2 = o.st.rotation;
28245
+ objectTurnBack[0] = -turn2[0];
28246
+ objectTurnBack[1] = -turn2[1];
28247
+ objectTurnBack[2] = -turn2[2];
28248
+ objectTurnBack[3] = turn2[3];
28249
+ objectOrigin[0] = origin[0] - o.st.position[0];
28250
+ objectOrigin[1] = origin[1] - o.st.position[1];
28251
+ objectOrigin[2] = origin[2] - o.st.position[2];
28252
+ const lo = rotateVecInto(objectTurnBack, objectOrigin, objectOrigin);
28253
+ const ld = rotateVecInto(objectTurnBack, d, objectDirection);
27326
28254
  for (const p of scope2?.parts.get(o) ?? (counts ? o.parts : partsAlong(o, lo, ld, maxDist))) {
27327
28255
  if (counts) counts.partVisits++;
27328
28256
  if (isLost(p) || ignore?.has(`${o.id}\0${p.spec.id}`)) continue;
@@ -27331,15 +28259,27 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27331
28259
  counts.shapeTests++;
27332
28260
  counts.shapeTested.add(o.id);
27333
28261
  }
27334
- const r = rayPart(o, p, origin, d);
28262
+ const r = rayPartInto(o.st.position, o.st.rotation, p.spec, p.q, origin, d, p.pos);
28263
+ if (r && r.t0 < 0 && r.t1 > 0 && p.st.chipped?.length && inGap(p, toLocal(p.pos, p.q, objLocal(o, origin)))) {
28264
+ r.t0 = 0;
28265
+ r.n = vec.scale(d, -1);
28266
+ }
27335
28267
  if (!r || r.t0 < 0 || r.t0 > maxDist) continue;
27336
28268
  if (p.st.opening && insideOpening(o, p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
27337
28269
  if (p.spec.apertures && throughAperture(p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
27338
- if (p.st.chipped && insideChip(p, objLocal(o, vec.madd(origin, d, Math.min(r.t0 + CHIP_PROBE_DEPTH, (r.t0 + r.t1) / 2))))) {
27339
- passed?.push({ o, p, t: r.t0 });
27340
- continue;
28270
+ const cutBand = !!p.st.chipped && insideChip(p, objLocal(o, vec.madd(origin, d, Math.min(r.t0 + CHIP_PROBE_DEPTH, (r.t0 + r.t1) / 2))));
28271
+ if (cutBand) {
28272
+ if (passed) {
28273
+ passed.push({ o, p, t: r.t0 });
28274
+ continue;
28275
+ }
28276
+ const bar2 = skip.body ? barAlong(o, p, origin, d, r.t0, r.t1) : null;
28277
+ if (bar2 === null) continue;
28278
+ r.t0 = bar2;
28279
+ r.n = vec.scale(d, -1);
27341
28280
  }
27342
- const gap = p.st.chipped?.length ? pastChips(o, p, origin, d, r.t0, r.t1) : null;
28281
+ const entry2 = p.st.chipped?.length && !cutBand ? toLocal(p.pos, p.q, objLocal(o, vec.madd(origin, d, Math.min(r.t0 + CHIP_PROBE_DEPTH, (r.t0 + r.t1) / 2)))) : null;
28282
+ const gap = entry2 ? skip.body && coreStands(p, entry2) ? coreBehind(o, p, origin, d, r.t0, r.t1) : pastChips(o, p, origin, d, r.t0, r.t1) : null;
27343
28283
  if (gap === "through") continue;
27344
28284
  if (gap) {
27345
28285
  r.t0 = gap.t;
@@ -27354,8 +28294,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27354
28294
  }
27355
28295
  if (!best || r.t0 < best.distance) {
27356
28296
  const point = vec.madd(origin, d, r.t0);
27357
- const member = p.castIn ? castMemberAt(o, { p, point, normal: r.n, dir: d, pathLen: r.t1 - r.t0 }, origin, d) : null;
27358
- best = member ? { object: o.id, part: member.p.spec.id, point: member.point, normal: member.normal, distance: r.t0, pathLen: member.pathLen } : { object: o.id, part: p.spec.id, point, normal: r.n, distance: r.t0, pathLen: r.t1 - r.t0 };
28297
+ const normal = copyOf2(r.n);
28298
+ const member = p.castIn ? castMemberAt(o, { p, point, normal, dir: d, pathLen: r.t1 - r.t0 }, origin, d) : null;
28299
+ best = member ? { object: o.id, part: member.p.spec.id, point: member.point, normal: member.normal, distance: r.t0, pathLen: member.pathLen } : { object: o.id, part: p.spec.id, point, normal, distance: r.t0, pathLen: r.t1 - r.t0 };
27359
28300
  }
27360
28301
  }
27361
28302
  }
@@ -27371,13 +28312,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27371
28312
  counts.shapeTested.add(im.impl.id);
27372
28313
  }
27373
28314
  const ov = im.poses.get(ps.id);
27374
- const r = rayPartRaw(im.position, im.rotation, ps, ov?.q ?? quatFromEuler2(...ps.rotation ?? [0, 0, 0]), origin, d, ov?.pos);
28315
+ const r = rayPartInto(im.position, im.rotation, ps, ov?.q ?? specTurnOf(ps), origin, d, ov?.pos ?? ps.position);
27375
28316
  if (!r || r.t1 < 0 || r.t0 > maxDist) continue;
27376
28317
  if (r.t0 < 0) {
27377
- if (precise && im.impl.surfaceRay) boxHit = boxHit ?? { object: im.impl.id, part: ps.id, point: origin, normal: r.n, distance: 0, pathLen: r.t1 };
28318
+ if (precise && im.impl.surfaceRay) boxHit = boxHit ?? { object: im.impl.id, part: ps.id, point: origin, normal: copyOf2(r.n), distance: 0, pathLen: r.t1 };
27378
28319
  continue;
27379
28320
  }
27380
- if (!boxHit || r.t0 < boxHit.distance) boxHit = { object: im.impl.id, part: ps.id, point: vec.madd(origin, d, r.t0), normal: r.n, distance: r.t0, pathLen: r.t1 - r.t0 };
28321
+ if (!boxHit || r.t0 < boxHit.distance) boxHit = { object: im.impl.id, part: ps.id, point: vec.madd(origin, d, r.t0), normal: copyOf2(r.n), distance: r.t0, pathLen: r.t1 - r.t0 };
27381
28322
  }
27382
28323
  if (!boxHit) continue;
27383
28324
  if (precise && im.impl.surfaceRay) {
@@ -27743,10 +28684,6 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27743
28684
  const sides = [0, 1, 2].sort((x, y) => A.max[y] - A.min[y] - (A.max[x] - A.min[x])).slice(0, 2);
27744
28685
  return sides.every((k) => face(k) >= PLATE_BACK_SHARE);
27745
28686
  };
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
28687
  const bondedShareLeft = (p) => {
27751
28688
  const whole2 = p.st.mass + (p.rt.removed ?? 0);
27752
28689
  return whole2 > 0 ? p.st.mass / whole2 : 0;
@@ -27867,6 +28804,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27867
28804
  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])];
27868
28805
  };
27869
28806
  const FRAGMENT_SHAPE = { shatter: "shard", splinter: "splinter", tear: "scrap" };
28807
+ const shardsOfCell = (cell, u, v) => {
28808
+ const own = createRng2(seedOf2(cell.center[0], cell.center[1], cell.center[2]));
28809
+ const cu = SHARD_CUT[0] + (SHARD_CUT[1] - SHARD_CUT[0]) * own.next(), cv = SHARD_CUT[0] + (SHARD_CUT[1] - SHARD_CUT[0]) * own.next();
28810
+ const out = [];
28811
+ for (const [a0, a1] of [[0, cu], [cu, 1]]) for (const [b0, b1] of [[0, cv], [cv, 1]]) {
28812
+ const size = [cell.size[0], cell.size[1], cell.size[2]];
28813
+ const center = [cell.center[0], cell.center[1], cell.center[2]];
28814
+ size[u] = cell.size[u] * (a1 - a0);
28815
+ size[v] = cell.size[v] * (b1 - b0);
28816
+ center[u] = cell.center[u] - cell.size[u] / 2 + cell.size[u] * (a0 + a1) / 2;
28817
+ center[v] = cell.center[v] - cell.size[v] / 2 + cell.size[v] * (b0 + b1) / 2;
28818
+ out.push({ ...cell, center, size });
28819
+ }
28820
+ return out;
28821
+ };
27870
28822
  const cellFragments = (o, p, cells, hitW, dir, speed, mass, tag, inner = false, knownHoles, drive = CHIP_DRIVE) => {
27871
28823
  const { c, q } = partXf(o, p);
27872
28824
  const holes = knownHoles ?? (p.st.holes.length > 0 ? localHolesOf(p) : []);
@@ -27875,7 +28827,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27875
28827
  const total = cells.reduce((sum2, cell) => sum2 + faceArea(cell), 0) || 1;
27876
28828
  const shape = p.spec.units ? "chunk" : FRAGMENT_SHAPE[p.mat.fracture] ?? "chunk";
27877
28829
  const laid = !!p.spec.units && p.spec.units.mortar !== p.spec.material;
27878
- return cells.map((cell, i) => {
28830
+ const pieces = shape === "shard" && bondedPlate(o, p) ? cells.flatMap((cell) => shardsOfCell(cell, u, v)) : cells;
28831
+ return pieces.map((cell, i) => {
27879
28832
  const cw = toWorld(c, q, cell.center);
27880
28833
  const out = vec.normalize(vec.sub(cw, hitW), [0, 1, 0]);
27881
28834
  const dv = dir ? vec.normalize(vec.madd(out, dir, drive)) : out;
@@ -28048,11 +29001,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28048
29001
  const toPart = quat.conjugate(p.q);
28049
29002
  const lo = toLocal(p.pos, p.q, objLocal(o, origin));
28050
29003
  const ld = rotateVec(toPart, objLocalDir(o, d));
28051
- const EPS24 = 1e-4;
29004
+ const EPS33 = 1e-4;
28052
29005
  let t = t0;
28053
29006
  let axis2 = -1;
28054
29007
  for (let step = 0; step < cells.length + 1; step++) {
28055
- const at4 = vec.madd(lo, ld, t + EPS24);
29008
+ const at4 = vec.madd(lo, ld, t + EPS33);
28056
29009
  const cell = cells.find((c) => Math.abs(at4[0] - c.center[0]) <= c.size[0] / 2 && Math.abs(at4[1] - c.center[1]) <= c.size[1] / 2 && Math.abs(at4[2] - c.center[2]) <= c.size[2] / 2);
28057
29010
  if (!cell) break;
28058
29011
  let out = Infinity;
@@ -28065,25 +29018,34 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28065
29018
  axis2 = a;
28066
29019
  }
28067
29020
  }
28068
- if (!Number.isFinite(out) || out >= t1 - EPS24) return "through";
28069
- t = out + 2 * EPS24;
29021
+ if (!Number.isFinite(out) || out >= t1 - EPS33) return "through";
29022
+ t = out + 2 * EPS33;
28070
29023
  }
28071
29024
  if (axis2 < 0) return null;
28072
29025
  const local2 = [0, 0, 0];
28073
29026
  local2[axis2] = -Math.sign(ld[axis2]);
28074
29027
  return { t, n: rotateVec(o.st.rotation, rotateVec(p.q, local2)) };
28075
29028
  };
29029
+ const coreBehind = (o, p, origin, d, t0, t1) => {
29030
+ const gap = pastChips(o, p, origin, d, t0, t1);
29031
+ const core = Math.min(t1, t0 + REBAR_COVER);
29032
+ if (gap === null || gap !== "through" && gap.t <= core) return gap;
29033
+ return { t: core, n: vec.scale(d, -1) };
29034
+ };
29035
+ const inGap = (p, lp) => (p.st.chipped ?? []).some((c) => Math.abs(lp[0] - c.center[0]) <= c.size[0] / 2 && Math.abs(lp[1] - c.center[1]) <= c.size[1] / 2 && Math.abs(lp[2] - c.center[2]) <= c.size[2] / 2);
29036
+ const coreStands = (p, lp) => {
29037
+ if (!p.spec.reinforcement || !isMember(p.dims, p.spec.structure?.role) || p.st.stripped) return false;
29038
+ const along2 = p.dims.indexOf(Math.max(...p.dims));
29039
+ const bands = Math.max(1, Math.round(p.dims[along2] / MEMBER_BAND));
29040
+ const band = clamp2(Math.floor((lp[along2] + p.dims[along2] / 2) / p.dims[along2] * bands), 0, bands - 1);
29041
+ return (p.rt.bands?.[band] ?? 0) < MEMBER_CUT_LOSS;
29042
+ };
28076
29043
  const insideChip = (p, objectPoint) => {
28077
29044
  const cells = p.st.chipped;
28078
29045
  if (!cells?.length) return false;
28079
29046
  const [u, v] = planeAxes(p.thin);
28080
29047
  const lp = toLocal(p.pos, p.q, objectPoint);
28081
- if (p.spec.reinforcement && isMember(p.dims, p.spec.structure?.role) && !p.st.stripped) {
28082
- const along2 = p.dims.indexOf(Math.max(...p.dims));
28083
- const bands = Math.max(1, Math.round(p.dims[along2] / MEMBER_BAND));
28084
- const band = clamp2(Math.floor((lp[along2] + p.dims[along2] / 2) / p.dims[along2] * bands), 0, bands - 1);
28085
- if ((p.rt.bands?.[band] ?? 0) < MEMBER_CUT_LOSS) return false;
28086
- }
29048
+ if (coreStands(p, lp)) return false;
28087
29049
  return cells.some((c) => Math.abs(lp[u] - c.center[u]) <= c.size[u] / 2 && Math.abs(lp[v] - c.center[v]) <= c.size[v] / 2);
28088
29050
  };
28089
29051
  const alongAt = (along2, at4) => {
@@ -28330,18 +29292,20 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28330
29292
  if (reinforcement) exposeRebar(o, p, src);
28331
29293
  if (p.structural) solveStructure(o);
28332
29294
  };
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));
29295
+ const blastReachOf = (p, energy) => {
29296
+ const resistance = Math.max(1, (p.mat.hits?.blunt?.unitJoules ?? chipEnergy) * p.mat.density * p.thickness);
28335
29297
  return BREACH_BLAST_REACH * Math.cbrt(Math.max(0, energy) / 1e3) * clamp2(Math.cbrt(BLAST_REFERENCE_RESISTANCE / resistance), 0.3, 2);
28336
29298
  };
28337
29299
  const blastUnits = (o, p, wp, energy, dist2, src, from) => {
28338
29300
  var _a;
28339
29301
  if (!p.staged && !bondedPlate(o, p) || p.st.stripped || isLost(p) || chipEnergy <= 0) return false;
28340
- const reach2 = blastReachOf(o, p, energy);
29302
+ const reach2 = blastReachOf(p, energy);
28341
29303
  if (dist2 >= reach2) return false;
28342
- const radius = Math.sqrt(reach2 * reach2 - dist2 * dist2);
28343
29304
  const [u, v] = planeAxes(p.thin);
28344
- const lp = toLocal(p.pos, p.q, objLocal(o, wp));
29305
+ const charge2 = from ? toLocal(p.pos, p.q, objLocal(o, from)) : null;
29306
+ const lp = charge2 ?? toLocal(p.pos, p.q, objLocal(o, wp));
29307
+ const off = charge2 ? Math.max(0, Math.abs(charge2[p.thin]) - p.dims[p.thin] / 2) : dist2;
29308
+ const radius = Math.sqrt(Math.max(0, reach2 * reach2 - off * off));
28345
29309
  const op = p.st.opening ? toLocal(p.pos, p.q, p.st.opening.center) : null;
28346
29310
  const grid = gridOf(p);
28347
29311
  const worn = (_a = p.rt).chips ?? (_a.chips = {});
@@ -28623,6 +29587,55 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28623
29587
  emit2({ ...base2(o, src), type: "yield", part: p.spec.id, joint: h.joint, point, toward: rotateVec(o.st.rotation, h.toward), moment: h.moment });
28624
29588
  }
28625
29589
  };
29590
+ const barAlong = (o, p, origin, d, t0, t1) => {
29591
+ const r = p.spec.reinforcement;
29592
+ if (!r || !isMember(p.dims, p.spec.structure?.role)) return null;
29593
+ const along2 = p.dims.indexOf(Math.max(...p.dims));
29594
+ const [u, v] = [0, 1, 2].filter((k) => k !== along2);
29595
+ const lo = toLocal(p.pos, p.q, objLocal(o, origin));
29596
+ const ld = rotateVec(quat.conjugate(p.q), objLocalDir(o, d));
29597
+ const across2 = Math.hypot(ld[u], ld[v]);
29598
+ if (across2 < 1e-6) return null;
29599
+ const cut = p.rt.severedBars ?? [];
29600
+ let best = null;
29601
+ rebarBars(p.dims, p.thin, r.spacing, p.spec.structure?.role).forEach(([a], i) => {
29602
+ if (cut.includes(i)) return;
29603
+ const du = a[u] - lo[u];
29604
+ const dv = a[v] - lo[v];
29605
+ if (Math.abs(du * ld[v] - dv * ld[u]) / across2 > r.diameter / 2) return;
29606
+ const t = (du * ld[u] + dv * ld[v]) / (across2 * across2);
29607
+ if (t >= t0 && t <= t1 && (best === null || t < best)) best = t;
29608
+ });
29609
+ return best;
29610
+ };
29611
+ const cutCageBars = (o, p, origin, d, caliber, src) => {
29612
+ var _a;
29613
+ const r = p.spec.reinforcement;
29614
+ if (!r || isLost(p)) return;
29615
+ const lo = toLocal(p.pos, p.q, objLocal(o, origin));
29616
+ const ld = vec.normalize(rotateVec(quat.conjugate(p.q), objLocalDir(o, d)));
29617
+ const reach2 = r.diameter / 2 + caliber / 2e3;
29618
+ const cut = (_a = p.rt).severedBars ?? (_a.severedBars = []);
29619
+ let severed = 0;
29620
+ rebarBars(p.dims, p.thin, r.spacing, p.spec.structure?.role).forEach(([a, b], i) => {
29621
+ if (cut.includes(i)) return;
29622
+ const near = lineToSegment(lo, ld, a, b);
29623
+ if (!near || near.distance > reach2) return;
29624
+ cut.push(i);
29625
+ severed++;
29626
+ debris2(o, p, "sparks", toWorld(o.st.position, o.st.rotation, toWorld(p.pos, p.q, near.point)), vec.scale(d, -1), 6, 3, src);
29627
+ });
29628
+ if (severed === 0) return;
29629
+ markDamaged(p);
29630
+ if (cageLeft(p) <= 0) {
29631
+ if (p.rt.hinges?.length) reyield(o, p, 0, src);
29632
+ loseCage(o, p, src);
29633
+ return;
29634
+ }
29635
+ if (p.rt.hinges?.length) reyield(o, p, barsMoment(p), src);
29636
+ solveStructure(o);
29637
+ collapseCheck(o, src);
29638
+ };
28626
29639
  const severBars = (o, p, origin, d, caliber, src) => {
28627
29640
  var _a;
28628
29641
  const r = p.spec.reinforcement;
@@ -28722,7 +29735,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28722
29735
  return;
28723
29736
  }
28724
29737
  if (p.bend) settleStructure(o);
28725
- if (!force && p.bend && (p.st.flexure ?? 0) > 1 && sectionOf3(p, p.bend.gravity).reinforced) {
29738
+ if (!force && p.bend && (p.st.flexure ?? 0) > 1 && sectionOf22(p, p.bend.gravity).reinforced) {
28726
29739
  hingeDrop(o, p, src);
28727
29740
  return;
28728
29741
  }
@@ -28937,6 +29950,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28937
29950
  const piece3 = round5.piece;
28938
29951
  const weight = piece3?.weight ?? 1;
28939
29952
  const piercing = round5.piercing ?? 1;
29953
+ if (p.st.stripped && p.spec.reinforcement) cutCageBars(o, p, entry2, d, caliber, src);
28940
29954
  if (p.st.stripped || p.st.opening && insideOpening(o, p, objLocal(o, entry2)) || insideChip(p, objLocal(o, vec.madd(entry2, d, Math.min(CHIP_PROBE_DEPTH, pathLen / 2))))) {
28941
29955
  return { penetrated: true, exitEnergy: E, exitPoint: vec.madd(entry2, d, Math.min(pathLen, p.thickness)), damage: 0 };
28942
29956
  }
@@ -30704,6 +31718,27 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30704
31718
  return st ? clone(st) : null;
30705
31719
  },
30706
31720
  part: (id, partId) => objects.get(id)?.byId.get(partId)?.st ?? impls.get(id)?.impl.state().parts.find((p) => p.id === partId) ?? null,
31721
+ assemblyFlex(id, options2) {
31722
+ const o = objects.get(id);
31723
+ if (!o) return null;
31724
+ const lost = new Set(options2?.lost ?? []);
31725
+ const kept = new Set(o.st.groups[0] ?? []);
31726
+ const framed = o.parts.filter((p) => lost.has(p.spec.id) || kept.has(p.spec.id) && !isLost(p));
31727
+ const ids = new Set(framed.map((p) => p.spec.id));
31728
+ const parts2 = framed.map((p) => ({
31729
+ id: p.spec.id,
31730
+ material: p.mat,
31731
+ dims: p.dims,
31732
+ position: p.pos,
31733
+ rotation: p.q,
31734
+ // a part that went is taken whole, as it was while it held
31735
+ mass: lost.has(p.spec.id) ? p.mass0 : p.st.mass,
31736
+ ...p.spec.grain ? { grain: GRAIN_AXIS[p.spec.grain] } : {},
31737
+ ...p.spec.shape.kind === "cylinder" ? { round: true } : {}
31738
+ }));
31739
+ const joints = o.joints.filter((j) => ids.has(j.spec.a) && ids.has(j.spec.b) && (!j.st.open || lost.has(j.spec.a) || lost.has(j.spec.b))).map((j) => ({ a: j.spec.a, b: j.spec.b, kind: j.spec.kind, position: j.pos }));
31740
+ return assemblyFlex({ parts: parts2, joints, lost: [...lost], ...options2?.loads ? { loads: options2.loads } : {}, ...options2?.friction !== void 0 ? { friction: options2.friction } : {} });
31741
+ },
30707
31742
  reset(id) {
30708
31743
  finishExplosions();
30709
31744
  const im = impls.get(id);
@@ -31699,7 +32734,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
31699
32734
  var BELOW = 0.35;
31700
32735
  var UP = 0.15;
31701
32736
  var END_REACH = 0.35;
31702
- var EPS22 = 1e-6;
32737
+ var EPS23 = 1e-6;
31703
32738
  var HOUSE_SHARING = "all";
31704
32739
  var BEARING = 0.15;
31705
32740
  var JAMB_CLEAR = 0.02;
@@ -31710,7 +32745,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
31710
32745
  const out = [];
31711
32746
  for (const [a, b] of intervals.slice().sort((x, y) => x[0] - y[0])) {
31712
32747
  const last = out[out.length - 1];
31713
- if (last && a <= last[1] + EPS22) last[1] = Math.max(last[1], b);
32748
+ if (last && a <= last[1] + EPS23) last[1] = Math.max(last[1], b);
31714
32749
  else out.push([a, b]);
31715
32750
  }
31716
32751
  return out;
@@ -31881,7 +32916,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
31881
32916
  }
31882
32917
  return { u, v, alongU };
31883
32918
  }
31884
- function sectionOf2(structure, options) {
32919
+ function sectionOf3(structure, options) {
31885
32920
  const unit = structure.construction.walls.unit;
31886
32921
  return typeof unit === "string" ? pillarSectionOf(getMasonryUnit(unit)) : { across: options.columnSide, along: options.columnSide };
31887
32922
  }
@@ -32035,13 +33070,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
32035
33070
  for (const { beam, host } of framings) rest(context, host, beam);
32036
33071
  for (const { part: beam } of beams) {
32037
33072
  const depth = depthToCarry(beam, context, options.beamStep);
32038
- if (depth > beam.y1 - beam.y0 + EPS22) deepen(beam, depth);
33073
+ if (depth > beam.y1 - beam.y0 + EPS23) deepen(beam, depth);
32039
33074
  }
32040
33075
  for (let changed = true, guard = 0; changed && guard < framings.length + 1; guard++) {
32041
33076
  changed = false;
32042
33077
  for (const { beam, host } of framings) {
32043
33078
  const section = sectionDepthAt(host, beam.aabb, context.parts);
32044
- if (section >= depthToHold(host, beam) - EPS22 || section > host.y1 - host.y0 + EPS22) continue;
33079
+ if (section >= depthToHold(host, beam) - EPS23 || section > host.y1 - host.y0 + EPS23) continue;
32045
33080
  deepen(host, depthToHold(host, beam));
32046
33081
  changed = true;
32047
33082
  }
@@ -32100,7 +33135,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
32100
33135
  const [gu0, gv0] = pointOf(line, found.lo);
32101
33136
  const [gu1, gv1] = pointOf(line, found.hi);
32102
33137
  const gap = [Math.min(gu0, gu1) - width / 2, Math.min(gv0, gv1) - width / 2, Math.max(gu0, gu1) + width / 2, Math.max(gv0, gv1) + width / 2];
32103
- if (span > 1.5 && Number.isFinite(span) && sectionDepthAt(plate2, gap, context.parts) < beamDepthFor(span, options) - EPS22) {
33138
+ if (span > 1.5 && Number.isFinite(span) && sectionDepthAt(plate2, gap, context.parts) < beamDepthFor(span, options) - EPS23) {
32104
33139
  const depth = Math.max(plate2.y1 - plate2.y0, beamDepthFor(span, options));
32105
33140
  plate2.y0 = round2(plate2.y1 - depth);
32106
33141
  plate2.mass = Math.max(1, Math.round((plate2.aabb[2] - plate2.aabb[0]) * (plate2.aabb[3] - plate2.aabb[1]) * depth * densityOf(plate2.material)));
@@ -32131,7 +33166,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
32131
33166
  panelsOf: /* @__PURE__ */ new Map(),
32132
33167
  pillars: 0,
32133
33168
  groundBase: firstColumn?.on ?? GROUND,
32134
- section: sectionOf2(structure, options)
33169
+ section: sectionOf3(structure, options)
32135
33170
  };
32136
33171
  const walls = parts2.filter((p) => /^wall_/.test(p.id) && (p.role === "wall" || p.role === "partition"));
32137
33172
  const jobs = [...bonds.map((part) => ({ part, bond: true })), ...slabs.map((part) => ({ part, bond: false }))].sort((a, b) => a.part.y0 - b.part.y0 || Number(b.bond) - Number(a.bond));
@@ -32148,7 +33183,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
32148
33183
  for (const beam of context.parts) {
32149
33184
  if (beam.role !== "beam" || beam.slab === void 0 || !/_b\d+$/.test(beam.id)) continue;
32150
33185
  const depth = depthToCarry(beam, context, options.beamStep);
32151
- if (depth > beam.y1 - beam.y0 + EPS22) deepen(beam, depth);
33186
+ if (depth > beam.y1 - beam.y0 + EPS23) deepen(beam, depth);
32152
33187
  }
32153
33188
  return { parts: context.parts, supports: context.supports };
32154
33189
  }
@@ -44979,7 +46014,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
44979
46014
  ],
44980
46015
  estimated: [
44981
46016
  "parts"
44982
- ]
46017
+ ],
46018
+ consumable: {
46019
+ form: "bar",
46020
+ unit: "g",
46021
+ amount: 100,
46022
+ dose: 1.5,
46023
+ emptyKg: 0
46024
+ }
44983
46025
  },
44984
46026
  {
44985
46027
  id: "shampoo",
@@ -44997,7 +46039,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
44997
46039
  stack: 3,
44998
46040
  shape: "bottle",
44999
46041
  color: 4885200,
45000
- rarity: "common"
46042
+ rarity: "common",
46043
+ consumable: {
46044
+ form: "liquid",
46045
+ unit: "ml",
46046
+ amount: 300,
46047
+ dose: 8,
46048
+ emptyKg: 0.044,
46049
+ density: 1.02
46050
+ }
45001
46051
  },
45002
46052
  {
45003
46053
  id: "toothpaste",
@@ -45015,7 +46065,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
45015
46065
  stack: 3,
45016
46066
  shape: "tube",
45017
46067
  color: 15790320,
45018
- rarity: "common"
46068
+ rarity: "common",
46069
+ consumable: {
46070
+ form: "paste",
46071
+ unit: "g",
46072
+ amount: 90,
46073
+ dose: 1,
46074
+ emptyKg: 0.01
46075
+ }
45019
46076
  },
45020
46077
  {
45021
46078
  id: "toothbrush",
@@ -56539,7 +57596,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56539
57596
  }
56540
57597
  var residentialTower = residentialTowerTemplate();
56541
57598
 
56542
- // ../game-floorplan-three/dist/chunk-Y7TCDFDL.js
57599
+ // ../game-floorplan-three/dist/chunk-RW7ZTU76.js
56543
57600
  var __defProp4 = Object.defineProperty;
56544
57601
  var __defNormalProp2 = (obj, key2, value) => key2 in obj ? __defProp4(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
56545
57602
  var __publicField2 = (obj, key2, value) => __defNormalProp2(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
@@ -61004,21 +62061,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
61004
62061
  const defined = { drainPipes };
61005
62062
  Object.assign(K, defined);
61006
62063
  }
61007
- var EPS23 = 1e-4;
62064
+ var EPS24 = 1e-4;
61008
62065
  function subtractRects(base2, holes) {
61009
62066
  let pieces = [base2];
61010
62067
  for (const h of holes) {
61011
62068
  const next = [];
61012
62069
  for (const r of pieces) {
61013
62070
  const a0 = Math.max(r.a0, h.a0), a1 = Math.min(r.a1, h.a1), y0 = Math.max(r.y0, h.y0), y1 = Math.min(r.y1, h.y1);
61014
- if (a1 - a0 < EPS23 || y1 - y0 < EPS23) {
62071
+ if (a1 - a0 < EPS24 || y1 - y0 < EPS24) {
61015
62072
  next.push(r);
61016
62073
  continue;
61017
62074
  }
61018
- if (a0 - r.a0 > EPS23) next.push({ a0: r.a0, a1: a0, y0: r.y0, y1: r.y1 });
61019
- if (r.a1 - a1 > EPS23) next.push({ a0: a1, a1: r.a1, y0: r.y0, y1: r.y1 });
61020
- if (y0 - r.y0 > EPS23) next.push({ a0, a1, y0: r.y0, y1: y0 });
61021
- if (r.y1 - y1 > EPS23) next.push({ a0, a1, y0: y1, y1: r.y1 });
62075
+ if (a0 - r.a0 > EPS24) next.push({ a0: r.a0, a1: a0, y0: r.y0, y1: r.y1 });
62076
+ if (r.a1 - a1 > EPS24) next.push({ a0: a1, a1: r.a1, y0: r.y0, y1: r.y1 });
62077
+ if (y0 - r.y0 > EPS24) next.push({ a0, a1, y0: r.y0, y1: y0 });
62078
+ if (r.y1 - y1 > EPS24) next.push({ a0, a1, y0: y1, y1: r.y1 });
61022
62079
  }
61023
62080
  pieces = next;
61024
62081
  }
@@ -61034,7 +62091,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
61034
62091
  const across0 = wall.alongU ? v0 : u0, across1 = wall.alongU ? v1 : u1;
61035
62092
  const half = wall.thickness / 2;
61036
62093
  const covered = Math.min(across1, wall.line + half) - Math.max(across0, wall.line - half);
61037
- if (covered < Math.min(wall.thickness * 0.3, across1 - across0) - EPS23) return null;
62094
+ if (covered < Math.min(wall.thickness * 0.3, across1 - across0) - EPS24) return null;
61038
62095
  return wall.alongU ? { a0: u0, a1: u1, y0, y1 } : { a0: v0, a1: v1, y0, y1 };
61039
62096
  }
61040
62097
  function addStageBox(THREE, parent, x0, y0, z0, x1, y1, z1, mat, partId) {
@@ -66372,18 +67429,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
66372
67429
  if (list2) mesh3.userData.collapsedRanges = list2.filter((r) => r[0] !== v0);
66373
67430
  withdrawSolids(mesh3, v0);
66374
67431
  }
67432
+ var hash2 = (i, j) => {
67433
+ const s = Math.sin(i * 127.1 + j * 311.7) * 43758.5453;
67434
+ return s - Math.floor(s);
67435
+ };
66375
67436
  function noise2(x, y, cell) {
66376
- const h = (i2, j2) => {
66377
- const s = Math.sin(i2 * 127.1 + j2 * 311.7) * 43758.5453;
66378
- return s - Math.floor(s);
66379
- };
66380
67437
  const fx = x / cell, fy = y / cell, i = Math.floor(fx), j = Math.floor(fy), u = fx - i, v = fy - j;
66381
67438
  const su = u * u * (3 - 2 * u), sv = v * v * (3 - 2 * v);
66382
- return (h(i, j) * (1 - su) + h(i + 1, j) * su) * (1 - sv) + (h(i, j + 1) * (1 - su) + h(i + 1, j + 1) * su) * sv;
67439
+ return (hash2(i, j) * (1 - su) + hash2(i + 1, j) * su) * (1 - sv) + (hash2(i, j + 1) * (1 - su) + hash2(i + 1, j + 1) * su) * sv;
66383
67440
  }
66384
67441
  var MASK_TEXEL = 0.02;
66385
67442
  var SPALL_MIN = 0.025;
66386
67443
  var SPALL_RAGGED = 0.045;
67444
+ var PLASTER_REACH = { least: SPALL_MIN, band: SPALL_RAGGED };
66387
67445
  var COVER2 = 0.015;
66388
67446
  var LUMP_BAR_INSET = 0.035;
66389
67447
  var LUMPS_PER_BAR = 1;
@@ -66879,7 +67937,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
66879
67937
  mask.data.fill(0);
66880
67938
  core.data.fill(0);
66881
67939
  const stamp = (m, s0, s1, y0, y1, inside22) => stampMask(m, { s0, s1, y0, y1, reach: reach2 }, inside22);
66882
- const plaster = (d, s, y) => isPlasterGone(d, { least: SPALL_MIN, band: SPALL_RAGGED }, () => ragged(s, y));
67940
+ const texel = { s: 0, y: 0 };
67941
+ const raggedAtTexel = () => ragged(texel.s, texel.y);
67942
+ const coreNoiseAtTexel = () => noise2(texel.s * 1.7, texel.y * 1.3, 0.012);
67943
+ const plaster = (d, s, y) => {
67944
+ texel.s = s;
67945
+ texel.y = y;
67946
+ return isPlasterGone(d, PLASTER_REACH, raggedAtTexel);
67947
+ };
67948
+ const coreThrough = (distance4, depth, s, y) => {
67949
+ texel.s = s;
67950
+ texel.y = y;
67951
+ return isCoreThrough(distance4, depth, coreNoiseAtTexel);
67952
+ };
66883
67953
  for (const c of holes) stamp(mask, c.a, c.b, c.y0, c.y1, (s, y) => plaster(boxDistance(s, y, c.a, c.b, c.y0, c.y1), s, y));
66884
67954
  for (const d of discs) stamp(mask, d.s - d.r, d.s + d.r, d.y - d.r, d.y + d.r, (s, y) => plaster(Math.max(0, Math.hypot(s - d.s, y - d.y) - d.r), s, y));
66885
67955
  for (const f of flakes) {
@@ -66888,7 +67958,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
66888
67958
  }
66889
67959
  for (const p of pits) {
66890
67960
  stamp(mask, p.s - p.rs, p.s + p.rs, p.y - p.ry, p.y + p.ry, (s, y) => plaster(Math.max(0, ellipseDistance(s, y, p.s, p.y, p.rs, p.ry)), s, y));
66891
- stamp(core, p.s - p.rs, p.s + p.rs, p.y - p.ry, p.y + p.ry, (s, y) => isCoreThrough(ellipseDistance(s, y, p.s, p.y, p.rs, p.ry), 0.35 * Math.min(p.rs, p.ry), () => noise2(s * 1.7, y * 1.3, 0.012)));
67961
+ stamp(core, p.s - p.rs, p.s + p.rs, p.y - p.ry, p.y + p.ry, (s, y) => coreThrough(ellipseDistance(s, y, p.s, p.y, p.rs, p.ry), 0.35 * Math.min(p.rs, p.ry), s, y));
66892
67962
  }
66893
67963
  for (const q of pillars) {
66894
67964
  const i0 = Math.max(0, Math.floor((q.a + 5e-3) / mask.len * mask.w)), i1 = Math.min(mask.w - 1, Math.floor((q.b - 5e-3) / mask.len * mask.w));
@@ -67632,7 +68702,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
67632
68702
  const left = breach.standing(part.id);
67633
68703
  if (!left) return true;
67634
68704
  const s0 = (left.alongU ? lx : lz) - left.start;
67635
- if (left.spans.some((c) => c.b > s0 - radius && c.a < s0 + radius && c.y1 > Math.min(ly0, ly1) && c.y0 < Math.max(ly0, ly1))) return true;
68705
+ const low1 = Math.min(ly0, ly1), high1 = Math.max(ly0, ly1);
68706
+ for (const c of left.spans) if (c.b > s0 - radius && c.a < s0 + radius && c.y1 > low1 && c.y0 < high1) return true;
67636
68707
  }
67637
68708
  return false;
67638
68709
  };
@@ -69258,7 +70329,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
69258
70329
  var HOLD_REACH2 = 0.05;
69259
70330
  var BACK_TOUCH = 0.02;
69260
70331
  var AGAINST_WALL = 0.1;
69261
- var SOFT = /* @__PURE__ */ new Set(["fabric", "paper", "foliage"]);
70332
+ var SOFT2 = /* @__PURE__ */ new Set(["fabric", "paper", "foliage"]);
69262
70333
  var gapOf = (a, b) => Math.max(0, ...[0, 1, 2].map((k) => Math.max(a.min[k] - b.max[k], b.min[k] - a.max[k])));
69263
70334
  function groupsOf(parts2, joints) {
69264
70335
  const root = new Map(parts2.map((part) => [part.id, part.id]));
@@ -69329,7 +70400,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
69329
70400
  continue;
69330
70401
  }
69331
70402
  const againstWall = held.length === 0 || held.some((part) => boxOf4(part.id).min[2] <= back2 + AGAINST_WALL);
69332
- const onWall = againstWall ? group.filter((part) => !SOFT.has(part.material) && boxOf4(part.id).min[2] <= back2 + BACK_TOUCH) : [];
70403
+ const onWall = againstWall ? group.filter((part) => !SOFT2.has(part.material) && boxOf4(part.id).min[2] <= back2 + BACK_TOUCH) : [];
69333
70404
  if (onWall.length === 0) continue;
69334
70405
  for (const part of onWall) part.anchored = true;
69335
70406
  changed = true;
@@ -90672,7 +91743,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
90672
91743
  var MAX_CASINGS = 120;
90673
91744
  var MAX_MAGAZINES = 12;
90674
91745
  var LIFETIME_S = 25;
90675
- var GRAVITY2 = 9.81;
91746
+ var GRAVITY3 = 9.81;
90676
91747
  function createBoxFx(options) {
90677
91748
  const { THREE, scene, camera: camera2, arsenal, groundAt } = options;
90678
91749
  const audio = options.audio ?? null;
@@ -90843,7 +91914,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
90843
91914
  const stepBody = (body, dt) => {
90844
91915
  body.age += dt;
90845
91916
  if (body.resting) return;
90846
- body.velocity.y -= GRAVITY2 * dt;
91917
+ body.velocity.y -= GRAVITY3 * dt;
90847
91918
  body.mesh.position.addScaledVector(body.velocity, dt);
90848
91919
  body.mesh.rotation.x += body.spin.x * dt;
90849
91920
  body.mesh.rotation.y += body.spin.y * dt;
@@ -93426,6 +94497,57 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
93426
94497
  return lehmer(mixEventSeed(eventSeed));
93427
94498
  }
93428
94499
  var SKIN = 5e-3;
94500
+ var Solids = class {
94501
+ constructor() {
94502
+ __publicField3(this, "queries", /* @__PURE__ */ new Map());
94503
+ __publicField3(this, "list", []);
94504
+ __publicField3(this, "hit", { x: 0, y: 0, z: 0, nx: 0, ny: 0, nz: 0 });
94505
+ }
94506
+ get empty() {
94507
+ return this.list.length === 0;
94508
+ }
94509
+ /** Declares or (with `null`) ends the solids `id` answers for. */
94510
+ set(id, query2) {
94511
+ if (query2) this.queries.set(id, query2);
94512
+ else this.queries.delete(id);
94513
+ this.list = [...this.queries.values()];
94514
+ }
94515
+ clear() {
94516
+ this.queries.clear();
94517
+ this.list = [];
94518
+ }
94519
+ /**
94520
+ * Stops a step that goes into a solid: `out` gets the nearest hit, put back `pad` metres off the surface (never behind where the step began) and
94521
+ * the surface's normal. Answers whether the step was stopped.
94522
+ */
94523
+ stop(move2, pad, out) {
94524
+ const dx = move2.x1 - move2.x0;
94525
+ const dy = move2.y1 - move2.y0;
94526
+ const dz = move2.z1 - move2.z0;
94527
+ const length2 = Math.hypot(dx, dy, dz);
94528
+ if (!(length2 > 0)) return false;
94529
+ let nearest = Infinity;
94530
+ for (const query2 of this.list) {
94531
+ if (!query2(move2, this.hit)) continue;
94532
+ const reached = ((this.hit.x - move2.x0) * dx + (this.hit.y - move2.y0) * dy + (this.hit.z - move2.z0) * dz) / length2;
94533
+ if (reached >= nearest) continue;
94534
+ nearest = reached;
94535
+ out.x = this.hit.x;
94536
+ out.y = this.hit.y;
94537
+ out.z = this.hit.z;
94538
+ out.nx = this.hit.nx;
94539
+ out.ny = this.hit.ny;
94540
+ out.nz = this.hit.nz;
94541
+ }
94542
+ if (nearest === Infinity) return false;
94543
+ const back2 = Math.min(Math.max(pad, 0) + SKIN, Math.max(nearest, 0));
94544
+ out.x -= dx / length2 * back2;
94545
+ out.y -= dy / length2 * back2;
94546
+ out.z -= dz / length2 * back2;
94547
+ return true;
94548
+ }
94549
+ };
94550
+ var SKIN2 = 5e-3;
93429
94551
  var MAX_PAD = 0.45;
93430
94552
  function rotation(q) {
93431
94553
  const [x, y, z, w] = q ?? [0, 0, 0, 1];
@@ -93457,10 +94579,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
93457
94579
  __publicField3(this, "q", new Float64Array(3));
93458
94580
  __publicField3(this, "h", new Float64Array(3));
93459
94581
  __publicField3(this, "move", { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 });
94582
+ __publicField3(this, "solids", new Solids());
93460
94583
  this.random = lehmer(seed);
93461
94584
  }
93462
94585
  get empty() {
93463
- return this.list.length === 0;
94586
+ return this.list.length === 0 && this.solids.empty;
94587
+ }
94588
+ /** Declares or (with `null`) ends the host solids `id` answers for (a destruction world's walls): what is carried stops at them and passes only their holes. */
94589
+ solid(id, query2) {
94590
+ this.solids.set(id, query2);
93464
94591
  }
93465
94592
  get size() {
93466
94593
  return this.list.length;
@@ -93543,6 +94670,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
93543
94670
  return this.confineMove(move2, dt);
93544
94671
  }
93545
94672
  confineMove(move2, dt) {
94673
+ if (this.confineSpaces(move2, dt)) return true;
94674
+ return !this.solids.empty && this.solids.stop(move2, Math.min(Math.max(0, move2.pad), MAX_PAD), this.out);
94675
+ }
94676
+ confineSpaces(move2, dt) {
93546
94677
  const list2 = this.list;
93547
94678
  if (list2.length === 0) return false;
93548
94679
  const { x0, y0, z0, x1, y1, z1 } = move2;
@@ -93583,7 +94714,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
93583
94714
  }
93584
94715
  }
93585
94716
  sign2 = l1[axis2] < 0 ? -1 : 1;
93586
- for (let a = 0; a < 3; a++) l1[a] = Math.min(h[a] - SKIN, Math.max(-(h[a] - SKIN), l1[a]));
94717
+ for (let a = 0; a < 3; a++) l1[a] = Math.min(h[a] - SKIN2, Math.max(-(h[a] - SKIN2), l1[a]));
93587
94718
  sign2 = -sign2;
93588
94719
  } else {
93589
94720
  const padded0 = Math.abs(l0[0]) <= s.hx + p && Math.abs(l0[1]) <= s.hy + p && Math.abs(l0[2]) <= s.hz + p;
@@ -93600,7 +94731,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
93600
94731
  }
93601
94732
  }
93602
94733
  sign2 = l0[axis2] < 0 ? -1 : 1;
93603
- l1[axis2] = sign2 * (h[axis2] + bound + SKIN);
94734
+ l1[axis2] = sign2 * (h[axis2] + bound + SKIN2);
93604
94735
  }
93605
94736
  const r = s.r;
93606
94737
  const out = this.out;
@@ -94483,7 +95614,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
94483
95614
  var BODY_Z2 = BODIES.map(([, z]) => z);
94484
95615
  var FACING = BODIES.map(([x, z]) => Math.atan2(-x, -z));
94485
95616
  var FUSE = 1.8;
94486
- var GRAVITY3 = 9.8;
95617
+ var GRAVITY4 = 9.8;
94487
95618
  var FLOOR = 0.07;
94488
95619
  var BOUNCE = -0.4;
94489
95620
  var SIDE_LOSS = 0.5;
@@ -94513,7 +95644,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
94513
95644
  ],
94514
95645
  tick: [
94515
95646
  when(lt(TIME, FUSE), [
94516
- set("vy", sub(variable("vy"), mul(GRAVITY3, DELTA))),
95647
+ set("vy", sub(variable("vy"), mul(GRAVITY4, DELTA))),
94517
95648
  set("px", add(variable("px"), mul(variable("vx"), DELTA))),
94518
95649
  set("py", add(variable("py"), mul(variable("vy"), DELTA))),
94519
95650
  set("pz", add(variable("pz"), mul(variable("vz"), DELTA))),
@@ -97587,6 +98718,24 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
97587
98718
  screen2.flashDecay = 0.5;
97588
98719
  }
97589
98720
  }
98721
+ var BIRTH = { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 };
98722
+ function bornFrom(core, puff3, ox, oy, oz) {
98723
+ const confiner = core.confiner;
98724
+ if (confiner.empty) return;
98725
+ BIRTH.x0 = ox;
98726
+ BIRTH.y0 = oy;
98727
+ BIRTH.z0 = oz;
98728
+ BIRTH.x1 = puff3.x;
98729
+ BIRTH.y1 = puff3.y;
98730
+ BIRTH.z1 = puff3.z;
98731
+ BIRTH.pad = puff3.s0 * PAD_OF_SIZE;
98732
+ if (!confiner.confineMove(BIRTH, 0)) return;
98733
+ const out = confiner.out;
98734
+ puff3.x = out.x;
98735
+ puff3.y = out.y;
98736
+ puff3.z = out.z;
98737
+ slideInto(out, puff3);
98738
+ }
97590
98739
  function composeFireballs(context) {
97591
98740
  const { core, def, random, x, y, z, size, scale, direction } = context;
97592
98741
  if (!core.layers.fire || !def.fireballs) return;
@@ -97603,7 +98752,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
97603
98752
  const life = random.between(def.smoke.life * 0.7, def.smoke.life);
97604
98753
  const h0 = random.between(1.05, 1.35) * heat;
97605
98754
  const hl = fuel ? random.between(0.8, 1.4) * (def.heatLifeScale ?? 1) : random.between(0.22, 0.42);
97606
- addPuff(core, random, {
98755
+ const fireball = addPuff(core, random, {
97607
98756
  x: x + d.x * size * 0.15,
97608
98757
  y: y + size * 0.25 + d.y * size * 0.1,
97609
98758
  z: z + d.z * size * 0.15,
@@ -97622,6 +98771,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
97622
98771
  color: context.smokeColor,
97623
98772
  kind: 0
97624
98773
  });
98774
+ bornFrom(core, fireball, x, y, z);
97625
98775
  }
97626
98776
  }
97627
98777
  function composeSmoke(context) {
@@ -97635,7 +98785,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
97635
98785
  const s1 = size * random.between(0.55, 0.85);
97636
98786
  const sg = size * random.between(0.18, 0.3);
97637
98787
  const life = random.between(def.smoke.life * 0.7, def.smoke.life * 1.1);
97638
- addPuff(core, random, {
98788
+ const smoke = addPuff(core, random, {
97639
98789
  x: x + d.x * size * 0.6,
97640
98790
  y: y + size * 0.4 + d.y * size * 0.5,
97641
98791
  z: z + d.z * size * 0.6,
@@ -97654,6 +98804,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
97654
98804
  color: context.smokeColor,
97655
98805
  kind: def.smoke.kind ?? 0
97656
98806
  });
98807
+ bornFrom(core, smoke, x, y, z);
97657
98808
  }
97658
98809
  }
97659
98810
  function composeShock(context) {
@@ -97678,7 +98829,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
97678
98829
  const s1 = size * random.between(0.5, 0.8);
97679
98830
  const sg = size * random.between(0.2, 0.35);
97680
98831
  const life = random.between(2.2, 4);
97681
- addPuff(core, random, {
98832
+ const dust = addPuff(core, random, {
97682
98833
  x: x + Math.cos(angle) * 0.3,
97683
98834
  y: 0.15,
97684
98835
  z: z + Math.sin(angle) * 0.3,
@@ -97695,6 +98846,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
97695
98846
  color: color2,
97696
98847
  kind: 1
97697
98848
  });
98849
+ bornFrom(core, dust, x, 0.15, z);
97698
98850
  }
97699
98851
  }
97700
98852
  function coneAngle(context) {
@@ -99766,6 +100918,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
99766
100918
  });
99767
100919
  const core = {
99768
100920
  profile,
100921
+ confiner: enclosures,
99769
100922
  puffs: createPuffPool(profile.puffs),
99770
100923
  sparks: createSparkPool(profile.sparks),
99771
100924
  glows: createGlowPool(profile.glows),
@@ -99906,6 +101059,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
99906
101059
  enclose(id, enclosure) {
99907
101060
  enclosures.set(id, enclosure);
99908
101061
  },
101062
+ solid(id, query2) {
101063
+ enclosures.solid(id, query2);
101064
+ },
99909
101065
  enclosures: () => enclosures,
99910
101066
  stop(handle) {
99911
101067
  player?.stop(handle);
@@ -100013,7 +101169,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
100013
101169
  }
100014
101170
  var DEGREES = 180 / Math.PI;
100015
101171
 
100016
- // ../game-vfx-three/dist/chunk-BLUUVMCE.js
101172
+ // ../game-vfx-three/dist/chunk-KIZDMENO.js
100017
101173
  var GLOW_VERTEX = `attribute vec4 aP;attribute vec4 aC;varying vec2 vU;varying vec4 vC;
100018
101174
  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]);
100019
101175
  vec3 wp=aP.xyz+(R*position.x+Up*position.y)*aP.w;vU=position.xy;vC=aC;gl_Position=projectionMatrix*viewMatrix*vec4(wp,1.);}`;
@@ -100846,6 +102002,7 @@ void main(){
100846
102002
  }
100847
102003
  };
100848
102004
  }
102005
+ var SHOWN_FIELDS = 6;
100849
102006
  var clamp5 = (value, min2, max2) => value < min2 ? min2 : value > max2 ? max2 : value;
100850
102007
  function layer2(container, name, blend) {
100851
102008
  const element = container.ownerDocument.createElement("div");
@@ -100863,8 +102020,20 @@ void main(){
100863
102020
  const sides = layer2(container, "sides");
100864
102021
  const gas = layer2(container, "gas");
100865
102022
  const elements = [flash2, white, red, sides, gas];
102023
+ const shown = new Float64Array(SHOWN_FIELDS).fill(Number.NaN);
102024
+ const isShown2 = (state) => {
102025
+ const same = shown[0] === state.flash && shown[1] === state.white && shown[2] === state.red && shown[3] === state.directionLeft && shown[4] === state.directionRight && shown[5] === state.gas;
102026
+ shown[0] = state.flash;
102027
+ shown[1] = state.white;
102028
+ shown[2] = state.red;
102029
+ shown[3] = state.directionLeft;
102030
+ shown[4] = state.directionRight;
102031
+ shown[5] = state.gas;
102032
+ return same;
102033
+ };
100866
102034
  return {
100867
102035
  update(state) {
102036
+ if (isShown2(state)) return;
100868
102037
  flash2.style.opacity = clamp5(state.flash, 0, 1).toFixed(3);
100869
102038
  white.style.opacity = "1";
100870
102039
  white.style.background = `rgba(235,240,255,${clamp5(state.white, 0, 1).toFixed(2)})`;
@@ -105431,7 +106600,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
105431
106600
  var AFTERMATH_DELAY = 2;
105432
106601
  var SHOOTER = "pistol_9mm";
105433
106602
  var AIM_HEIGHT = 0.2;
105434
- var GRAVITY4 = 9.81;
106603
+ var GRAVITY5 = 9.81;
105435
106604
  var REPORTED_OBJECTS = ["fridge", "kitchen_cabinet_base", "stove", "camp_table"];
105436
106605
  var RING_SEGMENTS = 128;
105437
106606
  var WALL_ID = "target_wall";
@@ -105580,7 +106749,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
105580
106749
  for (const shell of shells) {
105581
106750
  if (shell.landed) continue;
105582
106751
  shell.age += dt;
105583
- shell.velocity[1] -= GRAVITY4 * dt;
106752
+ shell.velocity[1] -= GRAVITY5 * dt;
105584
106753
  for (let axis2 = 0; axis2 < 3; axis2++) shell.position[axis2] = shell.position[axis2] + shell.velocity[axis2] * dt;
105585
106754
  const ground = host.groundAt(shell.position[0], shell.position[2]) + 0.18;
105586
106755
  if (shell.position[1] <= ground && shell.velocity[1] < 0) {