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
-
Item Index
Properties
- ALL static
- ANY static
- callback
- checkCollisionResponse
- CLOSEST static
- collisionGroup
- collisionMask
- direction
- from
- length
- mode
- skipBackfaces
- to
Methods
intersectBodies
-
bodies
Parameters:
-
bodies
ArrayAn array of Body objects.
intersectBody
-
body
Shoot a ray at a body, get back information about the hit.
Parameters:
-
body
Body
intersectShape
-
shape
-
angle
-
position
-
body
reportIntersection
-
fraction
-
normal
-
[faceIndex=-1]
Parameters:
-
fraction
Number -
normal
Array -
[faceIndex=-1]
Number optional
Returns:
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
skipBackfaces
Boolean
If set to true, the ray skips any hits with normal.dot(rayDirection) < 0.
to
Array
Ray end point