Class: Ray
Ray
Constructors
Properties
Accessors
Methods
- clone
- intersectBox
- pointAt
- copy
- setApproxDirection
- setOrigin
- getOrigin
- getPoint
- sqrDistToPoint
- applyMatrix
- pointInTriangle
- intersectTriangle
- intersectSphere
- intersectionSegment
Constructors
constructor
• new Ray(origin?, dir?): Ray
Build a new ray object
Parameters
| Name | Type | Description |
|---|---|---|
origin? | Vector3 | Ray starting point |
dir? | Vector3 | Ray direction |
Returns
Defined in
Properties
origin
• origin: Vector3
Ray starting point
Defined in
length
• length: number = Number.MAX_VALUE
length
Defined in
Accessors
direction
• get direction(): Vector3
Ray direction
Returns
Defined in
• set direction(dir): void
Parameters
| Name | Type |
|---|---|
dir | Vector3 |
Returns
void
Defined in
Methods
clone
▸ clone(): Ray
Clone a new Ray object
Returns
Defined in
intersectBox
▸ intersectBox(box, target?): Vector3
Determine whether it intersects a bounding box
Parameters
| Name | Type | Description |
|---|---|---|
box | IBound | bounding box |
target? | Vector3 | - |
Returns
whether intersect
Defined in
pointAt
▸ pointAt(t, target?): Vector3
Calculate a point on the ray
Parameters
| Name | Type | Description |
|---|---|---|
t | number | Length scalar |
target? | Vector3 | output target |
Returns
result
Defined in
copy
▸ copy(src): this
Sets the ray to be a copy of the original ray
Parameters
| Name | Type | Description |
|---|---|---|
src | Ray | Ray object source |
Returns
this
New ray object
Defined in
setApproxDirection
▸ setApproxDirection(dir): void
Fast to the approximate ray direction
Parameters
| Name | Type | Description |
|---|---|---|
dir | Vector3 | direction |
Returns
void
Defined in
setOrigin
▸ setOrigin(origin): void
Set ray origin
Parameters
| Name | Type | Description |
|---|---|---|
origin | Vector3 | ray origin |
Returns
void
Defined in
getOrigin
▸ getOrigin(): Vector3
Get ray origin
Returns
Defined in
getPoint
▸ getPoint(t): Vector3
Gets the point at the specified position on the ray
Parameters
| Name | Type | Description |
|---|---|---|
t | number | Length position |
Returns
Returns a point at the specified location
Defined in
sqrDistToPoint
▸ sqrDistToPoint(P): number
Calculate the distance from a point
Parameters
| Name | Type | Description |
|---|---|---|
P | Vector3 | Specify Point |
Returns
number
result
Defined in
applyMatrix
▸ applyMatrix(mat4): void
Applied matrix transformation
Parameters
| Name | Type | Description |
|---|---|---|
mat4 | Matrix4 | matrix |
Returns
void
Defined in
pointInTriangle
▸ pointInTriangle(P, A, B, C): boolean
Calculates whether a specified point is inside a triangle
Parameters
| Name | Type | Description |
|---|---|---|
P | Vector3 | point |
A | Vector3 | Triangle vertex 1 |
B | Vector3 | Triangle vertex 2 |
C | Vector3 | Triangle vertex 3 |
Returns
boolean
whether it is inside a triangle
Defined in
intersectTriangle
▸ intersectTriangle(orig, dir, face): Vector3
Determine whether a ray intersects a triangle
Parameters
| Name | Type | Description |
|---|---|---|
orig | Vector3 | Ray starting point |
dir | Vector3 | Ray direction |
face | Triangle | triangle |
Returns
point of intersection
Defined in
intersectSphere
▸ intersectSphere(o, dir, center, radius): Vector3
Determine whether a ray intersects the sphere
Parameters
| Name | Type | Description |
|---|---|---|
o | Vector3 | Ray starting point |
dir | Vector3 | Ray direction |
center | Vector3 | Sphere center |
radius | number | radius of sphericity |
Returns
point of intersection
Defined in
intersectionSegment
▸ intersectionSegment(sega, segb, threshold): Object
A test of the intersection between a ray and a given line segment within a given tolerance (threshold)
Parameters
| Name | Type | Description |
|---|---|---|
sega | Vector3 | The first point of a line segment used to test the intersection |
segb | Vector3 | 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
| Name | Type |
|---|---|
out | Vector3 |
length | number |

