Skip to main content

Box & Sphere Colliders

This example shows how to create a box, sphere, and plane collider.

this.world.createEntity([
new TMeshComponent({ source: 'inline', geometry: boxMesh.geometry }),
new TMaterialComponent(boxMesh.material),
new TRigidBodyComponent({ mass: 1 }, createBoxCollider(1, 1, 1)),
]);

// A fixed floor uses mass 0.
this.world.createEntity([
new TRigidBodyComponent({ mass: 0 }, createPlaneCollider(10, 10)),
]);