Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions dist/cannon-es.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6631,6 +6631,8 @@ class WheelInfo {
dampingCompression: 10,
dampingRelaxation: 10,
frictionSlip: 10000,
forwardAcceleration: 1,
sideAcceleration: 1,
steering: 0,
rotation: 0,
deltaRotation: 0,
Expand Down Expand Up @@ -6664,6 +6666,8 @@ class WheelInfo {
this.dampingCompression = options.dampingCompression;
this.dampingRelaxation = options.dampingRelaxation;
this.frictionSlip = options.frictionSlip;
this.forwardAcceleration = options.forwardAcceleration;
this.sideAcceleration = options.sideAcceleration;
this.steering = 0;
this.rotation = 0;
this.deltaRotation = 0;
Expand Down Expand Up @@ -7157,8 +7161,8 @@ class RaycastVehicle {
const maximpSquared = maximp * maximpSide;
wheel.forwardImpulse = rollingFriction; //wheelInfo.engineForce* timeStep;

const x = wheel.forwardImpulse * fwdFactor;
const y = wheel.sideImpulse * sideFactor;
const x = wheel.forwardImpulse * fwdFactor / wheel.forwardAcceleration;
const y = wheel.sideImpulse * sideFactor / wheel.sideAcceleration;
const impulseSquared = x * x + y * y;
wheel.sliding = false;

Expand Down
4 changes: 4 additions & 0 deletions dist/cannon-es.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1343,6 +1343,8 @@ declare module "objects/WheelInfo" {
dampingCompression?: number;
dampingRelaxation?: number;
frictionSlip?: number;
forwardAcceleration?: number;
sideAcceleration?: number;
steering?: number;
rotation?: number;
deltaRotation?: number;
Expand Down Expand Up @@ -1382,6 +1384,8 @@ declare module "objects/WheelInfo" {
dampingCompression: number;
dampingRelaxation: number;
frictionSlip: number;
forwardAcceleration: number;
sideAcceleration: number;
steering: number;
rotation: number;
deltaRotation: number;
Expand Down
8 changes: 6 additions & 2 deletions dist/cannon-es.js
Original file line number Diff line number Diff line change
Expand Up @@ -6627,6 +6627,8 @@ class WheelInfo {
dampingCompression: 10,
dampingRelaxation: 10,
frictionSlip: 10000,
forwardAcceleration: 1,
sideAcceleration: 1,
steering: 0,
rotation: 0,
deltaRotation: 0,
Expand Down Expand Up @@ -6660,6 +6662,8 @@ class WheelInfo {
this.dampingCompression = options.dampingCompression;
this.dampingRelaxation = options.dampingRelaxation;
this.frictionSlip = options.frictionSlip;
this.forwardAcceleration = options.forwardAcceleration;
this.sideAcceleration = options.sideAcceleration;
this.steering = 0;
this.rotation = 0;
this.deltaRotation = 0;
Expand Down Expand Up @@ -7153,8 +7157,8 @@ class RaycastVehicle {
const maximpSquared = maximp * maximpSide;
wheel.forwardImpulse = rollingFriction; //wheelInfo.engineForce* timeStep;

const x = wheel.forwardImpulse * fwdFactor;
const y = wheel.sideImpulse * sideFactor;
const x = wheel.forwardImpulse * fwdFactor / wheel.forwardAcceleration;
const y = wheel.sideImpulse * sideFactor / wheel.sideAcceleration;
const impulseSquared = x * x + y * y;
wheel.sliding = false;

Expand Down
2 changes: 1 addition & 1 deletion examples/raycast_vehicle.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
directionLocal: new CANNON.Vec3(0, -1, 0),
suspensionStiffness: 30,
suspensionRestLength: 0.3,
frictionSlip: 5,
frictionSlip: 1.4,
dampingRelaxation: 2.3,
dampingCompression: 4.4,
maxSuspensionForce: 100000,
Expand Down
4 changes: 2 additions & 2 deletions src/objects/RaycastVehicle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,8 @@ export class RaycastVehicle {

wheel.forwardImpulse = rollingFriction //wheelInfo.engineForce* timeStep;

const x = wheel.forwardImpulse * fwdFactor
const y = wheel.sideImpulse * sideFactor
const x = wheel.forwardImpulse * fwdFactor / wheel.forwardAcceleration
const y = wheel.sideImpulse * sideFactor / wheel.sideAcceleration

const impulseSquared = x * x + y * y

Expand Down
8 changes: 8 additions & 0 deletions src/objects/WheelInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export type WheelInfoOptions = {
dampingCompression?: number
dampingRelaxation?: number
frictionSlip?: number
forwardAcceleration?: number
sideAcceleration?: number
steering?: number
rotation?: number
deltaRotation?: number
Expand Down Expand Up @@ -93,6 +95,8 @@ export class WheelInfo {
dampingCompression: number
dampingRelaxation: number
frictionSlip: number
forwardAcceleration: number
sideAcceleration: number
steering: number
rotation: number // Rotation value, in radians.
deltaRotation: number
Expand Down Expand Up @@ -128,6 +132,8 @@ export class WheelInfo {
dampingCompression: 10,
dampingRelaxation: 10,
frictionSlip: 10000,
forwardAcceleration: 1,
sideAcceleration: 1,
steering: 0,
rotation: 0,
deltaRotation: 0,
Expand Down Expand Up @@ -162,6 +168,8 @@ export class WheelInfo {
this.dampingCompression = options.dampingCompression!
this.dampingRelaxation = options.dampingRelaxation!
this.frictionSlip = options.frictionSlip!
this.forwardAcceleration = options.forwardAcceleration!
this.sideAcceleration = options.sideAcceleration!
this.steering = 0
this.rotation = 0
this.deltaRotation = 0
Expand Down