Skip to content

@relu-interactives/spatial-ecs


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

Class: PhysicsComponent ​

Defined in: components/Physics.ts:388

Marker base class for every ECS component. Subclass Component to declare a typed data container that systems can query.

Remarks ​

Components own state only — runtime behaviour belongs in Behaviour subclasses for user scripts. Keep fields plain (numbers, strings, vectors, asset URLs).

Extends ​

Constructors ​

Constructor ​

ts
new PhysicsComponent(values?): PhysicsComponent;

Defined in: components/Physics.ts:412

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:390
pendingVelocity?PendingBodyVelocity | nullVelocity to apply the moment this body becomes dynamic again. Non-enumerable, like the Rapier refs — never serialized.components/Physics.ts:396
remoteBodyType?RigidbodyType | nullThe body's own type while another player simulates it. Multiplayer makes a body someone else owns kinematic here, so it follows their updates instead of falling on its own; this is what it goes back to. Non-enumerable.components/Physics.ts:402
rigidBodyRigidBody | nullLive Rapier rigid body. null until physics is initialized. NON-ENUMERABLE — Rapier wrappers (and, for trimesh, their vertex buffers) must never leak into snapshots/history/debug walks.components/Physics.ts:408
colliderCollider | nullLive Rapier collider. null until physics is initialized. NON-ENUMERABLE.components/Physics.ts:410

Methods ​

setValues() ​

ts
setValues(patch): void;

Defined in: components/Physics.ts:423

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