@adatechnology/game-weapons-three 0.26.1 → 0.26.2

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.
@@ -739,7 +739,8 @@ var GameWeaponsThree = (() => {
739
739
  PIECE_BOXES: "destruction.piece-boxes",
740
740
  STATIC_COLLIDERS: "destruction.static-colliders",
741
741
  SHAPES_GENERATE: "shapes.generate",
742
- WORLD_REGION: "world.region"
742
+ WORLD_REGION: "world.region",
743
+ VEHICLE_HULL_PLAN: "vehicles.hull-plan"
743
744
  };
744
745
  var WORKER_KIND_DEFAULTS = {
745
746
  [WORKER_KIND_ID.GROUND_TILES]: { lane: "sim", priority: 300, latencyFrames: 2, late: "sync" },
@@ -747,7 +748,8 @@ var GameWeaponsThree = (() => {
747
748
  [WORKER_KIND_ID.PIECE_BOXES]: { lane: "sim", priority: 200, latencyFrames: 2, late: "sync" },
748
749
  [WORKER_KIND_ID.STATIC_COLLIDERS]: { lane: "build", priority: 150, late: "sync" },
749
750
  [WORKER_KIND_ID.SHAPES_GENERATE]: { lane: "build", priority: 100, late: "sync" },
750
- [WORKER_KIND_ID.WORLD_REGION]: { lane: "background", priority: 10, latencyFrames: 10, late: "drop" }
751
+ [WORKER_KIND_ID.WORLD_REGION]: { lane: "background", priority: 10, latencyFrames: 10, late: "drop" },
752
+ [WORKER_KIND_ID.VEHICLE_HULL_PLAN]: { lane: "build", priority: 120, late: "keep-waiting" }
751
753
  };
752
754
 
753
755
  // ../game-weapons/dist/index.js
@@ -25000,6 +25002,20 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
25000
25002
  let time = 0;
25001
25003
  let counter = 0;
25002
25004
  const objects = /* @__PURE__ */ new Map();
25005
+ const slots = /* @__PURE__ */ new Map();
25006
+ let slotCounter = 0;
25007
+ let objectsRevision = 0;
25008
+ const putObject = (id, object2) => {
25009
+ if (!objects.has(id)) slots.set(id, ++slotCounter);
25010
+ objectsRevision++;
25011
+ objects.set(id, object2);
25012
+ };
25013
+ const dropObject = (id) => {
25014
+ if (objects.delete(id)) {
25015
+ slots.delete(id);
25016
+ objectsRevision++;
25017
+ }
25018
+ };
25003
25019
  const listeners = /* @__PURE__ */ new Map();
25004
25020
  let cur = [];
25005
25021
  const blasts = [];
@@ -26890,18 +26906,52 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
26890
26906
  if (o.soil?.sets.size) restCarry.soilSets = Object.fromEntries(o.soil.sets);
26891
26907
  const rest2 = build(sub2(inOld), o.id, o.soil ? o.base.pos : pos, o.soil ? o.base.rot : rot, restCarry);
26892
26908
  dirtyHosted.delete(o);
26893
- objects.set(o.id, rest2);
26894
- for (const [nid, object2] of fresh) objects.set(nid, object2);
26909
+ putObject(o.id, rest2);
26910
+ for (const [nid, object2] of fresh) putObject(nid, object2);
26895
26911
  return fresh.map(([nid]) => nid);
26896
26912
  };
26913
+ let rayBroad = null;
26914
+ let uncovered = [];
26915
+ let uncoveredFor = { hook: null, coverage: -1, objects: -1 };
26916
+ const metObjects = [];
26917
+ const rayObjects = [];
26918
+ const candidatesOf2 = (hook) => {
26919
+ const asked = hook.candidates;
26920
+ if (!asked) return null;
26921
+ const coverage2 = asked.revision();
26922
+ if (uncoveredFor.hook !== hook || uncoveredFor.coverage !== coverage2 || uncoveredFor.objects !== objectsRevision) {
26923
+ uncovered = [];
26924
+ for (const o of objects.values()) if (!asked.covers(o.id)) uncovered.push(o);
26925
+ uncoveredFor = { hook, coverage: coverage2, objects: objectsRevision };
26926
+ }
26927
+ if (uncovered.length * 2 > objects.size) return null;
26928
+ metObjects.length = 0;
26929
+ for (const id of asked.met()) {
26930
+ const o = objects.get(id);
26931
+ if (o && asked.covers(id)) metObjects.push(o);
26932
+ }
26933
+ metObjects.sort((a, b) => slots.get(a.id) - slots.get(b.id));
26934
+ rayObjects.length = 0;
26935
+ let m = 0;
26936
+ let u = 0;
26937
+ while (m < metObjects.length || u < uncovered.length) {
26938
+ const takeMet = u >= uncovered.length || m < metObjects.length && slots.get(metObjects[m].id) < slots.get(uncovered[u].id);
26939
+ rayObjects.push(takeMet ? metObjects[m++] : uncovered[u++]);
26940
+ }
26941
+ return rayObjects;
26942
+ };
26897
26943
  const raycastInternal = (origin, dir, maxDist, ignore, worldOnly = false, precise = false, skip = {}, scope2) => {
26898
26944
  const d = vec.normalize(dir);
26945
+ const asked = rayBroad && !scope2 && rayBroad.begin(origin, d, maxDist) ? rayBroad : null;
26946
+ const candidates = asked ? candidatesOf2(asked) : null;
26947
+ const outside = candidates ? null : asked;
26899
26948
  const minRadius = skip.minObjectRadius ?? 0;
26900
26949
  let best = null;
26901
26950
  const counts = sweepCounts;
26902
- for (const o of scope2 ? scope2.objects : objects.values()) {
26951
+ for (const o of scope2 ? scope2.objects : candidates ?? objects.values()) {
26903
26952
  if (counts) counts.objectVisits++;
26904
26953
  if (skip.skipLoose && o.loose || o.br < minRadius) continue;
26954
+ if (outside && !outside.mayMeet(o.id)) continue;
26905
26955
  if (raySphereMiss(origin, d, worldCentreOf(o), o.br, best ? Math.min(maxDist, best.distance) : maxDist)) continue;
26906
26956
  const qi = quat.conjugate(o.st.rotation);
26907
26957
  const lo = rotateVec(qi, vec.sub(origin, o.st.position));
@@ -29654,7 +29704,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29654
29704
  finishExplosions();
29655
29705
  const id = opts.id ?? nextId();
29656
29706
  if (taken(id)) throw new Error(`object "${id}" already exists`);
29657
- objects.set(id, build(resolveSpec(spec), id, opts.position ?? [0, 0, 0], opts.rotation ?? [0, 0, 0, 1]));
29707
+ putObject(id, build(resolveSpec(spec), id, opts.position ?? [0, 0, 0], opts.rotation ?? [0, 0, 0, 1]));
29658
29708
  return id;
29659
29709
  },
29660
29710
  register(impl, opts = {}) {
@@ -29689,7 +29739,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29689
29739
  impls.get(id)?.impl.dispose?.();
29690
29740
  const existing = objects.get(id);
29691
29741
  if (existing) dirtyHosted.delete(existing);
29692
- objects.delete(id);
29742
+ dropObject(id);
29693
29743
  impls.delete(id);
29694
29744
  },
29695
29745
  has: (id) => taken(id),
@@ -29808,6 +29858,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
29808
29858
  },
29809
29859
  beginExplosion,
29810
29860
  cancelExplosions,
29861
+ setRayBroadPhase(broadPhase2) {
29862
+ rayBroad = broadPhase2;
29863
+ },
29811
29864
  groundLoss(loss) {
29812
29865
  if (!(loss.radius > 0) || !(loss.depth > 0) || !Number.isFinite(loss.x) || !Number.isFinite(loss.z)) return;
29813
29866
  pendingLosses.push({ ...loss });
@@ -30062,7 +30115,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30062
30115
  }
30063
30116
  const o = getObj(id);
30064
30117
  dirtyHosted.delete(o);
30065
- objects.set(id, build(o.spec, id, o.base.pos, o.base.rot));
30118
+ putObject(id, build(o.spec, id, o.base.pos, o.base.rot));
30066
30119
  },
30067
30120
  on(type, fn) {
30068
30121
  const known = listeners.get(type) ?? [];
@@ -30091,17 +30144,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30091
30144
  finishExplosions();
30092
30145
  const existing = objects.get(id);
30093
30146
  if (existing) dirtyHosted.delete(existing);
30094
- objects.set(id, buildFromEntry(entry2, id));
30147
+ putObject(id, buildFromEntry(entry2, id));
30095
30148
  },
30096
30149
  load(snap) {
30097
30150
  cancelExplosions();
30098
30151
  if (snap.version !== 1) throw new Error(`unsupported snapshot version ${String(snap.version)}`);
30099
30152
  dirtyHosted.clear();
30100
30153
  objects.clear();
30154
+ slots.clear();
30155
+ objectsRevision++;
30101
30156
  time = snap.time;
30102
30157
  rng2.set(snap.rng);
30103
30158
  counter = snap.counter ?? 0;
30104
- for (const e of snap.objects) objects.set(e.id, buildFromEntry(e, e.id));
30159
+ for (const e of snap.objects) putObject(e.id, buildFromEntry(e, e.id));
30105
30160
  for (const e of snap.impls ?? []) {
30106
30161
  const im = impls.get(e.id);
30107
30162
  if (!im) continue;