Simulation
Physics
205 symbols, imported from @driftengine/physics.
Explained in Your first game, Rigid bodies.
Classes
BodySetBoxSurfaceCharacterControllerClothBodyClothControl- A skinned cloth's schedule, over one device.
ClothTargets- Skinned positions and normals from the last two poses, and the model matrices between.
ColliderSetCompositeSurfaceContactConstraintsContactEventsDisjointExecutor- The premise, turned into something that fails.
DynamicTreeIslandSet- Connected components of the contact graph, and the sleeping that rides on them.
JointSetPairSetPhysicsWorldRibbonSurfaceSerialExecutorShuffledExecutor- 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
positionsafter a step, orinterpolatebetween the last two for a frame'salpha. The schedule — poses, steps, resets, the blend — isClothControl's; this is its CPU device. StallEscapeStaticRegionsSweptStepVehicle
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.
BodyDescBodyPart- One piece of a compound body, offset from the body's centre in its own frame.
BuoyancyBuoyancyOptions- 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
Infinityis 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
ColliderSetanswering "where is the ground here?", so a solid holds a body up. ControllerInputControllerOptionsConvexPart- 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.
DecomposeOptionsDecompositionDistanceConstraints- 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.
ExecutorGroundProbeGroundSurface- 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.
JointDescLanePlan- Where one typed array sits in the staging buffer. Plain data, so it crosses
postMessage. ManifoldMassProperties- 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.
RagdollRagdollOptionsRayHit- 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.
RibbonSurfaceOptionsShapePose- 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.
StallEscapeOptionsStallInput- 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.
SurfaceHitSweptState- Anything with a planar velocity the sweep may redirect.
SweptStepOptionsTetherConstraints- 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.
VehicleInputVehicleOptionsWheelOptionsWorldOpinion- 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
aabbFromCenteraccelerateAlong- @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.
bodyBoundsboxCollider- The collider of a drawn box, exactly where it is drawn.
boxShape- The exact shape
MeshBuilder.addBoxdraws: 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.
colliderSurfacecollideShapes- Fill
outand return whether the shapes are withinmarginof touching. colourConstraints- Colour
indices,arityparticles a constraint, around the particlesinverseMasspins. 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.
createBodyBoundscreateBuoyancycreateManifoldcreateMassProperties- A target for
shapeMassProperties, so nothing allocates per call. createRayHitcreateSurfaceHitcylinderShape- A cylinder: a segment along y, grown by a disc rather than by a ball.
decomposeConvexdefaultTyreCurve- 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.
exactAcosMath.acos, reproducibly. Outside [-1, 1] this answers NaN, asMath.acosdoes.exactCosMath.cos, reproducibly.exactExpMath.exp, reproducibly.exactLogMath.log, reproducibly: fdlibm's algorithm, which is also V8's.exactSinMath.sin, reproducibly. NaN in, NaN out; an infinity answers NaN, asMath.sindoes.faceCount- How many faces the shape has. Zero for a sphere or a capsule, which have none.
faceVertices- Fill
outwith 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.
moveAxisoverlapWorld- Every body overlapping a shape at a pose. Fills
outto 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
falseif 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.
shapeMassPropertiessolveContactssolveIslandInto- 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
AxisBodyType- 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.
ControllerStateDecomposeFill- How the interior of the mesh is decided. See
DecomposeOptions.fill. DofModeEscapeResultEventKindFrictionModel- 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
AIRBORNEAXIS_XAXIS_YAXIS_ZBODY_DYNAMICBODY_KINEMATICBODY_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 insideMAX_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_FREEDOF_LIMITEDDOF_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_IDLEESCAPE_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_EXITEVENT_STAYGROUNDED- A kinematic capsule character: the mechanism, and the feel that rides on it.
JOINT_CONE_TWISTJOINT_DISTANCE- Joints: seven types, each solved with its own rows unrolled.
JOINT_FIXEDJOINT_PRISMATICJOINT_REVOLUTEJOINT_SIX_DOFJOINT_SPHERICALLINEAR_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_RESOLUTIONRESTITUTION_THRESHOLD- Below this approach speed a bounce is not worth having, and jitters if it is applied.
SLIDINGSUPPORT_DIRECTIONS- How many, which is also the most points any part can carry.