new Ray(origin, direction)
Constructs a new ray with the given values.
Parameters:
| Name | Type | Description |
|---|---|---|
origin |
Vector3 | The origin of the ray. |
direction |
Vector3 | The direction of the ray. |
Members
Methods
-
applyMatrix4(m) → {Ray}
-
Transforms this ray by the given 4x4 matrix.
Parameters:
Name Type Description mMatrix4 The 4x4 matrix.
-
at(t, result) → {Vector3}
-
Computes a position on the ray according to the given t value and stores the result in the given 3D vector. The t value has a range of [0, Infinity] where 0 means the position is equal with the origin of the ray.
Parameters:
Name Type Description tNumber A scalar value representing a position on the ray.
resultVector3 The result vector.
-
clone() → {Ray}
-
Creates a new ray and copies all values from this ray.
-
copy(ray) → {Ray}
-
Copies all values from the given ray to this ray.
Parameters:
Name Type Description rayRay The ray to copy.
-
equals(ray) → {Boolean}
-
Returns true if the given ray is deep equal with this ray.
Parameters:
Name Type Description rayRay The ray to test.
Returns:
Boolean -The result of the equality test.
-
intersectAABB(aabb, result) → {Vector3}
-
Performs a ray/AABB intersection test and stores the intersection point to the given 3D vector. If no intersection is detected, null is returned.
-
intersectBoundingSphere(sphere, result) → {Vector3}
-
Performs a ray/sphere intersection test and stores the intersection point to the given 3D vector. If no intersection is detected, null is returned.
Parameters:
Name Type Description sphereBoundingSphere A bounding sphere.
resultVector3 The result vector.
-
intersectBVH(bvh, result) → {Vector3}
-
Performs a ray/BVH intersection test and stores the intersection point to the given 3D vector. If no intersection is detected, null is returned.
-
intersectConvexHull(convexHull, result) → {Vector3}
-
Performs a ray/convex hull intersection test and stores the intersection point to the given 3D vector. If no intersection is detected, null is returned. The implementation is based on "Fast Ray-Convex Polyhedron Intersection" by Eric Haines, GRAPHICS GEMS II
Parameters:
Name Type Description convexHullConvexHull A convex hull.
resultVector3 The result vector.
-
intersectOBB(obb, result) → {Vector3}
-
Performs a ray/OBB intersection test and stores the intersection point to the given 3D vector. If no intersection is detected, null is returned.
Parameters:
Name Type Description obbOBB An orientend bounding box.
resultVector3 The result vector.
-
intersectPlane(plane, result) → {Vector3}
-
Performs a ray/plane intersection test and stores the intersection point to the given 3D vector. If no intersection is detected, null is returned.
-
intersectsAABB(aabb) → {boolean}
-
Performs a ray/AABB intersection test. Returns either true or false if there is a intersection or not.
Parameters:
Name Type Description aabbAABB An axis-aligned bounding box.
Returns:
boolean -Whether there is an intersection or not.
-
intersectsBoundingSphere(sphere) → {boolean}
-
Performs a ray/sphere intersection test. Returns either true or false if there is a intersection or not.
Parameters:
Name Type Description sphereBoundingSphere A bounding sphere.
Returns:
boolean -Whether there is an intersection or not.
-
intersectsBVH(bvh) → {boolean}
-
Performs a ray/BVH intersection test. Returns either true or false if there is a intersection or not.
Parameters:
Name Type Description bvhBVH A BVH.
Returns:
boolean -Whether there is an intersection or not.
-
intersectsConvexHull(convexHull) → {boolean}
-
Performs a ray/convex hull intersection test. Returns either true or false if there is a intersection or not.
Parameters:
Name Type Description convexHullConvexHull A convex hull.
Returns:
boolean -Whether there is an intersection or not.
-
intersectsOBB(obb) → {boolean}
-
Performs a ray/OBB intersection test. Returns either true or false if there is a intersection or not.
Parameters:
Name Type Description obbOBB An orientend bounding box.
Returns:
boolean -Whether there is an intersection or not.
-
intersectsPlane(plane) → {boolean}
-
Performs a ray/plane intersection test. Returns either true or false if there is a intersection or not.
Parameters:
Name Type Description planePlane A plane.
Returns:
boolean -Whether there is an intersection or not.
-
intersectTriangle(triangle, backfaceCulling, result) → {Vector3}
-
Performs a ray/triangle intersection test and stores the intersection point to the given 3D vector. If no intersection is detected, null is returned.
Parameters:
Name Type Description triangleTriangle A triangle.
backfaceCullingBoolean Whether back face culling is active or not.
resultVector3 The result vector.
-
set(origin, direction) → {Ray}
-
Sets the given values to this ray.
Parameters:
Name Type Description originVector3 The origin of the ray.
directionVector3 The direction of the ray.