Different collision shape types for different needs:

Physics V2 provides several shape types via PhysicsShapeType:

  • BOX: Simple box collision - efficient for rectangular objects
  • SPHERE: Spherical collision - most efficient, good for round objects
  • CYLINDER: Cylindrical collision - for tubes, pillars, etc.
  • CAPSULE: Capsule collision - ideal for character controllers
  • MESH: Uses actual mesh geometry - most accurate but computationally expensive
  • HEIGHTFIELD: Efficient for terrain - uses height data for collision
  • CONVEX_HULL: Creates simplified collision from mesh vertices - good balance
  • CONTAINER: For compound shapes with child shapes

For performance, always use the simplest collision shape that adequately represents your object.

// Complex mesh with accurate collision
const complexMesh = BABYLON.MeshBuilder.CreateTorusKnot("tk", {}, scene);
complexMesh.position.y = 10;

// Options for different collision types
// 1. Exact mesh collision (expensive)
new BABYLON.PhysicsAggregate(
    complexMesh, BABYLON.PhysicsShapeType.MESH,
    { mass: 3, restitution: 0.4 }, scene
);

// 2. Convex hull (better performance)
new BABYLON.PhysicsAggregate(
    complexMesh, BABYLON.PhysicsShapeType.CONVEX_HULL,
    { mass: 3, restitution: 0.4 }, scene
);

// 3. Simple approximation (best performance)
new BABYLON.PhysicsAggregate(
    complexMesh, BABYLON.PhysicsShapeType.SPHERE,
    { mass: 3, restitution: 0.4 }, scene
);