Data type
Ray
Represents a line with a starting point that casts infinitely in a specific direction.
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.
Constructors 1#
Properties 3#
Methods 2#
| ClosestPoint | Returns a Vector3 projected onto the ray so that it is within
the Ray line of sight. |
| Distance | Returns the distance between the given point and the closest point on the
Ray. |
ClosestPoint(point: Vector3): Vector3#
Returns a Vector3 projected onto the ray so that it is within
the Ray line of sight.
Note: the Ray must be a unit ray for this method to
behave as expected!
| Name | Type | Default | Description |
|---|---|---|---|
point | Vector3 | The point in 3D space to project onto the ray. |
Returns
Vector3— The point on the ray closest to the given point, or the ray origin if the projection falls behind it.
Distance(point: Vector3): number#
Returns the distance between the given point and the point on the ray
nearest to the given point (Datatype.Ray.ClosestPoint(point)).
| Name | Type | Default | Description |
|---|---|---|---|
point | Vector3 | The point in 3D space to measure distance from. |
Returns
number— The shortest distance between the given point and the closest point on the ray.