Class RaycastResult

Storage for Ray casting hit data.

Hierarchy

  • RaycastResult

Constructors

Properties

body: null | Body

The hit body, or null.

faceIndex: number

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

Default

-1
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.

Default

-1
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.

Methods

  • Get the distance to the hit point.

    Parameters

    Returns number

  • Get world hit point.

    Parameters

    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