API Docs for: 0.6.1
Show:

Ray Class

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

Constructor

Ray

()

Methods

_updateDirection

() private

Updates the _direction vector.

getAABB

(
  • aabb
)

Get the AABB of the ray.

Parameters:

intersectBodies

(
  • bodies
  • [result]
)

Parameters:

  • bodies Array

    An array of Body objects.

  • [result] RaycastResult optional

    Deprecated

intersectBody

(
  • body
  • [result]
)
private

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

Parameters:

  • body Body
  • [result] RaycastResult optional

    Deprecated - set the result property of the Ray instead.

intersectPlane

(
  • shape
  • angle
  • position
  • body
)
private

Parameters:

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

intersectRectangle

(
  • shape
  • angle
  • position
  • body
)
private

Parameters:

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

intersectShape

(
  • shape
  • angle
  • position
  • body
)
private

Parameters:

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

intersectWorld

(
  • world
  • options
)
Boolean

Do itersection against all bodies in the given World.

Parameters:

  • world World
  • options Object

Returns:

Boolean:

True if the ray hit anything, otherwise false.

reportIntersection

(
  • normal
  • hitPointWorld
  • shape
  • body
)
Boolean private

Parameters:

  • normal Array
  • hitPointWorld Array
  • shape Shape
  • body Body

Returns:

Boolean:

True if the intersections should continue

Properties

_direction

Array private

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.

collisionGroup

Number

Default: -1

collisionMask

Number

Default: -1

from

Array

hasHit

Boolean

Will be set to true during intersectWorld() if the ray hit anything.

mode

Number

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

precision

Number

The precision of the ray. Used when checking parallelity etc.

result

RaycastResult

Current result object.

skipBackfaces

Boolean

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

to

Array