@adatechnology/game-vehicles-three 0.2.0 → 0.3.0
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.d.ts +10 -1
- package/dist/index.global.js +326 -80
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +42 -20
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -321,6 +321,7 @@ var scenarioIds = [
|
|
|
321
321
|
"vehicles_kill_battery",
|
|
322
322
|
"vehicles_rollover",
|
|
323
323
|
"vehicles_melt",
|
|
324
|
+
"vehicles_burnt_wreck",
|
|
324
325
|
"vehicles_drive_arcade",
|
|
325
326
|
"vehicles_drive_semi"
|
|
326
327
|
];
|
|
@@ -352,7 +353,7 @@ var TEXT = {
|
|
|
352
353
|
en: {
|
|
353
354
|
group: "Vehicles",
|
|
354
355
|
name: "Vehicles area",
|
|
355
|
-
items: { hatch: "Compact hatch", sedan: "Midsize sedan", pickup: "Midsize pickup", sport_bike: "Sport bike", box_truck: "Box truck", city_bus: "City bus", battle_tank: "Battle tank", attack_helicopter: "Attack helicopter" },
|
|
356
|
+
items: { hatch: "Compact hatch", sedan: "Midsize sedan", pickup: "Midsize pickup", sport_bike: "Sport bike", box_truck: "Box truck", city_bus: "City bus", battle_tank: "Battle tank", attack_helicopter: "Attack helicopter", sedan_burnt: "Burnt sedan", hatch_burnt: "Burnt hatch" },
|
|
356
357
|
controls: { quality: "Quality", paint_by_seed: "Paint by seed", color_seed: "Colour seed", palette: "Palette", driving: "Driving", surface: "Surface" },
|
|
357
358
|
hints: {
|
|
358
359
|
quality: "High: the kit at full detail. Light: fewer segments and no interior (the light mode of the fleet); applies to the vehicles placed from now on",
|
|
@@ -385,7 +386,8 @@ var TEXT = {
|
|
|
385
386
|
vehicles_rollover: "Vehicles: roll over",
|
|
386
387
|
vehicles_melt: "Vehicles: melt (long fire burns the tyres)",
|
|
387
388
|
vehicles_drive_arcade: "Vehicles: arcade driving down a lane that ends in a wall",
|
|
388
|
-
vehicles_drive_semi: "Vehicles: semi-simulation braking on dry, wet and mud"
|
|
389
|
+
vehicles_drive_semi: "Vehicles: semi-simulation braking on dry, wet and mud",
|
|
390
|
+
vehicles_burnt_wreck: "Vehicles: the burnt sedan comes out of the kit burnt, with the glass gone"
|
|
389
391
|
},
|
|
390
392
|
checks: {
|
|
391
393
|
windshield_holes: "Windshield: {0} hole(s), went through {1:b} (expected: 1, true)",
|
|
@@ -410,13 +412,15 @@ var TEXT = {
|
|
|
410
412
|
arcade_bounce: "Arcade: the car bounces back at {0} m/s (expected: below 0)",
|
|
411
413
|
arcade_noise: "Arcade: {0} engine noise(s) and {1} crash noise(s) (expected: 1 or more each)",
|
|
412
414
|
semi_order: "Semi: braking from 80 km/h takes dry {0} m, wet {1} m, mud {2} m (expected: dry shorter than wet shorter than mud)",
|
|
413
|
-
semi_mud: "Semi: a 2WD car on mud {0:on} (expected: bogged on, a bog event)"
|
|
415
|
+
semi_mud: "Semi: a 2WD car on mud {0:on} (expected: bogged on, a bog event)",
|
|
416
|
+
wreck_burnt: "Burnt sedan: burnt flag {0:b} (expected: yes)",
|
|
417
|
+
wreck_glass: "Burnt sedan: {0} glass zone(s), {1} still above 0 (expected: 1 or more, none above 0)"
|
|
414
418
|
}
|
|
415
419
|
},
|
|
416
420
|
"pt-BR": {
|
|
417
421
|
group: "Ve\xEDculos",
|
|
418
422
|
name: "\xC1rea de ve\xEDculos",
|
|
419
|
-
items: { hatch: "Hatch compacto", sedan: "Sed\xE3 m\xE9dio", pickup: "Picape m\xE9dia", sport_bike: "Moto esportiva", box_truck: "Caminh\xE3o ba\xFA", city_bus: "\xD4nibus urbano", battle_tank: "Tanque de guerra", attack_helicopter: "Helic\xF3ptero de ataque" },
|
|
423
|
+
items: { hatch: "Hatch compacto", sedan: "Sed\xE3 m\xE9dio", pickup: "Picape m\xE9dia", sport_bike: "Moto esportiva", box_truck: "Caminh\xE3o ba\xFA", city_bus: "\xD4nibus urbano", battle_tank: "Tanque de guerra", attack_helicopter: "Helic\xF3ptero de ataque", sedan_burnt: "Sed\xE3 queimado", hatch_burnt: "Hatch queimado" },
|
|
420
424
|
controls: { quality: "Qualidade", paint_by_seed: "Pintar pela semente", color_seed: "Semente da cor", palette: "Paleta", driving: "Dire\xE7\xE3o", surface: "Piso" },
|
|
421
425
|
hints: {
|
|
422
426
|
quality: "Alta: o kit com todo o detalhe. Leve: menos segmentos e sem interior (o modo leve da frota); vale para os ve\xEDculos postos daqui em diante",
|
|
@@ -449,7 +453,8 @@ var TEXT = {
|
|
|
449
453
|
vehicles_rollover: "Ve\xEDculos: capotar",
|
|
450
454
|
vehicles_melt: "Ve\xEDculos: derreter (fogo longo queima os pneus)",
|
|
451
455
|
vehicles_drive_arcade: "Ve\xEDculos: dire\xE7\xE3o arcade numa pista que acaba num muro",
|
|
452
|
-
vehicles_drive_semi: "Ve\xEDculos: frenagem da semissimula\xE7\xE3o no seco, no molhado e na lama"
|
|
456
|
+
vehicles_drive_semi: "Ve\xEDculos: frenagem da semissimula\xE7\xE3o no seco, no molhado e na lama",
|
|
457
|
+
vehicles_burnt_wreck: "Ve\xEDculos: o sed\xE3 queimado sai do kit queimado, sem os vidros"
|
|
453
458
|
},
|
|
454
459
|
checks: {
|
|
455
460
|
windshield_holes: "Para-brisa: {0} furo(s), atravessou {1:b} (esperado: 1, sim)",
|
|
@@ -474,7 +479,9 @@ var TEXT = {
|
|
|
474
479
|
arcade_bounce: "Arcade: o carro volta a {0} m/s (esperado: abaixo de 0)",
|
|
475
480
|
arcade_noise: "Arcade: {0} ru\xEDdo(s) de motor e {1} de batida (esperado: 1 ou mais de cada)",
|
|
476
481
|
semi_order: "Semi: frear de 80 km/h leva no seco {0} m, no molhado {1} m, na lama {2} m (esperado: seco menor que molhado menor que lama)",
|
|
477
|
-
semi_mud: "Semi: um carro 2WD na lama {0:on} (esperado: atolado, com evento de atolamento)"
|
|
482
|
+
semi_mud: "Semi: um carro 2WD na lama {0:on} (esperado: atolado, com evento de atolamento)",
|
|
483
|
+
wreck_burnt: "Sed\xE3 queimado: marca de queimado {0:b} (esperado: sim)",
|
|
484
|
+
wreck_glass: "Sed\xE3 queimado: {0} zona(s) de vidro, {1} ainda acima de 0 (esperado: 1 ou mais, nenhuma acima de 0)"
|
|
478
485
|
}
|
|
479
486
|
}
|
|
480
487
|
};
|
|
@@ -633,6 +640,14 @@ var createScenarios = (deps) => {
|
|
|
633
640
|
const t = part(room, v, "tyre_front_left");
|
|
634
641
|
expect(events(room, "melt", v) >= 1 && (t.status === "melted" || t.melt > 0.5), say("tyre_melt", t.status, Math.round(t.melt * 100), events(room, "melt", v)));
|
|
635
642
|
}),
|
|
643
|
+
// new in the kit: the burnt wreck comes ready from the kit (the fleet's `burnt` scenario built into the vehicle), no damage applied by the area
|
|
644
|
+
scenario("vehicles_burnt_wreck", ({ room, expect }) => {
|
|
645
|
+
const c = room.spawn("sedan_burnt", [0, 0, -7], 0).root.userData.vehicle;
|
|
646
|
+
expect(c.zoneState.flags.burnt === true, say("wreck_burnt", c.zoneState.flags.burnt === true));
|
|
647
|
+
const glass = c.zones.filter((z) => z.type === "glass");
|
|
648
|
+
const up = glass.filter((z) => (c.zoneState.health[z.id] ?? 100) > 0);
|
|
649
|
+
expect(glass.length >= 1 && up.length === 0, say("wreck_glass", glass.length, up.length));
|
|
650
|
+
}),
|
|
636
651
|
// new in the kit: the drivers, headless (no vehicle is spawned)
|
|
637
652
|
scenario("vehicles_drive_arcade", ({ expect }) => {
|
|
638
653
|
const driver = createArcadeDriver();
|
|
@@ -698,6 +713,10 @@ var defaultEffectIds = {
|
|
|
698
713
|
exhaust: "vehicle_exhaust"
|
|
699
714
|
};
|
|
700
715
|
var defaultSoundIds = { engine: "engine_saw", horn: "horn", crash: "sfx_impact" };
|
|
716
|
+
var DEFAULT_TEST_WRECKS = [
|
|
717
|
+
{ key: "sedan_burnt", vehicle: "midsize_sedan", scenario: "burnt" },
|
|
718
|
+
{ key: "hatch_burnt", vehicle: "compact_hatch", scenario: "burnt" }
|
|
719
|
+
];
|
|
701
720
|
|
|
702
721
|
// src/test-area/module.ts
|
|
703
722
|
var VEHICLES_AREA_ID = "vehicles_area";
|
|
@@ -711,6 +730,8 @@ function createVehiclesTestModule(options = {}) {
|
|
|
711
730
|
const locale = options.locale ?? "pt-BR";
|
|
712
731
|
const text = TEXT[locale] ?? TEXT["pt-BR"];
|
|
713
732
|
const keys = options.vehicles ?? DEFAULT_TEST_VEHICLES;
|
|
733
|
+
const wrecks = options.wrecks ?? DEFAULT_TEST_WRECKS;
|
|
734
|
+
const entries = [...keys.map((key) => ({ key, id: itemId(key) })), ...wrecks.map((w) => ({ key: w.vehicle, id: w.key, scenario: w.scenario }))];
|
|
714
735
|
const effectIds = { ...defaultEffectIds, ...options.effects };
|
|
715
736
|
const soundIds = { ...defaultSoundIds, ...options.sounds };
|
|
716
737
|
const settings = { quality: "high", paint: false, seed: 1, palette: "auto", driving: "arcade", surface: "dry_asphalt" };
|
|
@@ -759,17 +780,17 @@ function createVehiclesTestModule(options = {}) {
|
|
|
759
780
|
}
|
|
760
781
|
entry.paint.color.set(color);
|
|
761
782
|
};
|
|
762
|
-
const item = (key) => ({
|
|
763
|
-
id:
|
|
764
|
-
name: text.items[
|
|
783
|
+
const item = ({ key, id: itemKey, scenario }) => ({
|
|
784
|
+
id: itemKey,
|
|
785
|
+
name: text.items[itemKey] ?? key,
|
|
765
786
|
movable: false,
|
|
766
787
|
// the first build of a vehicle takes most of a second
|
|
767
788
|
slow: true,
|
|
768
789
|
build: (THREE) => {
|
|
769
790
|
const kit = kitFor(THREE);
|
|
770
|
-
const built = buildVehicleItem(kit, key, { lod: settings.quality === "lite" });
|
|
791
|
+
const built = buildVehicleItem(kit, key, { lod: settings.quality === "lite", ...scenario ? { scenario } : {} });
|
|
771
792
|
built.root.userData.kit = kit;
|
|
772
|
-
const entry = { root: built.root, key, item: built, index: counter++, helpers: [] };
|
|
793
|
+
const entry = { root: built.root, key, ...scenario ? { scenario } : {}, item: built, index: counter++, helpers: [] };
|
|
773
794
|
placed.set(built.root.uuid, entry);
|
|
774
795
|
measure(entry);
|
|
775
796
|
paintOf(entry);
|
|
@@ -778,7 +799,7 @@ function createVehiclesTestModule(options = {}) {
|
|
|
778
799
|
impl: (root, id) => {
|
|
779
800
|
const r = root;
|
|
780
801
|
const kit = r.userData.kit;
|
|
781
|
-
const d = createVehicleDestructible(kit, r.userData.vehicle, { id, frame: root, name: text.items[
|
|
802
|
+
const d = createVehicleDestructible(kit, r.userData.vehicle, { id, frame: root, name: text.items[itemKey] ?? key });
|
|
782
803
|
tapEffects(d);
|
|
783
804
|
r.userData.destructible = d;
|
|
784
805
|
return d;
|
|
@@ -1052,7 +1073,7 @@ function createVehiclesTestModule(options = {}) {
|
|
|
1052
1073
|
for (const entry of placed.values()) {
|
|
1053
1074
|
const want = fleetDims2(entry.key);
|
|
1054
1075
|
const got = entry.size;
|
|
1055
|
-
if (!want || !got) continue;
|
|
1076
|
+
if (!want || !got || entry.scenario) continue;
|
|
1056
1077
|
worst = Math.max(worst, Math.abs(got.length - want.length), Math.abs(got.width - want.width), Math.abs(got.height - want.height));
|
|
1057
1078
|
}
|
|
1058
1079
|
return Math.round(worst * 1e3);
|
|
@@ -1064,23 +1085,23 @@ function createVehiclesTestModule(options = {}) {
|
|
|
1064
1085
|
get placed() {
|
|
1065
1086
|
return placed;
|
|
1066
1087
|
},
|
|
1067
|
-
items: () =>
|
|
1088
|
+
items: () => entries.map(item),
|
|
1068
1089
|
area: () => {
|
|
1069
1090
|
const gap = 1.6;
|
|
1070
1091
|
const WIDE = 6;
|
|
1071
1092
|
const rowOf = (list, z) => {
|
|
1072
1093
|
let cursor = 0;
|
|
1073
|
-
const spots = list.map((
|
|
1074
|
-
const width = fleetDims2(key)?.width ?? 2;
|
|
1094
|
+
const spots = list.map((entry) => {
|
|
1095
|
+
const width = fleetDims2(entry.key)?.width ?? 2;
|
|
1075
1096
|
const x = cursor + width / 2;
|
|
1076
1097
|
cursor += width + gap;
|
|
1077
|
-
return {
|
|
1098
|
+
return { id: entry.id, x };
|
|
1078
1099
|
});
|
|
1079
1100
|
return { spots, z, width: Math.max(0, cursor - gap) };
|
|
1080
1101
|
};
|
|
1081
|
-
const front = rowOf(
|
|
1082
|
-
const back = rowOf(
|
|
1083
|
-
const placements = [front, back].flatMap((row) => row.spots.map(({
|
|
1102
|
+
const front = rowOf(entries.filter((e) => (fleetDims2(e.key)?.width ?? 2) <= WIDE), 0);
|
|
1103
|
+
const back = rowOf(entries.filter((e) => (fleetDims2(e.key)?.width ?? 2) > WIDE), -16);
|
|
1104
|
+
const placements = [front, back].flatMap((row) => row.spots.map(({ id, x }) => ({ item: id, position: [x - row.width / 2, 0, row.z], rotationY: 0 })));
|
|
1084
1105
|
return { placements, view: { eye: [0, 5, Math.max(14, front.width * 0.6)], target: [0, 1, -2] } };
|
|
1085
1106
|
},
|
|
1086
1107
|
controls: () => {
|
|
@@ -1140,6 +1161,7 @@ function loadVehiclesTestModule(room, options = {}) {
|
|
|
1140
1161
|
}
|
|
1141
1162
|
export {
|
|
1142
1163
|
DEFAULT_TEST_VEHICLES,
|
|
1164
|
+
DEFAULT_TEST_WRECKS,
|
|
1143
1165
|
LITE_CLASSES,
|
|
1144
1166
|
PAGE_ITEM_ALIASES,
|
|
1145
1167
|
PAGE_SCENARIO_ALIASES,
|