@adatechnology/game-weapons-three 0.21.1 → 0.21.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.
@@ -15024,7 +15024,7 @@ var GameWeaponsThree = (() => {
15024
15024
  heat: DEFAULT_HEAT,
15025
15025
  noiseBurst: { step: 0.05, window: 3, cap: 0.5 },
15026
15026
  // jogo.js (Jogo) explosionsUpdate 68300-68312: vy -= 9,8·dt; chão vy·-0,35 e vx,vz·0,6; parede v·-0,4
15027
- explosives: { gravity: 9.8, groundRestitution: 0.35, groundFriction: 0.6, wallRestitution: 0.4, placeFuseFrom: 10, tripwire: { length: 10, angleDeg: 0, height: 0.15 } },
15027
+ explosives: { gravity: 9.8, groundRestitution: 0.35, groundFriction: 0.6, wallRestitution: 0.4, placeFuseFrom: 10, tripwire: { length: 10, angleDeg: 0, height: 0.15 }, unarmedImpact: "detonate", restSpeed: 0.5, selfDestructSeconds: 20 },
15028
15028
  // Arsenal §11: montar e desmontar exige chave de fenda ou bancada; 2/15/30 s e a troca do lança-granadas (0,8 s) são padrões aprovados pelo dono (2026-10-24)
15029
15029
  attachments: { fitSeconds: { field: 2, tool: 15, bench: 30 }, switchSeconds: 0.8, speedOfSound: 343 },
15030
15030
  // Arsenal §08: tempo de mira = 0,15 s + 0,05 s por kg. O quadril do Arsenal é ×6 (o ZombiAdA liga isso por configuração); o SDK é neutro (1)
@@ -15073,6 +15073,8 @@ var GameWeaponsThree = (() => {
15073
15073
  var distance = (a, b) => length(subtract(a, b));
15074
15074
  var negate = (v) => [0 - v[0], 0 - v[1], 0 - v[2]];
15075
15075
  var EPS = 1e-9;
15076
+ var STILL_STEPS = 2;
15077
+ var STILL_SHARE = 0.05;
15076
15078
  var bounce = (velocity, normal, ground, rules) => {
15077
15079
  const along = dot(velocity, normal);
15078
15080
  if (along >= 0) return velocity;
@@ -15100,6 +15102,8 @@ var GameWeaponsThree = (() => {
15100
15102
  __publicField(this, "isArmed");
15101
15103
  __publicField(this, "isDone", false);
15102
15104
  __publicField(this, "isDud", false);
15105
+ __publicField(this, "isLaunched");
15106
+ __publicField(this, "stillSteps", 0);
15103
15107
  this.explosive = init.explosive;
15104
15108
  this.position = [init.origin[0], init.origin[1], init.origin[2]];
15105
15109
  this.velocity = init.velocity ? [init.velocity[0], init.velocity[1], init.velocity[2]] : [0, 0, 0];
@@ -15109,6 +15113,7 @@ var GameWeaponsThree = (() => {
15109
15113
  this.isArmed = this.armDistance <= 0;
15110
15114
  this.fuseLeft = this.triggers.has("timer") ? init.fuse : void 0;
15111
15115
  this.rules = init.rules;
15116
+ this.isLaunched = this.triggers.has("impact") && this.moves();
15112
15117
  }
15113
15118
  get age() {
15114
15119
  return this.clock;
@@ -15138,6 +15143,10 @@ var GameWeaponsThree = (() => {
15138
15143
  const slice = this.fuseLeft === void 0 ? seconds : Math.min(seconds, this.fuseLeft);
15139
15144
  this.fly(slice, probe, events);
15140
15145
  if (this.isDone) return events;
15146
+ if (this.isLaunched && this.isSpent()) {
15147
+ events.push(this.detonate(this.clock >= this.rules.selfDestructSeconds ? "timer" : "impact"));
15148
+ return events;
15149
+ }
15141
15150
  if (this.fuseLeft !== void 0) {
15142
15151
  this.fuseLeft -= slice;
15143
15152
  if (this.fuseLeft <= EPS) events.push(this.detonate("timer"));
@@ -15153,11 +15162,17 @@ var GameWeaponsThree = (() => {
15153
15162
  moves() {
15154
15163
  return length(this.velocity) > EPS;
15155
15164
  }
15165
+ /** A launched round that came to rest (stopped, or still for `STILL_STEPS` steps) or flew past its self-destruct time. */
15166
+ isSpent() {
15167
+ if (this.clock >= this.rules.selfDestructSeconds) return true;
15168
+ return !this.moves() || this.stillSteps >= STILL_STEPS;
15169
+ }
15156
15170
  fly(seconds, probe, events) {
15157
15171
  if (seconds <= 0 || !this.moves()) {
15158
15172
  this.clock += Math.max(0, seconds);
15159
15173
  return;
15160
15174
  }
15175
+ const start = this.position;
15161
15176
  this.velocity = [this.velocity[0], this.velocity[1] - this.rules.gravity * seconds, this.velocity[2]];
15162
15177
  const next = [this.position[0] + this.velocity[0] * seconds, this.position[1] + this.velocity[1] * seconds, this.position[2] + this.velocity[2] * seconds];
15163
15178
  const hit = probe?.(this.position, next) ?? null;
@@ -15166,11 +15181,12 @@ var GameWeaponsThree = (() => {
15166
15181
  const planned = distance(this.position, next);
15167
15182
  this.flown += moved;
15168
15183
  this.position = [target[0], target[1], target[2]];
15169
- const hitAt = this.clock + (hit && planned > EPS ? seconds * Math.min(1, moved / planned) : seconds);
15184
+ const hitAt2 = this.clock + (hit && planned > EPS ? seconds * Math.min(1, moved / planned) : seconds);
15170
15185
  this.clock += seconds;
15171
15186
  if (length(this.velocity) > EPS) this.facing = normalize(this.velocity);
15187
+ this.stillSteps = distance(start, this.position) < this.rules.restSpeed * STILL_SHARE * seconds ? this.stillSteps + 1 : 0;
15172
15188
  this.checkArmed(events);
15173
- if (hit) this.onImpact(hit, hitAt, events);
15189
+ if (hit) this.onImpact(hit, hitAt2, events);
15174
15190
  }
15175
15191
  checkArmed(events) {
15176
15192
  if (this.isArmed || this.flown < this.armDistance) return;
@@ -15180,7 +15196,7 @@ var GameWeaponsThree = (() => {
15180
15196
  onImpact(hit, at4, events) {
15181
15197
  events.push({ type: "impact", at: at4, point: hit.point, armed: this.isArmed });
15182
15198
  if (this.triggers.has("impact")) {
15183
- if (this.isArmed) events.push(this.detonate("impact", at4));
15199
+ if (this.isArmed || this.rules.unarmedImpact !== "dud") events.push(this.detonate("impact", at4));
15184
15200
  else {
15185
15201
  this.isDone = true;
15186
15202
  this.isDud = true;
@@ -24904,6 +24920,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
24904
24920
  var BREACH_GRID_CAP = 4096;
24905
24921
  var MASONRY_CRUMBLE_SPEED = 0.6;
24906
24922
  var TILE_CLUMPS = 160;
24923
+ var TILE_THICKNESS = 0.018;
24907
24924
  var PANEL_EDGE_PILLAR = 2;
24908
24925
  var PANEL_EDGE_BASE = 4;
24909
24926
  var PANEL_EDGE_BEAM = 3;
@@ -26016,10 +26033,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
26016
26033
  const op = p.st.opening ? toLocal(p.pos, p.q, p.st.opening.center) : null;
26017
26034
  const cells = grid.filter((cell, i) => worn[i] !== -1 && !(op && p.st.opening && Math.hypot(cell.center[u] - op[u], cell.center[v] - op[v]) <= p.st.opening.radius));
26018
26035
  const { c } = partXf(o, p);
26019
- const fragments = cells.length > 0 ? [
26020
- ...cellFragments(o, p, clumpUnits(cells, p.thin, unitSpan(p), isTiledCover(p) ? TILE_CLUMPS : unitClumps), vec.add(c, [0, 1, 0]), null, MASONRY_CRUMBLE_SPEED, p.st.mass, "m_", true),
26021
- ...plasterFlakes(o, p, cells, vec.add(c, [0, 1, 0]), MASONRY_CRUMBLE_SPEED, "mp_")
26022
- ] : [];
26036
+ const tiles = isTiledCover(p);
26037
+ const pieces = cellFragments(o, p, clumpUnits(cells, p.thin, unitSpan(p), tiles ? TILE_CLUMPS : unitClumps), vec.add(c, [0, 1, 0]), null, MASONRY_CRUMBLE_SPEED, p.st.mass, "m_", true);
26038
+ const fragments = cells.length === 0 ? [] : tiles ? pieces.map((f) => ({ ...f, shape: "shard", size: f.size.map((x, k) => k === p.thin ? Math.min(x, TILE_THICKNESS) : x) })) : [...pieces, ...plasterFlakes(o, p, cells, vec.add(c, [0, 1, 0]), MASONRY_CRUMBLE_SPEED, "mp_")];
26023
26039
  p.st.status = "broken";
26024
26040
  p.st.hp = 0;
26025
26041
  p.st.mass = 0;
@@ -27509,6 +27525,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27509
27525
  return;
27510
27526
  }
27511
27527
  if (!force && giveAtCut(o, p, src)) return;
27528
+ if (!force && isTiledCover(p)) {
27529
+ crumbleMasonry(o, p, src);
27530
+ return;
27531
+ }
27512
27532
  const ex = p.spec.explodes;
27513
27533
  const style = force ?? (p.snap ? "snap" : p.mat.fracture === "none" ? "snap" : p.mat.fracture);
27514
27534
  const { c, q } = partXf(o, p);
@@ -29530,6 +29550,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29530
29550
  return loads;
29531
29551
  }
29532
29552
  var isBearing = (part) => part.role === "column" || part.role === "wall";
29553
+ function isRoofFrame2(part) {
29554
+ return part.role === "roof" || part.id.startsWith("rafter");
29555
+ }
29533
29556
  function sizeCapacities(parts, supports, options) {
29534
29557
  const loads = loadsAtRest(parts, supports);
29535
29558
  const worst = /* @__PURE__ */ new Map();
@@ -29543,7 +29566,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29543
29566
  for (const part of parts) {
29544
29567
  const load = loads.get(part.id);
29545
29568
  if (load === void 0 || part.role === "none") continue;
29546
- const factor = isBearing(part) ? Math.max(1 / options.safety, (worst.get(part.id) ?? 1) / options.redundancy) : 1 / options.safetyOthers;
29569
+ const afterLoss = (worst.get(part.id) ?? 1) / options.redundancy;
29570
+ const factor = isBearing(part) ? Math.max(1 / options.safety, afterLoss) : isRoofFrame2(part) ? Math.max(1 / options.safetyOthers, afterLoss) : 1 / options.safetyOthers;
29547
29571
  capacities.set(part.id, Math.max(1, load * factor));
29548
29572
  }
29549
29573
  return capacities;
@@ -32253,7 +32277,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
32253
32277
  }
32254
32278
  var residentialTower = residentialTowerTemplate();
32255
32279
 
32256
- // ../game-floorplan-three/dist/chunk-EWU252NT.js
32280
+ // ../game-floorplan-three/dist/chunk-J3D4FCFR.js
32257
32281
  var __defProp4 = Object.defineProperty;
32258
32282
  var __defNormalProp2 = (obj, key2, value) => key2 in obj ? __defProp4(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
32259
32283
  var __publicField2 = (obj, key2, value) => __defNormalProp2(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
@@ -33324,7 +33348,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
33324
33348
  }
33325
33349
  const wref = R.walls.find((w) => w.floor === f && w.axis === j.axis && Math.abs((alongU ? w.v0 : w.u0) - L) < EPS6), th = wref ? wref.thickness || 0.15 : 0.15, t = 0.05, tt = th + 0.02;
33326
33350
  const bar2 = (u0, y_0, u1, y_1, mat, color2, tw = tt) => alongU ? bx(mat, u0, y0 + y_0, L - tw / 2, u1, y0 + y_1, L + tw / 2, color2) : bx(mat, L - tw / 2, y0 + y_0, u0, L + tw / 2, y0 + y_1, u1, color2);
33327
- cursor.pc = pieceRecord("window_frame:" + j.id, "aluminium", null, { floor: f });
33351
+ const frame2 = pieceRecord("window_frame:" + j.id, "aluminium", null, { floor: f });
33352
+ cursor.pc = frame2;
33328
33353
  bar2(a, ya, a + t, yb, "metal", fr);
33329
33354
  bar2(b - t, ya, b, yb, "metal", fr);
33330
33355
  bar2(a, ya, b, ya + t, "metal", fr);
@@ -33337,6 +33362,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
33337
33362
  const am = (sd) => roomAt(f, alongU ? j.at : L + sd * 0.4, alongU ? L + sd * 0.4 : j.at);
33338
33363
  const outside = !am(1) ? 1 : !am(-1) ? -1 : 0;
33339
33364
  if (outside) {
33365
+ cursor.pc = frame2;
33340
33366
  const off = outside * (th / 2 + 0.03);
33341
33367
  if (alongU) bx("plaster", a - 0.05, y0 + ya - 0.04, L + (outside > 0 ? th / 2 : -th / 2 - 0.08), b + 0.05, y0 + ya, L + (outside > 0 ? th / 2 + 0.08 : -th / 2), pe_);
33342
33368
  else bx("plaster", L + (outside > 0 ? th / 2 : -th / 2 - 0.08), y0 + ya - 0.04, a - 0.05, L + (outside > 0 ? th / 2 + 0.08 : -th / 2), y0 + ya, b + 0.05, pe_);
@@ -33352,6 +33378,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
33352
33378
  else bx("metal", L + go - 0.012, y0 + y, a, L + go + 0.012, y0 + y + 0.025, b, g);
33353
33379
  }
33354
33380
  }
33381
+ cursor.pc = null;
33355
33382
  }
33356
33383
  if (j.boards && !boardItems.has(j.id) && !cut) {
33357
33384
  const inside2 = -(outside || -1), off = inside2 * (th / 2 + 0.04), n = Math.max(3, Math.round((yb - ya) / 0.16));
@@ -34284,7 +34311,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
34284
34311
  const { UV_SCALE, _Y, _h2, _q, accFor, cursor, put, rgbOf, structurePiece } = K;
34285
34312
  const sh = (...a) => K.sh(...a);
34286
34313
  const R_STYLE = () => shared3.ctx.r && shared3.ctx.r.style || "budget";
34287
- function tileRelief(mat, pts, color2, type) {
34314
+ function tileRelief(mat, pts, color2, type, origin) {
34288
34315
  const n = pts.length;
34289
34316
  if (n < 3) return;
34290
34317
  const [a, b, c] = pts;
@@ -34318,7 +34345,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
34318
34345
  ex /= el;
34319
34346
  ey /= el;
34320
34347
  ez /= el;
34321
- const o = pts[0], S = [], T2 = [];
34348
+ const o = origin ?? pts[0], S = [], T2 = [];
34322
34349
  for (const p of pts) {
34323
34350
  const rx = p[0] - o[0], ry = p[1] - o[1], rz = p[2] - o[2];
34324
34351
  S.push(rx * ex + ry * ey + rz * ez);
@@ -34383,6 +34410,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
34383
34410
  AC.nv += m * 2;
34384
34411
  }
34385
34412
  function ridge(a, b, type, roofColor) {
34413
+ const cuts = K.cfg.destruction ? baysAlong(a, b) : [];
34414
+ if (cuts.length) {
34415
+ let from = a;
34416
+ for (const f of [...cuts, 1]) {
34417
+ const to = [a[0] + (b[0] - a[0]) * f, a[1] + (b[1] - a[1]) * f, a[2] + (b[2] - a[2]) * f];
34418
+ ridgeCap(from, to, type, roofColor);
34419
+ from = to;
34420
+ }
34421
+ return;
34422
+ }
34423
+ ridgeCap(a, b, type, roofColor);
34424
+ }
34425
+ function ridgeCap(a, b, type, roofColor) {
34386
34426
  cursor.pc = pieceOfPane((a[0] + b[0]) / 2, (a[2] + b[2]) / 2);
34387
34427
  const dx = b[0] - a[0], dy = b[1] - a[1], dz = b[2] - a[2], Ln = Math.hypot(dx, dy, dz);
34388
34428
  if (Ln < 0.05) return;
@@ -34409,7 +34449,81 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
34409
34449
  }
34410
34450
  return m ? structurePiece(m.id) : null;
34411
34451
  }
34412
- const defined = { R_STYLE, tileRelief, ridge, pieceOfPane };
34452
+ function paneTiles(mat, pts, color2, type) {
34453
+ const panes = panesUnder(pts), whole = centroidPiece(pts);
34454
+ if (panes.length < 2 || !whole || !K.cfg.destruction) {
34455
+ cursor.pc = whole;
34456
+ tileRelief(mat, pts, color2, type);
34457
+ return;
34458
+ }
34459
+ for (const r of panes) {
34460
+ const part = clipToRect(pts, r);
34461
+ if (part.length < 3 || planArea(part) < 1e-4) continue;
34462
+ cursor.pc = centroidPiece(part);
34463
+ tileRelief(mat, part, color2, type, pts[0]);
34464
+ }
34465
+ }
34466
+ function centroidPiece(pts) {
34467
+ let cx = 0, cz = 0;
34468
+ for (const p of pts) {
34469
+ cx += p[0];
34470
+ cz += p[2];
34471
+ }
34472
+ return pieceOfPane(cx / pts.length, cz / pts.length);
34473
+ }
34474
+ function panesUnder(pts) {
34475
+ if (shared3.ctx.noPiece || !shared3.ctx.panes.length) return [];
34476
+ let x0 = Infinity, z0 = Infinity, x1 = -Infinity, z1 = -Infinity;
34477
+ for (const p of pts) {
34478
+ x0 = Math.min(x0, p[0]);
34479
+ x1 = Math.max(x1, p[0]);
34480
+ z0 = Math.min(z0, p[2]);
34481
+ z1 = Math.max(z1, p[2]);
34482
+ }
34483
+ const boxes = shared3.ctx.panes.map((a) => a.aabb).filter((b) => !!b && b[0] < x1 - 1e-4 && b[2] > x0 + 1e-4 && b[1] < z1 - 1e-4 && b[3] > z0 + 1e-4);
34484
+ if (boxes.length < 2) return boxes;
34485
+ const lo = [Math.min(...boxes.map((b) => b[0])), Math.min(...boxes.map((b) => b[1]))], hi = [Math.max(...boxes.map((b) => b[2])), Math.max(...boxes.map((b) => b[3]))];
34486
+ return boxes.map((b) => [b[0] <= lo[0] + 1e-6 ? -Infinity : b[0], b[1] <= lo[1] + 1e-6 ? -Infinity : b[1], b[2] >= hi[0] - 1e-6 ? Infinity : b[2], b[3] >= hi[1] - 1e-6 ? Infinity : b[3]]);
34487
+ }
34488
+ function baysAlong(a, b) {
34489
+ const rects = panesUnder([a, b, [b[0] + 1e-3, b[1], b[2] + 1e-3], [a[0] - 1e-3, a[1], a[2] - 1e-3]]);
34490
+ const alongX = Math.abs(b[0] - a[0]) >= Math.abs(b[2] - a[2]), i = alongX ? 0 : 2, k = alongX ? 0 : 1, span = b[i] - a[i];
34491
+ if (Math.abs(span) < 1e-6) return [];
34492
+ const cuts = /* @__PURE__ */ new Set();
34493
+ for (const r of rects) for (const v of [r[k], r[k + 2]]) {
34494
+ const f = (v - a[i]) / span;
34495
+ if (Number.isFinite(f) && f > 0.01 && f < 0.99) cuts.add(+f.toFixed(4));
34496
+ }
34497
+ return [...cuts].sort((p, q) => p - q);
34498
+ }
34499
+ function clipToRect(pts, r) {
34500
+ let poly = pts.map((p) => [p[0], p[1], p[2]]);
34501
+ const edges = [[0, r[0], 1], [0, r[2], -1], [2, r[1], 1], [2, r[3], -1]];
34502
+ for (const [axis2, at4, sign2] of edges) {
34503
+ if (!Number.isFinite(at4)) continue;
34504
+ const out = [];
34505
+ for (let i = 0; i < poly.length; i++) {
34506
+ const p = poly[i], q = poly[(i + 1) % poly.length], dp = (p[axis2] - at4) * sign2, dq = (q[axis2] - at4) * sign2;
34507
+ if (dp >= 0) out.push(p);
34508
+ if (dp >= 0 !== dq >= 0) {
34509
+ const t = dp / (dp - dq);
34510
+ out.push([p[0] + (q[0] - p[0]) * t, p[1] + (q[1] - p[1]) * t, p[2] + (q[2] - p[2]) * t]);
34511
+ }
34512
+ }
34513
+ poly = out;
34514
+ if (poly.length < 3) return [];
34515
+ }
34516
+ return poly;
34517
+ }
34518
+ function planArea(pts) {
34519
+ let a = 0;
34520
+ for (let i = 0; i < pts.length; i++) {
34521
+ const p = pts[i], q = pts[(i + 1) % pts.length];
34522
+ a += p[0] * q[2] - q[0] * p[2];
34523
+ }
34524
+ return Math.abs(a) / 2;
34525
+ }
34526
+ const defined = { R_STYLE, tileRelief, paneTiles, ridge, pieceOfPane };
34413
34527
  Object.assign(K, defined);
34414
34528
  }
34415
34529
  function installRoofRect(K, shared3) {
@@ -34418,15 +34532,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
34418
34532
  function roofRect(type, X0, Z0, X1, Z1, yb, roofColor, gable, F, touchesU = [0, 0, 0, 0]) {
34419
34533
  const C = shared3.ctx.colors, o = type === "fiber_cement" ? 0.3 : 0.45, x0 = X0 - (touchesU[0] ? 0 : o), x1 = X1 + (touchesU[2] ? 0 : o), z0 = Z0 - (touchesU[1] ? 0 : o), z1 = Z1 + (touchesU[3] ? 0 : o), dx = x1 - x0, dz = z1 - z0, xm = (x0 + x1) / 2, zm = (z0 + z1) / 2;
34420
34534
  const mat = type === "fiber_cement" ? "fiber_cement" : "tile", tp = type === "fiber_cement" ? 0.2 : 0.5, alongX = dx >= dz, up = [0, 1, 0];
34421
- const Q = (pts) => {
34422
- let cx = 0, cz = 0;
34423
- for (const p of pts) {
34424
- cx += p[0];
34425
- cz += p[2];
34426
- }
34427
- cursor.pc = pieceOfPane(cx / pts.length, cz / pts.length);
34428
- return tileRelief(mat, pts, roofColor, type);
34429
- };
34535
+ const Q = (pts) => K.paneTiles(mat, pts, roofColor, type);
34430
34536
  cursor.pc = pieceOfPane(xm, zm);
34431
34537
  {
34432
34538
  const wt = 0.075, yc = yb - 0.2, cf = C.facade != null ? C.facade : 14209216, fas = R_STYLE() === "budget" ? 7228980 : sh(roofColor, 0.55), sof = 15131352, tz = 0.035;
@@ -67760,9 +67866,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
67760
67866
  });
67761
67867
  }
67762
67868
  function placementOf(entry2) {
67869
+ const carrier = entry2.carrier;
67870
+ if (carrier) return { origin: carrier.origin, anchor: entry2.anchor, yaw: entry2.yaw, carrier, ...carrier.orientation ? { orientation: carrier.orientation } : {} };
67763
67871
  const origin = entry2.follow ? [entry2.origin[0] + positionOf2(entry2.follow)[0], entry2.origin[1] + positionOf2(entry2.follow)[1], entry2.origin[2] + positionOf2(entry2.follow)[2]] : entry2.origin;
67764
67872
  return { origin, anchor: entry2.anchor, yaw: entry2.yaw, ...entry2.orientation ? { orientation: entry2.orientation } : {} };
67765
67873
  }
67874
+ function moveCarrier(entry2) {
67875
+ const pose = entry2.track?.();
67876
+ if (!pose || !entry2.carrier) return;
67877
+ entry2.carrier.origin = [pose.point[0], pose.point[1], pose.point[2]];
67878
+ if (pose.orientation) entry2.carrier.orientation = pose.orientation;
67879
+ }
67766
67880
  function drawing(entry2, action) {
67767
67881
  const context = engine.context;
67768
67882
  const shared3 = context.random;
@@ -67788,7 +67902,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
67788
67902
  anchor: def.anchor ?? ORIGIN5,
67789
67903
  yaw: yawOf(heading, playOptions.direction),
67790
67904
  orientation: playOptions.orientation,
67791
- seconds: playOptions.seconds ?? (def.loop && def.loop > 0 ? def.loop : ENDLESS_SECONDS)
67905
+ seconds: playOptions.seconds ?? (def.loop && def.loop > 0 ? def.loop : ENDLESS_SECONDS),
67906
+ track: playOptions.track,
67907
+ carrier: playOptions.track ? { origin: point, orientation: playOptions.orientation } : void 0
67792
67908
  };
67793
67909
  playing.push(entry2);
67794
67910
  drawing(
@@ -67810,11 +67926,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
67810
67926
  for (let index = playing.length - 1; index >= 0; index--) {
67811
67927
  const entry2 = playing[index];
67812
67928
  const instance = entry2.instance;
67929
+ moveCarrier(entry2);
67813
67930
  instance.setup = { ...instance.setup, placement: placementOf(entry2) };
67814
67931
  drawing(entry2, () => instance.step(dt));
67815
67932
  if (instance.time >= entry2.seconds) playing.splice(index, 1);
67816
67933
  }
67817
67934
  },
67935
+ retrack() {
67936
+ let tracked = false;
67937
+ for (const entry2 of playing) {
67938
+ if (!entry2.carrier) continue;
67939
+ moveCarrier(entry2);
67940
+ tracked = true;
67941
+ }
67942
+ return tracked;
67943
+ },
67818
67944
  clear() {
67819
67945
  playing.length = 0;
67820
67946
  },
@@ -69426,6 +69552,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
69426
69552
  }
69427
69553
  }
69428
69554
  };
69555
+ function rotate(q, v) {
69556
+ const [qx, qy, qz, qw] = q;
69557
+ const ix = qw * v[0] + qy * v[2] - qz * v[1];
69558
+ const iy = qw * v[1] + qz * v[0] - qx * v[2];
69559
+ const iz = qw * v[2] + qx * v[1] - qy * v[0];
69560
+ const iw = -qx * v[0] - qy * v[1] - qz * v[2];
69561
+ return [ix * qw + iw * -qx + iy * -qz - iz * -qy, iy * qw + iw * -qy + iz * -qx - ix * -qz, iz * qw + iw * -qz + ix * -qy - iy * -qx];
69562
+ }
69563
+ function carriedPoint(carried) {
69564
+ const { carrier, local: local2 } = carried;
69565
+ const turned = carrier.orientation ? rotate(carrier.orientation, local2) : local2;
69566
+ return [carrier.origin[0] + turned[0], carrier.origin[1] + turned[1], carrier.origin[2] + turned[2]];
69567
+ }
69429
69568
  var CAPACITY3 = 400;
69430
69569
  var IDENTITY2 = [0, 0, 0, 1];
69431
69570
  function multiply2(a, b) {
@@ -69443,7 +69582,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
69443
69582
  get count() {
69444
69583
  return this.particles.length;
69445
69584
  }
69446
- spawn(options, frame2 = IDENTITY2) {
69585
+ spawn(options, frame2 = IDENTITY2, carried) {
69447
69586
  const velocity = options.v ?? [0, 0, 0];
69448
69587
  const world = options.wv ?? [0, 0, 0];
69449
69588
  const particle = {
@@ -69460,6 +69599,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
69460
69599
  y: options.p[1],
69461
69600
  z: options.p[2],
69462
69601
  frame: options.roll ? multiply2(frame2, aboutX(options.roll)) : frame2,
69602
+ roll: options.roll ? aboutX(options.roll) : void 0,
69603
+ carried,
69604
+ drift: [0, 0, 0],
69463
69605
  at: options.at ?? [0, 0, 0],
69464
69606
  rx: options.rot?.[0] ?? 0,
69465
69607
  ry: options.rot?.[1] ?? 0,
@@ -69500,9 +69642,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
69500
69642
  particle.vy *= keep;
69501
69643
  particle.vz *= keep;
69502
69644
  }
69503
- particle.x += particle.vx * dt;
69504
- particle.y += particle.vy * dt;
69505
- particle.z += particle.vz * dt;
69645
+ if (particle.carried) this.ride(particle, dt);
69646
+ else {
69647
+ particle.x += particle.vx * dt;
69648
+ particle.y += particle.vy * dt;
69649
+ particle.z += particle.vz * dt;
69650
+ }
69506
69651
  particle.rx += particle.spin[0] * dt;
69507
69652
  particle.ry += particle.spin[1] * dt;
69508
69653
  particle.rz += particle.spin[2] * dt;
@@ -69513,6 +69658,30 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
69513
69658
  clear() {
69514
69659
  this.particles.length = 0;
69515
69660
  }
69661
+ /** Puts every carried piece where its carrier is now (after the frame moved the thing it belongs to). */
69662
+ follow() {
69663
+ for (const particle of this.particles) if (particle.carried) this.place(particle);
69664
+ }
69665
+ /** A carried piece: how far its own velocity took it, then its place on the carrier. */
69666
+ ride(particle, dt) {
69667
+ const drift = particle.drift;
69668
+ drift[0] += particle.vx * dt;
69669
+ drift[1] += particle.vy * dt;
69670
+ drift[2] += particle.vz * dt;
69671
+ this.place(particle);
69672
+ }
69673
+ /** A carried piece's place on the carrier now plus its drift, turned with the carrier. */
69674
+ place(particle) {
69675
+ const carried = particle.carried;
69676
+ if (!carried) return;
69677
+ const drift = particle.drift;
69678
+ const [x, y, z] = carriedPoint(carried);
69679
+ particle.x = x + drift[0];
69680
+ particle.y = y + drift[1];
69681
+ particle.z = z + drift[2];
69682
+ const turn2 = carried.carrier.orientation;
69683
+ if (turn2) particle.frame = particle.roll ? multiply2(turn2, particle.roll) : turn2;
69684
+ }
69516
69685
  };
69517
69686
  var DEFAULT_FADE_IN = 0.1;
69518
69687
  var FLOATS_PER_VECTOR = 3;
@@ -69873,8 +70042,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
69873
70042
  }
69874
70043
  flash(point, color2, intensity, duration, distance4, force, steady) {
69875
70044
  const { level } = this.context.quality;
69876
- if (level >= 1 && !force) return;
69877
- if (level >= 2 && force !== "boom") return;
70045
+ if (level >= 1 && !force) return void 0;
70046
+ if (level >= 2 && force !== "boom") return void 0;
69878
70047
  const light = this.lights[this.next++ % LIGHT_CAPACITY];
69879
70048
  light.x = point[0];
69880
70049
  light.y = point[1];
@@ -69886,17 +70055,24 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
69886
70055
  light.t = 0;
69887
70056
  light.steady = steady === true;
69888
70057
  light.intensity = intensity;
70058
+ light.carried = void 0;
70059
+ return light;
69889
70060
  }
69890
70061
  clear() {
69891
70062
  for (const light of this.lights) light.intensity = 0;
69892
70063
  for (const light of this.fire) light.intensity = 0;
69893
70064
  }
70065
+ /** Puts every carried light that burns where its carrier is now. */
70066
+ follow() {
70067
+ for (const light of this.lights) if (light.intensity > 0 && light.carried) [light.x, light.y, light.z] = carriedPoint(light.carried);
70068
+ }
69894
70069
  update(dt) {
69895
70070
  for (const light of this.lights) {
69896
70071
  if (light.intensity <= 0) continue;
69897
70072
  light.t += dt;
69898
70073
  const age = light.t / light.duration;
69899
70074
  light.intensity = age >= 1 ? 0 : light.steady ? light.peak : light.peak * (1 - age) * (1 - age);
70075
+ if (light.carried) [light.x, light.y, light.z] = carriedPoint(light.carried);
69900
70076
  }
69901
70077
  }
69902
70078
  };
@@ -69904,7 +70080,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
69904
70080
  var FIRE_FLICKER_SWAY = 0.25;
69905
70081
  var FIRE_FLICKER_JITTER = 0.08;
69906
70082
  var LENS_FADE = 0.16;
69907
- function rotate(q, v) {
70083
+ function rotate2(q, v) {
69908
70084
  const [qx, qy, qz, qw] = q;
69909
70085
  const ix = qw * v[0] + qy * v[2] - qz * v[1];
69910
70086
  const iy = qw * v[1] + qz * v[0] - qx * v[2];
@@ -69961,7 +70137,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
69961
70137
  if (!placement) return point;
69962
70138
  const { anchor, origin, yaw, orientation } = placement;
69963
70139
  if (orientation) {
69964
- const turned = rotate(orientation, [point[0] - anchor[0], point[1] - anchor[1], point[2] - anchor[2]]);
70140
+ const turned = rotate2(orientation, [point[0] - anchor[0], point[1] - anchor[1], point[2] - anchor[2]]);
69965
70141
  return [origin[0] + turned[0], origin[1] + turned[1], origin[2] + turned[2]];
69966
70142
  }
69967
70143
  const x = point[0] - anchor[0];
@@ -69970,11 +70146,20 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
69970
70146
  const sin2 = Math.sin(yaw);
69971
70147
  return [origin[0] + cos2 * x + sin2 * z, origin[1] + point[1] - anchor[1], origin[2] - sin2 * x + cos2 * z];
69972
70148
  }
70149
+ /** A point of the recipe's space from the anchor, turned by the placement's yaw when it has no orientation (the carrier turns the rest). */
70150
+ local(point) {
70151
+ const placement = this.placement;
70152
+ if (!placement) return point;
70153
+ const offset = [point[0] - placement.anchor[0], point[1] - placement.anchor[1], point[2] - placement.anchor[2]];
70154
+ if (placement.carrier?.orientation) return offset;
70155
+ const turned = this.place(point);
70156
+ return [turned[0] - placement.origin[0], turned[1] - placement.origin[1], turned[2] - placement.origin[2]];
70157
+ }
69973
70158
  /** A direction or velocity of the recipe's space in the world. */
69974
70159
  turn(vector2) {
69975
70160
  const placement = this.placement;
69976
70161
  if (!placement) return vector2;
69977
- if (placement.orientation) return rotate(placement.orientation, vector2);
70162
+ if (placement.orientation) return rotate2(placement.orientation, vector2);
69978
70163
  const cos2 = Math.cos(placement.yaw);
69979
70164
  const sin2 = Math.sin(placement.yaw);
69980
70165
  return [cos2 * vector2[0] + sin2 * vector2[2], vector2[1], -sin2 * vector2[0] + cos2 * vector2[2]];
@@ -70009,7 +70194,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
70009
70194
  const options = placement ? { ...recipe2, p: this.place(recipe2.p), ...recipe2.v ? { v: this.turn(recipe2.v) } : {} } : recipe2;
70010
70195
  this.context.trace?.("mesh", [options]);
70011
70196
  const grouped = recipe2.at !== void 0 || recipe2.roll !== void 0;
70012
- return this.meshes.spawn(options, placement && grouped ? placement.orientation ?? [0, Math.sin(placement.yaw / 2), 0, Math.cos(placement.yaw / 2)] : void 0);
70197
+ const carried = placement?.carrier && grouped ? { carrier: placement.carrier, local: this.local(recipe2.p) } : void 0;
70198
+ return this.meshes.spawn(options, placement && grouped ? placement.orientation ?? [0, Math.sin(placement.yaw / 2), 0, Math.cos(placement.yaw / 2)] : void 0, carried);
70013
70199
  }
70014
70200
  debrisPiece(recipe2) {
70015
70201
  const options = this.placed(recipe2);
@@ -70033,9 +70219,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
70033
70219
  }
70034
70220
  /** `steady` (a seventh number): the light holds its intensity for its duration and goes out, where the Workshop's fades with the square of its age. */
70035
70221
  flash(recipe2) {
70036
- const args = this.placement ? [this.place(recipe2[0]), recipe2[1], recipe2[2], recipe2[3], recipe2[4], recipe2[5], recipe2[6]] : recipe2;
70222
+ const placement = this.placement;
70223
+ const args = placement ? [this.place(recipe2[0]), recipe2[1], recipe2[2], recipe2[3], recipe2[4], recipe2[5], recipe2[6]] : recipe2;
70037
70224
  this.context.trace?.("flash", args.slice(0, 6));
70038
- this.lights.flash(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
70225
+ const light = this.lights.flash(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
70226
+ if (light && placement?.carrier) light.carried = { carrier: placement.carrier, local: this.local(recipe2[0]) };
70039
70227
  }
70040
70228
  /** `fireLight` (W400): sways with the clock and flickers with one draw. */
70041
70229
  fireLight(slot, recipe2, intensity, time) {
@@ -70194,6 +70382,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
70194
70382
  const seed = playOptions.seed ?? (randomMode === "shared" ? void 0 : Math.imul(++handles.events, AUTO_SEED) + (options.seed ?? 0));
70195
70383
  return effectPlayer().play(id, [point[0], point[1], point[2]], { ...playOptions, ...seed !== void 0 ? { seed } : {} });
70196
70384
  },
70385
+ follow() {
70386
+ if (!engine || !player?.retrack()) return false;
70387
+ engine.meshes.follow();
70388
+ engine.lights.follow();
70389
+ return true;
70390
+ },
70197
70391
  burst: (kind, point, normal, count, speed, spriteOptions) => spriteSystem.burst(kind, point, normal, count, speed, spriteOptions),
70198
70392
  spawn: (kind, point, velocity, spriteOptions) => spriteSystem.spawn(kind, point, velocity, spriteOptions),
70199
70393
  onLand: (owner, listener) => spriteSystem.onLand(owner, listener),
@@ -70342,7 +70536,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
70342
70536
  };
70343
70537
  }
70344
70538
 
70345
- // ../game-vfx-three/dist/chunk-PZ6IVOLZ.js
70539
+ // ../game-vfx-three/dist/chunk-HJXLYDNY.js
70346
70540
  var GLOW_VERTEX = `attribute vec4 aP;attribute vec4 aC;varying vec2 vU;varying vec4 vC;
70347
70541
  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]);
70348
70542
  vec3 wp=aP.xyz+(R*position.x+Up*position.y)*aP.w;vU=position.xy;vC=aC;gl_Position=projectionMatrix*viewMatrix*vec4(wp,1.);}`;
@@ -71777,7 +71971,8 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
71777
71971
  ...request.orientation ? { orientation: request.orientation } : {},
71778
71972
  ...request.seed !== void 0 ? { seed: request.seed } : {},
71779
71973
  ...request.param !== void 0 ? { param: request.param } : {},
71780
- ...request.values ? { values: request.values } : {}
71974
+ ...request.values ? { values: request.values } : {},
71975
+ ...request.track ? { track: request.track } : {}
71781
71976
  });
71782
71977
  },
71783
71978
  stop: (handle) => world.stop(handle),
@@ -71806,6 +72001,11 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
71806
72001
  syncAll();
71807
72002
  overlay?.update(screenNow());
71808
72003
  },
72004
+ present() {
72005
+ if (!world.follow()) return;
72006
+ lights.sync();
72007
+ workshopLayers?.sync();
72008
+ },
71809
72009
  warmUpProbes() {
71810
72010
  releaseAnchors();
71811
72011
  marks.prepare();
@@ -71859,9 +72059,13 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
71859
72059
  const seed = () => 1 + Math.floor(random() * 2147483646);
71860
72060
  const barrel = (orientation) => vec3(new THREE.Vector3(1, 0, 0).applyQuaternion(orientation));
71861
72061
  return {
71862
- muzzleFlash(position, orientation, size, profile = MUZZLE_SMOKE.smokeless) {
72062
+ muzzleFlash(position, orientation, size, profile = MUZZLE_SMOKE.smokeless, track) {
71863
72063
  if (profile.puffs <= 0 && profile.flash <= 0) return;
71864
- sink?.play({ effect: VIEWMODEL_EFFECT_IDS.flash, point: vec3(position), direction: barrel(orientation), orientation: quaternion(orientation), seed: seed(), values: { size, ...profile } });
72064
+ const follow = track ? () => {
72065
+ const pose = track();
72066
+ return pose ? { point: vec3(pose.position), orientation: quaternion(pose.orientation) } : null;
72067
+ } : void 0;
72068
+ sink?.play({ effect: VIEWMODEL_EFFECT_IDS.flash, point: vec3(position), direction: barrel(orientation), orientation: quaternion(orientation), seed: seed(), values: { size, ...profile }, ...follow ? { track: follow } : {} });
71865
72069
  },
71866
72070
  smoke(position, velocity, size, life, opacity) {
71867
72071
  sink?.play({ effect: VIEWMODEL_EFFECT_IDS.smoke, point: vec3(position), seed: seed(), values: { vx: velocity.x, vy: velocity.y, vz: velocity.z, radius: size, life, opacity } });
@@ -72254,17 +72458,19 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
72254
72458
  particles.spawn(round5.group, toWorld2(session, vector2(-0.2, 1.1, 1.2)), { kind: "round", life: 25, radius: round5.radius, bounce: 0.3, spin: vector2(8, 12, 6), onRest: restFlat, ownsGeometry: true });
72255
72459
  } else ejectFromPort(false);
72256
72460
  };
72461
+ const trackOf = (mark) => () => root.parent ? { position: positionOf3(mark), orientation: root.getWorldQuaternion(new THREE.Quaternion()) } : null;
72257
72462
  return (event) => {
72258
72463
  const data = event.data ?? {};
72259
72464
  switch (event.type) {
72260
72465
  case "muzzle_flash":
72261
72466
  if (data.at === "ugl") {
72262
- if (parts.uglMuzzle && world.layers.muzzleFlash) world.afterPose(() => parts.uglMuzzle && effects.muzzleFlash(positionOf3(parts.uglMuzzle), root.getWorldQuaternion(new THREE.Quaternion()), UGL_FLASH));
72467
+ const ugl = parts.uglMuzzle;
72468
+ if (ugl && world.layers.muzzleFlash) world.afterPose(() => effects.muzzleFlash(positionOf3(ugl), root.getWorldQuaternion(new THREE.Quaternion()), UGL_FLASH, void 0, trackOf(ugl)));
72263
72469
  } else if (parts.muzzle && world.layers.muzzleFlash && (session.def.action.kind === "firearm" || session.def.action.kind === "launcher")) {
72264
72470
  const profile = muzzleSmokeOf({ caliber: session.caliber, weapon: session.def, suppressed: session.suppressed });
72265
72471
  const size = session.def.action.kind === "launcher" ? 2.2 : FLASH_BY_CASE[session.caseType];
72266
72472
  const muzzle2 = parts.muzzle;
72267
- world.afterPose(() => effects.muzzleFlash(positionOf3(muzzle2), root.getWorldQuaternion(new THREE.Quaternion()), size, profile));
72473
+ world.afterPose(() => effects.muzzleFlash(positionOf3(muzzle2), root.getWorldQuaternion(new THREE.Quaternion()), size, profile, trackOf(muzzle2)));
72268
72474
  }
72269
72475
  break;
72270
72476
  case "eject_casing":
@@ -72853,11 +73059,17 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
72853
73059
  play: (request) => {
72854
73060
  if (!lens2 || !request.point) return worldSink.play(request);
72855
73061
  const at4 = toWorldLens(camera2, lensPoint.set(...request.point), worldFovOf(), lens2.fov);
72856
- return worldSink.play({ ...request, point: [at4.x, at4.y, at4.z] });
73062
+ const track = request.track;
73063
+ return worldSink.play({ ...request, point: [at4.x, at4.y, at4.z], ...track ? { track: () => seenThroughLens(track()) } : {} });
72857
73064
  },
72858
73065
  stop: (handle) => worldSink.stop(handle)
72859
73066
  } : void 0;
72860
73067
  const effects = createEffects(THREE, lensSink, random);
73068
+ function seenThroughLens(pose) {
73069
+ if (!pose || !lens2) return pose;
73070
+ const at4 = toWorldLens(camera2, trackPoint.set(...pose.point), worldFovOf(), lens2.fov);
73071
+ return { ...pose, point: [at4.x, at4.y, at4.z] };
73072
+ }
72861
73073
  const hand = new THREE.Group();
72862
73074
  hand.name = VIEWMODEL_NODE_NAME;
72863
73075
  scene.add(hand);
@@ -73024,6 +73236,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
73024
73236
  let lens2 = null;
73025
73237
  let lensLayer = -1;
73026
73238
  const lensPoint = new THREE.Vector3();
73239
+ const trackPoint = new THREE.Vector3();
73027
73240
  const worldFovOf = () => camera2.fov ?? 72;
73028
73241
  const setLens = (kind) => {
73029
73242
  const fov = kind ? VIEW_HOLD[kind].fov : null;