Controlling Soft Body Stiffness in Ammo.js

This article provides an overview of the key mathematical parameters and configuration settings used in ammo.js (the JavaScript port of the Bullet physics engine) to control the deformation, stiffness, and structural integrity of soft bodies. By understanding these parameters, developers can realistically simulate diverse materials ranging from highly elastic gelatin to rigid cloth.

Core Material Coefficients

In ammo.js, soft body physical properties are primarily governed by the btSoftBody::Material structure. Three main stiffness coefficients dictate how the simulation responds to different types of stress:

Solver Iterations

The perceived stiffness of a soft body is heavily influenced by the constraint solver configuration. Even with stiffness coefficients set to 1.0, a low number of solver iterations will make the body behave like jelly due to numerical drift.

The structural integrity of a soft body is also determined by how its vertices (nodes) are interconnected. When creating a soft body helper, developers can generate different types of links:

Aerodynamics and Pressure Parameters

For specialized soft bodies, like balloons or sails, gas dynamics and external forces play a critical role in structural integrity: