calculateMomentOfInertia
calculateMomentOfInertia(mass : number, collisionType : number, geometry : THREE.BufferGeometry) : numberCalculate 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
massnumberBody mass (kg)
collisionTypenumberBodyCollisionType enum value
geometryTHREE.BufferGeometryBody 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);