Difference Between Rolling and Sliding Friction in Ammo.js
In ammo.js—the JavaScript port of the Bullet physics engine—simulating realistic physical interactions requires a clear understanding of how different forces oppose motion. This article explains the practical and mathematical differences between standard sliding friction and rolling friction, detailing how they affect rigid body simulations and how to configure them in your projects.
Standard Sliding Friction
Standard sliding friction (often referred to simply as “friction” in ammo.js) resists the relative lateral motion of two solid surfaces in contact. When a rigid body slides across a flat plane, sliding friction applies a force at the contact point in the direction opposite to the sliding movement.
In ammo.js, you configure this using the setFriction
method on a rigid body:
rigidBody.setFriction(0.5);This value typically ranges from 0.0 (completely
frictionless, like ice) to 1.0 or higher (very rough
surfaces). Sliding friction is essential for preventing objects from
sliding infinitely across surfaces when a force is applied.
Rolling Friction
Rolling friction resists the rotational motion of a round object—such as a sphere, cylinder, or wheel—as it rolls across a surface.
In a pure mathematical physics simulation, a perfect sphere contacting a perfectly flat ground has an infinitely small contact point. Because of this, standard sliding friction cannot generate enough torque to stop the sphere from rolling; without a counter-torque, a rolling ball in a physics engine would roll forever. Rolling friction solves this by applying an artificial torque that opposes the angular velocity of the rolling object.
In ammo.js, you configure this using the
setRollingFriction method:
rigidBody.setRollingFriction(0.1);Without setting a rolling friction value greater than zero, spherical objects in your ammo.js scene will never come to a stop on a flat surface, even if standard friction is set to a high value.
Key Differences Summary
- Type of Motion Resisted: Sliding friction resists linear translation along a contact surface. Rolling friction resists the angular rotation of an object rolling over a surface.
- Mechanism of Action: Sliding friction applies a force at the contact point opposite to the direction of slide. Rolling friction applies a resistive torque opposite to the object’s angular velocity.
- Primary Use Case: Sliding friction is used for box-like shapes, flat surfaces, and general slide resistance. Rolling friction is specifically required for spheres, cylinders, capsules, and wheels to prevent them from rolling indefinitely.