@adatechnology/game-vehicles 0.7.0 → 0.7.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.
package/dist/index.js CHANGED
@@ -12847,6 +12847,9 @@ var VehicleVisuals = class {
12847
12847
  /** Hinged panels created for the doors and the lid, by part id. */
12848
12848
  __publicField(this, "plates", /* @__PURE__ */ new Map());
12849
12849
  __publicField(this, "gone", /* @__PURE__ */ new Set());
12850
+ /** Where a part that comes off goes instead of the fling (a physics engine takes it as a body); null: the fling. */
12851
+ __publicField(this, "sink", null);
12852
+ __publicField(this, "detaching", null);
12850
12853
  /** Shows or hides the plate and the recess of a door or lid by its state (see `showWhenOpen`). */
12851
12854
  __publicField(this, "syncPlates", /* @__PURE__ */ new Map());
12852
12855
  /** Doors and lids whose own skin was cut from the body and hung on the hinge (true), or that had none to take and keep the plate (false). */
@@ -14120,10 +14123,29 @@ var VehicleVisuals = class {
14120
14123
  }
14121
14124
  fling(obj, v, w, trail) {
14122
14125
  const piece = this.I.fling(this.c, obj, v, w);
14123
- if (piece) piece.trail = trail;
14126
+ if (!piece) return;
14127
+ if (!this.sink || !this.detaching) {
14128
+ piece.trail = trail;
14129
+ return;
14130
+ }
14131
+ if (!this.sink(this.detaching, piece.o, [v.x, v.y, v.z], [w.x, w.y, w.z])) {
14132
+ piece.trail = trail;
14133
+ return;
14134
+ }
14135
+ const flying = this.c.flying;
14136
+ const at = flying ? flying.indexOf(piece) : -1;
14137
+ if (flying && at >= 0) flying.splice(at, 1);
14124
14138
  }
14125
14139
  /** Brings a part off the vehicle and throws it. Returns whether something visible moved. */
14126
14140
  detach(p, o) {
14141
+ this.detaching = p;
14142
+ try {
14143
+ return this.detachPart(p, o);
14144
+ } finally {
14145
+ this.detaching = null;
14146
+ }
14147
+ }
14148
+ detachPart(p, o) {
14127
14149
  if (this.gone.has(p.id)) return false;
14128
14150
  const V3 = this.THREE.Vector3;
14129
14151
  const c = this.c;
@@ -15470,6 +15492,9 @@ function createVehicleDestructible(kit, vehicleCtx, options = {}) {
15470
15492
  return d ? toWorld(d.box.center) : [0, 0, 0];
15471
15493
  },
15472
15494
  rollover,
15495
+ setPartSink: (sink) => {
15496
+ if (vis) vis.sink = sink;
15497
+ },
15473
15498
  detachedParts: () => [...ps.values()].filter((p) => !p.lost && !attached(p.def.id) || p.lost && p.def.visual && js.some((j) => j.open && j.def.a === p.def.id)).map((p) => p.def.id)
15474
15499
  };
15475
15500
  return impl;