API Docs for: 0.7.1
Show:

Ray Class

A line with a start and end point that is used to intersect shapes. For an example, see World.raycast

Constructor

Ray

(
  • [options]
)

Parameters:

  • [options] Object optional
    • [from] Array optional
    • [to] Array optional
    • [checkCollisionResponse=true] Boolean optional
    • [skipBackfaces=false] Boolean optional
    • [collisionMask=-1] Number optional
    • [collisionGroup=-1] Number optional
    • [mode=Ray.ANY] Number optional
    • [callback] Number optional

Methods

getAABB

(
  • aabb
)

Get the AABB of the ray.

Parameters:

intersectBodies

(
  • bodies
)

Parameters:

  • bodies Array

    An array of Body objects.

intersectBody

(
  • body
)
private

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

Parameters:

intersectShape

(
  • shape
  • angle
  • position
  • body
)
private

Parameters:

  • shape Shape
  • angle Number
  • position Array
  • body Body

reportIntersection

(
  • fraction
  • normal
  • [faceIndex=-1]
)
Boolean private

Parameters:

  • fraction Number
  • normal Array
  • [faceIndex=-1] Number optional

Returns:

Boolean:

True if the intersections should continue

update

()

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

Properties

ALL

Number static

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

ANY

Number static

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

callback

Function

Current, user-provided result callback. Will be used if mode is Ray.ALL.

checkCollisionResponse

Boolean

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

CLOSEST

Number static

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

collisionGroup

Number

Default: -1

collisionMask

Number

Default: -1

direction

Array

from

Array

Ray start point.

length

Number

Length of the ray

mode

Number

The intersection mode. Should be Ray.ANY, Ray.ALL or Ray.CLOSEST.

skipBackfaces

Boolean

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

to

Array

Ray end point