Class RigidBody

A rigid-body.

Hierarchy

  • RigidBody

Constructors

  • Parameters

    • rawSet: RawRigidBodySet
    • colliderSet: ColliderSet
    • handle: number

    Returns RigidBody

Properties

colliderSet: any
handle: number
rawSet: any
userData?: unknown

An arbitrary user-defined object associated with this rigid-body.

Methods

  • Adds a force at the center-of-mass of this rigid-body.

    Parameters

    • force: Vector

      the world-space force to add to the rigid-body.

    • wakeUp: boolean

      should the rigid-body be automatically woken-up?

    Returns void

  • Adds a force at the given world-space point of this rigid-body.

    Parameters

    • force: Vector

      the world-space force to add to the rigid-body.

    • point: Vector

      the world-space point where the impulse is to be applied on the rigid-body.

    • wakeUp: boolean

      should the rigid-body be automatically woken-up?

    Returns void

  • Adds a torque at the center-of-mass of this rigid-body.

    Parameters

    • torque: number

      the torque to add to the rigid-body.

    • wakeUp: boolean

      should the rigid-body be automatically woken-up?

    Returns void

  • The number of additional solver iterations that will be run for this rigid-body and everything that interacts with it directly or indirectly through contacts or joints.

    Returns number

  • The angular damping coefficient of this rigid-body.

    Returns number

  • The angular velocity of this rigid-body.

    Returns number

  • Applies an impulse at the center-of-mass of this rigid-body.

    Parameters

    • impulse: Vector

      the world-space impulse to apply on the rigid-body.

    • wakeUp: boolean

      should the rigid-body be automatically woken-up?

    Returns void

  • Applies an impulse at the given world-space point of this rigid-body.

    Parameters

    • impulse: Vector

      the world-space impulse to apply on the rigid-body.

    • point: Vector

      the world-space point where the impulse is to be applied on the rigid-body.

    • wakeUp: boolean

      should the rigid-body be automatically woken-up?

    Returns void

  • Applies an impulsive torque at the center-of-mass of this rigid-body.

    Parameters

    • torqueImpulse: number

      the torque impulse to apply on the rigid-body.

    • wakeUp: boolean

      should the rigid-body be automatically woken-up?

    Returns void

  • The status of this rigid-body: static, dynamic, or kinematic.

    Returns RigidBodyType

  • Retrieves the i-th collider attached to this rigid-body.

    Parameters

    • i: number

      The index of the collider to retrieve. Must be a number in [0, this.numColliders()[. This index is not the same as the unique identifier of the collider.

    Returns Collider

  • The dominance group, in [-127, +127] this rigid-body is part of.

    Returns number

  • The effective world-space angular inertia (that takes the potential rotation locking into account) of this rigid-body.

    Returns number

  • The inverse mass taking into account translation locking.

    Returns Vector

  • The square-root of the world-space inverse angular inertia tensor of the rigid-body, taking into account rotation locking.

    Returns number

  • Enable or disable CCD (Continuous Collision Detection) for this rigid-body.

    Parameters

    • enabled: boolean

      If true, CCD will be enabled for this rigid-body.

    Returns void

  • Internal

    Parameters

    Returns void

  • The scale factor applied to the gravity affecting this rigid-body.

    Returns number

  • The inverse of the mass of a rigid-body.

    If this is zero, the rigid-body is assumed to have infinite mass.

    Returns number

  • The inverse of the principal angular inertia of the rigid-body.

    Components set to zero are assumed to be infinite along the corresponding principal axis.

    Returns number

  • Is CCD enabled for this rigid-body?

    Returns boolean

  • Is this rigid-body dynamic?

    Returns boolean

  • Is this rigid-body enabled?

    Returns boolean

  • Is this rigid-body static?

    Returns boolean

  • Is this rigid-body kinematic?

    Returns boolean

  • Is the velocity of this rigid-body not zero?

    Returns boolean

  • Is this rigid-body sleeping?

    Returns boolean

  • Checks if this rigid-body is still valid (i.e. that it has not been deleted from the rigid-body set yet.

    Returns boolean

  • The linear damping coefficient of this rigid-body.

    Returns number

  • The linear velocity of this rigid-body.

    Returns Vector

  • The center of mass of a rigid-body expressed in its local-space.

    Returns Vector

  • Locks or unlocks the ability of this rigid-body to rotate.

    Parameters

    • locked: boolean

      If true, this rigid-body will no longer rotate due to torques and impulses.

    • wakeUp: boolean

      If true, this rigid-body will be automatically awaken if it is currently asleep.

    Returns void

  • Locks or unlocks the ability of this rigid-body to translate.

    Parameters

    • locked: boolean

      If true, this rigid-body will no longer translate due to forces and impulses.

    • wakeUp: boolean

      If true, this rigid-body will be automatically awaken if it is currently asleep.

    Returns void

  • The mass of this rigid-body.

    Returns number

  • The world-space next orientation of this rigid-body.

    If this rigid-body is kinematic this value is set by the setNextKinematicRotation method and is used for estimating the kinematic body velocity at the next timestep. For non-kinematic bodies, this value is currently unspecified.

    Returns number

  • The world-space next translation of this rigid-body.

    If this rigid-body is kinematic this value is set by the setNextKinematicTranslation method and is used for estimating the kinematic body velocity at the next timestep. For non-kinematic bodies, this value is currently unspecified.

    Returns Vector

  • The number of colliders attached to this rigid-body.

    Returns number

  • The angular inertia along the principal inertia axes of the rigid-body.

    Returns number

  • Recompute the mass-properties of this rigid-bodies based on its currently attached colliders.

    Returns void

  • Resets to zero the user forces (but not torques) applied to this rigid-body.

    Parameters

    • wakeUp: boolean

      should the rigid-body be automatically woken-up?

    Returns void

  • Resets to zero the user torques applied to this rigid-body.

    Parameters

    • wakeUp: boolean

      should the rigid-body be automatically woken-up?

    Returns void

  • Locks or unlocks the ability of this rigid-body to translation along individual coordinate axes.

    Deprecated

    use this.setEnabledTranslations with the same arguments instead.

    Parameters

    • enableX: boolean

      If false, this rigid-body will no longer rotate due to torques and impulses, along the X coordinate axis.

    • enableY: boolean

      If false, this rigid-body will no longer rotate due to torques and impulses, along the Y coordinate axis.

    • wakeUp: boolean

      If true, this rigid-body will be automatically awaken if it is currently asleep.

    Returns void

  • The world-space orientation of this rigid-body.

    Returns number

  • Sets the rigid-body's additional mass.

    The total angular inertia of the rigid-body will be scaled automatically based on this additional mass. If this scaling effect isn’t desired, use Self::additional_mass_properties instead of this method.

    This is only the "additional" mass because the total mass of the rigid-body is equal to the sum of this additional mass and the mass computed from the colliders (with non-zero densities) attached to this rigid-body.

    That total mass (which includes the attached colliders’ contributions) will be updated at the name physics step, or can be updated manually with this.recomputeMassPropertiesFromColliders.

    This will override any previous additional mass-properties set by this.setAdditionalMass, this.setAdditionalMassProperties, RigidBodyDesc::setAdditionalMass, or RigidBodyDesc.setAdditionalMassfProperties for this rigid-body.

    Parameters

    • mass: number

      The additional mass to set.

    • wakeUp: boolean

      If true then the rigid-body will be woken up if it was put to sleep because it did not move for a while.

    Returns void

  • Sets the rigid-body's additional mass-properties.

    This is only the "additional" mass-properties because the total mass-properties of the rigid-body is equal to the sum of this additional mass-properties and the mass computed from the colliders (with non-zero densities) attached to this rigid-body.

    That total mass-properties (which include the attached colliders’ contributions) will be updated at the name physics step, or can be updated manually with this.recomputeMassPropertiesFromColliders.

    This will override any previous mass-properties set by this.setAdditionalMass, this.setAdditionalMassProperties, RigidBodyDesc.setAdditionalMass, or RigidBodyDesc.setAdditionalMassProperties for this rigid-body.

    If wake_up is true then the rigid-body will be woken up if it was put to sleep because it did not move for a while.

    Parameters

    • mass: number
    • centerOfMass: Vector
    • principalAngularInertia: number
    • wakeUp: boolean

    Returns void

  • Sets the number of additional solver iterations that will be run for this rigid-body and everything that interacts with it directly or indirectly through contacts or joints.

    Compared to increasing the global World.numSolverIteration, setting this value lets you increase accuracy on only a subset of the scene, resulting in reduced performance loss.

    Parameters

    • iters: number

      The new number of additional solver iterations (default: 0).

    Returns void

  • Sets the linear damping factor applied to this rigid-body.

    Parameters

    • factor: number

      The damping factor to set.

    Returns void

  • Sets the angular velocity fo this rigid-body.

    Parameters

    • vel: number

      The angular velocity to set.

    • wakeUp: boolean

      Forces the rigid-body to wake-up if it was asleep.

    Returns void

  • Set a new status for this rigid-body: static, dynamic, or kinematic.

    Parameters

    Returns void

  • Sets the dominance group of this rigid-body.

    Parameters

    • group: number

      The dominance group of this rigid-body. Must be a signed integer in the range [-127, +127].

    Returns void

  • Sets whether this rigid-body is enabled or not.

    Parameters

    • enabled: boolean

      Set to false to disable this rigid-body and all its attached colliders.

    Returns void

  • Locks or unlocks the ability of this rigid-body to translation along individual coordinate axes.

    Parameters

    • enableX: boolean

      If false, this rigid-body will no longer rotate due to torques and impulses, along the X coordinate axis.

    • enableY: boolean

      If false, this rigid-body will no longer rotate due to torques and impulses, along the Y coordinate axis.

    • wakeUp: boolean

      If true, this rigid-body will be automatically awaken if it is currently asleep.

    Returns void

  • Sets the scale factor applied to the gravity affecting this rigid-body.

    Parameters

    • factor: number

      The scale factor to set. A value of 0.0 means that this rigid-body will on longer be affected by gravity.

    • wakeUp: boolean

      Forces the rigid-body to wake-up if it was asleep.

    Returns void

  • Sets the linear damping factor applied to this rigid-body.

    Parameters

    • factor: number

      The damping factor to set.

    Returns void

  • Sets the linear velocity of this rigid-body.

    Parameters

    • vel: Vector

      The linear velocity to set.

    • wakeUp: boolean

      Forces the rigid-body to wake-up if it was asleep.

    Returns void

  • If this rigid body is kinematic, sets its future rotation after the next timestep integration.

    This should be used instead of rigidBody.setRotation to make the dynamic object interacting with this kinematic body behave as expected. Internally, Rapier will compute an artificial velocity for this rigid-body from its current position and its next kinematic position. This velocity will be used to compute forces on dynamic bodies interacting with this body.

    Parameters

    • angle: number

      The kinematic rotation angle, in radians.

    Returns void

  • If this rigid body is kinematic, sets its future translation after the next timestep integration.

    This should be used instead of rigidBody.setTranslation to make the dynamic object interacting with this kinematic body behave as expected. Internally, Rapier will compute an artificial velocity for this rigid-body from its current position and its next kinematic position. This velocity will be used to compute forces on dynamic bodies interacting with this body.

    Parameters

    • t: Vector

      The kinematic translation to set.

    Returns void

  • Sets the rotation angle of this rigid-body.

    Parameters

    • angle: number

      The rotation angle, in radians.

    • wakeUp: boolean

      Forces the rigid-body to wake-up so it is properly affected by forces if it wasn't moving before modifying its position.

    Returns void

  • Sets the soft-CCD prediction distance for this rigid-body.

    See the documentation of RigidBodyDesc.setSoftCcdPrediction for additional details.

    Parameters

    • distance: number

    Returns void

  • Sets the translation of this rigid-body.

    Parameters

    • tra: Vector

      The world-space position of the rigid-body.

    • wakeUp: boolean

      Forces the rigid-body to wake-up so it is properly affected by forces if it wasn't moving before modifying its position.

    Returns void

  • Put this rigid body to sleep.

    A sleeping body no longer moves and is no longer simulated by the physics engine unless it is waken up. It can be woken manually with this.wakeUp() or automatically due to external forces like contacts.

    Returns void

  • Gets the soft-CCD prediction distance for this rigid-body.

    See the documentation of RigidBodyDesc.setSoftCcdPrediction for additional details.

    Returns number

  • The world-space translation of this rigid-body.

    Returns Vector

  • Wakes this rigid-body up.

    A dynamic rigid-body that does not move during several consecutive frames will be put to sleep by the physics engine, i.e., it will stop being simulated in order to avoid useless computations. This methods forces a sleeping rigid-body to wake-up. This is useful, e.g., before modifying the position of a dynamic body so that it is properly simulated afterwards.

    Returns void

  • The world-space center of mass of the rigid-body.

    Returns Vector

Generated using TypeDoc