@adatechnology/game-vehicles 0.4.2 → 0.4.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.
- package/dist/index.global.js +34 -3
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +34 -3
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.global.js
CHANGED
|
@@ -12592,6 +12592,8 @@ var GameVehicles = (() => {
|
|
|
12592
12592
|
/** Hinged panels created for the doors and the lid, by part id. */
|
|
12593
12593
|
__publicField(this, "plates", /* @__PURE__ */ new Map());
|
|
12594
12594
|
__publicField(this, "gone", /* @__PURE__ */ new Set());
|
|
12595
|
+
/** Shows or hides the plate and the recess of a door or lid by its state (see `showWhenOpen`). */
|
|
12596
|
+
__publicField(this, "syncPlates", /* @__PURE__ */ new Map());
|
|
12595
12597
|
__publicField(this, "lightsOn", true);
|
|
12596
12598
|
__publicField(this, "hood");
|
|
12597
12599
|
this.kit = kit;
|
|
@@ -12710,9 +12712,10 @@ var GameVehicles = (() => {
|
|
|
12710
12712
|
piv.position.set(hx, cy, sk + s * 0.016);
|
|
12711
12713
|
piv.userData.rigid = true;
|
|
12712
12714
|
this.c.vehicle.add(piv);
|
|
12713
|
-
this.box(len, hgt, 0.022, this.paint(), hingeFront ? -len / 2 : len / 2, 0, 0, piv);
|
|
12715
|
+
const panel = this.box(len, hgt, 0.022, this.paint(), hingeFront ? -len / 2 : len / 2, 0, 0, piv);
|
|
12714
12716
|
this.plates.set(p.id, piv);
|
|
12715
12717
|
this.extra.set(`recess_${p.id}`, [recess]);
|
|
12718
|
+
this.showWhenOpen(p.id, piv, panel, recess);
|
|
12716
12719
|
} else {
|
|
12717
12720
|
const sk = this.surface("x", -1, B, grid(B.y0, B.y1, B.z0, B.z1));
|
|
12718
12721
|
if (sk == null) return;
|
|
@@ -12725,10 +12728,37 @@ var GameVehicles = (() => {
|
|
|
12725
12728
|
piv.position.set(sk - 0.016, B.y1 - 0.05, 0);
|
|
12726
12729
|
piv.userData.rigid = true;
|
|
12727
12730
|
this.c.vehicle.add(piv);
|
|
12728
|
-
this.box(0.022, wy, wz, this.paint(), 0, -wy / 2, 0, piv);
|
|
12731
|
+
const panel = this.box(0.022, wy, wz, this.paint(), 0, -wy / 2, 0, piv);
|
|
12729
12732
|
this.plates.set(p.id, piv);
|
|
12730
12733
|
this.extra.set(`recess_${p.id}`, [recess]);
|
|
12731
|
-
|
|
12734
|
+
this.showWhenOpen(p.id, piv, panel, recess);
|
|
12735
|
+
}
|
|
12736
|
+
}
|
|
12737
|
+
/**
|
|
12738
|
+
* 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
|
|
12739
|
+
* 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`).
|
|
12740
|
+
*/
|
|
12741
|
+
showWhenOpen(id, piv, panel, recess) {
|
|
12742
|
+
const sync = () => {
|
|
12743
|
+
const r = piv.rotation;
|
|
12744
|
+
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;
|
|
12745
|
+
panel.visible = open;
|
|
12746
|
+
recess.visible = open;
|
|
12747
|
+
};
|
|
12748
|
+
const euler = piv.rotation;
|
|
12749
|
+
const quaternion = piv.quaternion;
|
|
12750
|
+
const onEuler = euler._onChangeCallback;
|
|
12751
|
+
const onQuaternion = quaternion._onChangeCallback;
|
|
12752
|
+
euler._onChange(() => {
|
|
12753
|
+
onEuler();
|
|
12754
|
+
sync();
|
|
12755
|
+
});
|
|
12756
|
+
quaternion._onChange(() => {
|
|
12757
|
+
onQuaternion();
|
|
12758
|
+
sync();
|
|
12759
|
+
});
|
|
12760
|
+
this.syncPlates.set(id, sync);
|
|
12761
|
+
sync();
|
|
12732
12762
|
}
|
|
12733
12763
|
makeMirror(p) {
|
|
12734
12764
|
const [cx, cy, cz] = p.box.center;
|
|
@@ -12914,6 +12944,7 @@ var GameVehicles = (() => {
|
|
|
12914
12944
|
const trail = 0;
|
|
12915
12945
|
let moved = false;
|
|
12916
12946
|
this.gone.add(p.id);
|
|
12947
|
+
this.syncPlates.get(p.id)?.();
|
|
12917
12948
|
switch (p.role) {
|
|
12918
12949
|
case "door":
|
|
12919
12950
|
case "lid":
|