@adatechnology/game-vehicles-three 0.3.1 → 0.3.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.global.js +23 -0
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.global.js
CHANGED
|
@@ -42838,6 +42838,7 @@ var GameVehiclesThree = (() => {
|
|
|
42838
42838
|
var LANE = { z: 11, from: -12, wall: 13 };
|
|
42839
42839
|
var MATERIAL_COLOURS = { metal: 13421772, glass: 4500223, rubber: 16750848, fuel: 16724736 };
|
|
42840
42840
|
var ZONE_COLOURS = { door: 5627221, hood: 14540083, lid: 14522675, bumper: 14505437, glass: 4500223, light: 16777215, wheel: 16742195 };
|
|
42841
|
+
var BODY_HEIGHT = 1.7;
|
|
42841
42842
|
function createVehiclesTestModule(options = {}) {
|
|
42842
42843
|
const locale = options.locale ?? "pt-BR";
|
|
42843
42844
|
const text = TEXT[locale] ?? TEXT["pt-BR"];
|
|
@@ -42969,6 +42970,7 @@ var GameVehiclesThree = (() => {
|
|
|
42969
42970
|
entry.root.updateMatrixWorld(true);
|
|
42970
42971
|
const inverse = new three.Matrix4().copy(entry.root.matrixWorld).invert();
|
|
42971
42972
|
const bounds = new three.Box3();
|
|
42973
|
+
const low = new three.Box3();
|
|
42972
42974
|
const piece = new three.Box3();
|
|
42973
42975
|
const matrix = new three.Matrix4();
|
|
42974
42976
|
entry.root.traverse((mesh2) => {
|
|
@@ -42978,9 +42980,11 @@ var GameVehiclesThree = (() => {
|
|
|
42978
42980
|
mesh2.geometry.computeBoundingBox();
|
|
42979
42981
|
piece.copy(mesh2.geometry.boundingBox).applyMatrix4(matrix.multiplyMatrices(inverse, mesh2.matrixWorld));
|
|
42980
42982
|
bounds.union(piece);
|
|
42983
|
+
if (piece.min.y < BODY_HEIGHT) low.union(piece);
|
|
42981
42984
|
});
|
|
42982
42985
|
const size = bounds.getSize(new three.Vector3());
|
|
42983
42986
|
entry.size = { length: size.z, width: size.x, height: size.y };
|
|
42987
|
+
if (!low.isEmpty()) entry.footprint = { minX: low.min.x, maxX: low.max.x, minZ: low.min.z, maxZ: low.max.z };
|
|
42984
42988
|
return entry.size;
|
|
42985
42989
|
};
|
|
42986
42990
|
const clearHelpers = () => {
|
|
@@ -43030,6 +43034,23 @@ var GameVehiclesThree = (() => {
|
|
|
43030
43034
|
}
|
|
43031
43035
|
helpersShown = boxKey();
|
|
43032
43036
|
};
|
|
43037
|
+
const local = { m: null, v: null };
|
|
43038
|
+
const inside = (root, fp, x, z, radius) => {
|
|
43039
|
+
if (!three) return false;
|
|
43040
|
+
local.m ?? (local.m = new three.Matrix4());
|
|
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
|
+
};
|
|
43046
|
+
const blocked = (x, z, radius) => {
|
|
43047
|
+
for (const entry of placed.values()) if (entry.root.parent && entry.footprint && inside(entry.root, entry.footprint, x, z, radius)) return true;
|
|
43048
|
+
if (lane) {
|
|
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;
|
|
43053
|
+
};
|
|
43033
43054
|
const clearLane = () => {
|
|
43034
43055
|
stopEngine();
|
|
43035
43056
|
if (!lane) return;
|
|
@@ -43250,10 +43271,12 @@ var GameVehiclesThree = (() => {
|
|
|
43250
43271
|
three = lent.THREE;
|
|
43251
43272
|
const stopChange = lent.bench?.onChange(onChange);
|
|
43252
43273
|
const stopFrame = lent.onFrame(frame);
|
|
43274
|
+
const stopBlocker = lent.addBlocker?.(blocked);
|
|
43253
43275
|
lent.audio?.register?.(LIBRARY_BANK);
|
|
43254
43276
|
return () => {
|
|
43255
43277
|
stopChange?.();
|
|
43256
43278
|
stopFrame();
|
|
43279
|
+
stopBlocker?.();
|
|
43257
43280
|
clearHelpers();
|
|
43258
43281
|
clearLane();
|
|
43259
43282
|
host = null;
|