Ray

A ray that emits from an origin in a certain direction.

Constructor

Ray( origin, direction )

origin -- Vector3 The origin of the Ray.
direction -- Vector3 The direction of the Ray. This must be normalized (with Vector3.normalize) for the methods to operate properly.
Initialises the origin and direction properties to the provided values.

Properties

.origin

The origin of the Ray.

.direction

The direction of the Ray. This must be normalized (with Vector3.normalize) for the methods to operate properly.

Methods

.applyMatrix4 ( matrix4 )

matrix4 -- Matrix4 The Matrix4 to transform this Ray by.
Transform this Ray by the Matrix4.

.at ( t, optionalTarget = null ) Vector3

t -- Float The distance along the Ray to retrieve a position for.
optionalTarget -- Vector3 Receives the position along the Ray if passed; otherwise a new Vector3 is created.
Get a Vector3 that is a given distance along this Ray.

.clone ()

Create a clone of this Ray.

.closestPointToPoint ( point, optionalTarget )

point -- Vector3 The point to get the closest approach to.
optionalTarget -- Vector3 Receives the return value if passed; otherwise a new Vector3 is created.
Get the point along this Ray that is closest to the Vector3 provided.

.copy ( ray )

ray -- Ray The Ray to copy values from.
Copy the properties of the provided Ray, then return this Ray.

.distanceSqToSegment ( v0, v1, optionalPointOnRay = null, optionalPointOnSegment = null ) Float

v0 -- Vector3 The start of the line segment. v1 -- Vector3 The end of the line segment. optionalPointOnRay -- Vector3 If this is provided, it receives the point on this Ray that is closest to the segment. optionalPointOnSegment -- Vector3 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.

.distanceToPlane ( plane )

plane -- Plane The Plane to get the distance to.
Get the distance from the origin to the Plane, or null if the Ray doesn't intersect the Plane.

.distanceToPoint ( point )

point -- Vector3 The Vector3 to compute a distance to.
Get the distance of the closest approach between the Ray and the Vector3.

.distanceSqToPoint ( point )

point -- Vector3 The Vector3 to compute a distance to.
Get the squared distance of the closest approach between the Ray and the Vector3.

.equals ( ray )

ray -- Ray The Ray to compare to.
Return whether this and the other Ray have equal offsets and directions.

.intersectBox ( box, optionalTarget = null ) Vector3?

box -- Box3 The Box3 to intersect with.
optionalTarget -- Vector3 The Vector3 to store the result in, or null to create a new Vector3.
Intersect this Ray with a Box3, returning the intersection point or null if there is no intersection.

.intersectPlane ( plane, optionalTarget = null ) Vector3?

plane -- Plane The Plane to intersect with.
optionalTarget -- Vector3 The Vector3 to store the result in, or null to create a new Vector3.
Intersect this Ray with a Plane, returning the intersection point or null if there is no intersection.
function ( a, b, c, backfaceCulling, optionalTarget )

.intersectTriangle ( a, b, c, backfaceCulling, optionalTarget = null ) Vector3?

a, b, c -- Vector3 The Vector3 points on the triangle.
backfaceCulling -- Boolean Whether to use backface culling.
optionalTarget -- Vector3 The Vector3 to store the result in, or null to create a new Vector3.
Intersect this Ray with a triangle, returning the intersection point or null if there is no intersection.

.intersectsBox ( box )

box -- Box3 The Box3 to intersect with.
Return whether or not this Ray intersects with the Box3.

.intersectsPlane ( plane )

plane -- Plane The Plane to intersect with.
Return whether or not this Ray intersects with the Plane.

.intersectsSphere ( sphere )

sphere -- Sphere The Sphere to intersect with.
Return whether or not this Ray intersects with the Sphere.

.recast ( t )

t -- The distance along the Ray to interpolate.
Shift the origin of this Ray along its direction by the distance given.

.set ( origin, direction )

origin -- Vector3 The origin of the Ray.
direction -- Vector3 The direction of the Ray. This must be normalized (with Vector3.normalize) for the methods to operate properly.
Copy the parameters to the origin and direction properties.

.lookAt ( v )

v -- Vector3 The vector to look at.
Adjusts the direction of the ray to point at the vector in world coordinates.

Source

src/math/Ray.js
Edit