File: AmmoPhysics.md | Updated: 11/15/2025
Can be used to include Ammo.js as a Physics engine into three.js apps. Make sure to include ammo.wasm.js first:
It is then possible to initialize the API via:
const physics = await AmmoPhysics();
<script src="jsm/libs/ammo.wasm.js"></script>
AmmoPhysics is an addon, and must be imported explicitly, see Installation#Addons.
import { AmmoPhysics } from 'three/addons/physics/AmmoPhysics.js';
Adds the given mesh to this physics simulation.
mesh | The mesh to add.
---|---
mass | The mass in kg of the mesh. Default is 0.
Adds the given scene to this physics simulation. Only meshes with a physics object in their Object3D#userData field will be honored. The object can be used to store the mass of the mesh. E.g.:
box.userData.physics = { mass: 1 };
scene | The scene or any type of 3D object to add.
---|---
Set the position of the given mesh which is part of the physics simulation. Calling this method will reset the current simulated velocity of the mesh.
mesh | The mesh to update the position for.
---|---
position | The new position.
index | If the mesh is instanced, the index represents the instanced ID. Default is 0.