Simulation

Physics

205 symbols, imported from @driftengine/physics.

Explained in Your first game, Rigid bodies.

Classes

BodySet
BoxSurface
CharacterController
ClothBody
ClothControl
A skinned cloth's schedule, over one device.
ClothTargets
Skinned positions and normals from the last two poses, and the model matrices between.
ColliderSet
CompositeSurface
ContactConstraints
ContactEvents
DisjointExecutor
The premise, turned into something that fails.
DynamicTree
IslandSet
Connected components of the contact graph, and the sleeping that rides on them.
JointSet
PairSet
PhysicsWorld
RibbonSurface
SerialExecutor
ShuffledExecutor
Reverse order, and it is a gate rather than a character anybody should choose.
SkinnedCloth
A garment's particles, constraints and solver state, stepped at the set-up's fixed step. Read positions after a step, or interpolate between the last two for a frame's alpha. The schedule — poses, steps, resets, the blend — is ClothControl's; this is its CPU device.
StallEscape
StaticRegions
SweptStep
Vehicle

Interfaces

Aabb
An axis-aligned box, and the one operation that builds one.
BendingConstraints
Dihedral bending: four particles — the shared edge, then each triangle's far corner.
Body
Moving body: center position + half extents. Mutated in place by moveAxis.
BodyDesc
BodyPart
One piece of a compound body, offset from the body's centre in its own frame.
Buoyancy
BuoyancyOptions
What water does to a body that falls in.
BuoyantState
Anything with a velocity. Declared structurally so nothing is imported in either direction.
ClothBatches
Constraints reordered by colour, and where each colour's run starts.
ClothCollider
A collider on a joint: a sphere, or a tapered capsule along its frame's +Z.
ClothDevice
What moves a skinned cloth's particles: the CPU's arrays, or a GPU's buffers.
ClothLimits
Where a particle may not go, measured from where skinning puts it. Each optional, one entry a particle (two for a stop), and Infinity is none — which is how cooked data says it.
ClothOptions
Cloth, as position-based dynamics with compliance.
Collider
A world obstacle: its bounds, and optionally the volume it really is.
ColliderBytes
What a collider set costs, in bytes, split so a streaming budget can act on it.
ColliderSurfaceOptions
A ColliderSet answering "where is the ground here?", so a solid holds a body up.
ControllerInput
ControllerOptions
ConvexPart
One convex piece of the decomposition, ready for hullShape.
ConvexShape
Convex collision shapes: the volume an element actually occupies, rather than a world-axis box around it.
DecomposeOptions
Decomposition
DistanceConstraints
Distance constraints: two particles, a rest length, a compliance (metres per newton).
EscapeVeto
A world's own veto over a direction the collider set says is clear.
Executor
GroundProbe
GroundSurface
Anything that can answer "where is the ground here?".
Heightfield
A heightfield as a collision shape: the samples, and every triangle generated from them.
HeightSurfaceOptions
Any function that answers "how high is the ground at this column?", as a GroundSurface.
IslandOverlap
Which body two islands both wrote, and which two they were.
IslandSolver
Something that can advance one island through a whole tick.
IslandSolveState
Everything one island's solve reaches, and nothing else the world holds.
JointDesc
LanePlan
Where one typed array sits in the staging buffer. Plain data, so it crosses postMessage.
Manifold
MassProperties
A shape's volume, centre of mass and inertia tensor, at a given density.
Parallelism
What a world's island solving is actually doing, and why.
PlanarState
Anything with a planar velocity. Declared structurally so nothing is imported either way.
PoolOutcome
What they got, and why, in a sentence fit to put on a debug overlay.
PoolRequest
What a consumer asked for.
PoolWorker
The part of a worker this pool uses.
PoseTarget
Anything shaped like an animation pose. Declared structurally so nothing is imported.
QueryFilter
Which bodies a query is allowed to see.
Ragdoll
RagdollOptions
RayHit
What a ray or a sweep found. Caller-owned; a query fills it and never allocates one.
ResolvedClothParameters
The parameters with every default filled in.
RibbonSurfaceOptions
ShapePose
Where a shape sits: a position and a unit quaternion.
SkinnedClothParameters
What the solver runs at. Every field has a default; the defaults are a garment's, not a sheet's.
SkinnedClothSetup
Everything a skinned cloth is made from.
StagePlan
The whole mirror's shape, posted to a worker once and again whenever a set grows.
StallEscapeOptions
StallInput
What the consumer knows about this tick that the geometry cannot say.
SurfaceBox
The tops of a set of flat, axis-aligned pads, answering as a ground surface.
SurfaceHit
SweptState
Anything with a planar velocity the sweep may redirect.
SweptStepOptions
TetherConstraints
Long-range attachments: a particle may be no further than a length from a kinematic anchor.
TriangleMesh
A static triangle mesh as a collision shape: the triangles, their planes, and the tree over them.
TyreCurve
Grip against slip, as a lookup table.
VehicleInput
VehicleOptions
WheelOptions
WorldOpinion
What the world knows that its colliders do not.
WorldOptions
Options a consumer sets once. Every one of them is a quality or feel dial, not a contract.

Functions

aabbFromCenter
accelerateAlong
@param wishX Unit direction the body is asking to travel in. @param wishZ @param wishSpeed How fast it is asking to go, in that direction. @param accel Metres per second squared this tick may deliver. @returns How much speed was actually added, so a consumer can tell a stalled motor from a satisfied one — a demand the ground refuses is exactly the interesting case for anything drawing wheelspin or smoke.
applyBuoyancy
Apply it, and report whether the body is submerged.
applyRestitution
One pass after every substep, giving back the bounce the solve suppressed.
batchesOf
A kind of constraint's batches: the set-up's own, checked, where it gives them, and coloured here where it does not. One decision for both solvers, which must batch a garment the same way.
bodyBounds
boxCollider
The collider of a drawn box, exactly where it is drawn.
boxShape
The exact shape MeshBuilder.addBox draws: eight corners, three axes.
capsuleShape
A capsule: a segment along y with a rounding radius.
collideCompound
Every touching pair of parts, as one manifold each.
colliderFromShape
Wrap a world-space shape in the bounds the broad phase needs.
colliderSurface
collideShapes
Fill out and return whether the shapes are within margin of touching.
colourConstraints
Colour indices, arity particles a constraint, around the particles inverseMass pins.
combineMassProperties
Several shapes as one body: volumes added, centre of mass weighted, tensors moved and summed.
coveredAbove
Whether anything solid stands over this column, between two heights.
createBodyBounds
createBuoyancy
createManifold
createMassProperties
A target for shapeMassProperties, so nothing allocates per call.
createRayHit
createSurfaceHit
cylinderShape
A cylinder: a segment along y, grown by a disc rather than by a ball.
decomposeConvex
defaultTyreCurve
A curve that rises to a peak and falls away, which is what a tyre does.
ejectFromSolid
Push a body out of solid geometry it has ended up inside.
exactAcos
Math.acos, reproducibly. Outside [-1, 1] this answers NaN, as Math.acos does.
exactCos
Math.cos, reproducibly.
exactExp
Math.exp, reproducibly.
exactLog
Math.log, reproducibly: fdlibm's algorithm, which is also V8's.
exactSin
Math.sin, reproducibly. NaN in, NaN out; an infinity answers NaN, as Math.sin does.
faceCount
How many faces the shape has. Zero for a sphere or a capsule, which have none.
faceVertices
Fill out with the vertex indices of one face, wound counter-clockwise seen from outside.
fingerprintBodies
A stable hash of every body's state, for comparing one run against another.
fingerprintColliders
A stable hash of the static geometry a simulation ran against.
heightfieldShape
Build a heightfield collision shape.
heightSurface
One field, or several stacked in the same world.
hullShape
The convex hull of a point cloud, with its separating features enumerated.
isDynamicBody
Whether a body is one the solver may move.
isStaticBody
Whether a body is one a query should treat as scenery.
layersInteract
The 32-layer mask, both ways. A pair layersInteract only if each side admits the other.
makeClothGrid
A rectangular sheet: positions, its stretch links, and the bend links across them.
meshShape
Build a static mesh shape.
moveAxis
overlapWorld
Every body overlapping a shape at a pose. Fills out to its length and returns how many.
pairA
Unpack a key's lower body index.
pairB
Unpack a key's higher body index.
pairKey
The key a pair of bodies is stored under, in either order.
partsBoundRadius
The largest distance from a body's own origin to any point of any part.
prepareContact
Turn one manifold into a constraint, with its effective masses and its local anchors.
ragdollFromBones
Build one.
raycastWorld
The nearest body a ray meets, or false if it meets none.
resetJointImpulses
Clear every joint's accumulated impulse, once per tick, before the substeps.
sampleTyreCurve
Sample a curve at at, holding the last value beyond its end.
segmentHit
Nearest obstruction along the segment origin → origin + delta, returned as a fraction of the segment in [0, 1] — 1 meaning unobstructed.
shapeBounds
World-axis bounds of a shape as placed (its points are its placement).
shapecastWorld
Sweep a shape from one point to another and report the first body it touches.
shapeMassProperties
solveContacts
solveIslandInto
Advance one island through every substep.
solveJoints
Solve every joint in a range, one iteration.
sphereShape
A ball: one point, all radius. It separates on other shapes' features.
validateClothSetup
Refuse a set-up whose arrays disagree, naming the array and both lengths.
warmStart
Apply the impulses carried over from the previous tick, before the first iteration.

Types

Axis
BodyType
Static never moves, kinematic moves but is not pushed, dynamic is solved.
ColliderGroup
A handle to one batch of colliders, so a region can be dropped without naming its members.
ControllerState
DecomposeFill
How the interior of the mesh is decided. See DecomposeOptions.fill.
DofMode
EscapeResult
EventKind
FrictionModel
How the two tangent rows are bounded against each other.
HeightField
A field of one height per column: the consumer's own (x, z) -> y.
JointType

Constants

AIRBORNE
AXIS_X
AXIS_Y
AXIS_Z
BODY_DYNAMIC
BODY_KINEMATIC
BODY_SENSOR
A sensor reports overlap and resolves none of it.
BODY_SLEEPING
Set on a body whose island is asleep. Woken bodies clear it together.
BODY_STATIC
Rigid body state, structure-of-arrays, indexed by a dense body index.
DEFAULT_MAX_HULLS
The default maxHulls, chosen so a decomposed body is well inside MAX_BODY_PARTS.
DEFAULT_RESOLUTION
The default and maximum grids. See DecomposeOptions.resolution.
DOF_COUNT
Six degrees: linear x, y, z, then angular x, y, z — all in body A's local frame.
DOF_FREE
DOF_LIMITED
DOF_LOCKED
What one degree of freedom does, for JOINT_SIX_DOF.
ESCAPE_EASED
Nothing had room, so the body was eased upward by hand.
ESCAPE_IDLE
ESCAPE_PUSHED
The body was pushed along axis/sign, through the sweep, so geometry still decided.
ESCAPE_SEALED
No room in any of the six directions, and the budget is spent. The consumer decides.
EVENT_ENTER
What touched what, drained after the tick rather than raised during it.
EVENT_EXIT
EVENT_STAY
GROUNDED
A kinematic capsule character: the mechanism, and the feel that rides on it.
JOINT_CONE_TWIST
JOINT_DISTANCE
Joints: seven types, each solved with its own rows unrolled.
JOINT_FIXED
JOINT_PRISMATIC
JOINT_REVOLUTE
JOINT_SIX_DOF
JOINT_SPHERICAL
LINEAR_SLOP
Contacts start with this much slack allowed before the bias fights them, in metres.
MAX_BIAS_VELOCITY
How fast the bias may push overlap out, in metres per second.
MAX_BODIES
The key packs two indices into 32 bits, so neither may reach this.
MAX_BODY_PARTS
The most parts one body may be made of.
MAX_CONTACTS
At most four points survive reduction, which is enough to hold a face flat.
MAX_PAIR_MANIFOLDS
How many contact planes one pair may produce.
MAX_RESOLUTION
RESTITUTION_THRESHOLD
Below this approach speed a bounce is not worth having, and jitters if it is applied.
SLIDING
SUPPORT_DIRECTIONS
How many, which is also the most points any part can carry.