@adatechnology/game-items-three 0.10.5 → 0.10.7

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.
@@ -1990,7 +1990,8 @@ var GameItemsThree = (() => {
1990
1990
  PIECE_BOXES: "destruction.piece-boxes",
1991
1991
  STATIC_COLLIDERS: "destruction.static-colliders",
1992
1992
  SHAPES_GENERATE: "shapes.generate",
1993
- WORLD_REGION: "world.region"
1993
+ WORLD_REGION: "world.region",
1994
+ VEHICLE_HULL_PLAN: "vehicles.hull-plan"
1994
1995
  };
1995
1996
  var WORKER_KIND_DEFAULTS = {
1996
1997
  [WORKER_KIND_ID.GROUND_TILES]: { lane: "sim", priority: 300, latencyFrames: 2, late: "sync" },
@@ -1998,7 +1999,8 @@ var GameItemsThree = (() => {
1998
1999
  [WORKER_KIND_ID.PIECE_BOXES]: { lane: "sim", priority: 200, latencyFrames: 2, late: "sync" },
1999
2000
  [WORKER_KIND_ID.STATIC_COLLIDERS]: { lane: "build", priority: 150, late: "sync" },
2000
2001
  [WORKER_KIND_ID.SHAPES_GENERATE]: { lane: "build", priority: 100, late: "sync" },
2001
- [WORKER_KIND_ID.WORLD_REGION]: { lane: "background", priority: 10, latencyFrames: 10, late: "drop" }
2002
+ [WORKER_KIND_ID.WORLD_REGION]: { lane: "background", priority: 10, latencyFrames: 10, late: "drop" },
2003
+ [WORKER_KIND_ID.VEHICLE_HULL_PLAN]: { lane: "build", priority: 120, late: "keep-waiting" }
2002
2004
  };
2003
2005
 
2004
2006
  // ../game-shapes/dist/index.js
@@ -16368,6 +16370,20 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
16368
16370
  let time = 0;
16369
16371
  let counter = 0;
16370
16372
  const objects = /* @__PURE__ */ new Map();
16373
+ const slots = /* @__PURE__ */ new Map();
16374
+ let slotCounter = 0;
16375
+ let objectsRevision = 0;
16376
+ const putObject = (id, object2) => {
16377
+ if (!objects.has(id)) slots.set(id, ++slotCounter);
16378
+ objectsRevision++;
16379
+ objects.set(id, object2);
16380
+ };
16381
+ const dropObject = (id) => {
16382
+ if (objects.delete(id)) {
16383
+ slots.delete(id);
16384
+ objectsRevision++;
16385
+ }
16386
+ };
16371
16387
  const listeners = /* @__PURE__ */ new Map();
16372
16388
  let cur = [];
16373
16389
  const blasts = [];
@@ -18258,18 +18274,52 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18258
18274
  if (o.soil?.sets.size) restCarry.soilSets = Object.fromEntries(o.soil.sets);
18259
18275
  const rest2 = build(sub(inOld), o.id, o.soil ? o.base.pos : pos, o.soil ? o.base.rot : rot, restCarry);
18260
18276
  dirtyHosted.delete(o);
18261
- objects.set(o.id, rest2);
18262
- for (const [nid, object2] of fresh) objects.set(nid, object2);
18277
+ putObject(o.id, rest2);
18278
+ for (const [nid, object2] of fresh) putObject(nid, object2);
18263
18279
  return fresh.map(([nid]) => nid);
18264
18280
  };
18281
+ let rayBroad = null;
18282
+ let uncovered = [];
18283
+ let uncoveredFor = { hook: null, coverage: -1, objects: -1 };
18284
+ const metObjects = [];
18285
+ const rayObjects = [];
18286
+ const candidatesOf2 = (hook) => {
18287
+ const asked = hook.candidates;
18288
+ if (!asked) return null;
18289
+ const coverage2 = asked.revision();
18290
+ if (uncoveredFor.hook !== hook || uncoveredFor.coverage !== coverage2 || uncoveredFor.objects !== objectsRevision) {
18291
+ uncovered = [];
18292
+ for (const o of objects.values()) if (!asked.covers(o.id)) uncovered.push(o);
18293
+ uncoveredFor = { hook, coverage: coverage2, objects: objectsRevision };
18294
+ }
18295
+ if (uncovered.length * 2 > objects.size) return null;
18296
+ metObjects.length = 0;
18297
+ for (const id of asked.met()) {
18298
+ const o = objects.get(id);
18299
+ if (o && asked.covers(id)) metObjects.push(o);
18300
+ }
18301
+ metObjects.sort((a, b) => slots.get(a.id) - slots.get(b.id));
18302
+ rayObjects.length = 0;
18303
+ let m = 0;
18304
+ let u = 0;
18305
+ while (m < metObjects.length || u < uncovered.length) {
18306
+ const takeMet = u >= uncovered.length || m < metObjects.length && slots.get(metObjects[m].id) < slots.get(uncovered[u].id);
18307
+ rayObjects.push(takeMet ? metObjects[m++] : uncovered[u++]);
18308
+ }
18309
+ return rayObjects;
18310
+ };
18265
18311
  const raycastInternal = (origin, dir, maxDist, ignore, worldOnly = false, precise = false, skip = {}, scope) => {
18266
18312
  const d = vec.normalize(dir);
18313
+ const asked = rayBroad && !scope && rayBroad.begin(origin, d, maxDist) ? rayBroad : null;
18314
+ const candidates = asked ? candidatesOf2(asked) : null;
18315
+ const outside = candidates ? null : asked;
18267
18316
  const minRadius = skip.minObjectRadius ?? 0;
18268
18317
  let best = null;
18269
18318
  const counts = sweepCounts;
18270
- for (const o of scope ? scope.objects : objects.values()) {
18319
+ for (const o of scope ? scope.objects : candidates ?? objects.values()) {
18271
18320
  if (counts) counts.objectVisits++;
18272
18321
  if (skip.skipLoose && o.loose || o.br < minRadius) continue;
18322
+ if (outside && !outside.mayMeet(o.id)) continue;
18273
18323
  if (raySphereMiss(origin, d, worldCentreOf(o), o.br, best ? Math.min(maxDist, best.distance) : maxDist)) continue;
18274
18324
  const qi = quat.conjugate(o.st.rotation);
18275
18325
  const lo = rotateVec(qi, vec.sub(origin, o.st.position));
@@ -21022,7 +21072,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21022
21072
  finishExplosions();
21023
21073
  const id = opts.id ?? nextId();
21024
21074
  if (taken(id)) throw new Error(`object "${id}" already exists`);
21025
- objects.set(id, build(resolveSpec(spec), id, opts.position ?? [0, 0, 0], opts.rotation ?? [0, 0, 0, 1]));
21075
+ putObject(id, build(resolveSpec(spec), id, opts.position ?? [0, 0, 0], opts.rotation ?? [0, 0, 0, 1]));
21026
21076
  return id;
21027
21077
  },
21028
21078
  register(impl, opts = {}) {
@@ -21057,7 +21107,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21057
21107
  impls.get(id)?.impl.dispose?.();
21058
21108
  const existing = objects.get(id);
21059
21109
  if (existing) dirtyHosted.delete(existing);
21060
- objects.delete(id);
21110
+ dropObject(id);
21061
21111
  impls.delete(id);
21062
21112
  },
21063
21113
  has: (id) => taken(id),
@@ -21176,6 +21226,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21176
21226
  },
21177
21227
  beginExplosion,
21178
21228
  cancelExplosions,
21229
+ setRayBroadPhase(broadPhase2) {
21230
+ rayBroad = broadPhase2;
21231
+ },
21179
21232
  groundLoss(loss) {
21180
21233
  if (!(loss.radius > 0) || !(loss.depth > 0) || !Number.isFinite(loss.x) || !Number.isFinite(loss.z)) return;
21181
21234
  pendingLosses.push({ ...loss });
@@ -21430,7 +21483,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21430
21483
  }
21431
21484
  const o = getObj(id);
21432
21485
  dirtyHosted.delete(o);
21433
- objects.set(id, build(o.spec, id, o.base.pos, o.base.rot));
21486
+ putObject(id, build(o.spec, id, o.base.pos, o.base.rot));
21434
21487
  },
21435
21488
  on(type, fn) {
21436
21489
  const known = listeners.get(type) ?? [];
@@ -21459,17 +21512,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21459
21512
  finishExplosions();
21460
21513
  const existing = objects.get(id);
21461
21514
  if (existing) dirtyHosted.delete(existing);
21462
- objects.set(id, buildFromEntry(entry2, id));
21515
+ putObject(id, buildFromEntry(entry2, id));
21463
21516
  },
21464
21517
  load(snap) {
21465
21518
  cancelExplosions();
21466
21519
  if (snap.version !== 1) throw new Error(`unsupported snapshot version ${String(snap.version)}`);
21467
21520
  dirtyHosted.clear();
21468
21521
  objects.clear();
21522
+ slots.clear();
21523
+ objectsRevision++;
21469
21524
  time = snap.time;
21470
21525
  rng3.set(snap.rng);
21471
21526
  counter = snap.counter ?? 0;
21472
- for (const e of snap.objects) objects.set(e.id, buildFromEntry(e, e.id));
21527
+ for (const e of snap.objects) putObject(e.id, buildFromEntry(e, e.id));
21473
21528
  for (const e of snap.impls ?? []) {
21474
21529
  const im = impls.get(e.id);
21475
21530
  if (!im) continue;