Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Ray

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

see

World.raycast for example usage

Hierarchy

  • Ray

Index

Constructors

  • Constructor for a new Ray

    Parameters

    Returns Ray

Properties

callback: ((result: RaycastResult) => void)

Type declaration

    • 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

  • getAABB(result: AABB): void
  • 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

  • reportIntersection(result: RaycastResult, fraction: number, normal: Vec2, faceIndex?: number): void
  • Parameters

    Returns void

  • update(): void
  • Should be called if you change the from or to point.

    Returns void