Skip to content

@orillusion/physics


Class: RigidBodyUtil ​

Defined in: packages/physics/utils/RigidBodyUtil.ts:8

Provides a set of methods related to AMMO rigid bodies

Constructors ​

Constructor ​

new RigidBodyUtil(): RigidBodyUtil

Returns ​

RigidBodyUtil

Methods ​

createRigidBody() ​

static createRigidBody(object3D, shape, mass, position?, rotation?): btRigidBody

Defined in: packages/physics/utils/RigidBodyUtil.ts:18

Creates an Ammo rigid body.

Parameters ​

object3D ​

Object3D

The 3D object.

shape ​

btCollisionShape

The collision shape.

mass ​

number

The mass of the collision body.

position? ​

Vector3

Optional parameter, the position of the rigid body; defaults to the 3D object's localPosition.

rotation? ​

Vector3 | Quaternion

Optional parameter, the rotation of the rigid body; defaults to the 3D object's localRotation.

Returns ​

btRigidBody

The newly created Ammo.btRigidBody object.


updateTransform() ​

static updateTransform(bodyRb, position, rotation, clearFV?): void

Defined in: packages/physics/utils/RigidBodyUtil.ts:46

Updates the position and rotation of the rigid body. This function applies the new position and rotation to the rigid body.

Parameters ​

bodyRb ​

btRigidBody

The rigid body object.

position ​

Vector3

The new position of the rigid body, expressed as a Vector3.

rotation ​

Vector3 | Quaternion

The new rotation of the rigid body, optional; can be a Vector3 representing Euler angles (automatically converted to a quaternion); defaults to a zero quaternion.

clearFV? ​

boolean

Whether to clear forces and velocities, optional; defaults to false.

Returns ​

void


updatePosition() ​

static updatePosition(bodyRb, value): void

Defined in: packages/physics/utils/RigidBodyUtil.ts:68

Updates the position of the rigid body

Parameters ​

bodyRb ​

btRigidBody

value ​

Vector3

Returns ​

void


updateRotation() ​

static updateRotation(bodyRb, value): void

Defined in: packages/physics/utils/RigidBodyUtil.ts:84

Updates the rotation of the rigid body

Parameters ​

bodyRb ​

btRigidBody

value ​

Vector3

Returns ​

void


updateScale() ​

static updateScale(bodyRb, value, mass): void

Defined in: packages/physics/utils/RigidBodyUtil.ts:101

Updates the scale of the rigid body

Parameters ​

bodyRb ​

btRigidBody

value ​

Vector3

mass ​

number

Returns ​

void


clearForcesAndVelocities() ​

static clearForcesAndVelocities(bodyRb): void

Defined in: packages/physics/utils/RigidBodyUtil.ts:116

Clears forces and velocities

Parameters ​

bodyRb ​

btRigidBody

Returns ​

void


activateCollisionBodies() ​

static activateCollisionBodies(): void

Defined in: packages/physics/utils/RigidBodyUtil.ts:125

Activates all collision pairs in the physics world

Returns ​

void


destroyRigidBody() ​

static destroyRigidBody(bodyRb): void

Defined in: packages/physics/utils/RigidBodyUtil.ts:149

Destroys the rigid body along with its motion state and collision shape

Parameters ​

bodyRb ​

btRigidBody

Returns ​

void


destroyConstraint() ​

static destroyConstraint(constraint): void

Defined in: packages/physics/utils/RigidBodyUtil.ts:162

Destroys a constraint

Parameters ​

constraint ​

btTypedConstraint

Returns ​

void