@adatechnology/game-vehicles-driving 0.2.31 → 0.3.1

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
@@ -510,13 +510,14 @@ var tracksOfBody = (tracks) => {
510
510
 
511
511
  // src/semi/from-stats.ts
512
512
  var RIDER_MASS_KG = 75;
513
- var MOTORCYCLE_POWER_FACTOR = 1.3;
514
513
  var MOTORCYCLE_POWER_RATING_1 = 11800 / (132 + RIDER_MASS_KG);
515
514
  var MOTORCYCLE_POWER_RATING_10 = 33400 / (168 + RIDER_MASS_KG);
516
- var motorcyclePower = (rating) => MOTORCYCLE_POWER_FACTOR * (MOTORCYCLE_POWER_RATING_1 + (MOTORCYCLE_POWER_RATING_10 - MOTORCYCLE_POWER_RATING_1) * (rating - 1) / 9);
515
+ var motorcyclePower = (rating) => MOTORCYCLE_POWER_RATING_1 + (MOTORCYCLE_POWER_RATING_10 - MOTORCYCLE_POWER_RATING_1) * (rating - 1) / 9;
516
+ var PHYSICS_TORQUE_SCALE = { car: 1.45, motorcycle: 1.3 };
517
517
  var carPower = (rating) => (0.06 + 0.015 * rating) * (defaultSemiSpec.engine.peakRpm * 2 * Math.PI / 60);
518
+ var TRACKED_POWER = 20.05;
518
519
  var peakTorqueOf = (type, rating, mass, peakRpm) => {
519
- const power = type === "motorcycle" ? motorcyclePower(rating) : carPower(rating);
520
+ const power = type === "motorcycle" ? motorcyclePower(rating) : type === "tracked" ? TRACKED_POWER : carPower(rating);
520
521
  return mass * power * 60 / (2 * Math.PI * peakRpm);
521
522
  };
522
523
  var cyclistFor = (top, wheelRadius) => {
@@ -572,6 +573,7 @@ function semiSpecFromStats(stats, body, base = {}) {
572
573
  gears,
573
574
  drag,
574
575
  brakeForce,
576
+ ...type === "car" || type === "motorcycle" ? { physicsTorqueScale: PHYSICS_TORQUE_SCALE[type] } : {},
575
577
  tyre: { ...spec.tyre, friction: 0.8 + 0.03 * stats.handling },
576
578
  ...pedal ? { pedal } : {},
577
579
  ...tracks ? { tracks } : {}
@@ -1174,6 +1176,7 @@ var WHEEL_WIDTH = 0.2;
1174
1176
  var CLUTCH_STRENGTH = 10;
1175
1177
  var CLUTCH_SLIP = 0.03;
1176
1178
  var BICYCLE_WHEEL_INERTIA = 0.1;
1179
+ var BICYCLE_IDLE_CADENCE_RPM = 40;
1177
1180
  var WHEEL_INERTIA_PER_MASS = 8e-4;
1178
1181
  var REFERENCE_RADIUS = 0.32;
1179
1182
  var MIN_WHEEL_INERTIA = 0.02;
@@ -1186,6 +1189,12 @@ var CAR_TRANSMISSION = { switchTime: 0.1, clutchReleaseTime: 0.1, switchLatency:
1186
1189
  var MOTORCYCLE_TRANSMISSION = { switchTime: 0.05, clutchReleaseTime: 0.07, switchLatency: 0.05 };
1187
1190
  var clutchFor = (peakTorque, maxRpm) => Math.max(CLUTCH_STRENGTH, peakTorque / (CLUTCH_SLIP * (maxRpm * 2 * Math.PI / 60)));
1188
1191
  var clamp5 = (x, low, high) => Math.max(low, Math.min(high, x));
1192
+ var pedalCurve = (pedal) => {
1193
+ const redline = pedal.cadenceRpm * 1.5;
1194
+ const idle = BICYCLE_IDLE_CADENCE_RPM;
1195
+ const heldWatts = (cadence) => pedal.cadenceRpm / cadence;
1196
+ return [[0, heldWatts(idle)], [idle / redline, heldWatts(idle)], [pedal.cadenceRpm / redline, 1], [1, 0]];
1197
+ };
1189
1198
  var torqueCurve = (spec) => {
1190
1199
  const { idleRpm, peakRpm, redlineRpm, peakTorque } = spec.engine;
1191
1200
  const at = (rpm) => torqueAt(spec, rpm) / peakTorque;
@@ -1262,7 +1271,7 @@ var drivetrainOf = (spec, options) => {
1262
1271
  gears: pedal.gears.map((ratio) => 1 / ratio),
1263
1272
  reverseGears: [],
1264
1273
  differentialRatio: 1,
1265
- torqueCurve: [[0, 1], [0.67, 1], [1, 0]],
1274
+ torqueCurve: pedalCurve(pedal),
1266
1275
  transmission: { shiftUpRpm: pedal.cadenceRpm * 0.95, shiftDownRpm: pedal.cadenceRpm * 0.5, clutchStrength: clutchFor(pedal.watts / crankSpeed, pedal.cadenceRpm * 1.5) }
1267
1276
  };
1268
1277
  }
@@ -1270,7 +1279,7 @@ var drivetrainOf = (spec, options) => {
1270
1279
  return {
1271
1280
  engineDamping: ENGINE_DAMPING,
1272
1281
  engineInertia: ENGINE_INERTIA_PER_TORQUE * spec.engine.peakTorque,
1273
- maxTorque: spec.engine.peakTorque * spec.efficiency * (ENGINE_FLOOR + (1 - ENGINE_FLOOR) * health),
1282
+ maxTorque: spec.engine.peakTorque * (spec.physicsTorqueScale ?? 1) * spec.efficiency * (ENGINE_FLOOR + (1 - ENGINE_FLOOR) * health),
1274
1283
  minRpm: spec.engine.idleRpm,
1275
1284
  maxRpm: spec.engine.redlineRpm,
1276
1285
  gears: spec.gears,