@adatechnology/game-vehicles 0.4.3 → 0.4.5
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.js
CHANGED
|
@@ -10981,6 +10981,8 @@ var VehicleVisuals = class {
|
|
|
10981
10981
|
/** Hinged panels created for the doors and the lid, by part id. */
|
|
10982
10982
|
__publicField(this, "plates", /* @__PURE__ */ new Map());
|
|
10983
10983
|
__publicField(this, "gone", /* @__PURE__ */ new Set());
|
|
10984
|
+
/** Shows or hides the plate and the recess of a door or lid by its state (see `showWhenOpen`). */
|
|
10985
|
+
__publicField(this, "syncPlates", /* @__PURE__ */ new Map());
|
|
10984
10986
|
__publicField(this, "lightsOn", true);
|
|
10985
10987
|
__publicField(this, "hood");
|
|
10986
10988
|
this.kit = kit;
|
|
@@ -11099,9 +11101,10 @@ var VehicleVisuals = class {
|
|
|
11099
11101
|
piv.position.set(hx, cy, sk + s * 0.016);
|
|
11100
11102
|
piv.userData.rigid = true;
|
|
11101
11103
|
this.c.vehicle.add(piv);
|
|
11102
|
-
this.box(len, hgt, 0.022, this.paint(), hingeFront ? -len / 2 : len / 2, 0, 0, piv);
|
|
11104
|
+
const panel = this.box(len, hgt, 0.022, this.paint(), hingeFront ? -len / 2 : len / 2, 0, 0, piv);
|
|
11103
11105
|
this.plates.set(p.id, piv);
|
|
11104
11106
|
this.extra.set(`recess_${p.id}`, [recess]);
|
|
11107
|
+
this.showWhenOpen(p.id, piv, panel, recess);
|
|
11105
11108
|
} else {
|
|
11106
11109
|
const sk = this.surface("x", -1, B, grid(B.y0, B.y1, B.z0, B.z1));
|
|
11107
11110
|
if (sk == null) return;
|
|
@@ -11114,10 +11117,37 @@ var VehicleVisuals = class {
|
|
|
11114
11117
|
piv.position.set(sk - 0.016, B.y1 - 0.05, 0);
|
|
11115
11118
|
piv.userData.rigid = true;
|
|
11116
11119
|
this.c.vehicle.add(piv);
|
|
11117
|
-
this.box(0.022, wy, wz, this.paint(), 0, -wy / 2, 0, piv);
|
|
11120
|
+
const panel = this.box(0.022, wy, wz, this.paint(), 0, -wy / 2, 0, piv);
|
|
11118
11121
|
this.plates.set(p.id, piv);
|
|
11119
11122
|
this.extra.set(`recess_${p.id}`, [recess]);
|
|
11120
|
-
|
|
11123
|
+
this.showWhenOpen(p.id, piv, panel, recess);
|
|
11124
|
+
}
|
|
11125
|
+
}
|
|
11126
|
+
/**
|
|
11127
|
+
* 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
|
|
11128
|
+
* 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`).
|
|
11129
|
+
*/
|
|
11130
|
+
showWhenOpen(id, piv, panel, recess) {
|
|
11131
|
+
const sync = () => {
|
|
11132
|
+
const r = piv.rotation;
|
|
11133
|
+
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;
|
|
11134
|
+
panel.visible = open;
|
|
11135
|
+
recess.visible = open;
|
|
11136
|
+
};
|
|
11137
|
+
const euler = piv.rotation;
|
|
11138
|
+
const quaternion = piv.quaternion;
|
|
11139
|
+
const onEuler = euler._onChangeCallback;
|
|
11140
|
+
const onQuaternion = quaternion._onChangeCallback;
|
|
11141
|
+
euler._onChange(() => {
|
|
11142
|
+
onEuler();
|
|
11143
|
+
sync();
|
|
11144
|
+
});
|
|
11145
|
+
quaternion._onChange(() => {
|
|
11146
|
+
onQuaternion();
|
|
11147
|
+
sync();
|
|
11148
|
+
});
|
|
11149
|
+
this.syncPlates.set(id, sync);
|
|
11150
|
+
sync();
|
|
11121
11151
|
}
|
|
11122
11152
|
makeMirror(p) {
|
|
11123
11153
|
const [cx, cy, cz] = p.box.center;
|
|
@@ -11303,6 +11333,7 @@ var VehicleVisuals = class {
|
|
|
11303
11333
|
const trail = 0;
|
|
11304
11334
|
let moved = false;
|
|
11305
11335
|
this.gone.add(p.id);
|
|
11336
|
+
this.syncPlates.get(p.id)?.();
|
|
11306
11337
|
switch (p.role) {
|
|
11307
11338
|
case "door":
|
|
11308
11339
|
case "lid":
|