A ray that emits from an origin in a certain direction. This is used by the Raycaster to assist with raycasting. Raycasting is used for mouse picking (working out what objects in the 3D space the mouse is over) amongst other things.
origin — (optional) the origin of the Ray. Default is a Vector3 at (0, 0, 0).
direction — Vector3 The direction of the Ray. This must be normalized (with Vector3.normalize) for the methods to operate properly. Default is a Vector3 at (0, 0, -1).
Creates a new Ray.
The origin of the Ray. Default is a Vector3 at (0, 0, 0)
.
The direction of the Ray. This must be normalized (with Vector3.normalize) for the methods to operate properly. Default is a Vector3 at (0, 0, -1).
matrix4 — the Matrix4 to apply to this Ray.
Transform this Ray by the Matrix4.
t — the distance along the Ray to retrieve a position for.
target — the result will be copied into this Vector3.
Get a Vector3 that is a given distance along this Ray.
Creates a new Ray with identical origin and direction to this one.
point — the point to get the closest approach to.
target — the result will be copied into this Vector3.
Get the point along this Ray that is closest to the Vector3 provided.
Copies the origin and direction properties of ray into this ray.
point — the Vector3 to compute a distance to.
Get the squared distance of the closest approach between the Ray and the Vector3.
v0 — the start of the line segment.
v1 — the end of the line segment.
optionalPointOnRay — (optional) if this is provided, it receives the point on this
Ray that is closest to the segment.
optionalPointOnSegment — (optional) if this is provided, it receives the point
on the line segment that is closest to this Ray.
Get the squared distance between this Ray and a line segment.
plane — the Plane to get the distance to.
Get the distance from origin to the Plane, or null
if the Ray doesn't intersect the Plane.
point — Vector3 The Vector3 to compute a distance to.
Get the distance of the closest approach between the Ray and the point.
Returns true if this and the other ray have equal origin and direction.
box — the Box3 to intersect with.
target — the result will be copied into this Vector3.
Intersect this Ray with a Box3, returning the intersection point or null
if there is no intersection.
plane — the Plane to intersect with.
target — the result will be copied into this Vector3.
Intersect this Ray with a Plane, returning the intersection point or null
if there is no intersection.
sphere — the Sphere to intersect with.
target — the result will be copied into this Vector3.
Intersect this Ray with a Sphere, returning the intersection point or null
if there is no intersection.
a, b, c — The Vector3 points making up the triangle.
backfaceCulling — whether to use backface culling.
target — the result will be copied into this Vector3.
Intersect this Ray with a triangle, returning the intersection point or null
if there is no intersection.
box — the Box3 to intersect with.
Return true if this Ray intersects with the Box3.
plane — the Plane to intersect with.
Return true if this Ray intersects with the Plane.
sphere — the Sphere to intersect with.
Return true if this Ray intersects with the Sphere.
Adjusts the direction of the ray to point at the vector in world coordinates.
t — The distance along the Ray to interpolate.
Shift the origin of this Ray along its direction by the distance given.
origin — the origin of the Ray.
origin — the direction of the Ray.
This must be normalized (with Vector3.normalize) for the methods to operate properly.
Sets this ray's origin and direction properties by copying the values from the given objects.
For more info on how to obtain the source code of this module see this page.