@adatechnology/game-vehicles-three 0.8.3 → 0.8.4

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.
@@ -1119,6 +1119,7 @@ function createGearGuess(profile) {
1119
1119
 
1120
1120
  // src/audio/vehicle-sound.ts
1121
1121
  var clamp012 = (v) => v < 0 ? 0 : v > 1 ? 1 : v;
1122
+ var slideOfGrip = (usage) => clamp012((Math.abs(usage) - 0.9) / 0.1);
1122
1123
  function createVehicleSound(audio, options = {}) {
1123
1124
  const profile = options.profile ?? CAR_ENGINE;
1124
1125
  const keys = { ...DEFAULT_VEHICLE_SOUND_KEYS, ...options.sounds };
@@ -1700,7 +1701,7 @@ function createVehiclesTestModule(options = {}) {
1700
1701
  position: [driver.state.x, 0.5, driver.state.z],
1701
1702
  speed,
1702
1703
  throttle: input.throttle,
1703
- ...semiState ? { rpm: semiState.rpm, slip: Math.max(0, ...semiState.slip.map(Math.abs)) } : { slip: braking && speed > 3 ? 0.6 : 0 },
1704
+ ...semiState ? { rpm: semiState.rpm, slip: Math.max(0, ...semiState.slip.map(slideOfGrip)) } : { slip: braking && speed > 3 ? 0.6 : 0 },
1704
1705
  surface: /dirt|gravel|sand|grass|mud/.test(settings.surface) ? "dirt" : "asphalt",
1705
1706
  brake: input.brake
1706
1707
  });
@@ -2519,6 +2520,7 @@ function createCockpit(o) {
2519
2520
  let sparkAgain = 0;
2520
2521
  let wiresBefore = 0;
2521
2522
  let gas = 0;
2523
+ let pedal = 0;
2522
2524
  const systems = createVehicleSystems();
2523
2525
  const context = o.built.context;
2524
2526
  const destructible = o.kit && context ? createVehicleDestructible3(o.kit, context, { id: "driven", frame: o.built.group }) : null;
@@ -2612,9 +2614,13 @@ function createCockpit(o) {
2612
2614
  get throttle() {
2613
2615
  return gas;
2614
2616
  },
2617
+ get brake() {
2618
+ return pedal;
2619
+ },
2615
2620
  step(dt) {
2616
2621
  const input = controls.input(dt, driver);
2617
2622
  gas = input.throttle;
2623
+ pedal = input.brake;
2618
2624
  if (input.start && sounds.starter) play(sounds.starter);
2619
2625
  const engine = driver.step(input, dt).events;
2620
2626
  controls.after(driver, dt);
@@ -3764,7 +3770,18 @@ function createProvingModule(options) {
3764
3770
  steer = p.driver.state.steerAngle;
3765
3771
  if (p.time > 9) parking = null;
3766
3772
  }
3767
- if (car) engine?.update({ dt, position: [car.built.group.position.x, 0.5, car.built.group.position.z], speed, throttle: run ? 1 : driving?.throttle ?? 0, rpm: driving ? driving.driver.state.rpm : void 0 });
3773
+ if (car) {
3774
+ const semi = run?.driver.state ?? driving?.driver.state;
3775
+ const asked = run ? run.input : { throttle: driving?.throttle ?? 0, brake: driving?.brake ?? 0 };
3776
+ engine?.update({
3777
+ dt,
3778
+ position: [car.built.group.position.x, 0.5, car.built.group.position.z],
3779
+ speed,
3780
+ throttle: asked.throttle,
3781
+ brake: asked.brake,
3782
+ ...semi ? { rpm: semi.rpm, slip: Math.max(0, ...semi.slip.map(slideOfGrip)) } : {}
3783
+ });
3784
+ }
3768
3785
  const f = frameOf(speed);
3769
3786
  if (f && rig.vehicle && settings.camera !== "room") rig.vehicle.update(rig.camera, f, dt);
3770
3787
  if (f && rig.vehicle) for (const m of rig.mirrors) rig.vehicle.placeMirror(m.camera, aimed(m.pose), f);
@@ -3916,6 +3933,7 @@ export {
3916
3933
  VEHICLE_PRELOAD_SOUNDS,
3917
3934
  VEHICLE_SOUND_BANK,
3918
3935
  createEngineBudget,
3936
+ slideOfGrip,
3919
3937
  createVehicleSound,
3920
3938
  VEHICLE_LOD_DISTANCE,
3921
3939
  createVehicleLod,
@@ -3942,4 +3960,4 @@ export {
3942
3960
  createProvingModule,
3943
3961
  loadProvingModule
3944
3962
  };
3945
- //# sourceMappingURL=chunk-C7FZFX3K.js.map
3963
+ //# sourceMappingURL=chunk-VF34TPYO.js.map