Skip to content
Merged
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
12 changes: 7 additions & 5 deletions app/(core)/physics/InclinedPlaneBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class InclinedPlaneBody extends PhysicsBody {
/**
* Physics step constrained to plane
*/
stepAlongPlane(dt, netForceParallel) {
stepAlongPlane(dt, netForceParallel, angleRad = 0) {
if (dt <= 0) return;

// Calculate acceleration from net force
Expand All @@ -36,12 +36,14 @@ export class InclinedPlaneBody extends PhysicsBody {
// Update position along plane
this.planeState.posAlongPlane += this.planeState.velAlongPlane * dt;

// Sync with base state for compatibility
this.state.acceleration.set(this.planeState.accAlongPlane, 0);
this.state.velocity.set(this.planeState.velAlongPlane, 0);
// Sync with base state β€” project scalar plane values onto 2D axes
const v = this.planeState.velAlongPlane;
const a = this.planeState.accAlongPlane;
this.state.velocity.set(v * Math.cos(angleRad), v * Math.sin(angleRad));
this.state.acceleration.set(a * Math.cos(angleRad), a * Math.sin(angleRad));

// Update moving state
this.isMoving = Math.abs(this.planeState.velAlongPlane) > 0.001;
this.isMoving = Math.abs(v) > 0.001;
}

/**
Expand Down
Loading