Class RaycastResult

Storage for Ray casting hit data.


  • RaycastResult



body: null | Body

The hit body, or null.

faceIndex: number

The index of the hit triangle, if the hit shape was indexable.


fraction: number

Distance to the hit, as a fraction. 0 is at the "from" point, 1 is at the "to" point. Will be set to -1 if there was no hit yet.


isStopped: boolean

If the ray should stop traversing.

normal: Vec2

The normal of the hit, oriented in world space.

shape: null | Shape

The hit shape, or null.


  • Get the distance to the hit point.


    Returns number

  • Get world hit point.


    Returns Vec2

  • Returns true if the ray hit something since the last reset().

    Returns boolean

  • Reset all result data. Must be done before re-using the result object.

    Returns void

  • Parameters

    • normal: Vec2
    • shape: Shape
    • body: Body
    • fraction: number
    • faceIndex: number

    Returns void

  • Parameters

    Returns boolean

  • Can be called while iterating over hits to stop searching for hit points.

    Returns void