@babylonjs/core 7.51.0 → 7.51.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.
@@ -125,6 +125,14 @@ export class PhysicsCharacterController {
125
125
  * default 1e38
126
126
  */
127
127
  this.characterStrength = 1e38;
128
+ /**
129
+ * Acceleration factor. A value of 1 means reaching max velocity immediately
130
+ */
131
+ this.acceleration = 0.05;
132
+ /**
133
+ * maximum acceleration in world space coordinate
134
+ */
135
+ this.maxAcceleration = 50;
128
136
  /**
129
137
  * character mass
130
138
  * default 0
@@ -1195,17 +1203,16 @@ export class PhysicsCharacterController {
1195
1203
  desiredVelocitySF.scaleInPlace(len);
1196
1204
  const diff = this._tmpVecs[5];
1197
1205
  desiredVelocitySF.subtractToRef(relative, diff);
1198
- // Clamp it by maxVelocityDelta and limit it by gain.
1206
+ // Clamp it by maxAcceleration and limit it by gain.
1199
1207
  {
1200
1208
  const lenSq = diff.lengthSquared();
1201
- const gain = 0.05;
1202
- const maxVelocityDelta = 50.0 * deltaTime;
1209
+ const maxVelocityDelta = this.maxAcceleration * deltaTime;
1203
1210
  let tmp;
1204
- if (lenSq * gain * gain > maxVelocityDelta * maxVelocityDelta) {
1211
+ if (lenSq * this.acceleration * this.acceleration > maxVelocityDelta * maxVelocityDelta) {
1205
1212
  tmp = maxVelocityDelta / Math.sqrt(lenSq);
1206
1213
  }
1207
1214
  else {
1208
- tmp = gain;
1215
+ tmp = this.acceleration;
1209
1216
  }
1210
1217
  diff.scaleInPlace(tmp);
1211
1218
  }