eulerjs API / @eulerjs/core / JavaScriptBackend
JavaScriptBackend
Defined in: packages/core/src/javascript/JavaScriptBackend.ts:35
The built-in backend, in plain JavaScript: semi-implicit Euler integration with an exact gyroscopic term, and joints and contacts solved over substeps substeps per step, by extended position-based dynamics (XPBD) or by soft step (see JavaScriptBackendOptions).
Implements
Constructors
Constructor
new JavaScriptBackend(options?): JavaScriptBackend;Defined in: packages/core/src/javascript/JavaScriptBackend.ts:66
Parameters
| Parameter | Type |
|---|---|
options? | JavaScriptBackendOptions |
Returns
JavaScriptBackend
Properties
| Property | Modifier | Type | Default value | Defined in |
|---|---|---|---|---|
name | readonly | "javascript" | 'javascript' | packages/core/src/javascript/JavaScriptBackend.ts:36 |
Accessors
contacts
Get Signature
get contacts(): readonly Contact[];Defined in: packages/core/src/javascript/JavaScriptBackend.ts:70
The contacts that pushed during the last step, one for each touching point.
Returns
readonly Contact[]
The contacts that pushed during the last step, one for each touching point.
Implementation of
sensorOverlaps
Get Signature
get sensorOverlaps(): readonly SensorOverlap[];Defined in: packages/core/src/javascript/JavaScriptBackend.ts:74
Each pair of colliders, one or both a sensor, that overlapped during the last step, among bodies at least one of which was awake.
Returns
readonly SensorOverlap[]
Each pair of colliders, one or both a sensor, that overlapped during the last step, among bodies at least one of which was awake.
Implementation of
Methods
addBody()
addBody(body): void;Defined in: packages/core/src/javascript/JavaScriptBackend.ts:78
Parameters
| Parameter | Type |
|---|---|
body | Body |
Returns
void
Implementation of
addJoint()
addJoint(joint): void;Defined in: packages/core/src/javascript/JavaScriptBackend.ts:117
Throws an EulerError for a kind of joint the backend can't simulate.
Parameters
| Parameter | Type |
|---|---|
joint | Joint |
Returns
void
Implementation of
applyLoads()
applyLoads(
body,
force,
torque
): void;Defined in: packages/core/src/javascript/JavaScriptBackend.ts:187
Adds a force through the centre of mass and a torque about it, both in world space, to the next step only.
Parameters
| Parameter | Type |
|---|---|
body | Body |
force | Vector3 |
torque | Vector3 |
Returns
void
Implementation of
castRay()
castRay(
origin,
direction,
maxDistance,
filter,
all
): QueryHit[];Defined in: packages/core/src/javascript/JavaScriptBackend.ts:203
Every collider a ray from origin along the unit direction meets within maxDistance, with where it first meets it, nearest first; only the nearest unless all. Uses the bodies as the backend last had them: the world writes poses you changed before asking.
Parameters
| Parameter | Type |
|---|---|
origin | Vector3 |
direction | Vector3 |
maxDistance | number |
filter | QueryFilter |
all | boolean |
Returns
QueryHit[]
Implementation of
castShape()
castShape(
shape,
position,
quaternion,
direction,
maxDistance,
filter
): QueryHit | undefined;Defined in: packages/core/src/javascript/JavaScriptBackend.ts:207
Where shape, at position turned by quaternion and swept along the unit direction, first touches a collider within maxDistance.
Parameters
| Parameter | Type |
|---|---|
shape | Collider |
position | Vector3 |
quaternion | Quaternion |
direction | Vector3 |
maxDistance | number |
filter | QueryFilter |
Returns
QueryHit | undefined
Implementation of
dispose()
dispose(): void;Defined in: packages/core/src/javascript/JavaScriptBackend.ts:251
Frees whatever the backend holds; called by world.dispose().
Returns
void
Implementation of
isSleeping()
isSleeping(body): boolean;Defined in: packages/core/src/javascript/JavaScriptBackend.ts:215
Parameters
| Parameter | Type |
|---|---|
body | Body |
Returns
boolean
Implementation of
overlap()
overlap(
shape,
position,
quaternion,
filter
): OverlapHit[];Defined in: packages/core/src/javascript/JavaScriptBackend.ts:211
Every collider that shape, at position turned by quaternion, overlaps or touches.
Parameters
| Parameter | Type |
|---|---|
shape | Collider |
position | Vector3 |
quaternion | Quaternion |
filter | QueryFilter |
Returns
Implementation of
readMotion()
readMotion(body, target): void;Defined in: packages/core/src/javascript/JavaScriptBackend.ts:195
Writes the backend's pose and velocities for the body into target.
Parameters
| Parameter | Type |
|---|---|
body | Body |
target | BodyMotion |
Returns
void
Implementation of
removeBody()
removeBody(body): void;Defined in: packages/core/src/javascript/JavaScriptBackend.ts:98
Parameters
| Parameter | Type |
|---|---|
body | Body |
Returns
void
Implementation of
removeJoint()
removeJoint(joint): void;Defined in: packages/core/src/javascript/JavaScriptBackend.ts:135
Parameters
| Parameter | Type |
|---|---|
joint | Joint |
Returns
void
Implementation of
setCollisionsBetween()
setCollisionsBetween(
bodyA,
bodyB,
enabled
): void;Defined in: packages/core/src/javascript/JavaScriptBackend.ts:152
Stops two bodies colliding with each other, or lets them again. The world calls it at most once each way per pair, and with enabled true for every pair it disabled before either body is removed. Joints with collideConnected false keep their bodies apart on their own.
Parameters
| Parameter | Type |
|---|---|
bodyA | Body |
bodyB | Body |
enabled | boolean |
Returns
void
Implementation of
PhysicsBackend.setCollisionsBetween
sleep()
sleep(body): void;Defined in: packages/core/src/javascript/JavaScriptBackend.ts:182
Puts the body to sleep now, stopping it.
Parameters
| Parameter | Type |
|---|---|
body | Body |
Returns
void
Implementation of
step()
step(settings): void;Defined in: packages/core/src/javascript/JavaScriptBackend.ts:219
Parameters
| Parameter | Type |
|---|---|
settings | StepSettings |
Returns
void
Implementation of
updateBody()
updateBody(body): void;Defined in: packages/core/src/javascript/JavaScriptBackend.ts:109
The body's mass properties or list of colliders changed.
Parameters
| Parameter | Type |
|---|---|
body | Body |
Returns
void
Implementation of
wakeUp()
wakeUp(body): void;Defined in: packages/core/src/javascript/JavaScriptBackend.ts:178
Wakes the body and restarts its sleep timer, even if it is already awake.
Parameters
| Parameter | Type |
|---|---|
body | Body |
Returns
void
Implementation of
writePose()
writePose(body): void;Defined in: packages/core/src/javascript/JavaScriptBackend.ts:164
Moves the backend's copy of the body to the body's position and quaternion.
Parameters
| Parameter | Type |
|---|---|
body | Body |
Returns
void
Implementation of
writeVelocity()
writeVelocity(body): void;Defined in: packages/core/src/javascript/JavaScriptBackend.ts:174
Sets the backend's copy of the body's velocity and angular velocity to the body's.
Parameters
| Parameter | Type |
|---|---|
body | Body |
Returns
void
