Class: Ray
Defined in: src/math/Ray.ts:11
Ray
Constructors
Constructor
new Ray(
origin?,dir?):Ray
Defined in: src/math/Ray.ts:34
Build a new ray object
Parameters
origin?
Ray starting point
dir?
Ray direction
Returns
Ray
Properties
origin
origin:
Vector3
Defined in: src/math/Ray.ts:16
Ray starting point
length
length:
number=Number.MAX_VALUE
Defined in: src/math/Ray.ts:21
length
Accessors
direction
Get Signature
get direction():
Vector3
Defined in: src/math/Ray.ts:43
Ray direction
Returns
Set Signature
set direction(
dir):void
Defined in: src/math/Ray.ts:50
Set the ray direction (normalized internally)
Parameters
dir
Returns
void
Methods
clone()
clone():
Ray
Defined in: src/math/Ray.ts:59
Clone a new Ray object
Returns
Ray
intersectBox()
intersectBox(
box,target?):Vector3
Defined in: src/math/Ray.ts:78
Compute the intersection point of this ray with a bounding box
Parameters
box
IBound
bounding box
target?
optional output point
Returns
the intersection point, or null if there is none
pointAt()
pointAt(
t,target?):Vector3
Defined in: src/math/Ray.ts:129
Calculate a point on the ray
Parameters
t
number
Length scalar
target?
output target
Returns
result
copy()
copy(
src):this
Defined in: src/math/Ray.ts:142
Sets the ray to be a copy of the original ray
Parameters
src
Ray
Ray object source
Returns
this
New ray object
setApproxDirection()
setApproxDirection(
dir):void
Defined in: src/math/Ray.ts:154
Fast to the approximate ray direction
Parameters
dir
direction
Returns
void
setOrigin()
setOrigin(
origin):void
Defined in: src/math/Ray.ts:162
Set ray origin
Parameters
origin
ray origin
Returns
void
getOrigin()
getOrigin():
Vector3
Defined in: src/math/Ray.ts:169
Get ray origin
Returns
getPoint()
getPoint(
t):Vector3
Defined in: src/math/Ray.ts:178
Gets the point at the specified position on the ray
Parameters
t
number
Length position
Returns
Returns a point at the specified location
sqrDistToPoint()
sqrDistToPoint(
P):number
Defined in: src/math/Ray.ts:188
Calculate the distance from a point
Parameters
P
Specify Point
Returns
number
result
applyMatrix()
applyMatrix(
mat4):void
Defined in: src/math/Ray.ts:204
Applied matrix transformation
Parameters
mat4
matrix
Returns
void
pointInTriangle()
pointInTriangle(
P,A,B,C):boolean
Defined in: src/math/Ray.ts:221
Calculates whether a specified point is inside a triangle
Parameters
P
point
A
Triangle vertex 1
B
Triangle vertex 2
C
Triangle vertex 3
Returns
boolean
whether it is inside a triangle
intersectTriangle()
intersectTriangle(
orig,dir,face):Vector3
Defined in: src/math/Ray.ts:266
Determine whether a ray intersects a triangle
Parameters
orig
Ray starting point
dir
Ray direction
face
Triangle
triangle
Returns
point of intersection
intersectSphere()
intersectSphere(
o,dir,center,radius):Vector3
Defined in: src/math/Ray.ts:329
Determine whether a ray intersects the sphere
Parameters
o
Ray starting point
dir
Ray direction
center
Sphere center
radius
number
radius of sphericity
Returns
point of intersection
intersectionSegment()
intersectionSegment(
sega,segb,threshold):object
Defined in: src/math/Ray.ts:361
A test of the intersection between a ray and a given line segment within a given tolerance (threshold)
Parameters
sega
The first point of a line segment used to test the intersection
segb
The second point of a line segment used to test the intersection
threshold
number
Margin, if the ray does not intersect the line segment but is close to the given threshold, the intersection is successful
Returns
object
If there is an intersection, then the distance from the ray origin to the intersection, if there is no intersection, is -1
out
out:
Vector3
length
length:
number

