API

Function setPhysicsBodyMass

  • Sets a body's mass, preserving the shape-derived inertia tensor, centre of mass, inertia orientation, and active rotation-axis locks (matching Babylon.js HavokPlugin — only the mass scalar is overridden). A body with no shape attached yet has no inertia tensor to derive, so it falls back to an isotropic inertia proportional to the mass until a shape is set.

    Parameters

    • world: PhysicsWorld

      The physics world.

    • body: PhysicsBody

      The body to update.

    • mass: number

      Mass in kilograms.

    • OptionalcenterOfMass: Vec3

      Optional body-local centre of mass override. When omitted, the shape-derived centre of mass is preserved. Use this when the collision shape is offset from the body's reference frame (e.g. a prop whose body origin sits at its base but whose shape is centred on its middle) so it tumbles around its real centre.

    Returns void