Ammo.js

~1.9 MB asm.js

Full 3D physics in the browser — soft bodies, vehicles, and everything the Bullet engine can do.


01

See It in Action

Full 3D physics simulation — objects that fall, collide, and tumble with real mass and momentum.

Boxes with real mass fall onto a ground plane, collide, and pile up — basic 3D rigid body physics.

Preview

02

What is Ammo.js?

Ammo.js brings the Bullet physics engine to the browser. Bullet is the same physics engine used in Grand Theft Auto, Red Dead Redemption, and many AAA games — Ammo.js lets you use that same simulation power in a web page.

Unlike simpler physics libraries, Ammo.js supports soft bodies (cloth, ropes, jelly), vehicle physics (cars with suspension and steering), and the full Bullet feature set. The trade-off is size (~1.9 MB) and a verbose, C++-style API.

💪
Full Bullet Physics Engine
The same physics engine behind AAA games, running in your browser. Rigid bodies, soft bodies, vehicles, and more.
🧵
Soft Body & Cloth Simulation
Simulate deformable objects like cloth, ropes, and soft volumes — something most JavaScript physics engines cannot do.
🚗
Vehicle Physics
Built-in vehicle support for realistic car physics with suspension, steering, and wheel friction.

03

When to Use Ammo.js

Use when
Complex 3D physics games with vehicles and ragdolls
Cloth and soft body simulations (flags, curtains, characters)
Destructible environments with breakable objects
Vehicle simulations with realistic suspension and handling
Projects that need feature parity with native Bullet physics
Avoid when
Simple 2D physics — use Matter.js instead, it is much lighter
Quick prototypes — the API is verbose C++-style, Cannon.js or Rapier have friendlier APIs
Projects that need a small bundle — at ~1.9 MB, consider Rapier (~250 KB WASM) for better size

04

How Ammo.js Compares

Ammo.js vs Cannon.js

Ammo.js has far more features (soft body, vehicles, Bullet compatibility) but is harder to learn. Cannon.js is lighter and has a cleaner JavaScript API.

Ammo.js wins at
Soft body, vehicles, cloth, Bullet compatibility, more collision shapes
Cannon.js wins at
Smaller bundle (~45 KB), cleaner API, easier to learn, pure JavaScript
View Full Comparison →
Ammo.js vs Rapier

Rapier is the modern choice — faster, smaller, better API. Ammo.js wins only if you need soft body physics or Bullet-specific features.

Ammo.js wins at
Soft body, cloth, vehicle physics, Bullet ecosystem compatibility
Rapier wins at
Smaller WASM (~250 KB), deterministic, modern API, active development
View Full Comparison →
Ammo.js vs Matter.js

Completely different scope. Ammo.js is for 3D physics, Matter.js is for 2D physics. Choose based on dimension.

Ammo.js wins at
3D physics, soft body, vehicles, much more physics features
Matter.js wins at
2D simplicity, built-in renderer, tiny bundle (~30 KB), easier to learn
View Full Comparison →

05

Get Started with Ammo.js

Terminal
npm install ammo.js
Terminal
yarn add ammo.js
HTML
<script src="https://cdn.jsdelivr.net/gh/kripken/ammo.js@main/builds/ammo.js"></script>
Quick Start
// Ammo.js must be initialized before use
Ammo().then(function(Ammo) {
  // Create physics world
  const collisionConfig = new Ammo.btDefaultCollisionConfiguration();
  const dispatcher = new Ammo.btCollisionDispatcher(collisionConfig);
  const broadphase = new Ammo.btDbvtBroadphase();
  const solver = new Ammo.btSequentialImpulseConstraintSolver();
  const world = new Ammo.btDiscreteDynamicsWorld(
    dispatcher, broadphase, solver, collisionConfig
  );
  world.setGravity(new Ammo.btVector3(0, -9.82, 0));

  // Create a rigid body (box)
  const boxShape = new Ammo.btBoxShape(new Ammo.btVector3(0.5, 0.5, 0.5));
  const transform = new Ammo.btTransform();
  transform.setIdentity();
  transform.setOrigin(new Ammo.btVector3(0, 10, 0));

  const mass = 1;
  const localInertia = new Ammo.btVector3(0, 0, 0);
  boxShape.calculateLocalInertia(mass, localInertia);

  const motionState = new Ammo.btDefaultMotionState(transform);
  const rbInfo = new Ammo.btRigidBodyConstructionInfo(
    mass, motionState, boxShape, localInertia
  );
  const body = new Ammo.btRigidBody(rbInfo);
  world.addRigidBody(body);

  // Step the simulation
  world.stepSimulation(1 / 60, 10);
});

06

Related Libraries