@adatechnology/game-vehicles-three 0.8.7 → 0.9.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 CHANGED
@@ -1,5 +1,5 @@
1
- import { E as EngineProfile, V as VehicleSoundKeys, B as BuiltVehicle } from './testing-Cb10i9fm.js';
2
- export { a as BIKE_ENGINE, b as BuildVehicleOptions, C as CAR_ENGINE, c as CRASH_SPEEDS, D as DEFAULT_TEST_VEHICLES, d as DEFAULT_TEST_WRECKS, e as DEFAULT_VEHICLE_SOUND_KEYS, f as DocumentLike, g as ENGINE_PROFILES, h as EffectsLike, i as EngineLayer, j as EngineLoadLayer, F as FleetDims, M as ModuleRoomLike, P as PAGE_ITEM_ALIASES, k as PAGE_SCENARIO_ALIASES, l as PROVING_AREA_ID, m as PROVING_TEXT, n as ProvingModuleOptions, o as ProvingRoomLike, p as ProvingText, T as TRUCK_ENGINE, q as VEHICLES_AREA_ID, r as VEHICLE_SCENARIO_IDS, s as VehicleEffectIds, t as VehicleFleetContent, u as VehicleQuality, v as VehicleSoundIds, w as VehicleWreck, x as VehiclesContext, y as VehiclesRoom, z as VehiclesTestFleet, A as VehiclesTestOptions, G as VehiclesThree, H as VehiclesThreeOptions, I as createProvingModule, J as createVehiclesTestModule, K as createVehiclesThree, L as defaultEffectIds, N as defaultSoundIds, O as loadProvingModule, Q as loadVehiclesTestModule } from './testing-Cb10i9fm.js';
1
+ import { E as EngineProfile, V as VehicleSoundKeys, B as BuiltVehicle } from './testing-D6oFFVUd.js';
2
+ export { a as BIKE_ENGINE, b as BuildVehicleOptions, C as CAR_ENGINE, c as CRASH_SPEEDS, D as DEFAULT_TEST_VEHICLES, d as DEFAULT_TEST_WRECKS, e as DEFAULT_VEHICLE_SOUND_KEYS, f as DocumentLike, g as ENGINE_PROFILES, h as EffectsLike, i as EngineLayer, j as EngineLoadLayer, F as FleetDims, M as ModuleRoomLike, P as PAGE_ITEM_ALIASES, k as PAGE_SCENARIO_ALIASES, l as PROVING_AREA_ID, m as PROVING_TEXT, n as ProvingModuleOptions, o as ProvingRoomLike, p as ProvingText, T as TRUCK_ENGINE, q as VEHICLES_AREA_ID, r as VEHICLE_SCENARIO_IDS, s as VehicleEffectIds, t as VehicleFleetContent, u as VehicleQuality, v as VehicleSoundIds, w as VehicleWreck, x as VehiclesContext, y as VehiclesRoom, z as VehiclesTestFleet, A as VehiclesTestOptions, G as VehiclesThree, H as VehiclesThreeOptions, I as createProvingModule, J as createVehiclesTestModule, K as createVehiclesThree, L as defaultEffectIds, N as defaultSoundIds, O as engineProfileOfGroup, Q as hornOfGroup, R as loadProvingModule, S as loadVehiclesTestModule } from './testing-D6oFFVUd.js';
3
3
  import { EffectSink, Vec3, AudioSink, AnimationClipSpec } from '@adatechnology/game-contracts';
4
4
  import { CabinSource, VehicleContext } from '@adatechnology/game-vehicles';
5
5
  import { LoopRecipe, Falloff, SampleAlias, SoundRecipe, SoundBank } from '@adatechnology/game-audio';
@@ -60,9 +60,9 @@ declare const CAR_START_RUN_STOP: {
60
60
  };
61
61
  /**
62
62
  * The vehicle ids answered by the recordings of the kit's manifest (files kept by the game, never in the SDK): the car engine layers by RPM, the
63
- * start and the stop cut out of one recording, the door and the trunk. Each recipe above stays as the fallback while the files load or where the
64
- * game has none. `car_door_open` is a file id of its own and needs no alias; the hood, the truck, the bike, the tyres, crashes and horns have no
65
- * recording yet.
63
+ * start and the stop cut out of one recording, the door, the trunk and the hood, the crashes, the tyres on asphalt and on gravel, and the idle of a
64
+ * truck and of a motorcycle. Each recipe above stays as the fallback while the files load or where the game has none. `car_door_open`, `car_hood_open`,
65
+ * `air_brake` and the horns (`horn_car`, `horn_truck`, `horn_bike`) are file ids of their own and need no alias.
66
66
  */
67
67
  declare const VEHICLE_SAMPLE_ALIASES: readonly SampleAlias[];
68
68
  /** The ids a host should decode as the vehicles load (`AudioSink.preload`): every aliased recording and the door's own file id. */
@@ -151,6 +151,8 @@ type VehicleSoundOptions = {
151
151
  readonly crankSeconds?: number;
152
152
  /** Shared by the vehicles of a scene: only the nearest few keep their loops (`createEngineBudget`). */
153
153
  readonly budget?: EngineBudget;
154
+ /** Lets the brake chambers out as the vehicle stops on the brakes (a truck's air brakes). Default: only for the truck profile. */
155
+ readonly airBrake?: boolean;
154
156
  };
155
157
  /** What was asked of the sink, for the checks and the bench: the RPM in use and the level of each loop. */
156
158
  type VehicleSoundReading = {
@@ -67,8 +67,10 @@ var GameVehiclesThree = (() => {
67
67
  defaultEffectIds: () => defaultEffectIds,
68
68
  defaultSoundIds: () => defaultSoundIds,
69
69
  engineMix: () => engineMix,
70
+ engineProfileOfGroup: () => engineProfileOfGroup,
70
71
  firingHz: () => firingHz,
71
72
  fuse: () => fuse,
73
+ hornOfGroup: () => hornOfGroup,
72
74
  layerWeight: () => layerWeight,
73
75
  liteMaterials: () => liteMaterials,
74
76
  liteMeshes: () => liteMeshes,
@@ -46192,6 +46194,8 @@ var GameVehiclesThree = (() => {
46192
46194
  skidAsphalt: "tire_skid_asphalt",
46193
46195
  skidDirt: "tire_skid_dirt",
46194
46196
  roll: "tire_roll",
46197
+ rollDirt: "tire_roll_gravel",
46198
+ airBrake: "air_brake",
46195
46199
  brakeSqueal: "brake_squeal",
46196
46200
  hitBody: "vehicle_hit_pedestrian",
46197
46201
  siren: "siren",
@@ -46235,6 +46239,9 @@ var GameVehiclesThree = (() => {
46235
46239
  closedThrottle: 0.5
46236
46240
  };
46237
46241
  var ENGINE_PROFILES = { car: CAR_ENGINE, truck: TRUCK_ENGINE, bike: BIKE_ENGINE };
46242
+ var TRUCK_GROUPS = /* @__PURE__ */ new Set(["heavy", "agricultural"]);
46243
+ var engineProfileOfGroup = (group) => group === "motorcycles" ? BIKE_ENGINE : TRUCK_GROUPS.has(group) ? TRUCK_ENGINE : CAR_ENGINE;
46244
+ var hornOfGroup = (group) => group === "motorcycles" ? "horn_bike" : TRUCK_GROUPS.has(group) ? "horn_truck" : "horn_car";
46238
46245
 
46239
46246
  // src/audio/bank.ts
46240
46247
  var VEHICLE_LOOP_FALLOFF = { model: "inverse_square", k: 4e-3, cutoffK: 0.01 };
@@ -46275,6 +46282,7 @@ var GameVehiclesThree = (() => {
46275
46282
  noiseLoop("tire_skid_asphalt", "bandpass", 1900, 5, "rubber squealing on asphalt: a narrow band of noise near 2 kHz"),
46276
46283
  noiseLoop("tire_skid_dirt", "lowpass", 700, 0.8, "tyres sliding on dirt and gravel: a dull, wide hiss"),
46277
46284
  noiseLoop("tire_roll", "lowpass", 400, 0.7, "road noise of the tyres rolling, brighter with the speed"),
46285
+ noiseLoop("tire_roll_gravel", "bandpass", 1400, 0.6, "tyres rolling on gravel: a wide crunching hiss, louder with the speed"),
46278
46286
  // a pad on a disc: a thin, nearly pure whistle near 3.4 kHz (a narrow band of noise, so it wavers as a real squeal does)
46279
46287
  // a siren: a square through a low-pass, its pitch swept by the vehicle every frame (wail: a slow rise and fall; yelp: a fast one)
46280
46288
  toneLoop("siren", "square", "lowpass", 2600, 0.8, "emergency siren, the sweep driven by the vehicle"),
@@ -46341,10 +46349,14 @@ var GameVehiclesThree = (() => {
46341
46349
  // the game's horn (two squares at 415 and 523 Hz, jogo L70272) heard from where the car is; a truck's air horn lower and longer
46342
46350
  recipe2("horn_car", [sceneTone({ wave: "square", f: 415, d: 0.6, vol: 0.09 }), sceneTone({ wave: "square", f: 523, d: 0.6, vol: 0.09 })], "car horn: the game chord, placed and panned"),
46343
46351
  recipe2("horn_truck", [sceneTone({ wave: "sawtooth", f: 220, d: 1.1, vol: 0.1 }), sceneTone({ wave: "sawtooth", f: 277, d: 1.1, vol: 0.08 }), sceneNoise({ type: "bandpass", f: 900, q: 2, d: 1.1, vol: 0.05 })], "truck air horn: low reedy chord"),
46352
+ recipe2("horn_bike", [sceneTone({ wave: "square", f: 620, d: 0.35, vol: 0.07 }), sceneTone({ wave: "square", f: 780, d: 0.35, vol: 0.07 })], "motorcycle horn: a short, thin two-note beep"),
46353
+ // the compressed air let out of a truck's brake chambers as it stops: a hiss that dies away
46354
+ recipe2("air_brake", [sceneNoise({ type: "highpass", f: 2200, a: 0.01, d: 1.1, vol: 0.28 }), sceneNoise({ type: "bandpass", f: 900, q: 0.8, d: 0.35, vol: 0.2 }), sceneTone({ f: 120, f2: 70, d: 0.12, vol: 0.2 })], "air brakes: the chambers venting as the truck stops"),
46344
46355
  // a car door is a padded "tum" with a latch, not a hollow metal box (the fridge's shut_metal)
46345
46356
  recipe2("car_door_open", [...latch(0, 0.32), sceneNoise({ f: 400, d: 0.06, vol: 0.14, delay: 0.035 })], "car door: the handle pulled, the latch released, the seal letting go"),
46346
46357
  recipe2("car_door_close", [sceneTone({ f: 75, f2: 48, d: 0.16, vol: 0.75 }), sceneNoise({ f: 320, d: 0.1, vol: 0.6 }), ...latch(0.012, 0.3)], "car door shut: a dull padded thump and the latch catching"),
46347
46358
  recipe2("car_trunk_close", [sceneTone({ f: 90, f2: 55, d: 0.15, vol: 0.65 }), sceneNoise({ type: "bandpass", f: 500, q: 1, d: 0.12, vol: 0.5 }), ...latch(0.01, 0.28), sceneNoise({ type: "bandpass", f: 1800, q: 3, d: 0.04, vol: 0.1, delay: 0.06 })], "trunk or hatch shut: a lighter thump, the latch and a small rattle"),
46359
+ recipe2("car_hood_open", [...latch(0, 0.3), sceneTone({ f: [180, 230], f2: 140, d: 0.3, vol: 0.04, delay: 0.06 }), sceneNoise({ type: "bandpass", f: 700, q: 2, d: 0.25, vol: 0.12, delay: 0.05 })], "hood released: the latch giving and the lid rising a little on its springs"),
46348
46360
  recipe2("car_hood_close", [sceneTone({ f: 70, f2: 40, d: 0.22, vol: 0.8 }), sceneNoise({ type: "bandpass", f: 850, q: 1.4, d: 0.2, vol: 0.6, wet: 0.3 }), sceneTone({ f: 900, f2: 860, d: 0.18, vol: 0.05 }), ...latch(0.015, 0.3)], "hood slammed: a big sheet of metal ringing a little, the latch")
46349
46361
  ];
46350
46362
  var CAR_RECORDED_RPM = { idle: 1e3, high: 2520 };
@@ -46356,6 +46368,13 @@ var GameVehiclesThree = (() => {
46356
46368
  /** The ignition off: the engine running down to the end of the file. */
46357
46369
  stop: { offset: 9.96, duration: 0.64 }
46358
46370
  };
46371
+ var idleLayer = (id, file, rpm, profile) => ({
46372
+ id,
46373
+ file,
46374
+ loop: true,
46375
+ baseFrequency: firingHz(profile, rpm),
46376
+ falloff: VEHICLE_LOOP_FALLOFF
46377
+ });
46359
46378
  var carLayer = (id, file, rpm, harmonic, offset) => ({
46360
46379
  id,
46361
46380
  file,
@@ -46374,9 +46393,20 @@ var GameVehiclesThree = (() => {
46374
46393
  { id: "engine_start", file: "engine_start_run_stop", only: CAR_START_RUN_STOP.take, ...CAR_START_RUN_STOP.start, falloff: VEHICLE_LOOP_FALLOFF },
46375
46394
  { id: "engine_stop", file: "engine_start_run_stop", only: CAR_START_RUN_STOP.take, ...CAR_START_RUN_STOP.stop, falloff: VEHICLE_LOOP_FALLOFF },
46376
46395
  { id: "car_door_close", file: "car_door_shut" },
46377
- { id: "car_trunk_close", file: "car_trunk_shut" }
46396
+ { id: "car_trunk_close", file: "car_trunk_shut" },
46397
+ { id: "car_hood_close", file: "car_hood_shut" },
46398
+ // a crash by speed: a dent in the plastic, the body folding, the wreck (file ids that are not the recipes' own: `crash_light` and its kin would read as tiers of `crash`)
46399
+ { id: "crash_light", file: "crash_dent" },
46400
+ { id: "crash_medium", file: "crash_fold" },
46401
+ { id: "crash_heavy", file: "crash_wreck" },
46402
+ // tyres: the squeal of rubber on asphalt and the crunch of gravel, chained like the engines
46403
+ { id: "tire_skid_asphalt", file: "tire_skid_asphalt_loop", loop: { crossfade: 0.6 }, falloff: VEHICLE_LOOP_FALLOFF },
46404
+ { id: "tire_roll_gravel", file: "tire_roll_gravel_loop", loop: { crossfade: 0.6 }, falloff: VEHICLE_LOOP_FALLOFF },
46405
+ // the idle of a truck and of a motorcycle, at the profile's idle RPM (the take plays at its own pitch there); the other layers stay on their recipes
46406
+ idleLayer("engine_truck_low", "engine_loop_truck_idle", TRUCK_ENGINE.idleRpm, TRUCK_ENGINE),
46407
+ idleLayer("engine_bike_low", "engine_loop_bike_idle", BIKE_ENGINE.idleRpm, BIKE_ENGINE)
46378
46408
  ];
46379
- var VEHICLE_PRELOAD_SOUNDS = [...VEHICLE_SAMPLE_ALIASES.map((alias) => alias.id), "car_door_open"];
46409
+ var VEHICLE_PRELOAD_SOUNDS = [...VEHICLE_SAMPLE_ALIASES.map((alias) => alias.id), "car_door_open", "car_hood_open", "horn_car", "horn_truck", "horn_bike", "air_brake"];
46380
46410
  var VEHICLE_SOUND_BANK = { id: "vehicles_three", sounds: VEHICLE_SOUNDS, loops: VEHICLE_LOOPS, sampleAliases: VEHICLE_SAMPLE_ALIASES };
46381
46411
 
46382
46412
  // src/audio/engine-budget.ts
@@ -46413,12 +46443,13 @@ var GameVehiclesThree = (() => {
46413
46443
  const profile = options.profile ?? CAR_ENGINE;
46414
46444
  const keys = { ...DEFAULT_VEHICLE_SOUND_KEYS, ...options.sounds };
46415
46445
  const crankSeconds = options.crankSeconds ?? 0.75;
46446
+ const airBrake = options.airBrake ?? profile.id === TRUCK_ENGINE.id;
46416
46447
  const gears = createGearGuess(profile);
46417
46448
  const loops = /* @__PURE__ */ new Map();
46418
46449
  const budget = options.budget;
46419
46450
  const self = {};
46420
46451
  const levels = {};
46421
- const state = { running: false, cranking: 0, catches: false, flare: 0, rpm: 0, sirenPhase: 0 };
46452
+ const state = { running: false, cranking: 0, catches: false, flare: 0, rpm: 0, sirenPhase: 0, rolling: false };
46422
46453
  const loopOf = (sound) => {
46423
46454
  let handle = loops.get(sound);
46424
46455
  if (!handle && audio?.loop) {
@@ -46479,7 +46510,15 @@ var GameVehiclesThree = (() => {
46479
46510
  const dirt = frame.surface === "dirt";
46480
46511
  setLoop(keys.skidAsphalt, heard * (dirt ? 0 : 0.16 * slide), frame.position, { cutoff: 1700 + 600 * slide });
46481
46512
  setLoop(keys.skidDirt, heard * (dirt ? 0.2 * slide : 0), frame.position, { cutoff: 500 + 500 * slide });
46482
- setLoop(keys.roll, heard * 0.06 * clamp012(speed / 25), frame.position, { cutoff: 250 + 45 * Math.min(speed, 40) });
46513
+ setLoop(keys.roll, heard * (dirt ? 0 : 0.06 * clamp012(speed / 25)), frame.position, { cutoff: 250 + 45 * Math.min(speed, 40) });
46514
+ setLoop(keys.rollDirt, heard * (dirt ? 0.1 * clamp012(speed / 20) : 0), frame.position, { cutoff: 700 + 60 * Math.min(speed, 30) });
46515
+ if (airBrake) {
46516
+ if (speed > 2) state.rolling = true;
46517
+ else if (state.rolling && speed < 0.8) {
46518
+ state.rolling = false;
46519
+ if ((frame.brake ?? 0) > 0.3 && heard > 0) play(keys.airBrake, frame.position, 0.8);
46520
+ }
46521
+ }
46483
46522
  const squeal = clamp012(((frame.brake ?? 0) - 0.3) / 0.4) * clamp012(speed / 0.8) * clamp012((5 - speed) / 2) * (slide > 0 ? 0 : 1);
46484
46523
  setLoop(keys.brakeSqueal, heard * 0.05 * squeal, frame.position, { cutoff: 3200 + 400 * squeal });
46485
46524
  const siren = frame.siren ?? "off";
@@ -50798,7 +50837,7 @@ var GameVehiclesThree = (() => {
50798
50837
  if (id === "turn_circle") run.driver.place(0, TRACK.start, 0);
50799
50838
  rig.vehicle?.reset();
50800
50839
  stopEngine();
50801
- engine = createVehicleSound(host.audio, { sounds });
50840
+ engine = createVehicleSound(host.audio, { sounds, profile: engineProfileOfGroup(car.subject.category) });
50802
50841
  engine.start([car.built.group.position.x, 0.5, car.built.group.position.z]);
50803
50842
  host.log(fillText(text.log.start, name(settings.vehicle), text.tests[id] ?? id));
50804
50843
  drawBoard();
@@ -50855,7 +50894,7 @@ var GameVehiclesThree = (() => {
50855
50894
  gauge: kitFor(three).materials?.gauge,
50856
50895
  needle: kitFor(three).materials?.amber,
50857
50896
  // the engine's own sound turns the key (starter, catch, idle by RPM)
50858
- sounds: { starter: "" },
50897
+ sounds: { starter: "", horn: hornOfGroup(car.subject.category) },
50859
50898
  hasKey,
50860
50899
  weather,
50861
50900
  stock: (compartment) => options.stock?.(compartment, settings.vehicle) ?? [],
@@ -50895,7 +50934,7 @@ var GameVehiclesThree = (() => {
50895
50934
  }
50896
50935
  rig.vehicle?.reset();
50897
50936
  stopEngine();
50898
- engine = createVehicleSound(host.audio, { sounds });
50937
+ engine = createVehicleSound(host.audio, { sounds, profile: engineProfileOfGroup(car.subject.category) });
50899
50938
  host.bench?.sheet?.({ kicker: text.name, title: fillText(text.log.drive, name(settings.vehicle)), body: `${text.cabin.keys} \xB7 ${sysText.keys} \xB7 ${sysText.bodyKeys}` });
50900
50939
  host.log(fillText(text.log.drive, name(settings.vehicle)));
50901
50940
  };
@@ -51300,6 +51339,7 @@ var GameVehiclesThree = (() => {
51300
51339
  lent.audio?.register?.(CABIN_BANK);
51301
51340
  lent.audio?.register?.(VEHICLE_SOUND_BANK);
51302
51341
  lent.audio?.register?.(RADIO_BANK);
51342
+ lent.audio?.preload?.(VEHICLE_PRELOAD_SOUNDS);
51303
51343
  const stopChange = lent.bench?.onChange(onChange);
51304
51344
  const stopFrame = lent.onFrame(frame);
51305
51345
  const stopClear = lent.onClear?.(() => {