Skip to main content

Class: RigidBody

Defined in: physics/rigid-body.ts:68

A rigid body participating in a PhysicsWorld simulation. Stores the body's shape, transform, motion state, and mass properties.

Constructors

Constructor

new RigidBody(options): RigidBody

Defined in: physics/rigid-body.ts:109

Creates a new RigidBody instance.

Parameters

options

RigidBodyOptions

The options for the body.

Returns

RigidBody

Properties

angle

angle: number

Defined in: physics/rigid-body.ts:71


angularVelocity

angularVelocity: number

Defined in: physics/rigid-body.ts:75


friction

readonly friction: number

Defined in: physics/rigid-body.ts:95


id

readonly id: number

Defined in: physics/rigid-body.ts:77


inertia

readonly inertia: number

Defined in: physics/rigid-body.ts:89


inverseInertia

readonly inverseInertia: number

Defined in: physics/rigid-body.ts:91


inverseMass

readonly inverseMass: number

Defined in: physics/rigid-body.ts:87


isSensor

readonly isSensor: boolean

Defined in: physics/rigid-body.ts:83


isStatic

readonly isStatic: boolean

Defined in: physics/rigid-body.ts:81


mass

readonly mass: number

Defined in: physics/rigid-body.ts:85


position

position: Vector2

Defined in: physics/rigid-body.ts:69


restitution

readonly restitution: number

Defined in: physics/rigid-body.ts:93


shape

readonly shape: Shape

Defined in: physics/rigid-body.ts:79


userData?

optional userData: unknown

Defined in: physics/rigid-body.ts:101

Arbitrary data associated with this body by the consumer (e.g. an ECS entity id). Not read or written by the physics simulation itself.


velocity

velocity: Vector2

Defined in: physics/rigid-body.ts:73

Accessors

aabb

Get Signature

get aabb(): Rect

Defined in: physics/rigid-body.ts:156

The conservative axis-aligned bounding box of the body, used for broad-phase collision detection.

Returns

Rect

Methods

applyImpulse()

applyImpulse(impulse, contactPoint): void

Defined in: physics/rigid-body.ts:172

Applies a linear and angular impulse to the body at a world-space contact point relative to its center of mass.

Parameters

impulse

Vector2

The impulse to apply.

contactPoint

Vector2

The point at which to apply the impulse, relative to the body's center of mass.

Returns

void