Skip to content

@relu-interactives/spatial-ecs


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

Class: PhysicsComponent ​

Defined in: components/Physics.ts:387

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:405

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:389
pendingVelocity?PendingBodyVelocity | nullVelocity to apply the moment this body becomes dynamic again. Non-enumerable, like the Rapier refs — never serialized.components/Physics.ts:395
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:401
colliderCollider | nullLive Rapier collider. null until physics is initialized. NON-ENUMERABLE.components/Physics.ts:403

Methods ​

setValues() ​

ts
setValues(patch): void;

Defined in: components/Physics.ts:416

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