Does Ammo.js Support Soft Body Dynamics?

This article explains whether the standard build of ammo.js supports soft body dynamics out of the box. It covers the default capabilities of the library, the specific components required to implement soft bodies, and key performance considerations for web developers using this physics engine.

Yes, the standard build of ammo.js supports soft body dynamics out of the box. Because ammo.js is a direct port of the C++ Bullet Physics engine to JavaScript using Emscripten, it inherits Bullet’s robust soft body simulation capabilities. The default build includes the necessary classes and methods to simulate deformable objects like cloth, ropes, and pressurized soft volumes.

How to Implement Soft Bodies in Ammo.js

While soft body support is included in the standard build, you cannot use the default rigid body setup. To enable soft bodies, you must instantiate a specific physics world and collision configuration.

The standard setup requires the following components:

Creating Soft Bodies

Ammo.js provides a helper class called btSoftBodyHelpers to simplify the creation of soft bodies. Using this helper, you can generate:

These soft bodies require a btSoftBodyWorldInfo object, which compiles global simulation parameters like gravity and air density specifically for the soft body solver.

Potential Pitfalls and Build Considerations

Although the official standard build supports soft bodies, some third-party distributions, minified packages, or custom builds of ammo.js strip these features out to reduce file size.

If you receive errors indicating that btSoftRigidDynamicsWorld or btSoftBodyHelpers is undefined, you are likely using a customized “rigid-body-only” build. To fix this, you must compile ammo.js from the official source repository using the default WebIDL file (ammo.idl), which includes all soft body bindings by default, or download the complete, unpruned standard build.