Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RigidBody

A rigid-body. A rigid-body.

Hierarchy

  • RigidBody

Index

Constructors

constructor

Properties

Readonly handle

Private rawSet

rawSet: any

Methods

angularDamping

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

    Returns number

  • The angular damping coefficient of this rigid-body.

    Returns number

angvel

  • The angular velocity of this rigid-body.

    Returns Vector

  • The angular velocity of this rigid-body.

    Returns Vector

applyForce

  • applyForce(force: Vector, wakeUp: boolean): void
  • applyForce(force: Vector, wakeUp: boolean): void
  • Applies a force at the center-of-mass of this rigid-body.

    Parameters

    • force: Vector

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

    • wakeUp: boolean

      should the rigid-body be automatically woken-up?

    Returns void

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

    Parameters

    • force: Vector

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

    • wakeUp: boolean

      should the rigid-body be automatically woken-up?

    Returns void

applyForceAtPoint

  • applyForceAtPoint(force: Vector, point: Vector, wakeUp: boolean): void
  • applyForceAtPoint(force: Vector, point: Vector, wakeUp: boolean): void
  • Applies a force at the given world-space point of this rigid-body.

    Parameters

    • force: Vector

      the world-space force 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 a force at the given world-space point of this rigid-body.

    Parameters

    • force: Vector

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

applyImpulse

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

  • 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

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

  • 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

applyTorque

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

    Parameters

    • torque: Vector

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

    • wakeUp: boolean

      should the rigid-body be automatically woken-up?

    Returns void

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

    Parameters

    • torque: Vector

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

    • wakeUp: boolean

      should the rigid-body be automatically woken-up?

    Returns void

applyTorqueImpulse

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

  • 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

bodyType

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

    Returns RigidBodyType

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

    Returns RigidBodyType

collider

  • Retrieves the handle of 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 ColliderHandle

  • Retrieves the handle of 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 ColliderHandle

dominanceGroup

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

    Returns number

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

    Returns number

enableCcd

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

  • 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

gravityScale

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

    Returns number

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

    Returns number

isCcdEnabled

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

    Returns void

  • Is CCD enabled for this rigid-body?

    Returns void

isDynamic

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

    Returns boolean

  • Is this rigid-body dynamic?

    Returns boolean

isKinematic

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

    Returns boolean

  • Is this rigid-body kinematic?

    Returns boolean

isMoving

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

    Returns boolean

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

    Returns boolean

isSleeping

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

    Returns boolean

  • Is this rigid-body sleeping?

    Returns boolean

isStatic

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

    Returns boolean

  • Is this rigid-body static?

    Returns boolean

isValid

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

  • 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

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

    Returns number

  • The linear damping coefficient of this rigid-body.

    Returns number

linvel

  • The linear velocity of this rigid-body.

    Returns Vector

  • The linear velocity of this rigid-body.

    Returns Vector

lockRotations

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

  • 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

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

  • 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

  • mass(): number
  • mass(): number
  • The mass of this rigid-body.

    Returns number

  • The mass of this rigid-body.

    Returns number

nextRotation

  • 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 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

nextTranslation

  • 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 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

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

    Returns number

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

    Returns number

restrictRotations

  • restrictRotations(enableX: boolean, enableY: boolean, enableZ: boolean, wakeUp: boolean): 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.

    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

  • 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

rotation

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

    Returns Rotation

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

    Returns Rotation

setAngularDamping

  • setAngularDamping(factor: number): 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

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

    Parameters

    • factor: number

      The damping factor to set.

    Returns void

setAngvel

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

  • 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

setDominanceGroup

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

  • 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

setGravityScale

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

  • 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

  • setLinearDamping(factor: number): 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

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

    Parameters

    • factor: number

      The damping factor to set.

    Returns void

setLinvel

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

  • 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

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

  • 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

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

  • 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

  • setRotation(rot: Rotation, wakeUp: boolean): 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

  • 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

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

  • 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

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

  • 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

translation

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

    Returns Vector

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

    Returns Vector

wakeUp

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

  • 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