Ray

Show Deprecated

The Ray data type represents a half-line, finite in one direction but infinite in the other. It can be defined by a 3D point, where the line originates from, and a direction vector, which is the direction it goes in.

Summary

Constructors

new(Origin: Vector3, Direction: Vector3)  

Properties

The Ray with a normalized direction (the direction has a magnitude of 1).

The position of the origin.

The direction vector of the Ray.

Methods


Returns a Vector3 projected onto the ray so that it is within the Ray's line of sight.

Distance(point: Vector3): number  

Returns the distance between the given point and the closest point on the Ray.

Constructors

new

Parameters

Origin: Vector3
Direction: Vector3

Properties

Unit

The Ray with a normalized direction (the direction has a magnitude of 1).

Origin

The position of the origin.

Direction

The direction vector of the Ray.

Methods

ClosestPoint

Returns a Vector3 projected onto the ray so that it is within the Ray's line of sight.

Note: the Ray must be a unit ray for this method to behave as expected!

Parameters

point: Vector3

Returns

Distance

Returns the distance between the given point and the point on the ray nearest to the given point (Ray.ClosestPoint()).

Parameters

point: Vector3

Returns