Class: RigidBody
Defined in: physics/rigid-body.ts:78
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:129
Creates a new RigidBody instance.
Parameters
options
The options for the body.
Returns
RigidBody
Properties
angle
angle:
number
Defined in: physics/rigid-body.ts:81
angularDrag
readonlyangularDrag:number
Defined in: physics/rigid-body.ts:107
angularVelocity
angularVelocity:
number
Defined in: physics/rigid-body.ts:85
friction
readonlyfriction:number
Defined in: physics/rigid-body.ts:105
id
readonlyid:number
Defined in: physics/rigid-body.ts:87
inertia
readonlyinertia:number
Defined in: physics/rigid-body.ts:99
inverseInertia
readonlyinverseInertia:number
Defined in: physics/rigid-body.ts:101
inverseMass
readonlyinverseMass:number
Defined in: physics/rigid-body.ts:97
isSensor
readonlyisSensor:boolean
Defined in: physics/rigid-body.ts:93
isStatic
readonlyisStatic:boolean
Defined in: physics/rigid-body.ts:91
mass
readonlymass:number
Defined in: physics/rigid-body.ts:95
position
position:
Vector2
Defined in: physics/rigid-body.ts:79
restitution
readonlyrestitution:number
Defined in: physics/rigid-body.ts:103
shape
readonlyshape:Shape
Defined in: physics/rigid-body.ts:89
userData?
optionaluserData?:unknown
Defined in: physics/rigid-body.ts:113
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:83
Accessors
aabb
Get Signature
get aabb():
Rect
Defined in: physics/rigid-body.ts:179
The conservative axis-aligned bounding box of the body, used for broad-phase collision detection.
Returns
Methods
applyImpulse()
applyImpulse(
impulse,contactPoint):void
Defined in: physics/rigid-body.ts:204
Applies a linear and angular impulse to the body at a world-space contact point relative to its center of mass.
Parameters
impulse
The impulse to apply.
contactPoint
The point at which to apply the impulse, relative to the body's center of mass.
Returns
void
applyTorque()
applyTorque(
torque,deltaTimeInSeconds):void
Defined in: physics/rigid-body.ts:220
Applies a torque to the body, changing its angular velocity by
torque * inverseInertia * deltaTimeInSeconds. Unlike
applyImpulse, which is an instantaneous change, this represents
a torque acting continuously over deltaTimeInSeconds, so it must be
called every step to sustain a continuous spin (the same way gravity
is integrated). Has no effect on static bodies, whose inverseInertia
is always zero.
Parameters
torque
number
The torque to apply, in N·m.
deltaTimeInSeconds
number
The duration the torque acts over.
Returns
void