Class Ray

A line with a start and end point that is used to intersect shapes.

See

raycast for example usage

Hierarchy

  • Ray

Constructors

  • Constructor for a new Ray

    Parameters

    Returns Ray

Properties

callback: ((result) => void)

Type declaration

    • (result): void
    • Current, user-provided result callback. Will be used if mode is Ray.ALL.

      Parameters

      Returns void

checkCollisionResponse: boolean

Set to true if you want the Ray to take .collisionResponse flags into account on bodies and shapes.

collisionGroup: number

Collision group.

Default

-1
collisionMask: number

Collision mask.

Default

-1
direction: Vec2 = ...

The direction of the ray

from: Vec2

Ray start point.

length: number = 1

Length of the ray

mode: 2 | 1 | 4

The intersection mode.

skipBackfaces: boolean

If set to true, the ray skips any hits with normal.dot(rayDirection) < 0.

to: Vec2

Ray end point

ALL: 4 = 4

This raycasting mode will traverse all intersection points and executes a callback for each one.

ANY: 2 = 2

This raycasting mode will make the Ray stop when it finds the first intersection point.

CLOSEST: 1 = 1

This raycasting mode will make the Ray traverse through all intersection points and only return the closest one.

Methods

  • Get the AABB of the ray.

    Parameters

    Returns void

  • Parameters

    Returns void

  • Shoot a ray at a body, get back information about the hit.

    Parameters

    Returns void

  • Shoot a ray at a shape, get back information about the hit

    Parameters

    Returns void

  • Parameters

    Returns void

  • Should be called if you change the from or to point.

    Returns void