Options
All
  • Public
  • Public/Protected
  • All
Menu

A rigid-body.

Hierarchy

  • RigidBody

Index

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

  • addForce(force: Vector, wakeUp: boolean): void
  • 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

  • addForceAtPoint(force: Vector, point: Vector, wakeUp: boolean): 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

  • addTorque(torque: Vector, wakeUp: boolean): void
  • Adds a torque at the center-of-mass of this rigid-body.

    Parameters

    • torque: Vector

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

    • wakeUp: boolean

      should the rigid-body be automatically woken-up?

    Returns void

  • angularDamping(): number
  • The angular damping coefficient of this rigid-body.

    Returns number

  • The angular velocity of this rigid-body.

    Returns Vector

  • applyImpulse(impulse: Vector, wakeUp: boolean): void
  • 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

  • applyImpulseAtPoint(impulse: Vector, point: Vector, wakeUp: boolean): 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

  • applyTorqueImpulse(torqueImpulse: Vector, wakeUp: boolean): void
  • Applies an impulsive torque at the center-of-mass of this rigid-body.

    Parameters

    • torqueImpulse: Vector

      the world-space 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

  • dominanceGroup(): number
  • The dominance group, in [-127, +127] this rigid-body is part of.

    Returns number

  • enableCcd(enabled: boolean): void
  • 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

  • finalizeDeserialization(colliderSet: ColliderSet): void
  • internal

    Parameters

    Returns void

  • gravityScale(): number
  • The scale factor applied to the gravity affecting this rigid-body.

    Returns number

  • isCcdEnabled(): boolean
  • Is CCD enabled for this rigid-body?

    Returns boolean

  • isDynamic(): boolean
  • Is this rigid-body dynamic?

    Returns boolean

  • isFixed(): boolean
  • Is this rigid-body static?

    Returns boolean

  • isKinematic(): boolean
  • Is this rigid-body kinematic?

    Returns boolean

  • isMoving(): boolean
  • Is the velocity of this rigid-body not zero?

    Returns boolean

  • isSleeping(): boolean
  • Is this rigid-body sleeping?

    Returns boolean

  • isValid(): 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

  • linearDamping(): number
  • The linear damping coefficient of this rigid-body.

    Returns number

  • The linear velocity of this rigid-body.

    Returns Vector

  • lockRotations(locked: boolean, wakeUp: boolean): void
  • 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

  • lockTranslations(locked: boolean, wakeUp: boolean): 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

  • mass(): number
  • 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 Rotation

  • 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

  • numColliders(): number
  • The number of colliders attached to this rigid-body.

    Returns number

  • recomputeMassPropertiesFromColliders(): void
  • Recompute the mass-properties of this rigid-bodies based on its currently attached colliders.

    Returns void

  • resetForces(wakeUp: boolean): 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

  • resetTorques(wakeUp: boolean): 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

  • restrictRotations(enableX: boolean, enableY: boolean, enableZ: boolean, wakeUp: boolean): void
  • Locks or unlocks the ability of this rigid-body to rotate along individual coordinate axes.

    deprecated

    use this.setEnabledRotations 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.

    • enableZ: boolean

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

    • wakeUp: boolean

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

    Returns void

  • restrictTranslations(enableX: boolean, enableY: boolean, enableZ: boolean, wakeUp: boolean): void
  • Locks or unlocks the ability of this rigid-body to translate along individual coordinate axes.

    deprecated

    use this.setEnabledTranslations with the same arguments instead.

    Parameters

    • enableX: boolean

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

    • enableY: boolean

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

    • enableZ: boolean

      If false, this rigid-body will no longer translate due to torques and impulses, along the Z 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 Rotation

  • setAdditionalMass(mass: number, wakeUp: boolean): void
  • 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

  • setAdditionalMassProperties(mass: number, centerOfMass: Vector, principalAngularInertia: Vector, angularInertiaLocalFrame: Rotation, wakeUp: boolean): 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: Vector
    • angularInertiaLocalFrame: Rotation
    • wakeUp: boolean

    Returns void

  • setAngularDamping(factor: number): void
  • Sets the linear damping factor applied to this rigid-body.

    Parameters

    • factor: number

      The damping factor to set.

    Returns void

  • setAngvel(vel: Vector, wakeUp: boolean): void
  • Sets the angular velocity fo this rigid-body.

    Parameters

    • vel: Vector

      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

  • setDominanceGroup(group: number): 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

  • setEnabledRotations(enableX: boolean, enableY: boolean, enableZ: boolean, wakeUp: boolean): void
  • Locks or unlocks the ability of this rigid-body to rotate 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.

    • enableZ: boolean

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

    • wakeUp: boolean

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

    Returns void

  • setEnabledTranslations(enableX: boolean, enableY: boolean, enableZ: boolean, wakeUp: boolean): void
  • Locks or unlocks the ability of this rigid-body to translate along individual coordinate axes.

    Parameters

    • enableX: boolean

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

    • enableY: boolean

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

    • enableZ: boolean

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

    • wakeUp: boolean

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

    Returns void

  • setGravityScale(factor: number, wakeUp: boolean): 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

  • setLinearDamping(factor: number): void
  • Sets the linear damping factor applied to this rigid-body.

    Parameters

    • factor: number

      The damping factor to set.

    Returns void

  • setLinvel(vel: Vector, wakeUp: boolean): void
  • Sets the linear velocity fo 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

  • setNextKinematicRotation(rot: Rotation): 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

    • rot: Rotation

      The kinematic rotation to set.

    Returns void

  • setNextKinematicTranslation(t: Vector): 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

  • setRotation(rot: Rotation, wakeUp: boolean): void
  • Sets the rotation quaternion of this rigid-body.

    This does nothing if a zero quaternion is provided.

    Parameters

    • rot: Rotation
    • 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

  • setTranslation(tra: Vector, wakeUp: boolean): 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

  • sleep(): 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

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

    Returns Vector

  • wakeUp(): void
  • 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

Generated using TypeDoc