API

Function physicsRaycast

  • Cast a ray from from to to and return the first body it hits.

    collideWith/membership filter which bodies the ray can hit (by their shape filter masks). For MESH shapes the hit triangle index is reported; non-mesh shapes report -1. Run at least one physics step first so the broadphase exists.

    Parameters

    • world: PhysicsWorld

      The physics world to query.

    • from: Vec3

      World-space ray origin.

    • to: Vec3

      World-space ray end point.

    • query: RaycastQuery = {}

      Optional collision-filter masks and trigger behaviour.

    Returns RaycastResult

    The raycast result; hasHit is false when the ray clears every matching body.