@adatechnology/game-vehicles-three 0.1.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.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();
@@ -694,9 +709,14 @@ var defaultEffectIds = {
694
709
  glass: "glass_burst",
695
710
  sparks: "impact_metal",
696
711
  leak: "vehicle_leak",
712
+ leakIgnited: "vehicle_leak_ignited",
697
713
  exhaust: "vehicle_exhaust"
698
714
  };
699
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
+ ];
700
720
 
701
721
  // src/test-area/module.ts
702
722
  var VEHICLES_AREA_ID = "vehicles_area";
@@ -710,6 +730,8 @@ function createVehiclesTestModule(options = {}) {
710
730
  const locale = options.locale ?? "pt-BR";
711
731
  const text = TEXT[locale] ?? TEXT["pt-BR"];
712
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 }))];
713
735
  const effectIds = { ...defaultEffectIds, ...options.effects };
714
736
  const soundIds = { ...defaultSoundIds, ...options.sounds };
715
737
  const settings = { quality: "high", paint: false, seed: 1, palette: "auto", driving: "arcade", surface: "dry_asphalt" };
@@ -758,15 +780,17 @@ function createVehiclesTestModule(options = {}) {
758
780
  }
759
781
  entry.paint.color.set(color);
760
782
  };
761
- const item = (key) => ({
762
- id: itemId(key),
763
- name: text.items[itemId(key)] ?? key,
783
+ const item = ({ key, id: itemKey, scenario }) => ({
784
+ id: itemKey,
785
+ name: text.items[itemKey] ?? key,
764
786
  movable: false,
787
+ // the first build of a vehicle takes most of a second
788
+ slow: true,
765
789
  build: (THREE) => {
766
790
  const kit = kitFor(THREE);
767
- const built = buildVehicleItem(kit, key, { lod: settings.quality === "lite" });
791
+ const built = buildVehicleItem(kit, key, { lod: settings.quality === "lite", ...scenario ? { scenario } : {} });
768
792
  built.root.userData.kit = kit;
769
- 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: [] };
770
794
  placed.set(built.root.uuid, entry);
771
795
  measure(entry);
772
796
  paintOf(entry);
@@ -775,7 +799,7 @@ function createVehiclesTestModule(options = {}) {
775
799
  impl: (root, id) => {
776
800
  const r = root;
777
801
  const kit = r.userData.kit;
778
- const d = createVehicleDestructible(kit, r.userData.vehicle, { id, frame: root, name: text.items[itemId(key)] ?? key });
802
+ const d = createVehicleDestructible(kit, r.userData.vehicle, { id, frame: root, name: text.items[itemKey] ?? key });
779
803
  tapEffects(d);
780
804
  r.userData.destructible = d;
781
805
  return d;
@@ -802,7 +826,7 @@ function createVehiclesTestModule(options = {}) {
802
826
  for (const e of events) {
803
827
  const position = e.point ?? e.worldPoint;
804
828
  if (!position) continue;
805
- if (e.type === "ignite") fx.play({ effect: effectIds.ignite, point: position });
829
+ if (e.type === "ignite") fx.play({ effect: /fuel_tank|tank/.test(e.part ?? "") ? effectIds.leakIgnited : effectIds.ignite, point: position });
806
830
  else if (e.type === "explode") fx.play({ effect: effectIds.explode, point: position });
807
831
  else if (e.type === "leak") fx.play({ effect: effectIds.leak, point: position });
808
832
  else if (e.type === "fracture" && /glass|window|windshield/.test(e.part ?? "")) fx.play({ effect: effectIds.glass, point: position });
@@ -1049,7 +1073,7 @@ function createVehiclesTestModule(options = {}) {
1049
1073
  for (const entry of placed.values()) {
1050
1074
  const want = fleetDims2(entry.key);
1051
1075
  const got = entry.size;
1052
- if (!want || !got) continue;
1076
+ if (!want || !got || entry.scenario) continue;
1053
1077
  worst = Math.max(worst, Math.abs(got.length - want.length), Math.abs(got.width - want.width), Math.abs(got.height - want.height));
1054
1078
  }
1055
1079
  return Math.round(worst * 1e3);
@@ -1061,23 +1085,23 @@ function createVehiclesTestModule(options = {}) {
1061
1085
  get placed() {
1062
1086
  return placed;
1063
1087
  },
1064
- items: () => keys.map(item),
1088
+ items: () => entries.map(item),
1065
1089
  area: () => {
1066
1090
  const gap = 1.6;
1067
1091
  const WIDE = 6;
1068
1092
  const rowOf = (list, z) => {
1069
1093
  let cursor = 0;
1070
- const spots = list.map((key) => {
1071
- const width = fleetDims2(key)?.width ?? 2;
1094
+ const spots = list.map((entry) => {
1095
+ const width = fleetDims2(entry.key)?.width ?? 2;
1072
1096
  const x = cursor + width / 2;
1073
1097
  cursor += width + gap;
1074
- return { key, x };
1098
+ return { id: entry.id, x };
1075
1099
  });
1076
1100
  return { spots, z, width: Math.max(0, cursor - gap) };
1077
1101
  };
1078
- const front = rowOf(keys.filter((key) => (fleetDims2(key)?.width ?? 2) <= WIDE), 0);
1079
- const back = rowOf(keys.filter((key) => (fleetDims2(key)?.width ?? 2) > WIDE), -16);
1080
- const placements = [front, back].flatMap((row) => row.spots.map(({ key, x }) => ({ item: itemId(key), position: [x - row.width / 2, 0, row.z], rotationY: 0 })));
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 })));
1081
1105
  return { placements, view: { eye: [0, 5, Math.max(14, front.width * 0.6)], target: [0, 1, -2] } };
1082
1106
  },
1083
1107
  controls: () => {
@@ -1137,6 +1161,7 @@ function loadVehiclesTestModule(room, options = {}) {
1137
1161
  }
1138
1162
  export {
1139
1163
  DEFAULT_TEST_VEHICLES,
1164
+ DEFAULT_TEST_WRECKS,
1140
1165
  LITE_CLASSES,
1141
1166
  PAGE_ITEM_ALIASES,
1142
1167
  PAGE_SCENARIO_ALIASES,