Shape casting
A shape cast sweeps an entire shape along a direction and reports the first contact. It’s the swept-volume cousin of a raycast — perfect for probing the ground under a character’s feet, testing whether a body fits, or fat rays that won’t slip through cracks.
Drag to orbit
How it works
Section titled “How it works”// castShape(shape, startPosition, startRotation, sweepDirection, options?)const hit = world.castShape( Shape.sphere(0.4), [x, 4.5, 0], // where the sweep starts undefined, // start rotation (identity) [0, -6, 0], // sweep direction + length: 6 units straight down);
if (hit) { const landingY = 4.5 + -6 * hit.fraction; // start.y + direction.y * fraction hit.point; // contact point on the surface hit.normal; // surface normal hit.penetrationDepth; // overlap if the shape started intersecting}castShape returns a ShapeCastHit with the same body/fraction/point/normal as a raycast, plus contactPointOnCaster, contactPointOnBody, and penetrationDepth for richer contact resolution.