API

Interface RaycastResult

Result of a physicsRaycast query.

interface RaycastResult {
    body: PhysicsBody | null;
    bodyIndex: number;
    hasHit: boolean;
    hitDistance: number;
    hitNormal: Vec3;
    hitPoint: Vec3;
    triangleIndex: number;
}
Index
body: PhysicsBody | null

The body that was hit, or null when nothing was hit (or the body is not tracked).

bodyIndex: number

Thin-instance index of body; 0 for an ordinary body and -1 when no tracked body was resolved.

hasHit: boolean

Whether the ray hit a body.

hitDistance: number

Distance from the ray origin (from) to the contact point.

hitNormal: Vec3

Surface normal at the contact point.

hitPoint: Vec3

World-space contact point.

triangleIndex: number

Index of the triangle hit on a MESH shape, or -1 for non-mesh shapes.