@adatechnology/game-vehicles-three 0.3.3 → 0.3.4

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.
@@ -40400,6 +40400,7 @@ var GameVehiclesThree = (() => {
40400
40400
  __publicField(this, "extra", /* @__PURE__ */ new Map());
40401
40401
  __publicField(this, "plates", /* @__PURE__ */ new Map());
40402
40402
  __publicField(this, "gone", /* @__PURE__ */ new Set());
40403
+ __publicField(this, "syncPlates", /* @__PURE__ */ new Map());
40403
40404
  __publicField(this, "lightsOn", true);
40404
40405
  __publicField(this, "hood");
40405
40406
  this.kit = kit;
@@ -40518,9 +40519,10 @@ var GameVehiclesThree = (() => {
40518
40519
  piv.position.set(hx, cy, sk + s * 0.016);
40519
40520
  piv.userData.rigid = true;
40520
40521
  this.c.vehicle.add(piv);
40521
- this.box(len, hgt, 0.022, this.paint(), hingeFront ? -len / 2 : len / 2, 0, 0, piv);
40522
+ const panel = this.box(len, hgt, 0.022, this.paint(), hingeFront ? -len / 2 : len / 2, 0, 0, piv);
40522
40523
  this.plates.set(p.id, piv);
40523
40524
  this.extra.set(`recess_${p.id}`, [recess]);
40525
+ this.showWhenOpen(p.id, piv, panel, recess);
40524
40526
  } else {
40525
40527
  const sk = this.surface("x", -1, B, grid(B.y0, B.y1, B.z0, B.z1));
40526
40528
  if (sk == null) return;
@@ -40533,10 +40535,37 @@ var GameVehiclesThree = (() => {
40533
40535
  piv.position.set(sk - 0.016, B.y1 - 0.05, 0);
40534
40536
  piv.userData.rigid = true;
40535
40537
  this.c.vehicle.add(piv);
40536
- this.box(0.022, wy, wz, this.paint(), 0, -wy / 2, 0, piv);
40538
+ const panel = this.box(0.022, wy, wz, this.paint(), 0, -wy / 2, 0, piv);
40537
40539
  this.plates.set(p.id, piv);
40538
40540
  this.extra.set(`recess_${p.id}`, [recess]);
40539
- }
40541
+ this.showWhenOpen(p.id, piv, panel, recess);
40542
+ }
40543
+ }
40544
+ /**
40545
+ * A closed door or lid is the body's own surface: the flat plate over it and the dark recess under it show only while it swings open or once it has come off, so the closed car
40546
+ * keeps the shape of its model instead of flat panels over its curved sides. Follows the hinge's rotation, whoever turns it (the clips of a host, `detach`).
40547
+ */
40548
+ showWhenOpen(id, piv, panel, recess) {
40549
+ const sync = () => {
40550
+ const r = piv.rotation;
40551
+ const open = Math.abs(r.x) + Math.abs(r.y) + Math.abs(r.z) > 1e-3 || this.gone.has(id) || piv.parent !== this.c.vehicle;
40552
+ panel.visible = open;
40553
+ recess.visible = open;
40554
+ };
40555
+ const euler = piv.rotation;
40556
+ const quaternion = piv.quaternion;
40557
+ const onEuler = euler._onChangeCallback;
40558
+ const onQuaternion = quaternion._onChangeCallback;
40559
+ euler._onChange(() => {
40560
+ onEuler();
40561
+ sync();
40562
+ });
40563
+ quaternion._onChange(() => {
40564
+ onQuaternion();
40565
+ sync();
40566
+ });
40567
+ this.syncPlates.set(id, sync);
40568
+ sync();
40540
40569
  }
40541
40570
  makeMirror(p) {
40542
40571
  const [cx, cy, cz] = p.box.center;
@@ -40722,6 +40751,7 @@ var GameVehiclesThree = (() => {
40722
40751
  const trail = 0;
40723
40752
  let moved = false;
40724
40753
  this.gone.add(p.id);
40754
+ this.syncPlates.get(p.id)?.();
40725
40755
  switch (p.role) {
40726
40756
  case "door":
40727
40757
  case "lid":
@@ -43221,6 +43251,7 @@ var GameVehiclesThree = (() => {
43221
43251
  return {
43222
43252
  id: VEHICLES_AREA_ID,
43223
43253
  name: text.name,
43254
+ ground: { surface: "road" },
43224
43255
  group: text.group,
43225
43256
  get placed() {
43226
43257
  return placed;