@adatechnology/game-weapons-three 0.11.2 → 0.11.3

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.
@@ -19527,9 +19527,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19527
19527
  const tz = 2 * (qx * v[1] - qy * v[0]);
19528
19528
  return [v[0] + qw * tx + (qy * tz - qz * ty), v[1] + qw * ty + (qz * tx - qx * tz), v[2] + qw * tz + (qx * ty - qy * tx)];
19529
19529
  };
19530
- var toLocal = (position, rotation, p) => rotateVec([-rotation[0], -rotation[1], -rotation[2], rotation[3]], [p[0] - position[0], p[1] - position[1], p[2] - position[2]]);
19531
- var toWorld = (position, rotation, p) => {
19532
- const r = rotateVec(rotation, p);
19530
+ var toLocal = (position, rotation2, p) => rotateVec([-rotation2[0], -rotation2[1], -rotation2[2], rotation2[3]], [p[0] - position[0], p[1] - position[1], p[2] - position[2]]);
19531
+ var toWorld = (position, rotation2, p) => {
19532
+ const r = rotateVec(rotation2, p);
19533
19533
  return [r[0] + position[0], r[1] + position[1], r[2] + position[2]];
19534
19534
  };
19535
19535
  var shapeDims = (s) => {
@@ -19934,8 +19934,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19934
19934
  };
19935
19935
  var cellsOutside = (cells, thin, point, radius) => cells.filter((c) => planeDistance(c, thin, point) > radius);
19936
19936
  var MAX_MARKS_PER_FRAGMENT = 12;
19937
- var marksInBox = (center, size, rotation, holes) => {
19938
- const inverse = rotation ? quat.conjugate(rotation) : void 0;
19937
+ var marksInBox = (center, size, rotation2, holes) => {
19938
+ const inverse = rotation2 ? quat.conjugate(rotation2) : void 0;
19939
19939
  const marks = [];
19940
19940
  for (const hole of holes) {
19941
19941
  const offset = [hole.point[0] - center[0], hole.point[1] - center[1], hole.point[2] - center[2]];
@@ -22529,8 +22529,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
22529
22529
  }
22530
22530
  solveStructure(o);
22531
22531
  if (peak <= sec.steel) return;
22532
- const rotation = (elasticEnergy(peak, L, EI, flexure.loadFactor) - elasticEnergy(sec.steel, L, EI, flexure.loadFactor)) / (2 * sec.steel);
22533
- p.rt.hinge = (p.rt.hinge ?? 0) + rotation;
22532
+ const rotation2 = (elasticEnergy(peak, L, EI, flexure.loadFactor) - elasticEnergy(sec.steel, L, EI, flexure.loadFactor)) / (2 * sec.steel);
22533
+ p.rt.hinge = (p.rt.hinge ?? 0) + rotation2;
22534
22534
  markDamaged(p);
22535
22535
  if (p.rt.hinge >= flexure.failRotationDeg * Math.PI / 180) hingeDrop(o, p, src);
22536
22536
  };
@@ -23232,8 +23232,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23232
23232
  const detachEvents = (o, opened, by, src) => {
23233
23233
  for (const j of opened) emit2({ ...base(o, src), type: "detach", joint: j.spec.id, parts: [j.spec.a, j.spec.b], by, groups: o.st.groups.map((g) => [...g]) });
23234
23234
  };
23235
- const slideOffResting = (o, rotation) => {
23236
- const upY = 1 - 2 * (rotation[0] * rotation[0] + rotation[2] * rotation[2]);
23235
+ const slideOffResting = (o, rotation2) => {
23236
+ const upY = 1 - 2 * (rotation2[0] * rotation2[0] + rotation2[2] * rotation2[2]);
23237
23237
  if (upY >= RESTING_HOLD_COS) return;
23238
23238
  const opened = o.joints.filter((j) => j.spec.kind === "resting" && !j.st.open);
23239
23239
  if (opened.length === 0) return;
@@ -24656,11 +24656,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24656
24656
  impls.set(id, { impl, position: opts.position ?? [0, 0, 0], rotation: opts.rotation ?? [0, 0, 0, 1], poses: /* @__PURE__ */ new Map() });
24657
24657
  return id;
24658
24658
  },
24659
- setPartPose(objectId, partId, position, rotation) {
24660
- const q = quatFromEuler(...rotation ?? [0, 0, 0]);
24659
+ setPartPose(objectId, partId, position, rotation2) {
24660
+ const q = quatFromEuler(...rotation2 ?? [0, 0, 0]);
24661
24661
  const im = impls.get(objectId);
24662
24662
  if (im) {
24663
- im.impl.setPartPose?.(partId, position, rotation);
24663
+ im.impl.setPartPose?.(partId, position, rotation2);
24664
24664
  im.poses.set(partId, { pos: [position[0], position[1], position[2]], q });
24665
24665
  return;
24666
24666
  }
@@ -24677,17 +24677,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24677
24677
  },
24678
24678
  has: (id) => taken(id),
24679
24679
  ids: () => [...objects.keys(), ...impls.keys()],
24680
- setTransform(id, position, rotation) {
24680
+ setTransform(id, position, rotation2) {
24681
24681
  const im = impls.get(id);
24682
24682
  if (im) {
24683
24683
  im.position = [position[0], position[1], position[2]];
24684
- im.rotation = [rotation[0], rotation[1], rotation[2], rotation[3]];
24684
+ im.rotation = [rotation2[0], rotation2[1], rotation2[2], rotation2[3]];
24685
24685
  return;
24686
24686
  }
24687
24687
  const o = getObj(id);
24688
- o.base = { pos: [position[0], position[1], position[2]], rot: [rotation[0], rotation[1], rotation[2], rotation[3]] };
24688
+ o.base = { pos: [position[0], position[1], position[2]], rot: [rotation2[0], rotation2[1], rotation2[2], rotation2[3]] };
24689
24689
  applySoilPose(o);
24690
- slideOffResting(o, rotation);
24690
+ slideOffResting(o, rotation2);
24691
24691
  },
24692
24692
  splitGroup(id, group, newId) {
24693
24693
  if (impls.has(id)) throw new Error(`object "${id}" is a registered DestructibleImpl and cannot be split; its module owns its pieces`);
@@ -35942,12 +35942,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
35942
35942
  }
35943
35943
  const n = counters.get(key2) ?? 0;
35944
35944
  counters.set(key2, n + 1);
35945
- let rotation = null;
35945
+ let rotation2 = null;
35946
35946
  if (turned) {
35947
35947
  xyz.setFromQuaternion(q, "XYZ");
35948
- rotation = [xyz.x, xyz.y, xyz.z];
35948
+ rotation2 = [xyz.x, xyz.y, xyz.z];
35949
35949
  }
35950
- drawn.push({ id: `${key2}_${n}`, key: key2, shape, position: [px - root.x, py, pz - root.z], rotation, color: color2, min: min2, max: max2 });
35950
+ drawn.push({ id: `${key2}_${n}`, key: key2, shape, position: [px - root.x, py, pz - root.z], rotation: rotation2, color: color2, min: min2, max: max2 });
35951
35951
  };
35952
35952
  const A = {
35953
35953
  box(M, mat, x, y, z, bw, bh, bd, color2, ry = 0, rx = 0, rz = 0) {
@@ -39914,10 +39914,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
39914
39914
  materials.push(material);
39915
39915
  return material;
39916
39916
  };
39917
- const mesh3 = (geometry, material, position = [0, 0, 0], rotation = [0, 0, 0], scale) => {
39917
+ const mesh3 = (geometry, material, position = [0, 0, 0], rotation2 = [0, 0, 0], scale) => {
39918
39918
  const object2 = new T2.Mesh(geometry, material);
39919
39919
  object2.position.set(...position);
39920
- object2.rotation.set(...rotation);
39920
+ object2.rotation.set(...rotation2);
39921
39921
  if (scale) object2.scale.set(...scale);
39922
39922
  return object2;
39923
39923
  };
@@ -44194,8 +44194,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
44194
44194
  return G(
44195
44195
  mesh3(bx(0.9, 1.3, 0.46), wood(4861979), [0, 0.35, 0]),
44196
44196
  mesh3(bx(0.92, 0.5, 0.5), cloth2(2829099), [0, 0.1, 0]),
44197
- ...limbs.map(([geometry, position, rotation]) => mesh3(geometry, limbMaterial, [...position], [...rotation])),
44198
- ...strings.map(([geometry, position, rotation]) => mesh3(geometry, stringMaterial, [...position], [...rotation]))
44197
+ ...limbs.map(([geometry, position, rotation2]) => mesh3(geometry, limbMaterial, [...position], [...rotation2])),
44198
+ ...strings.map(([geometry, position, rotation2]) => mesh3(geometry, stringMaterial, [...position], [...rotation2]))
44199
44199
  );
44200
44200
  };
44201
44201
  var crossbow = ({ mesh: mesh3, bx, G, wood, metal: metal2, cloth: cloth2 }) => {
@@ -44252,8 +44252,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
44252
44252
  return G(
44253
44253
  mesh3(cyl(0.12, 0.1, 0.65, 8), frame2, [0, -0.425, 0]),
44254
44254
  mesh3(cyl(0.126, 0.126, 0.3, 8), cloth2(8007455), [0, -0.5, 0]),
44255
- ...arms.map(([geometry, position, rotation]) => mesh3(geometry, frame2, [...position], [...rotation])),
44256
- ...bands.map(([geometry, position, rotation]) => mesh3(geometry, band, [...position], [...rotation])),
44255
+ ...arms.map(([geometry, position, rotation2]) => mesh3(geometry, frame2, [...position], [...rotation2])),
44256
+ ...bands.map(([geometry, position, rotation2]) => mesh3(geometry, band, [...position], [...rotation2])),
44257
44257
  mesh3(bx(0.26, 0.2, 0.05), cloth2(9067061), [0, 0.2, 0])
44258
44258
  );
44259
44259
  };
@@ -52044,11 +52044,231 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52044
52044
  glow.outIntensity = glow.i * Math.pow(1 - age, glow.curve) * flicker;
52045
52045
  }
52046
52046
  }
52047
+ var LEHMER_MULTIPLIER = 16807;
52048
+ var LEHMER_MODULUS = 2147483647;
52049
+ var HASH_MIX = 2654435761;
52050
+ function normalizeLehmerSeed(seed) {
52051
+ const whole = Math.floor(Math.abs(seed)) % (LEHMER_MODULUS - 1);
52052
+ return whole === 0 ? 1 : whole;
52053
+ }
52054
+ function lehmer(seed) {
52055
+ let state = normalizeLehmerSeed(seed);
52056
+ const next = () => {
52057
+ state = state * LEHMER_MULTIPLIER % LEHMER_MODULUS;
52058
+ return (state - 1) / (LEHMER_MODULUS - 1);
52059
+ };
52060
+ return {
52061
+ next,
52062
+ between: (min2, max2) => min2 + (max2 - min2) * next(),
52063
+ direction(out) {
52064
+ const up = next() * 2 - 1;
52065
+ const angle = next() * Math.PI * 2;
52066
+ const ring22 = Math.sqrt(1 - up * up);
52067
+ out.x = ring22 * Math.cos(angle);
52068
+ out.y = up;
52069
+ out.z = ring22 * Math.sin(angle);
52070
+ return out;
52071
+ },
52072
+ get state() {
52073
+ return state;
52074
+ }
52075
+ };
52076
+ }
52077
+ function mixEventSeed(eventSeed) {
52078
+ let mixed = Math.imul((eventSeed | 0) ^ HASH_MIX, 2246822507);
52079
+ mixed ^= mixed >>> 13;
52080
+ mixed = Math.imul(mixed, 3266489909);
52081
+ mixed ^= mixed >>> 16;
52082
+ return (mixed >>> 0) % (LEHMER_MODULUS - 1) + 1;
52083
+ }
52084
+ function streamFor3(eventSeed) {
52085
+ return lehmer(mixEventSeed(eventSeed));
52086
+ }
52087
+ var SKIN = 5e-3;
52088
+ var MAX_PAD = 0.45;
52089
+ function rotation(q) {
52090
+ const [x, y, z, w] = q ?? [0, 0, 0, 1];
52091
+ const n = Math.hypot(x, y, z, w) || 1;
52092
+ const qx = x / n;
52093
+ const qy = y / n;
52094
+ const qz = z / n;
52095
+ const qw = w / n;
52096
+ return new Float64Array([
52097
+ 1 - 2 * (qy * qy + qz * qz),
52098
+ 2 * (qx * qy - qz * qw),
52099
+ 2 * (qx * qz + qy * qw),
52100
+ 2 * (qx * qy + qz * qw),
52101
+ 1 - 2 * (qx * qx + qz * qz),
52102
+ 2 * (qy * qz - qx * qw),
52103
+ 2 * (qx * qz - qy * qw),
52104
+ 2 * (qy * qz + qx * qw),
52105
+ 1 - 2 * (qx * qx + qy * qy)
52106
+ ]);
52107
+ }
52108
+ var Enclosures = class {
52109
+ constructor(seed = 20973) {
52110
+ __publicField2(this, "spaces", /* @__PURE__ */ new Map());
52111
+ __publicField2(this, "list", []);
52112
+ __publicField2(this, "random");
52113
+ __publicField2(this, "out", { x: 0, y: 0, z: 0, nx: 0, ny: 0, nz: 0 });
52114
+ __publicField2(this, "l0", new Float64Array(3));
52115
+ __publicField2(this, "l1", new Float64Array(3));
52116
+ __publicField2(this, "q", new Float64Array(3));
52117
+ this.random = lehmer(seed);
52118
+ }
52119
+ get empty() {
52120
+ return this.list.length === 0;
52121
+ }
52122
+ get size() {
52123
+ return this.list.length;
52124
+ }
52125
+ /** Declares, moves or (with `null`) ends the space `id`. */
52126
+ set(id, enclosure) {
52127
+ if (!enclosure) {
52128
+ if (this.spaces.delete(id)) this.list = [...this.spaces.values()];
52129
+ return;
52130
+ }
52131
+ const [hx, hy, hz] = enclosure.halfSize;
52132
+ const space = {
52133
+ cx: enclosure.center[0],
52134
+ cy: enclosure.center[1],
52135
+ cz: enclosure.center[2],
52136
+ hx: Math.abs(hx),
52137
+ hy: Math.abs(hy),
52138
+ hz: Math.abs(hz),
52139
+ r: rotation(enclosure.orientation),
52140
+ radius: Math.hypot(hx, hy, hz),
52141
+ openings: enclosure.openings ?? [],
52142
+ leak: Math.max(0, enclosure.leak ?? 0)
52143
+ };
52144
+ const old = this.spaces.get(id);
52145
+ this.spaces.set(id, space);
52146
+ const at3 = old ? this.list.indexOf(old) : -1;
52147
+ if (at3 >= 0) this.list[at3] = space;
52148
+ else this.list.push(space);
52149
+ }
52150
+ get(id) {
52151
+ const s = this.spaces.get(id);
52152
+ if (!s) return void 0;
52153
+ return { center: [s.cx, s.cy, s.cz], halfSize: [s.hx, s.hy, s.hz], openings: s.openings, leak: s.leak };
52154
+ }
52155
+ ids() {
52156
+ return [...this.spaces.keys()];
52157
+ }
52158
+ clear() {
52159
+ this.spaces.clear();
52160
+ this.list = [];
52161
+ }
52162
+ /** Whether a point is inside any space (on the inside of its walls). */
52163
+ inside(x, y, z) {
52164
+ for (const s of this.list) {
52165
+ this.toLocal(s, x, y, z, this.l0);
52166
+ if (Math.abs(this.l0[0]) <= s.hx && Math.abs(this.l0[1]) <= s.hy && Math.abs(this.l0[2]) <= s.hz) return true;
52167
+ }
52168
+ return false;
52169
+ }
52170
+ toLocal(s, x, y, z, out) {
52171
+ const dx = x - s.cx;
52172
+ const dy = y - s.cy;
52173
+ const dz = z - s.cz;
52174
+ const r = s.r;
52175
+ out[0] = r[0] * dx + r[3] * dy + r[6] * dz;
52176
+ out[1] = r[1] * dx + r[4] * dy + r[7] * dz;
52177
+ out[2] = r[2] * dx + r[5] * dy + r[8] * dz;
52178
+ }
52179
+ /** Passes at `rate` per second. */
52180
+ chance(rate, dt) {
52181
+ return rate > 0 && this.random.next() < 1 - Math.exp(-rate * dt);
52182
+ }
52183
+ /** The opening the wall point `q` (local) is in lets it through now. */
52184
+ through(s, q, dt) {
52185
+ for (const o of s.openings) {
52186
+ if (Math.abs(q[0] - o.center[0]) > o.halfSize[0] || Math.abs(q[1] - o.center[1]) > o.halfSize[1] || Math.abs(q[2] - o.center[2]) > o.halfSize[2]) continue;
52187
+ if (o.rate === void 0 || this.chance(o.rate, dt)) return true;
52188
+ }
52189
+ return this.chance(s.leak, dt);
52190
+ }
52191
+ confine(x0, y0, z0, x1, y1, z1, pad, dt) {
52192
+ const list2 = this.list;
52193
+ if (list2.length === 0) return false;
52194
+ const p = Math.min(Math.max(0, pad), MAX_PAD);
52195
+ const l0 = this.l0;
52196
+ const l1 = this.l1;
52197
+ const q = this.q;
52198
+ for (const s of list2) {
52199
+ const reach = s.radius + p + 0.05;
52200
+ const dx = x1 - s.cx;
52201
+ const dy = y1 - s.cy;
52202
+ const dz = z1 - s.cz;
52203
+ if (dx * dx + dy * dy + dz * dz > reach * reach) {
52204
+ const ex = x0 - s.cx;
52205
+ const ey = y0 - s.cy;
52206
+ const ez = z0 - s.cz;
52207
+ if (ex * ex + ey * ey + ez * ez > reach * reach) continue;
52208
+ }
52209
+ this.toLocal(s, x0, y0, z0, l0);
52210
+ this.toLocal(s, x1, y1, z1, l1);
52211
+ const h = [s.hx, s.hy, s.hz];
52212
+ const in0 = Math.abs(l0[0]) <= s.hx && Math.abs(l0[1]) <= s.hy && Math.abs(l0[2]) <= s.hz;
52213
+ let axis2 = 0;
52214
+ let sign2 = 1;
52215
+ if (in0) {
52216
+ if (Math.abs(l1[0]) <= s.hx && Math.abs(l1[1]) <= s.hy && Math.abs(l1[2]) <= s.hz) continue;
52217
+ for (let a = 0; a < 3; a++) q[a] = Math.min(h[a], Math.max(-h[a], l1[a]));
52218
+ if (this.through(s, q, dt)) continue;
52219
+ let worst = -Infinity;
52220
+ for (let a = 0; a < 3; a++) {
52221
+ const over = Math.abs(l1[a]) - h[a];
52222
+ if (over > worst) {
52223
+ worst = over;
52224
+ axis2 = a;
52225
+ }
52226
+ }
52227
+ sign2 = l1[axis2] < 0 ? -1 : 1;
52228
+ for (let a = 0; a < 3; a++) l1[a] = Math.min(h[a] - SKIN, Math.max(-(h[a] - SKIN), l1[a]));
52229
+ sign2 = -sign2;
52230
+ } else {
52231
+ const padded0 = Math.abs(l0[0]) <= s.hx + p && Math.abs(l0[1]) <= s.hy + p && Math.abs(l0[2]) <= s.hz + p;
52232
+ const bound = padded0 ? 0 : p;
52233
+ if (!(Math.abs(l1[0]) <= s.hx + bound && Math.abs(l1[1]) <= s.hy + bound && Math.abs(l1[2]) <= s.hz + bound)) continue;
52234
+ for (let a = 0; a < 3; a++) q[a] = Math.min(h[a], Math.max(-h[a], l1[a]));
52235
+ if (this.through(s, q, dt)) continue;
52236
+ let worst = -Infinity;
52237
+ for (let a = 0; a < 3; a++) {
52238
+ const over = Math.abs(l0[a]) - (h[a] + bound);
52239
+ if (over > worst) {
52240
+ worst = over;
52241
+ axis2 = a;
52242
+ }
52243
+ }
52244
+ sign2 = l0[axis2] < 0 ? -1 : 1;
52245
+ l1[axis2] = sign2 * (h[axis2] + bound + SKIN);
52246
+ }
52247
+ const r = s.r;
52248
+ const out = this.out;
52249
+ out.x = s.cx + r[0] * l1[0] + r[1] * l1[1] + r[2] * l1[2];
52250
+ out.y = s.cy + r[3] * l1[0] + r[4] * l1[1] + r[5] * l1[2];
52251
+ out.z = s.cz + r[6] * l1[0] + r[7] * l1[1] + r[8] * l1[2];
52252
+ out.nx = r[axis2] * sign2;
52253
+ out.ny = r[3 + axis2] * sign2;
52254
+ out.nz = r[6 + axis2] * sign2;
52255
+ return true;
52256
+ }
52257
+ return false;
52258
+ }
52259
+ };
52260
+ function slideAlong(out, vx2, vy2, vz2) {
52261
+ const into = vx2 * out.nx + vy2 * out.ny + vz2 * out.nz;
52262
+ if (into >= 0) return [vx2, vy2, vz2];
52263
+ return [vx2 - into * out.nx, vy2 - into * out.ny, vz2 - into * out.nz];
52264
+ }
52047
52265
  var FLOOR_FRACTION = 0.4;
52048
52266
  var FLOOR_BOUNCE = -0.2;
52049
52267
  var ARRIVAL_FRAME = 30;
52050
52268
  var ARRIVAL_BASE = 0.3;
52051
52269
  var GROWTH_CAP_SECONDS = 3.5;
52270
+ var CARRIED_KINDS = [true, true, false, true, false];
52271
+ var PAD_OF_SIZE = 0.35;
52052
52272
  function createPuffPool(capacity) {
52053
52273
  const placeholder = { next: () => 0, between: (min2) => min2, direction: (out) => out, state: 0 };
52054
52274
  return new OrderedPool(capacity, () => ({
@@ -52143,13 +52363,24 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52143
52363
  if (puff3.vy < 0) puff3.vy *= FLOOR_BOUNCE;
52144
52364
  }
52145
52365
  }
52146
- function updatePuffs(pool, dt, wind) {
52366
+ function updatePuffs(pool, dt, wind, confiner) {
52147
52367
  pool.compact(ageOrKeep2, dt);
52368
+ const confining = confiner !== void 0 && !confiner.empty;
52148
52369
  for (const puff3 of pool.items) {
52149
52370
  const age = puff3.t / puff3.life;
52150
52371
  const heat = puff3.h0 > 0 ? puff3.h0 * Math.pow(Math.max(0, 1 - puff3.t / puff3.hl), 1.25) : 0;
52372
+ const x0 = puff3.x;
52373
+ const y0 = puff3.y;
52374
+ const z0 = puff3.z;
52151
52375
  if (puff3.ring) moveOnRing(puff3, puff3.ring, wind);
52152
52376
  else moveFree(puff3, dt, age, heat, wind);
52377
+ if (confining && CARRIED_KINDS[puff3.kind] && confiner.confine(x0, y0, z0, puff3.x, puff3.y, puff3.z, puff3.size * PAD_OF_SIZE, dt)) {
52378
+ const out = confiner.out;
52379
+ puff3.x = out.x;
52380
+ puff3.y = out.y;
52381
+ puff3.z = out.z;
52382
+ [puff3.vx, puff3.vy, puff3.vz] = slideAlong(out, puff3.vx, puff3.vy, puff3.vz);
52383
+ }
52153
52384
  const size = puff3.s0 + (puff3.s1 - puff3.s0) * (1 - Math.exp(-puff3.t * puff3.gk)) + puff3.sg * Math.min(puff3.t, GROWTH_CAP_SECONDS);
52154
52385
  puff3.size = size * Math.min(1, puff3.t * ARRIVAL_FRAME + ARRIVAL_BASE);
52155
52386
  puff3.age = age;
@@ -52675,10 +52906,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52675
52906
  ])
52676
52907
  ]
52677
52908
  };
52678
- function localToWorld(translation, rotation, local2) {
52909
+ function localToWorld(translation, rotation2, local2) {
52679
52910
  const [x, y, z] = local2;
52680
- const [a, c, e] = [Math.cos(rotation[0]), Math.cos(rotation[1]), Math.cos(rotation[2])];
52681
- const [b, d, f] = [Math.sin(rotation[0]), Math.sin(rotation[1]), Math.sin(rotation[2])];
52911
+ const [a, c, e] = [Math.cos(rotation2[0]), Math.cos(rotation2[1]), Math.cos(rotation2[2])];
52912
+ const [b, d, f] = [Math.sin(rotation2[0]), Math.sin(rotation2[1]), Math.sin(rotation2[2])];
52682
52913
  const [ae, af, be, bf] = [a * e, a * f, b * e, b * f];
52683
52914
  return [
52684
52915
  c * e * x + -c * f * y + d * z + translation[0],
@@ -54341,46 +54572,6 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54341
54572
  var ALL_EFFECTS = [BLOOD_HIT, HEADSHOT, DISMEMBER, BLOATER_CLOUD, SCREAMER_SHRIEK, CORPSE_DECAY, REANIMATION, EYES_IN_FOG, MUZZLE_FLASH, IMPACT_BY_MATERIAL, PENETRATION, CASINGS_AND_MAGAZINE, MOLOTOV, GRENADE, EXPLOSIVE_BARREL, SHOPFRONT_GLASS, DOOR_STAGES, BUILDING_COLLAPSE, BLOCK_WALL, METAL_DOOR_EFFECT, IRON_RAILING, WOODEN_FENCE, HIT_POINT_BREAKAGE, PRESSURE_CYLINDERS, BUILDING_FIRE, RAIN_AND_PUDDLES, FOG_AND_ASH, SCRAPING_SPARKS, ENGINE_SMOKE, FUEL_LEAK, CAR_EXPLOSION, WINDSHIELD, HEADLIGHTS_IN_RAIN, DAMAGE_AND_BITE, INFECTION_PHASES, PANIC, BLOATER_BLINDNESS, CAMPFIRE, COUGH_AND_BREATH];
54342
54573
  var WORKSHOP_EFFECTS = Object.fromEntries(ALL_EFFECTS.map((effect) => [effect.id, effect]));
54343
54574
  var GAME_EFFECTS = { ...WORKSHOP_EFFECTS, ...Object.fromEntries([...EVENT_EFFECTS, ...VIEWMODEL_EFFECTS, ...VEHICLE_EFFECTS].map((effect) => [effect.id, effect])) };
54344
- var LEHMER_MULTIPLIER = 16807;
54345
- var LEHMER_MODULUS = 2147483647;
54346
- var HASH_MIX = 2654435761;
54347
- function normalizeLehmerSeed(seed) {
54348
- const whole = Math.floor(Math.abs(seed)) % (LEHMER_MODULUS - 1);
54349
- return whole === 0 ? 1 : whole;
54350
- }
54351
- function lehmer(seed) {
54352
- let state = normalizeLehmerSeed(seed);
54353
- const next = () => {
54354
- state = state * LEHMER_MULTIPLIER % LEHMER_MODULUS;
54355
- return (state - 1) / (LEHMER_MODULUS - 1);
54356
- };
54357
- return {
54358
- next,
54359
- between: (min2, max2) => min2 + (max2 - min2) * next(),
54360
- direction(out) {
54361
- const up = next() * 2 - 1;
54362
- const angle = next() * Math.PI * 2;
54363
- const ring22 = Math.sqrt(1 - up * up);
54364
- out.x = ring22 * Math.cos(angle);
54365
- out.y = up;
54366
- out.z = ring22 * Math.sin(angle);
54367
- return out;
54368
- },
54369
- get state() {
54370
- return state;
54371
- }
54372
- };
54373
- }
54374
- function mixEventSeed(eventSeed) {
54375
- let mixed = Math.imul((eventSeed | 0) ^ HASH_MIX, 2246822507);
54376
- mixed ^= mixed >>> 13;
54377
- mixed = Math.imul(mixed, 3266489909);
54378
- mixed ^= mixed >>> 16;
54379
- return (mixed >>> 0) % (LEHMER_MODULUS - 1) + 1;
54380
- }
54381
- function streamFor3(eventSeed) {
54382
- return lehmer(mixEventSeed(eventSeed));
54383
- }
54384
54575
  var TABLE = {
54385
54576
  concrete: { dust: 9078138, chip: 7236195, spark: 2 },
54386
54577
  metal: { dust: 0, chip: 0, spark: 18 },
@@ -55684,8 +55875,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55684
55875
  function addScorch(store, random, x, z, radius) {
55685
55876
  const variant = Math.floor(random.next() * SCORCH_VARIANTS);
55686
55877
  const lift = 0.03 + nextLift(store) * 1e-3;
55687
- const rotation = random.next() * 6;
55688
- store.add({ kind: "scorch", x, z, radius, variant, lift, rotation });
55878
+ const rotation2 = random.next() * 6;
55879
+ store.add({ kind: "scorch", x, z, radius, variant, lift, rotation: rotation2 });
55689
55880
  }
55690
55881
  function addRimRocks(store, ground, random, x, z, radius) {
55691
55882
  const count = Math.round(6 + radius * 7);
@@ -55714,8 +55905,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55714
55905
  function addCrater(store, ground, random, spec) {
55715
55906
  ground?.dent(random, spec.x, spec.z, spec.radius, spec.depth);
55716
55907
  if (!spec.marks) return;
55717
- const rotation = random.next() * 6;
55718
- store.add({ kind: "dirt", x: spec.x, z: spec.z, radius: spec.radius * 1.02, lift: 0.045, rotation });
55908
+ const rotation2 = random.next() * 6;
55909
+ store.add({ kind: "dirt", x: spec.x, z: spec.z, radius: spec.radius * 1.02, lift: 0.045, rotation: rotation2 });
55719
55910
  addRimRocks(store, ground, random, spec.x, spec.z, spec.radius);
55720
55911
  }
55721
55912
  function addBloodSplat(store, ground, random, spec) {
@@ -56271,6 +56462,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56271
56462
  state.gas = Math.max(0, state.gas - dt / DECAY.gasSeconds);
56272
56463
  state.beat *= Math.exp(-DECAY.beat * dt);
56273
56464
  }
56465
+ var PAD_OF_SIZE2 = 0.35;
56274
56466
  var clamp4 = (v, lo, hi) => v < lo ? lo : v > hi ? hi : v;
56275
56467
  var lerp4 = (a, b, t) => a + (b - a) * t;
56276
56468
  function rgb(hex2) {
@@ -56430,9 +56622,20 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56430
56622
  vy2 *= k;
56431
56623
  vz2 *= k;
56432
56624
  }
56433
- const x = this.position[i3] + vx2 * dt;
56625
+ let x = this.position[i3] + vx2 * dt;
56434
56626
  let y = this.position[i3 + 1] + vy2 * dt;
56435
- const z = this.position[i3 + 2] + vz2 * dt;
56627
+ let z = this.position[i3 + 2] + vz2 * dt;
56628
+ const confiner = host.confiner;
56629
+ if (def.carried && confiner && !confiner.empty) {
56630
+ const pad = this.size0[i] * lerp4(1, def.grow, t) * PAD_OF_SIZE2;
56631
+ if (confiner.confine(this.position[i3], this.position[i3 + 1], this.position[i3 + 2], x, y, z, pad, dt)) {
56632
+ const out = confiner.out;
56633
+ x = out.x;
56634
+ y = out.y;
56635
+ z = out.z;
56636
+ [vx2, vy2, vz2] = slideAlong(out, vx2, vy2, vz2);
56637
+ }
56638
+ }
56436
56639
  if (def.ground !== "none") {
56437
56640
  const own = this.floor[i];
56438
56641
  const gy = Number.isNaN(own) ? host.groundAt(x, z) + 5e-3 : own;
@@ -56518,7 +56721,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56518
56721
  alpha: 0.35,
56519
56722
  fadeIn: 0.15,
56520
56723
  cone: 0.6,
56521
- ground: "none"
56724
+ ground: "none",
56725
+ carried: true
56522
56726
  },
56523
56727
  sparks: {
56524
56728
  id: "sparks",
@@ -56562,7 +56766,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56562
56766
  alpha: 0.4,
56563
56767
  fadeIn: 0.1,
56564
56768
  cone: 0.4,
56565
- ground: "none"
56769
+ ground: "none",
56770
+ carried: true
56566
56771
  },
56567
56772
  shards: {
56568
56773
  id: "shards",
@@ -56720,7 +56925,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56720
56925
  fadeIn: 0.1,
56721
56926
  cone: 0.5,
56722
56927
  ground: "stop",
56723
- flutter: 0.6
56928
+ flutter: 0.6,
56929
+ carried: true
56724
56930
  },
56725
56931
  steam: {
56726
56932
  id: "steam",
@@ -56742,7 +56948,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56742
56948
  alpha: 0.35,
56743
56949
  fadeIn: 0.15,
56744
56950
  cone: 0.6,
56745
- ground: "none"
56951
+ ground: "none",
56952
+ carried: true
56746
56953
  },
56747
56954
  flash: {
56748
56955
  id: "flash",
@@ -56875,7 +57082,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56875
57082
  const host = {
56876
57083
  groundAt: this.options.groundAt,
56877
57084
  gravity: this.options.gravity,
56878
- land: (owner, x, y, z, color2, tag) => this.listeners.get(owner)?.(x, y, z, color2, tag)
57085
+ land: (owner, x, y, z, color2, tag) => this.listeners.get(owner)?.(x, y, z, color2, tag),
57086
+ ...this.options.confiner ? { confiner: this.options.confiner } : {}
56879
57087
  };
56880
57088
  if (this.additive.live > 0 || this.additive.drawCount > 0) this.additive.update(dt, host);
56881
57089
  if (this.normal.live > 0 || this.normal.drawCount > 0) this.normal.update(dt, host);
@@ -57081,8 +57289,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57081
57289
  * Takes away the marks inside a box: world `center`, `half` extents along the axes of the world `rotation` (a quaternion, x y z w; none means the
57082
57290
  * world axes). The surface they were on is gone (a brick came out of a wall with its bullet holes). Returns how many went.
57083
57291
  */
57084
- clearInside(center, half, rotation = [0, 0, 0, 1]) {
57085
- const qx = -rotation[0], qy = -rotation[1], qz = -rotation[2], qw = rotation[3];
57292
+ clearInside(center, half, rotation2 = [0, 0, 0, 1]) {
57293
+ const qx = -rotation2[0], qy = -rotation2[1], qz = -rotation2[2], qw = rotation2[3];
57086
57294
  let gone = 0;
57087
57295
  for (const decal2 of this.decals) {
57088
57296
  if (!decal2.on) continue;
@@ -57203,10 +57411,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57203
57411
  var DEFAULT_FADE_IN = 0.1;
57204
57412
  var FLOATS_PER_VECTOR = 3;
57205
57413
  var BYTE_MAX2 = 255;
57414
+ var CARRIED_GRAVITY = 3;
57415
+ var PAD_OF_SIZE3 = 0.35;
57206
57416
  var SpritePool = class {
57207
- constructor(capacity, context) {
57417
+ /** `carried`: the normal-blend pool (smoke, dust, steam), whose light sprites go round the closed spaces; the additive one (flames, sparks) does not. */
57418
+ constructor(capacity, context, carried = false) {
57208
57419
  __publicField2(this, "capacity", capacity);
57209
57420
  __publicField2(this, "context", context);
57421
+ __publicField2(this, "carried", carried);
57210
57422
  __publicField2(this, "count", 0);
57211
57423
  __publicField2(this, "position");
57212
57424
  __publicField2(this, "velocity");
@@ -57306,6 +57518,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57306
57518
  }
57307
57519
  update(dt, leaveDecal) {
57308
57520
  const { position, velocity } = this;
57521
+ const confiner = this.context.confiner;
57309
57522
  for (let index = this.count - 1; index >= 0; index--) {
57310
57523
  this.life[index] -= dt;
57311
57524
  if (this.life[index] <= 0) {
@@ -57319,9 +57532,25 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57319
57532
  velocity[offset] *= factor;
57320
57533
  velocity[offset + 1] *= factor;
57321
57534
  velocity[offset + 2] *= factor;
57535
+ const x0 = position[offset];
57536
+ const y0 = position[offset + 1];
57537
+ const z0 = position[offset + 2];
57322
57538
  position[offset] += velocity[offset] * dt;
57323
57539
  position[offset + 1] += velocity[offset + 1] * dt;
57324
57540
  position[offset + 2] += velocity[offset + 2] * dt;
57541
+ if (this.carried && confiner && !confiner.empty && Math.abs(this.gravity[index]) < CARRIED_GRAVITY) {
57542
+ const size = this.startSize[index] * (1 + (this.growth[index] - 1) * age);
57543
+ if (confiner.confine(x0, y0, z0, position[offset], position[offset + 1], position[offset + 2], size * PAD_OF_SIZE3, dt)) {
57544
+ const out = confiner.out;
57545
+ position[offset] = out.x;
57546
+ position[offset + 1] = out.y;
57547
+ position[offset + 2] = out.z;
57548
+ const [vx2, vy2, vz2] = slideAlong(out, velocity[offset], velocity[offset + 1], velocity[offset + 2]);
57549
+ velocity[offset] = vx2;
57550
+ velocity[offset + 1] = vy2;
57551
+ velocity[offset + 2] = vz2;
57552
+ }
57553
+ }
57325
57554
  const mode = this.groundMode[index];
57326
57555
  if (mode) {
57327
57556
  const groundHeight = this.context.groundAt(position[offset], position[offset + 2]);
@@ -57598,9 +57827,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57598
57827
  __publicField2(this, "placement");
57599
57828
  __publicField2(this, "accumulators", /* @__PURE__ */ new Map());
57600
57829
  const profile = options.profile ?? PROFILES.high;
57601
- this.context = { random: options.random, groundAt: options.groundAt ?? workshopGround, quality: { level: 0, mult: 1 }, trace: options.trace };
57830
+ this.context = { random: options.random, groundAt: options.groundAt ?? workshopGround, quality: { level: 0, mult: 1 }, trace: options.trace, ...options.confiner ? { confiner: options.confiner } : {} };
57602
57831
  this.add = new SpritePool(profile.sprites.add, this.context);
57603
- this.normal = new SpritePool(profile.sprites.normal, this.context);
57832
+ this.normal = new SpritePool(profile.sprites.normal, this.context, true);
57604
57833
  this.streaks = new StreakPool(profile.streaks, this.context);
57605
57834
  this.debris = new DebrisPool(this.context);
57606
57835
  this.decals = new DecalPool(this.context);
@@ -57788,12 +58017,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57788
58017
  const groundAt = options.groundAt ?? (ground ? (x, z) => ground.heightAt(x, z) : () => 0);
57789
58018
  const handles = { next: 0, events: 0 };
57790
58019
  const low = options.profile === "low";
58020
+ const enclosures = new Enclosures(20973 + (options.seed ?? 0));
57791
58021
  const spriteSystem = new SpriteKindSystem({
57792
58022
  capacity: options.sprites?.capacity ?? (low ? 1250 : 2500),
57793
58023
  density: options.sprites?.density ?? (low ? 0.6 : 1),
57794
58024
  seed: 2654435761 + (options.seed ?? 0),
57795
58025
  groundAt,
57796
58026
  gravity: options.gravity ?? DEFAULT_GRAVITY,
58027
+ confiner: enclosures,
57797
58028
  ...options.sprites?.kinds ? { kinds: options.sprites.kinds } : {}
57798
58029
  });
57799
58030
  const core = {
@@ -57843,7 +58074,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57843
58074
  return [camera2.x, camera2.y, camera2.z];
57844
58075
  }, forward: (local2) => [local2[0] ?? 0, local2[1] ?? 0, local2[2] ?? 0] };
57845
58076
  function workshop() {
57846
- return engine ?? (engine = new WorkshopEngine({ random: sharedRandom, profile, groundAt }));
58077
+ return engine ?? (engine = new WorkshopEngine({ random: sharedRandom, profile, groundAt, confiner: enclosures }));
57847
58078
  }
57848
58079
  function effectPlayer() {
57849
58080
  return player ?? (player = createEffectPlayer({ engine: workshop(), effects, view }));
@@ -57902,6 +58133,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57902
58133
  puff3.vz += dz * strength;
57903
58134
  }
57904
58135
  },
58136
+ enclose(id, enclosure) {
58137
+ enclosures.set(id, enclosure);
58138
+ },
58139
+ enclosures: () => enclosures,
57905
58140
  stop(handle) {
57906
58141
  player?.stop(handle);
57907
58142
  const fires = core.fires;
@@ -57929,7 +58164,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57929
58164
  core.clock.time += dt;
57930
58165
  core.schedule.update(core.clock.time);
57931
58166
  updateRings(core.rings, dt);
57932
- updatePuffs(core.puffs, dt, wind);
58167
+ updatePuffs(core.puffs, dt, wind, enclosures);
57933
58168
  updateSparks(core.sparks, { dt, groundAt });
57934
58169
  updateGlows(core.glows, dt);
57935
58170
  updateShocks(core.shocks, core.puffs.items, dt);
@@ -59313,6 +59548,8 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
59313
59548
  });
59314
59549
  },
59315
59550
  stop: (handle) => world.stop(handle),
59551
+ // a module's closed space (a shut car's cabin): the world's smoke, dust and steam go round it
59552
+ enclose: (id, enclosure) => world.enclose(id, enclosure),
59316
59553
  configure(settings) {
59317
59554
  const band = settings.lod_band;
59318
59555
  if (typeof band === "string" && band in LOD_BANDS) world.forceLod(LOD_BANDS[band] ?? null);