calculateMomentOfInertia

@three-blocks/pro
calculateMomentOfInertia(mass : number, collisionType : number, geometry : THREE.BufferGeometry) : number

Calculate moment of inertia based on mass and collision shape.

Uses simplified scalar approximation (average of principal moments) for performance. Formulas:

  • Sphere: I = 0.4 × m × r²
  • Capsule/Cylinder: I = (1/12) × m × (3r² + h²)
  • Box: I = (1/12) × m × (w² + h² + d²) / 3
Parameters
massnumber
Body mass (kg)
collisionTypenumber
BodyCollisionType enum value
geometryTHREE.BufferGeometry
Body geometry (for bounds)
Returns
number — Scalar moment of inertia (kg·m²)
Example
import { calculateMomentOfInertia, BodyCollisionType } from '@three-blocks/pro';

const inertia = calculateMomentOfInertia(1.0, BodyCollisionType.SPHERE, sphereGeometry);
console.log('Inertia:', inertia);