From 7dafe35599246b04a2c7dd38fb026f01b0e8b048 Mon Sep 17 00:00:00 2001 From: Atharv Aggarwal Date: Thu, 12 Mar 2026 13:44:48 +0530 Subject: [PATCH] Fixed the block sliding beyond ground in inclined plane sim --- simulations/InclinedPlane.jsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/simulations/InclinedPlane.jsx b/simulations/InclinedPlane.jsx index 8d267bf2..dea3a660 100644 --- a/simulations/InclinedPlane.jsx +++ b/simulations/InclinedPlane.jsx @@ -191,6 +191,18 @@ export default function InclinedPlane() { if (bodyRef.current.trail.enabled) { bodyRef.current.updateTrailOnPlane(); } + + const currentDist = bodyRef.current.planeState.posAlongPlane; + const currentScreenY = + planeRef.current.startY - + toPixels(currentDist) * Math.sin(angleRad); + + // the logic that defines 'bottom' + if (currentScreenY >= planeRef.current.startY) { + bodyRef.current.planeState.posAlongPlane = 0; + bodyRef.current.planeState.velAlongPlane = 0; + bodyRef.current.planeState.accAlongPlane = 0; + } } // Render scene