ReadonlyjoltReadonlyjoltReadonlysystemReadonlybodyReadonlytempTemp allocator, needed by CharacterVirtual updates.
Live list of tracked bodies with their primitive collision shapes (in
body-local space). A debug renderer reads body.GetPosition() /
GetRotation() to place each part in the world. Bodies whose shape is a
triangle mesh / height-field / convex hull appear with empty parts.
StaticcreateCreates a physics world, loading the Jolt WASM backend on first use. Pass
PhysicsInitOptions (e.g. { wasmUrl }) on the first call if you're
not building with Vite; with Vite, no arguments are needed.
Optionalopts: PhysicsInitOptionsPacks a (group, mask) pair into a Jolt object layer.
Builds a mask-aware object-layer filter for collision queries (raycasts,
character sweeps): it accepts a body when its layer collides with
objectLayer per the world's pair filter. The caller owns the returned
filter and must jolt.destroy() it. Unlike SpecifiedObjectLayerFilter
(exact-equality), this honors the (group, mask) collision rules.
Builds the matching broad-phase filter for objectLayer. Caller destroys.
Sets world gravity (default is (0, -9.81, 0)).
Casts a ray against every collider and returns the closest hit point (world
space), or null if nothing was hit. direction is the full ray vector — its
length is the maximum cast distance. Useful for grounding a camera/character
against the streamed terrain colliders. staticOnly restricts the cast to
the World (non-moving) layer so a ray fired from above an actor doesn't hit
the actor itself.
Fast straight-down ground raycast that allocates no Jolt objects per call
(it reuses cached scratch), so it's safe to call hundreds of times per frame —
e.g. baking a collision heightmap by sampling the streamed colliders. Casts
from (x, y, z) down dist meters and returns the world Y of the closest hit,
or null. staticOnly restricts to the World layer (ignores dynamic actors,
so a ray over the player doesn't hit the player).
Adds an axis-aligned box body. half is the half-extent on each axis.
Adds a capsule body — the standard actor/projectile shape. halfHeight is
the half-length of the cylindrical section (excluding the hemispherical
caps), so total height is 2 * (halfHeight + radius). The capsule's axis is
the local Y (up) axis.
Adds a cylinder body. halfHeight is the half-length along the local Y
(up) axis, so total height is 2 * halfHeight; radius is the cross-section
radius. Used by the level collision (Godot CylinderShape3D).
Adds a static triangle-mesh collider from raw geometry — arbitrary,
possibly concave "soup" (ramps, level geometry, the surface of a wavy
terrain). positions is packed xyz triplets; indices is a triangle list.
Triangle meshes have no defined inertia, so Jolt only allows them on static
(or kinematic) bodies — this is the standard rule in every physics engine.
opts tunes the static body's surface and collision layer/mask.
Static collider for INSTANCED geometry: one initJolt.MeshShape per
unique mesh, referenced at every instance transform through a
StaticCompoundShape. Jolt builds + caches each unique mesh shape ONCE, so
peak memory scales with the unique meshes — not the merged instance soup that
a single huge addMeshCollider would build (which OOMs the WASM heap on a
heavily-instanced level). instances[i].mesh indexes unique;
instances[i].matrix is a column-major 4×4 (translation · rotation · scale).
Adds a static compound collider from a list of primitive sub-shapes
(box / cylinder / sphere / capsule), each with its own local position +
rotation. Builds a single Jolt StaticCompoundShape so a whole authored
level collision set (hundreds of shapes) is one body / one broadphase entry
— far cheaper than one body per shape, and exact (unlike a trimesh of the
visible geometry). Sub-shape axes follow the engine convention (box
half-extents per axis; cylinder/capsule axis = local Y). Always static.
This is what the StaticBody component builds from its child
Colliders (Godot StaticBody3D + CollisionShape3D children).
Adds a static height-field collider — the fast, memory-light path for
terrain. heights is a sampleCount × sampleCount row-major grid of world
Y values (index = z·sampleCount + x); cellSize is the world spacing
between samples; the field is placed so its origin sample sits at originXz.
Adds a dynamic body whose shape is the convex hull of points — the
way to give a falling object a custom (convex) mesh shape. For concave
objects, decompose into several hulls and combine with a compound shape.
Creates and adds a constraint between two bodies (e.g. a
PointConstraintSettings). The settings object is consumed and destroyed.
Advances the simulation. Sub-steps long frames to keep each step stable.
Removes and destroys every body and constraint, leaving the world empty.
Removes and destroys a single body. Its shape frees once no body holds it.
Full teardown: clears the world then frees the Jolt interface itself.
Install a global begin-overlap callback invoked for every contact pair with both bodies' stable ids (bodyKey). The caller resolves ids to owners. Pass null to clear. Installs the contact listener on first use.
The stable id key for a body, matching the keys passed to the contact callback.
The runtime Jolt module — use for
new this.jolt.Vec3(...)etc.