Skip to content

@relu-interactives/spatial-ecs


@relu-interactives/spatial-ecs / components / PhysicsComponent

Class: PhysicsComponent

Defined in: components/Physics.ts:350

Unified physics component combining a Rapier rigid body and a Rapier collider into a single authoring and runtime container.

Use values.rigidbody to configure body type, mass, damping, locks, etc. Use values.collider to configure collider shape, size, offset, material properties, and sensor mode.

The runtime rigidBody and collider references are created by the physics system when the project loads and are null until physics is initialized.

Extends

Constructors

Constructor

ts
new PhysicsComponent(values?): PhysicsComponent;

Defined in: components/Physics.ts:358

Parameters

ParameterType
values?{ rigidbody?: Partial<RigidbodyState>; collider?: Partial<ColliderState>; }
values.rigidbody?Partial<RigidbodyState>
values.collider?Partial<ColliderState>

Returns

PhysicsComponent

Overrides

Component.constructor

Properties

PropertyTypeDescriptionDefined in
valuesPhysicsStateAuthoring state. Saved with the project.components/Physics.ts:352
rigidBodyRigidBody | nullLive Rapier rigid body. null until physics is initialized.components/Physics.ts:354
colliderCollider | nullLive Rapier collider. null until physics is initialized.components/Physics.ts:356

Methods

setValues()

ts
setValues(patch): void;

Defined in: components/Physics.ts:369

Patch rigidbody and/or collider state. Each sub-object is deep-merged with the current values via the respective normalizer.

Parameters

ParameterType
patch{ rigidbody?: Partial<RigidbodyState>; collider?: Partial<ColliderState>; }
patch.rigidbody?Partial<RigidbodyState>
patch.collider?Partial<ColliderState>

Returns

void