Skip to content

3D Physics

A 3D model can be imported, animated, skinned and lit. This is what makes it stand somewhere: a rigid-body world powered by Jolt Physics or, if the project chooses, PhysX, running in its own WebAssembly module.

It sits beside the 2D physics, not on top of it. A 2D scene keeps the solver, the units and the feel it already has, and a project that never asks for a 3D world never loads it.

Like the 2D side module, the 3D world loads on its own in the editor and the web runtime when a scene uses a 3D body. In a custom app, add the plugin yourself; every option is optional (gravity defaults to { x: 0, y: -9.81, z: 0 }, fixedTimestep to 1/60, collisionSteps to 1, pixelsPerUnit to 100, maxBodies to 1024; layerMasks is covered under collision layers):

import { Physics3DPlugin } from 'esengine/physics3d';
app.addPlugin(new Physics3DPlugin('physics3d.js', { gravity: { x: 0, y: -9.81, z: 0 } }));

The 3D world runs on Jolt by default. Project Settings → Physics → 3D solver switches it to PhysX, the solver Unity runs, for a project that should behave like its Unity original. In the manifest:

"features": { "physics": { "backend3d": "physx" } }

Nothing else changes. Both backends answer the same components, joints, characters, queries and collision events, and the same 98-behaviour smoke runs against each (node tools/check-physics3d.mjs, node tools/check-physics3d-physx.mjs). A build ships only the module it chose: physics3d.wasm for Jolt, physics3d-physx.wasm for PhysX. Editor Play uses the same choice.

PhysX is set up with Unity’s defaults: projected Gauss-Seidel, patch friction, Average friction and bounce combine, a 0.01 m contact offset, a 2 m/s bounce threshold, a 0.005 sleep threshold, 6 position and 1 velocity iterations, and a 50 rad/s maximum angular speed. Where the two engines differ, PhysX follows Unity:

  • A trigger reports a character entering it, as OnTriggerEnter does for a CharacterController. A Jolt character is not a body, so a Jolt sensor never sees one.
  • A body that falls asleep inside a trigger is still inside it. Jolt reports an exit when the body sleeps.
  • A character keeps a skin of a tenth of its radius (Unity’s recommended skin width), so it stands that much higher than a Jolt character.
  • A character climbs onto a dynamic body no taller than its step height. A taller one is pushed, with no more force than its push strength.

What it costs: the PhysX web module is 3.5 MB (1.14 MB gzipped), against Jolt’s 1.3 MB, and it loads only in a project that chose it. A chaotic scene (a ball glancing off the edge of a hinged door) ends differently on the two solvers, as it would between any two engines.

Native builds for Windows, Linux and Android run the solver the project chose, so a native game and its web build use the same solver. Desktop apps compile both solvers in, which adds 4 MB to every Windows executable. An Android package carries PhysX as a library of its own, libestella_physx.so, only when the project chose PhysX: that adds about 2 MB to the download (4.9 MB installed, per ABI), and a Jolt project pays nothing. macOS and iOS builds include only Jolt for now. A PhysX project there runs on Jolt and logs that once at startup.

An entity is in the world when it carries a RigidBody3D and a shape. A body with no shape has no extent to collide with, so it is left out entirely rather than falling forever as an invisible point.

cmds.spawn()
.insert(Transform, { position: { x: 0, y: 400, z: 0 } })
.insert(RigidBody3D, { bodyType: BodyType.Dynamic })
.insert(CapsuleCollider3D, { radius: 30, halfHeight: 50 });
Field What it does
bodyType Static never moves, Kinematic is moved by hand, Dynamic is solved.
gravityScale This body’s share of world gravity. 0 is weightlessness, not slow falling.
mass Kilograms. 0 (the default) takes it from the shape at the density of water: a ball of 10 cm radius is 4.2 kg. Set it to make a hollow crate light or a small anvil heavy; it reaches a body already in play when it changes. A static or kinematic body has none.
linearDamping / angularDamping How quickly motion bleeds off (both default 0.05; 2D bodies default to 0).
fixedRotation Freezes the orientation the body was given — what keeps a character from toppling. It does not right a body that starts tilted.
layer Which of the sixteen collision layers the body is in.
continuousCollision Checks the whole path a step covers rather than where the body ended up. What a bullet needs; off by default, since it costs more.
Component Extent
BoxCollider3D halfExtents on each axis.
SphereCollider3D radius.
CapsuleCollider3D An upright capsule: halfHeight is the cylinder’s half, with a cap of radius on each end, so the total height is 2 * (halfHeight + radius).

Defaults: halfExtents { 0.5, 0.5, 0.5 }, radius 0.5 (0.3 on the capsule), halfHeight 0.5 — world units, so a freshly added shape is small until you size it. All three also carry friction (0.3), restitution (0) and isSensor (false).

Each of the three also takes an optional center: the shape’s place from the entity origin, in world units (default { 0, 0, 0 }). The body stays at the entity, so a dynamic body turns about its origin and an off-centre shape swings round it.

A MeshCollider3D collides against a mesh’s own triangles — a terrain, a staircase, the inside of a room. It is what a box and a capsule cannot say.

cmds.spawn()
.insert(Transform, {})
.insert(RigidBody3D, { bodyType: BodyType.Static })
.insert(MeshCollider3D, { mesh: 'assets/models/level.esmesh' });

For imported geometry that has to MOVE, use a ConvexCollider3D: it collides against the tightest convex volume around the same vertices, which a solver handles as readily as a box. A rock, a chamfered crate, a barrel that rolls — anything whose concave detail does not need to be felt.

cmds.spawn()
.insert(Transform, { position: { x: 0, y: 400, z: 0 } })
.insert(RigidBody3D, { bodyType: BodyType.Dynamic })
.insert(ConvexCollider3D, { mesh: 'assets/models/rock.esmesh' });

The 3D Physics example running with collider outlines drawn over boxes, spheres, capsules and cones

The 3D Physics example with the physics debug draw on: every collider is outlined, whatever the body does.

The viewport draws every 3D collider as a wireframe, turned the way its entity is — nothing else on screen says how big the box around a model is. It is on the same switch as the 2D collider gizmos.

An entity gets ONE body shape, chosen in the order BoxCollider3D, SphereCollider3D, MeshCollider3D, ConvexCollider3D, CapsuleCollider3D. Whatever loses — a disabled collider, one shadowed by that order, or any collider on an entity with no enabled RigidBody3D — is drawn dimmed and dashed: still there to author, visibly not what the world will collide with. A CharacterController3D capsule is drawn beside it, since a character is swept rather than solved.

The editor’s gizmos are hidden in play, so the running game draws its own. Turn the Physics3DDebugDraw resource on when you need to see why something got stuck where it did:

app.getResource(Physics3DDebugDraw).enabled = true;
Field What it does
enabled Off by default — an overlay costs a line per edge per frame.
showColliders The shape of every body the solver built.
showContacts A cross at each contact point reported this step.

A Planet with gravity above 0 pulls every dynamic body toward its centre instead of along the world’s single gravity vector, so a round world has a down everywhere (see Terrain for the planet itself).

A CharacterController3D replaces a RigidBody3D rather than accompanying one: a body the solver pushes and a character that sweeps are two answers to where an entity is. Set velocity from gameplay each step and read the result back.

const drive = defineSystem([Query(Mut(CharacterController3D)), Res(Input)], (q, input) => {
for (const [, c] of q) {
c.velocity.x = (input.isKeyDown('KeyD') ? 200 : 0) - (input.isKeyDown('KeyA') ? 200 : 0);
if (input.isKeyPressed('Space') && c.isOnFloor) c.velocity.y = 500;
}
});
app.addSystemToSchedule(Schedule.FixedUpdate, drive);
Field What it does
velocity Desired velocity in world units/second. A positive y is a jump.
radius / halfHeight The upright capsule that is swept (defaults 0.3 / 0.5, world units), shaped like CapsuleCollider3D’s.
stepHeight Tallest step it climbs instead of stopping at (default 0.4). 0 climbs nothing.
snapDown How far it reaches down to stay on the floor over a crest (default 0.5). 0 is off.
maxSlope Steepest ground it can stand on, radians (default 0.87, about 50°); beyond this it slides.
mass The character’s mass in kilograms (default 70), used when it shoves bodies.
pushForce How hard it shoves dynamic bodies it walks into (default 5000). 0 moves nothing.
layer Which collision layer it is in (0–15).
isOnFloor / floorNormal / realVelocity Outputs, read after the step.

Details of the Player: Character Controller 3D with radius, half height and slope, and Third Person Controller with move speed and acceleration

The Character Controller 3D and Third Person Controller of the Third Person example’s player.

ThirdPersonController and ThirdPersonCamera are the gameplay layer above a character: input becomes a request, the character controller answers it, and the answer is what the animator hears.

// Nothing to write. Both are components a scene declares.
world.insert(player, ThirdPersonController, { moveSpeed: 320, jumpSpeed: 520 });
world.insert(rig, ThirdPersonCamera, { target: player, distance: 420 });

The stick is read in the camera’s GROUND plane, so an eye angled steeply down still walks the character across the floor. Pitch never reaches the character.

Field What it does
moveSpeed Top speed on the ground, world units/second (default 320).
acceleration / deceleration How fast it reaches that speed, and sheds it, units/second² (defaults 2400 / 3200).
rotationSpeed How fast it turns to face where it went, degrees/second (default 720).
jumpSpeed Upward speed a jump starts with. 0 (the default) cannot jump.
airControl How much of acceleration applies off the ground, 0..1 (default 0.3).
cameraRelative Read the stick in the camera’s ground plane (default true) rather than the world’s.
camera Whose forward the stick is read against; 0 (the default) means the first ThirdPersonCamera found.
idleThreshold Speed under which the animator is told the character is standing still (default 8).

ThirdPersonCamera orbits a target under pointer control:

Field What it does
target The entity it orbits; 0 leaves the camera inert.
distance How far back it sits when nothing is in the way, world units (default 420).
yaw / pitch Turn about world up, and above the horizon (positive looks down), degrees (defaults 0 / 15).
minPitch / maxPitch Pitch limits, degrees (defaults -30 / 70).
sensitivity Degrees per pixel of pointer travel (default 0.2).
followDamping How fast the position catches up, per second; 0 is rigid (default 12).
targetOffset Lifts the pivot off the target’s origin so the eye frames the chest, not the feet (default { 0, 90, 0 }).
obstruction / obstructionRadius / obstructionLayers Pull in when something solid is between pivot and eye (default on), how fat the probe is (default 15), and which layers it hits (0 is all).

FirstPersonController looks, walks, jumps and crouches in a CharacterController3D, the way the third-person layer does: it asks, and the physics world answers. Put it on the body, with a camera as its child; the body turns with the player’s yaw and the camera tilts with the pitch.

// Components a scene declares.
world.insert(player, CharacterController3D, { radius: 30, halfHeight: 90 });
world.insert(player, FirstPersonController, { moveSpeed: 320, jumpSpeed: 420 });
// …and a Camera on a child of `player`.
  • Looking. On the web the first click takes the pointer (pointerLock) and the mouse turns the view; without it the view turns while a button is held. On a touch screen a finger that starts touchLookFrom pixels across the screen (480 by default) turns it, which leaves the left for a stick. A mini game has no pointer to take, so it looks by touch.
  • Walking. WASD or the arrow keys, Shift to sprint, Space to jump, Ctrl or C to crouch. The speed, the sprint and crouch multipliers, the acceleration and how much say the player has in the air are fields.
  • Crouching makes the capsule again at crouchHalfHeight, with the feet where they were: the physics world cannot resize a character, so the old one is let go for a step. Standing up first looks for a ceiling, and the player stays down where there is none to stand under.

A held thing drawn with the world’s camera goes through walls and stretches with a wide field of view. FirstPersonViewModel, on the player’s camera, draws it with a second camera instead: one is made under the camera, drawing only the sorting layer you name (layer, 20 by default), with a field of view and near plane of its own, over the world and not clearing it. The player’s camera is told not to draw that layer. Put the held thing under the camera and give its renderers that layer.

world.insert(camera, FirstPersonViewModel, { layer: 20, fov: 50, nearPlane: 1 });
world.insert(weapon, MeshRenderer, { mesh: 'builtin:cube', layer: 20 });

Both are in esengine/gameplay. There is no weapon system, ballistics or damage in them, and no template yet; the input is the keyboard, the pointer and the touch screen, and a virtual stick or a gamepad are not read.

A Ragdoll on a skinned character turns its bones into jointed bodies when you switch active on, and gives the pose back to the animation when you switch it off. It reads the skeleton the character already has (the joints its skinned mesh names), so there is nothing to author beyond the switch and a few numbers.

world.insert(enemy, Ragdoll, { active: false });
// When it is knocked down:
world.insert(enemy, Ragdoll, { ...world.get(enemy, Ragdoll), active: true });
  • Each bone that is long enough gets a box along it, joined by a swing/twist joint to the nearest bone above that has one, at the pose the animation had that frame, so nothing snaps. The animation keeps running underneath; the bodies’ pose is put back over it each frame.
  • Limits. With the Humanoid profile (the default) each joint gets the share of swing and twist its part of a body has, read from the bone’s name (a spine stiff, a shoulder loose, a shin almost a hinge). A knee and an elbow are one-way hinges of at most bend degrees: a shin folds back and a forearm folds forward, which is told from facing, the way the character looks along its own axes.
  • Standing up blends from the pose the bodies were left in to the one the animation gives, over recoverTime seconds.
  • A bone of its own. A RagdollJoint on a bone’s entity gives it no body, or limits of its own in degrees (and a bend and fold to make any bone a one-way hinge).
  • Select a ragdoll in the editor to see the boxes and the joint limits it would be made of, from the pose its skeleton is in.

It is a passive ragdoll: nothing drives the limbs. Target-device acceptance is recorded separately.

Three facts, and the whole of a combat system is keeping them apart:

an animation event ≠ a hit ≠ damage

The clip says only that the swing reached its effective moment. What was in that space is the physics world’s answer. What that does to anyone is gameplay’s. Collapse any two and you get a combat system that cannot be re-aimed, re-timed or re-balanced without touching the other two.

MeleeAttack sits beside an Animator whose attack clip declares three beats on a customEvent track — attack-start, hit, attack-end:

world.insert(player, MeleeAttack, { radius: 70, damage: 25, anchor: swordSocket });
world.insert(dummy, Health, { current: 100, max: 100 });
Field What it does
radius Radius of the sphere a hit beat tests, world units (default 60).
damage What a landed blow takes off (default 25).
layers Physics layers the swing can reach; 0 is every layer.
anchor The entity whose WORLD placement the query is centred on.
attackId Engine-written: the live swing, 0 when none is running.
hitCount Engine-written: how many targets it has landed on.

A swing is an INSTANCE with its own id and its own set of who it has already reached, so one swing lands on one target once and the next one may land again. A hit window is normally several hit beats, and leaning on “the event only fires once” instead breaks the first time a clip declares two — silently, as double damage, which reads as a balance problem rather than a bug.

A blade can move farther in one frame than its own reach. Checked only where the anchor stands on each beat, it passes through a target between two frames and nothing lands. Declare the frames the swing can land in as one attack-active window instead, a customEvent with a duration:

{ "time": 0.18, "duration": 0.12, "name": "attack-active", "payload": {} }

While it is open, the swing sweeps the path its anchor travelled since the last frame: spheres of radius along the line from where the anchor was to where it is, no farther apart than half the radius, so a fast arc still meets what it passed. The window opening is the swing beginning, and it ends when the window shuts or when the clip is left before it does (cancelled into a dodge, say). The swing lands on each target once however many frames it stays in reach, and two attacks of a combo are two swings even where their windows touch. A clip that says attack-start as well swings once, not twice.

Nothing in the swing writes health. A landed blow is sent on the Damage bus and one system answers it, so Health has a single author and every rule that will ever sit between a hit and a health bar has one seam to sit in:

import { defineSystem, EventReader, GetWorld, Res, Damage, Children, ParticleEmitter, Particle } from 'esengine';
const hitSparks = defineSystem(
[EventReader(Damage), GetWorld(), Res(Particle)],
(blows, world, particles) => {
for (const blow of blows) {
if (!world.has(blow.target, Children)) continue;
for (const child of world.get(blow.target, Children).entities) {
if (world.has(child, ParticleEmitter)) particles.play(child);
}
}
},
{ name: 'HitSparkSystem' },
);

A blow carries target, source, amount and the point it landed at (x, y, z) — that point cannot be recovered later, because by the time a spark is drawn the swing has moved on. The bus is double buffered, so a blow sent this frame lands on the next.

A character’s capsule is one shape, so a shot that meets it cannot say whether it met a head or a boot. Give the character a Hitboxes and each bone long enough gets a box along it, the size its ragdoll would give it: a kinematic body the world moves to wherever the animation has put the bone, and a sensor, so nothing walks into it or is pushed by it, its own character included. A ray meets the bone, and hitPartOf says whose it is and which.

world.insert(soldier, Hitboxes, { layer: HITBOXES });
// a shot:
const hit = physics.raycast(muzzle, aim, WORLD | HITBOXES_MASK);
const part = hit && hitPartOf(world, hit.entity); // { character, bone: 'head' }
const damage = part?.bone.toLowerCase().includes('head') ? 100 : 34;
Property Default Description
skin 0 The skinned mesh whose bones get boxes; 0 finds the first on the entity or below it.
thickness 0.25 A box’s thickness as a fraction of its bone’s length.
minBoneLength 5 A bone shorter than this (world units) gets no box; what hangs from it is its parent’s.
layer 0 The collision layer the boxes are in, so a shot can ask for them and a sight line leave them out.

While the character’s Ragdoll is limp its bones are bodies of their own, which a ray meets just as well; the boxes give way to them and come back when it stands up. How much a head is worth against a hand is the game’s: the engine says which part was met.

A door, a rope bridge, a lift, a ragdoll: none of them are one body and a shape. They are two bodies and a rule about how they may move relative to each other. A joint lives on the entity that declares it and names the other one.

cmds.spawn()
.insert(Transform, { position: { x: 100, y: 0, z: 0 } })
.insert(RigidBody3D, {})
.insert(BoxCollider3D, { halfExtents: { x: 50, y: 100, z: 5 } })
.insert(HingeJoint3D, {
connectedEntity: frame,
anchor: { x: -50, y: 0, z: 0 }, // the door's own edge
axis: { x: 0, y: 1, z: 0 }, // upright
enableLimit: true, lowerAngle: 0, upperAngle: Math.PI / 2,
});
Component Rule
PointJoint3D A shared point, free to turn on all three axes.
HingeJoint3D One axis of rotation, with optional limits and a motor.
SliderJoint3D One axis of travel, with optional limits and a motor.
DistanceJoint3D A distance kept: a rope with maxLength, a rod when the lengths meet, a spring with frequency.
FixedJoint3D No freedom at all — the two move as one.

anchor and axis are written in the declaring entity’s own local space, in world units, and are resolved against its transform when the joint is made. That pose is also the zero of every limit: a door placed closed has angle 0 and opens to upperAngle.

Set motorSpeed from gameplay at any time — the world is re-driven when it changes. So are a hinge’s or slider’s enableLimit, lowerAngle/upperAngle or lowerTranslation/upperTranslation and maxMotorTorque/maxMotorForce, and a distance joint’s minLength, maxLength, frequency and damping: a door locked by narrowing its range stops, a rope shortened while something hangs on it pulls it up. Every joint also takes a breakForce (N) and breakTorque (N m): held with more than either over a step, it is taken out of the world, its enabled lowered, and the break told in Physics3DEvents.jointBreaks. A chandelier on a FixedJoint3D with a breakForce comes down when a shot or a blast pulls harder than its mount holds; raising enabled again joins the two where they are then. A range always holds the pose the joint was made in: one that does not reach 0 (lowerAngle: 0.2) is widened to 0, and a hinge’s goes no further than half a turn either way, in both solvers. In the other direction, HingeJoint3D.angle and SliderJoint3D.translation are written back each step, so a game can ask how far the door swung without integrating the swing a second time.

Details of a Hinge Joint 3D: connected entity, anchor, axis, angle limits and motor

A Hinge Joint 3D on the 3D Physics example’s door: the connected frame, the hinge axis and its angle limits.

The Physics3D resource answers spatial questions in world units.

const q = app.getResource(Physics3D);
// Is anything on this line?
const hit = q.raycast(muzzle, { x: 0, y: 0, z: -2000 }, ENEMIES);
// Can this thing GET there? A ray is infinitely thin and slips through gaps a
// moving body would not fit — that is what a swept shape answers instead.
const blocked = q.sphereCast(from, 30, travel, WORLD);
// What is already here, before something is spawned into it?
const occupants = q.overlapSphere(spawnPoint, 50);
Query Answers
raycast(origin, direction, layerMask?) The nearest body on a line, as { entity, fraction, x, y, z, normalX, normalY, normalZ }, or null. direction carries the ray’s length.
raycastAll(origin, direction, layerMask?, maxHits?) Every body on the line, nearest first, each with fraction and exitFraction where the line goes in and out and thickness, how much of it the line crosses in world units: a shot through thin cover spends its strength on each in turn.
sphereCast(origin, radius, direction, layerMask?) The first body a moving sphere would meet, same shape, or null.
boxCast(origin, halfExtents, direction, layerMask?, rotation?) The same for a box, turned by rotation or not at all: whether a crate fits through a door.
capsuleCast(origin, radius, halfHeight, direction, layerMask?, rotation?) The same for a capsule standing along its own y, as a character does; halfHeight is half its straight part.
overlapSphere(centre, radius, layerMask?) / overlapBox(centre, halfExtents, layerMask?) Every body already inside a volume, as { entity, x, y, z }[].

Physics3D holds null until the physics module has finished loading, so a system that asks in the first frames should check for it.

The same Physics3D resource pushes bodies about: throwing, kicking, knocking back, a blast. Lengths and speeds are world units, as Transform’s; masses kilograms; angles radians. An impulse is kilograms by world units a second, so a 2 kg body given an impulse of 200 gains 100 world units a second; a force is the same per second.

const physics = app.getResource(Physics3D);
// Kick a ball where the foot meets it: it flies and spins.
physics.applyImpulse(ball, { x: 0, y: 150, z: -600 }, footPoint);
// A blast: every moving body within 400 thrown away and a little up,
// and every Breakable it reaches hard enough broken.
physics.explode(grenadeAt, 400, 3000, { upward: 0.4 });
Call Does
applyImpulse(entity, impulse, at?) Strikes it all at once: its velocity changes by impulse / mass. At at, a world point, it also turns it; without, at its centre of mass. Wakes it.
applyForce(entity, force, at?) Pushes it over the next fixed step only: a steady push is given again each step, from a system in Schedule.FixedUpdate.
applyTorque(entity, torque) / applyAngularImpulse(entity, impulse) Twists it, over the next step or all at once, about each world axis. Kilograms by world units squared a second squared, and a second.
setLinearVelocity(entity, v) / getLinearVelocity(entity) Its speed, in world units a second.
setAngularVelocity(entity, w) / getAngularVelocity(entity) Its spin, in radians a second.
getMass(entity) Kilograms; null for a body that does not move. Set with RigidBody3D.mass.
getMassData(entity) { mass, centre, inertia }: kilograms, its centre of mass in the world, and how hard it is to turn about each of its own axes (kg by world units squared; its moments of inertia where those are its principal axes, as a box’s are; Infinity about an axis it may not turn on).
setAwake(entity, awake) / isAwake(entity) Wake a sleeping body, or put one to sleep until something touches it.
setGravity(g) / getGravity() The world’s gravity, in metres a second squared as the project’s physics settings give it. A sleeping body stays put until woken.
explode(centre, radius, impulse, { upward?, layers? }) Strikes every moving body within radius away from centre with impulse, less the further it is and none at the edge; upward (0..1) tips the push toward the sky. A Breakable it reaches is struck as hard, standing or not. Answers how many bodies it moved.

A body that does not move takes none of it, and each call answers false (or null) for an entity the world has no body for yet, which is true for the frame an entity is spawned in.

Every body is in one of sixteen layers, and a project says which layers hear from which. Both sides must agree — one of them refusing is enough to keep two bodies apart, so a rule only has to be written once to hold.

app.addPlugin(physics3dPlugin(url, {
layerMasks: [
0xFFFF, // 0: everything
0xFFFF, // 1: the world
~(1 << 3), // 2: bullets — not their own team
0xFFFF, // 3: that team
],
}));

Each step publishes what touched what into the Physics3DEvents resource. It is drained per fixed step, so a system reading it must run inside one — a read from Update sees whatever the last step happened to leave.

const events = app.getResource(Physics3DEvents);
for (const hit of events.contactEnters) {
// both entities, and where they met
spawnSparks(hit.pointX, hit.pointY, hit.pointZ);
}
for (const { sensorEntity, visitorEntity } of events.sensorEnters) {
if (sensorEntity === goalZone) score(visitorEntity);
}
Channel What it carries
contactEnters Both entities, the contact normal and the point, in the same units as Transform, and speed: how fast the first was closing on the second where they met, along the normal, in those units a second, read before the solver answered (a ball dropped a metre lands at about 4.4 m/s); mass, the kilograms they met with, 1 / (1/a + 1/b) with a body that does not move counting as no inverse mass, so a stone landing on a floor meets it with its own; and impulse, speed times mass, how hard.
contactExits Only the pair — see below.
characterHits What a character ran into that it was not already touching, once a meeting: character, other, the point, the normal toward the character, speed, mass (its own against something that does not move) and impulse, as a contact’s. A Breakable a character runs into is struck with it, so a dive through a window breaks it and a lean on it does not.
jointBreaks Joints that gave way this step: entity, force (N) and torque (N m).
sensorEnters / sensorExits The sensor first, then the visitor.

A collider with isSensor reports overlaps and stops nothing: the visitor passes straight through and shows up in sensorEnters instead of contactEnters.

Nothing stops an entity carrying both sets, but nothing merges them either: the two worlds do not see each other, and a 2D collider will never stop a 3D body. Pick one per scene.

SwingTwistJoint3D locks translation and limits rotation with an elliptical swing cone and a separate twist interval. axis is local constraint X (twist), normalAxis is its local Y reference. Directions are normalized and orthogonalized; zero or parallel directions are rejected.

SixDOFJoint3D independently controls each axis using JointMotion3D.Locked (0), Limited (1), or Free (2) in translationMotion and rotationMotion. Locked axes stay at the creation pose; limited axes use the corresponding lower/upper vector; free axes ignore those bounds. Limited lower bounds must be strictly below upper bounds. Angular limits lie within −π to π; Y/Z rotation uses Jolt’s pyramid limits.

cmds.spawn().insert(SixDOFJoint3D, {
connectedEntity: base,
translationMotion: { x: JointMotion3D.Limited, y: JointMotion3D.Locked, z: JointMotion3D.Locked },
translationLower: { x: -100, y: 0, z: 0 },
translationUpper: { x: 100, y: 0, z: 0 },
});

The Inspector shows angles in degrees; files and scripts store radians. Translation limits and linear velocity use world units and world units/s. Angular velocity is rad/s; force and torque are N and N·m, independent of pixelsPerUnit.

Motors default off. enableMotor, linearVelocity (SixDOF only), angularVelocity, maxMotorForce and maxMotorTorque can change while running without rebuilding the joint. Targets describe connected body B relative to the owning body A, in constraint axes. If B is static, A moves in the opposite direction. Each motor axis shares the specified force/torque cap. This is velocity control, not a pose servo or active ragdoll.

Changing a frame, collision setting or limit rebuilds these joints using the current pose as zero. Disabling/removing a component releases it before its bodies are removed. joint3DSettingsError(settings) reports invalid settings; invalid joints remain uncreated instead of entering the solver with malformed limits.

The existing 3D Physics example includes a shoulder/arm and a limited carriage. Press J to reverse their motors; F1 toggles collider debug drawing. Select either joint in the editor to inspect its limits. Viewport limits are read-only; edit their numbers in Details. These components are experimental. Headless Jolt checks cover limits and motors; target-device acceptance is recorded separately.

CompoundCollider3D combines boxes, spheres and capsules into one native body on the same entity as RigidBody3D. Each parts entry has a local position and rotation, plus halfExtents, radius or capsule halfHeight. These dimensions and offsets are in model units: the entity’s composed scale places them in world space before the physics unit conversion. Both Jolt and PhysX consume the same component and packet layout.

Use finite positive placement scales. A rotated box or capsule under non-uniform scale needs baked collision geometry; the component rejects that unsupported case instead of creating a mismatched shape. Mesh and convex colliders also apply the model’s composed scale to their source vertices.

Nothing is cut when it breaks. A model is cut beforehand into pieces that fit together with no gap (a model’s fracture step writes them as a prefab, each piece a mesh with a body and a convex hull), and a Breakable swaps the whole for the pieces when its flag is raised.

world.insert(pot, Breakable, { pieces: 'assets/models/pot_pieces.esprefab', burst: 300 });
// when it is hit:
world.update(pot, Breakable, (b) => { b.origin = hitPointInItsOwnSpace; b.broken = true; });
Property Type Default Description
pieces prefab '' The prefab of its pieces.
broken boolean false Raise to break it; lower to make it whole again.
burst number 300 How fast the pieces leave, in world units a second, out from origin. 0 lets them fall where they are.
origin vec3 0,0,0 Where it is struck, from its own origin.
lifetime number 0 Seconds the pieces last before they are taken away. 0 keeps them.
breakImpulse number 0 A hit at least this hard breaks it: speed times mass, kg by world units a second. 0 breaks it only when broken is raised.

The whole is hidden, not removed: its renderer, body and colliders are switched off and come back when broken is lowered. Without a 3D world the pieces appear in place and stay there.

To have it break when something hits it, give it a breakImpulse and a collider of its own (the editor’s reply to a fractured model hands over a ConvexCollider3D of its shape as hull). A contact at least that hard breaks it, and the pieces leave from where it was hit; the hardest hit wins when there are several in a step. How hard is the speed at which the two came together times the mass they met with, so in a scene of 100 units to the metre a 1 kg stone landing at 10 m/s is 1000 and a 50 g pebble at the same speed is 50. With the collider alone it stands still and a stone meets it with the stone’s own mass; with a dynamic RigidBody3D as well it can be knocked over, and when it falls it meets the floor with its own. Give the stones and the pot the masses they should have with RigidBody3D.mass.

Physics3D.setLinearVelocity(entity, velocity) is what throws them, and is there for anything else that needs to send a body off: a blast, a kick. It answers false for an entity that has no body yet, which is true for the frame an entity is spawned in.

When it breaks, Broke is sent, once the pieces stand in its place, for the sound, the dust and the score: { entity, x, y, z, impulse }, where it was struck in the world and how hard (0 when its flag was raised by hand).

app.addSystemToSchedule(Schedule.Update, defineSystem([EventReader(Broke), Res(Audio)], (broke, audio) => {
// Louder the harder it was struck; a pot broken by hand makes its quietest sound.
for (const b of broke) audio.playSFX('assets/shatter.wav', { volume: Math.min(1, 0.3 + b.impulse / 3000) });
}));