Capítulo 517 de 859

Chapter 517: AmmoPhysics

Core Idea

Can be used to include Ammo.js as a Physics engine into three.js apps. The API can be initialized via:

The component automatically imports Ammo.js from a CDN so make sure to use the component with an active Internet connection.

Code Examples

const physics = await AmmoPhysics();
  • What it demonstrates: Typical usage of AmmoPhysics.

Reference Tables

Methods

MethodDescription
.addMesh( mesh : Mesh, mass : number, restitution : number )Adds the given mesh to this physics simulation.
.addScene( scene : Object3D )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 ma…
.setMeshPosition( mesh : Mesh, position : Vector3, index : number )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.

Key Takeaways

  1. Key methods: addMesh, addScene, setMeshPosition.

Connects To