Constructor
new Ray(originopt, directionopt)
Constructs a new ray.
Members
direction :Vector3
The (normalized) direction of the ray.
(readonly) isRay :boolean
This flag can be used for type testing.
- boolean
- Default Value
- true
origin :Vector3
The origin of the ray.
Methods
applyMatrix4(matrix4) → {Ray}
Transforms this ray with the given 4x4 transformation matrix.
Name | Type | Description |
---|---|---|
matrix4 | Matrix4 | The transformation matrix. |
A reference to this ray.
- Type:
- Ray
at(t, target) → {Vector3}
Returns a vector that is located at a given distance along this ray.
Name | Type | Description |
---|---|---|
t | number | The distance along the ray to retrieve a position for. |
target | Vector3 | The target vector that is used to store the method's result. |
A position on the ray.
- Type:
- Vector3
clone() → {Ray}
Returns a new ray with copied values from this instance.
A clone of this instance.
- Type:
- Ray
closestPointToPoint(point, target) → {Vector3}
Returns the point along this ray that is closest to the given point.
Name | Type | Description |
---|---|---|
point | Vector3 | A point in 3D space to get the closet location on the ray for. |
target | Vector3 | The target vector that is used to store the method's result. |
The closest point on this ray.
- Type:
- Vector3
copy(ray) → {Ray}
Copies the values of the given ray to this instance.
Name | Type | Description |
---|---|---|
ray | Ray | The ray to copy. |
A reference to this ray.
- Type:
- Ray
distanceSqToPoint(point) → {number}
Returns the squared distance of the closest approach between this ray and the given point.
Name | Type | Description |
---|---|---|
point | Vector3 | A point in 3D space to compute the distance to. |
The squared distance.
- Type:
- number
distanceToPlane(plane) → (nullable) {number}
Computes the distance from the ray's origin to the given plane. Returns null
if the ray does not intersect with the plane.
Name | Type | Description |
---|---|---|
plane | Plane | The plane to compute the distance to. |
Whether this ray intersects with the given sphere or not.
- Type:
- number
distanceToPoint(point) → {number}
Returns the distance of the closest approach between this ray and the given point.
Name | Type | Description |
---|---|---|
point | Vector3 | A point in 3D space to compute the distance to. |
The distance.
- Type:
- number
equals(ray) → {boolean}
Returns true
if this ray is equal with the given one.
Name | Type | Description |
---|---|---|
ray | Ray | The ray to test for equality. |
Whether this ray is equal with the given one.
- Type:
- boolean
intersectBox(box, target) → (nullable) {Vector3}
Intersects this ray with the given bounding box, returning the intersection point or null
if there is no intersection.
Name | Type | Description |
---|---|---|
box | Box3 | The box to intersect. |
target | Vector3 | The target vector that is used to store the method's result. |
The intersection point.
- Type:
- Vector3
intersectPlane(plane, target) → (nullable) {Vector3}
Intersects this ray with the given plane, returning the intersection point or null
if there is no intersection.
Name | Type | Description |
---|---|---|
plane | Plane | The plane to intersect. |
target | Vector3 | The target vector that is used to store the method's result. |
The intersection point.
- Type:
- Vector3
intersectSphere(sphere, target) → (nullable) {Vector3}
Intersects this ray with the given sphere, returning the intersection point or null
if there is no intersection.
Name | Type | Description |
---|---|---|
sphere | Sphere | The sphere to intersect. |
target | Vector3 | The target vector that is used to store the method's result. |
The intersection point.
- Type:
- Vector3
intersectTriangle(a, b, c, backfaceCulling, target) → (nullable) {Vector3}
Intersects this ray with the given triangle, returning the intersection point or null
if there is no intersection.
Name | Type | Description |
---|---|---|
a | Vector3 | The first vertex of the triangle. |
b | Vector3 | The second vertex of the triangle. |
c | Vector3 | The third vertex of the triangle. |
backfaceCulling | boolean | Whether to use backface culling or not. |
target | Vector3 | The target vector that is used to store the method's result. |
The intersection point.
- Type:
- Vector3
intersectsBox(box) → {boolean}
Returns true
if this ray intersects with the given box.
Name | Type | Description |
---|---|---|
box | Box3 | The box to intersect. |
Whether this ray intersects with the given box or not.
- Type:
- boolean
intersectsPlane(plane) → {boolean}
Returns true
if this ray intersects with the given plane.
Name | Type | Description |
---|---|---|
plane | Plane | The plane to intersect. |
Whether this ray intersects with the given plane or not.
- Type:
- boolean
intersectsSphere(sphere) → {boolean}
Returns true
if this ray intersects with the given sphere.
Name | Type | Description |
---|---|---|
sphere | Sphere | The sphere to intersect. |
Whether this ray intersects with the given sphere or not.
- Type:
- boolean
recast(t) → {Ray}
Shift the origin of this ray along its direction by the given distance.
Name | Type | Description |
---|---|---|
t | number | The distance along the ray to interpolate. |
A reference to this ray.
- Type:
- Ray
set(origin, direction) → {Ray}
Sets the ray's components by copying the given values.
A reference to this ray.
- Type:
- Ray