@adatechnology/game-weapons-three 0.29.0 → 0.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17281,7 +17281,8 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
17281
17281
  seconds: 0.7
17282
17282
  }
17283
17283
  ],
17284
- reset: 1.2
17284
+ reset: 1.2,
17285
+ contactLength: 0.3
17285
17286
  },
17286
17287
  {
17287
17288
  id: "two_hand_swing",
@@ -28207,9 +28208,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28207
28208
  at4[p.thin] = Math.sign(lp[p.thin]) * p.dims[p.thin] / 2;
28208
28209
  const r = vec.distance(toWorld(p.pos, p.q, at4), centre);
28209
28210
  const side = sideOnOverpressure(tnt, r);
28210
- const reflected = 2 * side + 6 * side * side / (side + 7 * 101325);
28211
+ const reflected2 = 2 * side + 6 * side * side / (side + 7 * 101325);
28211
28212
  const impulse = bodyImpulse(tnt, r);
28212
- if (reflected > PANEL_PRESSURE && impulse > PANEL_IMPULSE && (reflected - PANEL_PRESSURE) * (impulse - PANEL_IMPULSE) >= PANEL_PI) loaded++;
28213
+ if (reflected2 > PANEL_PRESSURE && impulse > PANEL_IMPULSE && (reflected2 - PANEL_PRESSURE) * (impulse - PANEL_IMPULSE) >= PANEL_PI) loaded++;
28213
28214
  }
28214
28215
  if (loaded < PANEL_POINTS_LOADED) return false;
28215
28216
  const grid = gridOf(p);
@@ -53193,7 +53194,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53193
53194
  d: 0.38,
53194
53195
  h: 0.3,
53195
53196
  y: 0.9,
53196
- solid: false,
53197
+ solid: true,
53197
53198
  massKg: 14,
53198
53199
  sounds: {
53199
53200
  leaves: {
@@ -54770,12 +54771,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54770
54771
  const zb = oz + inw * v1;
54771
54772
  return { floor: p.floor, x0: ox + u0, x1: ox + u1, z0: Math.min(za, zb), z1: Math.max(za, zb) };
54772
54773
  });
54773
- const CELL2 = 0.5;
54774
+ const CELL3 = 0.5;
54774
54775
  const grid = /* @__PURE__ */ new Map();
54775
54776
  const key2 = (a, i, j) => (a * 4096 + (i + 2048)) * 4096 + (j + 2048);
54776
54777
  for (const s of segs) {
54777
- for (let i = Math.floor(s.x0 / CELL2); i <= Math.floor(s.x1 / CELL2); i++) {
54778
- for (let j = Math.floor(s.z0 / CELL2); j <= Math.floor(s.z1 / CELL2); j++) {
54778
+ for (let i = Math.floor(s.x0 / CELL3); i <= Math.floor(s.x1 / CELL3); i++) {
54779
+ for (let j = Math.floor(s.z0 / CELL3); j <= Math.floor(s.z1 / CELL3); j++) {
54779
54780
  const k = key2(s.floor, i, j);
54780
54781
  if (!grid.has(k)) grid.set(k, []);
54781
54782
  grid.get(k).push(s);
@@ -54784,7 +54785,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54784
54785
  }
54785
54786
  return function blocked(x, z, floor2) {
54786
54787
  const a = floor2 == null || floor2 < 0 ? 0 : floor2;
54787
- const list2 = grid.get(key2(a, Math.floor(x / CELL2), Math.floor(z / CELL2)));
54788
+ const list2 = grid.get(key2(a, Math.floor(x / CELL3), Math.floor(z / CELL3)));
54788
54789
  if (!list2) return false;
54789
54790
  for (const s of list2) if (x > s.x0 && x < s.x1 && z > s.z0 && z < s.z1) return true;
54790
54791
  return false;
@@ -93152,6 +93153,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
93152
93153
  var QUALITY = { $: "quality" };
93153
93154
  var FRESH = { $: "fresh" };
93154
93155
  var DIRECTION = { $: "direction" };
93156
+ var NORMAL = { $: "normal" };
93155
93157
  var CAMERA_POSITION = { $: "cameraPosition" };
93156
93158
  var burst = (system, count, spawn2) => ({ op: "burst", system, count, spawn: spawn2 });
93157
93159
  var spawn = (system, options) => ({ op: "spawn", system, spawn: options });
@@ -93673,7 +93675,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
93673
93675
  var TIP22 = [-0.8, 1.38, 3.4 - 0.78];
93674
93676
  var PORT2 = [-0.76, 1.4, 3.32];
93675
93677
  var FORWARD3 = [0, 0, -1];
93676
- var NORMAL = [0, 0, 1];
93678
+ var NORMAL2 = [0, 0, 1];
93677
93679
  var WALL_Z2 = -4.45;
93678
93680
  var SHOTS = [[0, 0.45, 0.9], [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6], [0], [0]];
93679
93681
  var SHOT_TIME = pick2(pick2(SHOTS, PARAM), INDEX);
@@ -93698,8 +93700,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
93698
93700
  set("target", [add(-0.8, rnd(-0.4, 0.4)), add(1.4, rnd(-0.3, 0.3)), WALL_Z2]),
93699
93701
  when(
93700
93702
  eq(PARAM, SHOTGUN),
93701
- [repeat(8, call2("impact", "concrete", [add(-0.8, rnd(-0.5, 0.5)), add(1.4, rnd(-0.4, 0.4)), WALL_Z2], NORMAL, 0.35))],
93702
- [call2("impact", "concrete", variable("target"), NORMAL, ite(eq(PARAM, BARRETT), 2, 1))]
93703
+ [repeat(8, call2("impact", "concrete", [add(-0.8, rnd(-0.5, 0.5)), add(1.4, rnd(-0.4, 0.4)), WALL_Z2], NORMAL2, 0.35))],
93704
+ [call2("impact", "concrete", variable("target"), NORMAL2, ite(eq(PARAM, BARRETT), 2, 1))]
93703
93705
  ),
93704
93706
  when(and(eq(PARAM, AK), eq(mod(round4(mul(SHOT_TIME, 10)), 3), 0)), [spawn("streak", { p: TIP22, dir: FORWARD3, cone: 0, sp: 90, life: 0.09, len: 0.025, c0: 16752704, a: 1 })])
93705
93707
  )
@@ -95094,7 +95096,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
95094
95096
  };
95095
95097
  var VIEWMODEL_EFFECTS = [MUZZLE_FLASH2, SMOKE_PUFF, BACKBLAST, FLAME_JET];
95096
95098
  var aliasOf = (base, id, changes) => ({ ...base, id, pageId: `vehicle:${id}`, anchor: CAR_ORIGIN2, ...changes });
95099
+ var BODYWORK_IMPACT = {
95100
+ id: "impact_bodywork",
95101
+ pageId: "vehicle:impact_bodywork",
95102
+ team: "vehicles",
95103
+ budget: { particles: 80, debris: 20, lights: 1 },
95104
+ loop: 2,
95105
+ timeline: [call2("bodywork_impact", [0, 0, 0], NORMAL, [variable("dx"), variable("dy"), variable("dz")], variable("bore"), variable("paint"), variable("metal"))]
95106
+ };
95097
95107
  var VEHICLE_EFFECTS = [
95108
+ BODYWORK_IMPACT,
95098
95109
  /** The engine on fire: `engine_smoke` at its worst condition (black smoke, flames in the hood, a light). */
95099
95110
  aliasOf(ENGINE_SMOKE, "vehicle_fire", { params: { id: "condition", options: ["100", "60", "30", "10"], default: 3 }, loop: 12 }),
95100
95111
  /** The exhaust of a car under way: `engine_smoke` in the best condition, for half a second so a moving car asks again. */
@@ -95799,6 +95810,46 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
95799
95810
  return evaluateCall(value.$, args.map((entry2) => resolve(entry2, context)));
95800
95811
  }
95801
95812
  }
95813
+ var PISTOL_BORE = 9e-3;
95814
+ var BARE_STEEL = 11778236;
95815
+ var DEFAULT_PAINT = 9147290;
95816
+ var DEFAULT_DIRECTION = [0, 0, -1];
95817
+ var MAX_SCALE = 3;
95818
+ var MIN_SCALE = 0.6;
95819
+ function reflected(direction, normal) {
95820
+ const along2 = direction[0] * normal[0] + direction[1] * normal[1] + direction[2] * normal[2];
95821
+ const out = [direction[0] - 2 * along2 * normal[0], direction[1] - 2 * along2 * normal[1], direction[2] - 2 * along2 * normal[2]];
95822
+ const length2 = Math.hypot(out[0], out[1], out[2]);
95823
+ if (length2 < 1e-6 || Math.abs(along2) > 0.98) return normal;
95824
+ return [out[0] / length2, out[1] / length2, out[2] / length2];
95825
+ }
95826
+ var numberOr = (value, fallback2) => typeof value === "number" && Number.isFinite(value) ? value : fallback2;
95827
+ function bodyworkHitOf(values) {
95828
+ const raw = Array.isArray(values.direction) ? values.direction : [];
95829
+ const direction = raw.length === 3 && raw.every((entry2) => typeof entry2 === "number" && Number.isFinite(entry2)) ? [raw[0], raw[1], raw[2]] : DEFAULT_DIRECTION;
95830
+ return { direction, bore: numberOr(values.bore, PISTOL_BORE), paint: numberOr(values.paint, DEFAULT_PAINT), metal: numberOr(values.metal, BARE_STEEL) };
95831
+ }
95832
+ function bodyworkScale(bore) {
95833
+ return Math.min(MAX_SCALE, Math.max(MIN_SCALE, bore / PISTOL_BORE));
95834
+ }
95835
+ function bodyworkImpact(engine, point, normal, hit) {
95836
+ const scale = bodyworkScale(hit.bore);
95837
+ const off = reflected(hit.direction, normal);
95838
+ if (engine.quality < 2) {
95839
+ engine.burst("streak", Math.round(14 * scale), { p: point, dir: off, cone: 0.75, sp: [4, 12], life: [0.08, 0.3], len: 0.03, c0: 16774352, c1: 16738840, g: 9.8, gnd: 2 });
95840
+ engine.burst("add", 2, { p: plusScaled(point, normal, 0.01), size: [0.06 * scale, 0.12 * scale], life: 0.05, c0: 16770736, fi: 0 });
95841
+ engine.flash([plusScaled(point, normal, 0.15), 16760432, 1.6 * scale, 0.05, 4]);
95842
+ }
95843
+ const flakes = engine.scaled(Math.round(5 * scale));
95844
+ for (let index = 0; index < flakes; index++) {
95845
+ engine.debrisPiece({ p: point, dir: normal, cone: 0.9, sp: [1.2, 3.5], size: [8e-3 * scale, 12e-4, 6e-3 * scale], k: [0.5, 1.4], c: hit.paint, life: 6, bounce: 0.2 });
95846
+ }
95847
+ const slivers = engine.scaled(Math.round(2 * scale));
95848
+ for (let index = 0; index < slivers; index++) {
95849
+ engine.debrisPiece({ p: point, dir: off, cone: 0.6, sp: [2.5, 6], size: [25e-4, 15e-4, 0.01 * scale], k: [0.6, 1.3], c: hit.metal, life: 6, bounce: 0.35 });
95850
+ }
95851
+ engine.burst("normal", Math.round(6 * scale), { p: point, dir: normal, cone: 0.7, sp: [0.4, 1.4], drag: 2.5, life: [0.4, 0.9], size: [0.03, 0.07], grow: 3, c0: hit.paint, a: 0.45, g: -0.05 });
95852
+ }
95802
95853
  var UP12 = [0, 1, 0];
95803
95854
  var ZERO2 = [0, 0, 0];
95804
95855
  var FULL_TURN_DRAWN = 6.283;
@@ -95948,9 +95999,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
95948
95999
  casing: ({ engine }, [port, type]) => casing(engine, port, type),
95949
96000
  chips: ({ engine }, [point, direction, count, spread2]) => chips(engine, point, direction, count, spread2),
95950
96001
  spark_at: ({ engine }, [point, direction, count, spread2]) => sparkAt(engine, point, direction, count, spread2),
95951
- rust_at: ({ engine }, [point, count]) => rustAt(engine, point, count)
96002
+ rust_at: ({ engine }, [point, count]) => rustAt(engine, point, count),
96003
+ bodywork_impact: ({ engine }, [point, normal, direction, bore, paint2, metal2]) => bodyworkImpact(engine, point, normal, bodyworkHitOf({ direction, bore, paint: paint2, metal: metal2 }))
95952
96004
  };
95953
- var DEFAULT_DIRECTION = [0, 0, -1];
96005
+ var DEFAULT_DIRECTION2 = [0, 0, -1];
95954
96006
  var DEFAULT_NORMAL = [0, 1, 0];
95955
96007
  var SCREEN_FIELDS = {
95956
96008
  shake: "shake",
@@ -96017,7 +96069,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
96017
96069
  return instance().fresh;
96018
96070
  },
96019
96071
  get direction() {
96020
- return instance().setup.direction ?? DEFAULT_DIRECTION;
96072
+ return instance().setup.direction ?? DEFAULT_DIRECTION2;
96021
96073
  },
96022
96074
  get normal() {
96023
96075
  return instance().setup.normal ?? DEFAULT_NORMAL;
@@ -97775,6 +97827,69 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
97775
97827
  addScaled(out, tangentB, sinTilt * Math.sin(phase));
97776
97828
  return out;
97777
97829
  }
97830
+ var CELL2 = 0.12;
97831
+ var OBSTACLE_BOUNCE = 0.3;
97832
+ var radiusOf = (piece2) => Math.max(piece2.sx, piece2.sz) * 0.5;
97833
+ var thicknessOf2 = (piece2) => Math.min(piece2.sx, piece2.sy, piece2.sz);
97834
+ var cellKey2 = (i, k) => (i + 4096) * 8192 + (k + 4096);
97835
+ var RestingGrid = class {
97836
+ constructor() {
97837
+ __publicField3(this, "cells", /* @__PURE__ */ new Map());
97838
+ }
97839
+ clear() {
97840
+ for (const list2 of this.cells.values()) list2.length = 0;
97841
+ }
97842
+ rebuild(pieces) {
97843
+ this.clear();
97844
+ for (const piece2 of pieces) {
97845
+ if (!piece2.on || !piece2.rest) continue;
97846
+ const key2 = cellKey2(Math.floor(piece2.x / CELL2), Math.floor(piece2.z / CELL2));
97847
+ const list2 = this.cells.get(key2);
97848
+ if (list2) list2.push(piece2);
97849
+ else this.cells.set(key2, [piece2]);
97850
+ }
97851
+ }
97852
+ /** The height a piece at `piece`'s place lands at on the pieces under it (the top of the highest one it overlaps), or `-Infinity` over none. */
97853
+ supportUnder(piece2) {
97854
+ const i = Math.floor(piece2.x / CELL2);
97855
+ const k = Math.floor(piece2.z / CELL2);
97856
+ const reach2 = radiusOf(piece2);
97857
+ let top = -Infinity;
97858
+ for (let di = -1; di <= 1; di++) {
97859
+ for (let dk = -1; dk <= 1; dk++) {
97860
+ for (const other of this.cells.get(cellKey2(i + di, k + dk)) ?? []) {
97861
+ if (other === piece2) continue;
97862
+ if (Math.hypot(other.x - piece2.x, other.z - piece2.z) > reach2 + radiusOf(other)) continue;
97863
+ const otherTop = other.y + thicknessOf2(other) * 0.5;
97864
+ if (otherTop <= piece2.y + thicknessOf2(piece2) * 0.5) top = Math.max(top, otherTop + thicknessOf2(piece2) * 0.5);
97865
+ }
97866
+ }
97867
+ }
97868
+ return top;
97869
+ }
97870
+ };
97871
+ function pushOutOfObstacles(piece2, obstacles) {
97872
+ let moved = false;
97873
+ for (const body of obstacles) {
97874
+ if (piece2.y < body.bottom || piece2.y > body.top) continue;
97875
+ const dx = piece2.x - body.x;
97876
+ const dz = piece2.z - body.z;
97877
+ const distance4 = Math.hypot(dx, dz);
97878
+ const reach2 = body.radius + radiusOf(piece2);
97879
+ if (distance4 >= reach2) continue;
97880
+ const nx = distance4 > 1e-6 ? dx / distance4 : 1;
97881
+ const nz = distance4 > 1e-6 ? dz / distance4 : 0;
97882
+ piece2.x = body.x + nx * reach2;
97883
+ piece2.z = body.z + nz * reach2;
97884
+ const into = piece2.vx * nx + piece2.vz * nz;
97885
+ if (into < 0) {
97886
+ piece2.vx -= (1 + OBSTACLE_BOUNCE) * into * nx;
97887
+ piece2.vz -= (1 + OBSTACLE_BOUNCE) * into * nz;
97888
+ }
97889
+ moved = true;
97890
+ }
97891
+ return moved;
97892
+ }
97778
97893
  var CAPACITY = 500;
97779
97894
  var GRAVITY22 = 9.8;
97780
97895
  var QUARTER_TURN4 = 1.5708;
@@ -97795,6 +97910,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
97795
97910
  __publicField3(this, "count", 0);
97796
97911
  __publicField3(this, "next", 0);
97797
97912
  __publicField3(this, "direction", { x: 0, y: 0, z: 0 });
97913
+ __publicField3(this, "resting", new RestingGrid());
97798
97914
  }
97799
97915
  spawn(options) {
97800
97916
  const random = this.context.random;
@@ -97832,14 +97948,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
97832
97948
  }
97833
97949
  update(dt) {
97834
97950
  this.count = 0;
97951
+ const contacts = this.context.debrisContacts;
97952
+ const obstacles = contacts?.obstacles() ?? [];
97953
+ let moving = false;
97835
97954
  for (const piece2 of this.pieces) {
97836
97955
  if (!piece2.on) continue;
97837
- this.count++;
97838
97956
  piece2.life -= dt;
97839
- if (piece2.life <= 0) {
97840
- piece2.on = false;
97841
- continue;
97842
- }
97957
+ if (piece2.life <= 0) piece2.on = false;
97958
+ else if (!piece2.rest) moving = true;
97959
+ }
97960
+ if (moving && contacts) this.resting.rebuild(this.pieces);
97961
+ else this.resting.clear();
97962
+ for (const piece2 of this.pieces) {
97963
+ if (!piece2.on) continue;
97964
+ this.count++;
97965
+ if (obstacles.length > 0 && pushOutOfObstacles(piece2, obstacles)) piece2.rest = false;
97843
97966
  if (!piece2.rest) this.move(piece2, dt);
97844
97967
  }
97845
97968
  }
@@ -97855,7 +97978,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
97855
97978
  piece2.rx += piece2.ax * dt;
97856
97979
  piece2.ry += piece2.ay * dt;
97857
97980
  piece2.rz += piece2.az * dt;
97858
- const groundHeight = this.context.groundAt(piece2.x, piece2.z) + Math.min(piece2.sx, piece2.sy, piece2.sz) * 0.5;
97981
+ const groundHeight = Math.max(this.context.groundAt(piece2.x, piece2.z) + Math.min(piece2.sx, piece2.sy, piece2.sz) * 0.5, this.resting.supportUnder(piece2));
97859
97982
  if (piece2.y >= groundHeight) return;
97860
97983
  piece2.y = groundHeight;
97861
97984
  piece2.vy *= -piece2.bounce;
@@ -98515,6 +98638,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
98515
98638
  this.decals = new DecalPool(this.context);
98516
98639
  this.lights = new FlashLightPool(this.context);
98517
98640
  }
98641
+ /**
98642
+ * Turns on the touch of the debris pieces (a game's world; the Workshop page's recording has none): they pile on the pieces at rest under them, and the
98643
+ * upright bodies `obstacles` answers (the player, asked once a frame while a piece moves) stop them and push them. `null` turns it off.
98644
+ */
98645
+ setDebrisContacts(obstacles) {
98646
+ if (obstacles) this.context.debrisContacts = { obstacles };
98647
+ else delete this.context.debrisContacts;
98648
+ }
98518
98649
  get random() {
98519
98650
  return this.context.random;
98520
98651
  }