From e8aaeb46cbc6c84edb494d504f441590af1d58aa Mon Sep 17 00:00:00 2001 From: Dhruv Arora Date: Tue, 25 Jun 2024 13:55:42 -0700 Subject: [PATCH] Added basic friction - floor friction and longitudinal and latitudinal friction --- fission/src/systems/physics/PhysicsSystem.ts | 12 +++++++----- fission/src/systems/simulation/driver/WheelDriver.ts | 5 +++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/fission/src/systems/physics/PhysicsSystem.ts b/fission/src/systems/physics/PhysicsSystem.ts index 3a0f164f5a..8461f6cbc2 100644 --- a/fission/src/systems/physics/PhysicsSystem.ts +++ b/fission/src/systems/physics/PhysicsSystem.ts @@ -68,8 +68,10 @@ class PhysicsSystem extends WorldSystem { new THREE.Vector3(0.0, -2.0, 0.0), undefined ) + ground.SetFriction(0.7); this._joltBodyInterface.AddBody(ground.GetID(), JOLT.EActivation_Activate) } + /** * TEMPORARY @@ -453,11 +455,11 @@ class PhysicsSystem extends WorldSystem { wheelSettings.mSuspensionMaxLength = 0.0000006 wheelSettings.mInertia = 1 - const friction = new JOLT.LinearCurve() - friction.Clear() - friction.AddPoint(1, 1) - friction.AddPoint(0, 1) - wheelSettings.mLongitudinalFriction = friction + // const friction = new JOLT.LinearCurve() + // friction.Clear() + // friction.AddPoint(1, 1) + // friction.AddPoint(0, 1) + // wheelSettings.mLongitudinalFriction = friction const vehicleSettings = new JOLT.VehicleConstraintSettings() diff --git a/fission/src/systems/simulation/driver/WheelDriver.ts b/fission/src/systems/simulation/driver/WheelDriver.ts index 5758e357ba..627e48b384 100644 --- a/fission/src/systems/simulation/driver/WheelDriver.ts +++ b/fission/src/systems/simulation/driver/WheelDriver.ts @@ -2,6 +2,9 @@ import Jolt from "@barclah/jolt-physics" import Driver from "./Driver" import JOLT from "@/util/loading/JoltSyncLoader" +const LATERIAL_FRICTION = 0.6; +const LONGITUDINAL_FRICTION = 0.8; + class WheelDriver extends Driver { private _constraint: Jolt.VehicleConstraint private _wheel: Jolt.WheelWV @@ -22,6 +25,8 @@ class WheelDriver extends Driver { this._constraint = constraint; this._wheel = JOLT.castObject(this._constraint.GetWheel(0), JOLT.WheelWV); + this._wheel.set_mCombinedLateralFriction(LATERIAL_FRICTION); + this._wheel.set_mCombinedLongitudinalFriction(LONGITUDINAL_FRICTION); } public Update(_: number): void {