@adatechnology/game-vehicles-three 0.3.2 → 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.
- package/dist/index.global.js +56 -18
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +8 -15
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/dist/index.global.js
CHANGED
|
@@ -118,6 +118,22 @@ var GameVehiclesThree = (() => {
|
|
|
118
118
|
node.userData[KIT_ORIGIN_KEY] = { ...origin };
|
|
119
119
|
return object2;
|
|
120
120
|
}
|
|
121
|
+
function footprintBlocker(object2, footprint) {
|
|
122
|
+
return (x, z, radius) => {
|
|
123
|
+
const o = typeof object2 === "function" ? object2() : object2;
|
|
124
|
+
const fp = typeof footprint === "function" ? footprint() : footprint;
|
|
125
|
+
if (!o || !fp || !o.parent) return false;
|
|
126
|
+
o.updateWorldMatrix?.(true, false);
|
|
127
|
+
const e = o.matrixWorld.elements;
|
|
128
|
+
const dx = x - e[12];
|
|
129
|
+
const dz = z - e[14];
|
|
130
|
+
const ax = e[0] ** 2 + e[1] ** 2 + e[2] ** 2;
|
|
131
|
+
const az = e[8] ** 2 + e[9] ** 2 + e[10] ** 2;
|
|
132
|
+
const lx = (dx * e[0] + dz * e[2]) / (ax || 1);
|
|
133
|
+
const lz = (dx * e[8] + dz * e[10]) / (az || 1);
|
|
134
|
+
return lx > fp.minX - radius && lx < fp.maxX + radius && lz > fp.minZ - radius && lz < fp.maxZ + radius;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
121
137
|
|
|
122
138
|
// ../game-vehicles-fleet/dist/index.js
|
|
123
139
|
var military = [
|
|
@@ -40384,6 +40400,7 @@ var GameVehiclesThree = (() => {
|
|
|
40384
40400
|
__publicField(this, "extra", /* @__PURE__ */ new Map());
|
|
40385
40401
|
__publicField(this, "plates", /* @__PURE__ */ new Map());
|
|
40386
40402
|
__publicField(this, "gone", /* @__PURE__ */ new Set());
|
|
40403
|
+
__publicField(this, "syncPlates", /* @__PURE__ */ new Map());
|
|
40387
40404
|
__publicField(this, "lightsOn", true);
|
|
40388
40405
|
__publicField(this, "hood");
|
|
40389
40406
|
this.kit = kit;
|
|
@@ -40502,9 +40519,10 @@ var GameVehiclesThree = (() => {
|
|
|
40502
40519
|
piv.position.set(hx, cy, sk + s * 0.016);
|
|
40503
40520
|
piv.userData.rigid = true;
|
|
40504
40521
|
this.c.vehicle.add(piv);
|
|
40505
|
-
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);
|
|
40506
40523
|
this.plates.set(p.id, piv);
|
|
40507
40524
|
this.extra.set(`recess_${p.id}`, [recess]);
|
|
40525
|
+
this.showWhenOpen(p.id, piv, panel, recess);
|
|
40508
40526
|
} else {
|
|
40509
40527
|
const sk = this.surface("x", -1, B, grid(B.y0, B.y1, B.z0, B.z1));
|
|
40510
40528
|
if (sk == null) return;
|
|
@@ -40517,10 +40535,37 @@ var GameVehiclesThree = (() => {
|
|
|
40517
40535
|
piv.position.set(sk - 0.016, B.y1 - 0.05, 0);
|
|
40518
40536
|
piv.userData.rigid = true;
|
|
40519
40537
|
this.c.vehicle.add(piv);
|
|
40520
|
-
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);
|
|
40521
40539
|
this.plates.set(p.id, piv);
|
|
40522
40540
|
this.extra.set(`recess_${p.id}`, [recess]);
|
|
40523
|
-
|
|
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();
|
|
40524
40569
|
}
|
|
40525
40570
|
makeMirror(p) {
|
|
40526
40571
|
const [cx, cy, cz] = p.box.center;
|
|
@@ -40706,6 +40751,7 @@ var GameVehiclesThree = (() => {
|
|
|
40706
40751
|
const trail = 0;
|
|
40707
40752
|
let moved = false;
|
|
40708
40753
|
this.gone.add(p.id);
|
|
40754
|
+
this.syncPlates.get(p.id)?.();
|
|
40709
40755
|
switch (p.role) {
|
|
40710
40756
|
case "door":
|
|
40711
40757
|
case "lid":
|
|
@@ -43034,22 +43080,13 @@ var GameVehiclesThree = (() => {
|
|
|
43034
43080
|
}
|
|
43035
43081
|
helpersShown = boxKey();
|
|
43036
43082
|
};
|
|
43037
|
-
const
|
|
43038
|
-
|
|
43039
|
-
|
|
43040
|
-
|
|
43041
|
-
local.v ?? (local.v = new three.Vector3());
|
|
43042
|
-
root.updateWorldMatrix(true, false);
|
|
43043
|
-
const p = local.v.set(x, 0, z).applyMatrix4(local.m.copy(root.matrixWorld).invert());
|
|
43044
|
-
return p.x > fp.minX - radius && p.x < fp.maxX + radius && p.z > fp.minZ - radius && p.z < fp.maxZ + radius;
|
|
43045
|
-
};
|
|
43083
|
+
const laneBlocked = footprintBlocker(
|
|
43084
|
+
() => lane?.group,
|
|
43085
|
+
() => lane ? { minX: -lane.car.width / 2, maxX: lane.car.width / 2, minZ: -lane.car.length / 2, maxZ: lane.car.length / 2 } : null
|
|
43086
|
+
);
|
|
43046
43087
|
const blocked = (x, z, radius) => {
|
|
43047
|
-
for (const entry of placed.values()) if (entry.
|
|
43048
|
-
|
|
43049
|
-
const half = { l: lane.car.length / 2, w: lane.car.width / 2 };
|
|
43050
|
-
if (inside(lane.group, { minX: -half.w, maxX: half.w, minZ: -half.l, maxZ: half.l }, x, z, radius)) return true;
|
|
43051
|
-
}
|
|
43052
|
-
return false;
|
|
43088
|
+
for (const entry of placed.values()) if (entry.footprint && footprintBlocker(entry.root, entry.footprint)(x, z, radius)) return true;
|
|
43089
|
+
return laneBlocked(x, z, radius);
|
|
43053
43090
|
};
|
|
43054
43091
|
const clearLane = () => {
|
|
43055
43092
|
stopEngine();
|
|
@@ -43214,6 +43251,7 @@ var GameVehiclesThree = (() => {
|
|
|
43214
43251
|
return {
|
|
43215
43252
|
id: VEHICLES_AREA_ID,
|
|
43216
43253
|
name: text.name,
|
|
43254
|
+
ground: { surface: "road" },
|
|
43217
43255
|
group: text.group,
|
|
43218
43256
|
get placed() {
|
|
43219
43257
|
return placed;
|