@adatechnology/game-vehicles-three 0.3.1 → 0.3.3
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 +30 -0
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -303,6 +303,7 @@ function markDamageables(c, damageables) {
|
|
|
303
303
|
}
|
|
304
304
|
|
|
305
305
|
// src/test-area/module.ts
|
|
306
|
+
import { footprintBlocker } from "@adatechnology/game-contracts";
|
|
306
307
|
import { buildVehicleItem, createVehicleDestructible, createVehicleKit } from "@adatechnology/game-vehicles";
|
|
307
308
|
import { createArcadeDriver as createArcadeDriver2, createSemiSimDriver as createSemiSimDriver2, createSurfaces as createSurfaces2, vehicleCorners as vehicleCorners2 } from "@adatechnology/game-vehicles-driving";
|
|
308
309
|
import { colorFromSeed as colorFromSeed2, fleetDims as fleetDims2, installFleet, paintPalettes as paintPalettes2, paletteOf as paletteOf2 } from "@adatechnology/game-vehicles-fleet";
|
|
@@ -728,6 +729,7 @@ var itemId = (key) => ITEM_OF[key] ?? key;
|
|
|
728
729
|
var LANE = { z: 11, from: -12, wall: 13 };
|
|
729
730
|
var MATERIAL_COLOURS = { metal: 13421772, glass: 4500223, rubber: 16750848, fuel: 16724736 };
|
|
730
731
|
var ZONE_COLOURS = { door: 5627221, hood: 14540083, lid: 14522675, bumper: 14505437, glass: 4500223, light: 16777215, wheel: 16742195 };
|
|
732
|
+
var BODY_HEIGHT = 1.7;
|
|
731
733
|
function createVehiclesTestModule(options = {}) {
|
|
732
734
|
const locale = options.locale ?? "pt-BR";
|
|
733
735
|
const text = TEXT[locale] ?? TEXT["pt-BR"];
|
|
@@ -859,6 +861,7 @@ function createVehiclesTestModule(options = {}) {
|
|
|
859
861
|
entry.root.updateMatrixWorld(true);
|
|
860
862
|
const inverse = new three.Matrix4().copy(entry.root.matrixWorld).invert();
|
|
861
863
|
const bounds = new three.Box3();
|
|
864
|
+
const low = new three.Box3();
|
|
862
865
|
const piece = new three.Box3();
|
|
863
866
|
const matrix = new three.Matrix4();
|
|
864
867
|
entry.root.traverse((mesh) => {
|
|
@@ -868,9 +871,11 @@ function createVehiclesTestModule(options = {}) {
|
|
|
868
871
|
mesh.geometry.computeBoundingBox();
|
|
869
872
|
piece.copy(mesh.geometry.boundingBox).applyMatrix4(matrix.multiplyMatrices(inverse, mesh.matrixWorld));
|
|
870
873
|
bounds.union(piece);
|
|
874
|
+
if (piece.min.y < BODY_HEIGHT) low.union(piece);
|
|
871
875
|
});
|
|
872
876
|
const size = bounds.getSize(new three.Vector3());
|
|
873
877
|
entry.size = { length: size.z, width: size.x, height: size.y };
|
|
878
|
+
if (!low.isEmpty()) entry.footprint = { minX: low.min.x, maxX: low.max.x, minZ: low.min.z, maxZ: low.max.z };
|
|
874
879
|
return entry.size;
|
|
875
880
|
};
|
|
876
881
|
const clearHelpers = () => {
|
|
@@ -920,6 +925,14 @@ function createVehiclesTestModule(options = {}) {
|
|
|
920
925
|
}
|
|
921
926
|
helpersShown = boxKey();
|
|
922
927
|
};
|
|
928
|
+
const laneBlocked = footprintBlocker(
|
|
929
|
+
() => lane?.group,
|
|
930
|
+
() => lane ? { minX: -lane.car.width / 2, maxX: lane.car.width / 2, minZ: -lane.car.length / 2, maxZ: lane.car.length / 2 } : null
|
|
931
|
+
);
|
|
932
|
+
const blocked = (x, z, radius) => {
|
|
933
|
+
for (const entry of placed.values()) if (entry.footprint && footprintBlocker(entry.root, entry.footprint)(x, z, radius)) return true;
|
|
934
|
+
return laneBlocked(x, z, radius);
|
|
935
|
+
};
|
|
923
936
|
const clearLane = () => {
|
|
924
937
|
stopEngine();
|
|
925
938
|
if (!lane) return;
|
|
@@ -1140,10 +1153,12 @@ function createVehiclesTestModule(options = {}) {
|
|
|
1140
1153
|
three = lent.THREE;
|
|
1141
1154
|
const stopChange = lent.bench?.onChange(onChange);
|
|
1142
1155
|
const stopFrame = lent.onFrame(frame);
|
|
1156
|
+
const stopBlocker = lent.addBlocker?.(blocked);
|
|
1143
1157
|
lent.audio?.register?.(LIBRARY_BANK);
|
|
1144
1158
|
return () => {
|
|
1145
1159
|
stopChange?.();
|
|
1146
1160
|
stopFrame();
|
|
1161
|
+
stopBlocker?.();
|
|
1147
1162
|
clearHelpers();
|
|
1148
1163
|
clearLane();
|
|
1149
1164
|
host = null;
|