Small World Engine API Reference - v0.78.00
    Preparing search index...

    Class RigidBody

    A component that adds Newtonian physics capabilities to an Object3D.

    Index
    • Parameters

      • mass: number = 1.0

        The initial mass. Use 0 for static objects.

      • inertia: number = mass

        The scalar moment of inertia. Defaults to mass.

      Returns RigidBody

    _sleepTimer: number = 0

    Internal timer tracking inactivity duration.

    acceleration: Vector3D = ...

    Current acceleration vector.

    allowSleep: boolean = true

    If false, the body will never be put to sleep automatically.

    angularAcceleration: Vector3D = ...

    Current angular acceleration vector.

    angularDamping: number = 0.98

    Angular damping, simulates rotational air resistance.

    angularVelocity: Vector3D = ...

    Current angular velocity vector.

    forces: Vector3D = ...

    Accumulated forces for the current integration step.

    friction: number = 0.5

    Coulomb contact friction coefficient (0.0 = ice, 1.0 = high grip).

    inertiaTensor: Vector3D = ...

    3D Principal moments of inertia (Ix, Iy, Iz).

    inverseInertiaTensor: Vector3D = ...

    Precalculated inverse principal inertia components (1/Ix, 1/Iy, 1/Iz).

    isSleeping: boolean = false

    Whether the body is currently asleep (skipping integration and broadphase queries).

    isTrigger: boolean = false

    If true, the body detects collisions/triggers but does not physically resolve them.

    linearDamping: number = 1.0

    Linear damping factor for atmospheric drag in free motion (1.0 = no drag).

    prevPosition: Vector3D = ...

    Position at the start of the most recently completed fixed-timestep substep. Together with the object's current (post-substep) position, this lets PhysicsSystem.applyRenderInterpolation blend the rendered transform between the two, decoupling the render framerate from the fixed physics tick instead of snapping to the latest substep every frame.

    prevRotation: Vector3D = ...

    Rotation (Euler, radians) counterpart to prevPosition -- see its doc for details.

    restitution: number = 0.2

    How much velocity is retained after a bounce (0.0 = clay, 1.0 = superball).

    sleepAngularThreshold: number = 0.05

    Angular velocity magnitude threshold below which the body may fall asleep (rad/s).

    sleepLinearThreshold: number = 0.05

    Linear velocity magnitude threshold below which the body may fall asleep (m/s).

    sleepTimeThreshold: number = 0.5

    How long (seconds) velocity must remain below thresholds before entering sleep.

    torque: Vector3D = ...

    Accumulated torque for the current integration step.

    velocity: Vector3D = ...

    Current velocity vector.

    • get inverseInertia(): number

      Precalculated inverse scalar inertia.

      Returns number

    • get inverseMass(): number

      Precalculated inverse mass for performance.

      Returns number

    • get isSensor(): boolean

      Alias for isTrigger for backwards compatibility.

      Returns boolean

    • set isSensor(value: boolean): void

      Parameters

      • value: boolean

      Returns void

    • get mass(): number

      The mass of the object. 0 means static/kinematic (infinite mass).

      Returns number

    • set mass(value: number): void

      Parameters

      • value: number

      Returns void

    • Applies a continuous force at an off-center world-space point, accumulating both linear force and torque.

      Parameters

      • force: Vector3D

        The force vector.

      • worldPoint: Vector3D

        The world-space point where force is applied.

      • centerOfMass: Vector3D

        Center of mass in world space.

      Returns void

    • Applies an instantaneous impulse to the center of mass, directly altering velocity.

      Parameters

      Returns void

    • Applies an instantaneous impulse at an off-center world-space contact point, altering both linear and angular velocity.

      Parameters

      • impulse: Vector3D

        The impulse vector J.

      • worldPoint: Vector3D

        The world-space point where impulse is applied.

      • centerOfMass: Vector3D

        Center of mass in world space (e.g. obj.position or bounds.center).

      Returns void

    • Clears all accumulated forces and torques. Called by the PhysicsSystem after integration.

      Returns void

    • Sets the 3D principal moments of inertia for a cuboid / box of mass m with given dimensions.

      Parameters

      • width: number

        Size along X axis.

      • height: number

        Size along Y axis.

      • depth: number

        Size along Z axis.

      Returns void

    • Sets the principal moments of inertia for a solid cylinder oriented along the Y axis.

      Parameters

      • radius: number

        Cylinder radius in XZ plane.

      • height: number

        Cylinder height along Y axis.

      Returns void

    • Sets the moment of inertia for a solid sphere of mass m and given radius.

      Parameters

      • radius: number

        Sphere radius.

      Returns void