Class Ray
Hierarchy
- Ray
Index
Constructors
Properties
Methods
Constructors
constructor
Properties
directionSearch playground for direction
direction
lengthSearch playground for length
length of the ray
originSearch playground for origin
origin point
Methods
intersection SegmentSearch playground for intersectionSegment
-
Intersection test between the ray and a given segment whithin a given tolerance (threshold)
Parameters
-
sega: DeepImmutable<Vector3>
the first point of the segment to test the intersection against
-
segb: DeepImmutable<Vector3>
the second point of the segment to test the intersection against
-
threshold: number
the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
Returns number
the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
-
intersects AxisSearch playground for intersectsAxis
-
Calculate the intercept of a ray on a given axis
Parameters
-
axis: string
to check 'x' | 'y' | 'z'
-
Optional offset: number
from axis interception (i.e. an offset of 1y is intercepted above ground)
Returns Nullable<Vector3>
a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
-
intersects BoxSearch playground for intersectsBox
-
Checks if the ray intersects a box This does not account for the ray lenght by design to improve perfs.
Parameters
-
box: DeepImmutable<BoundingBox>
the bounding box to check
-
Optional intersectionTreshold: number
extra extend to be added to the BoundingBox in all direction
Returns boolean
if the box was hit
-
intersects Box Min MaxSearch playground for intersectsBoxMinMax
-
Checks if the ray intersects a box This does not account for the ray lenght by design to improve perfs.
Parameters
-
minimum: DeepImmutable<Vector3>
bound of the box
-
maximum: DeepImmutable<Vector3>
bound of the box
-
Optional intersectionTreshold: number
extra extend to be added to the box in all direction
Returns boolean
if the box was hit
-
intersects MeshSearch playground for intersectsMesh
-
Checks if ray intersects a mesh
Parameters
-
mesh: DeepImmutable<AbstractMesh>
the mesh to check
-
Optional fastCheck: boolean
defines if the first intersection will be used (and not the closest)
Returns PickingInfo
picking info of the intersecton
-
intersects MeshesSearch playground for intersectsMeshes
-
Checks if ray intersects a mesh
Parameters
-
meshes: Array<DeepImmutable<AbstractMesh>>
the meshes to check
-
Optional fastCheck: boolean
defines if the first intersection will be used (and not the closest)
-
Optional results: Array<PickingInfo>
array to store result in
Returns Array<PickingInfo>
Array of picking infos
-
intersects PlaneSearch playground for intersectsPlane
-
Checks if ray intersects a plane
Parameters
-
plane: DeepImmutable<Plane>
the plane to check
Returns Nullable<number>
the distance away it was hit
-
intersects SphereSearch playground for intersectsSphere
-
If the ray hits a sphere
Parameters
-
sphere: DeepImmutable<BoundingSphere>
the bounding sphere to check
-
Optional intersectionTreshold: number
extra extend to be added to the BoundingSphere in all direction
Returns boolean
true if it hits the sphere
-
intersects TriangleSearch playground for intersectsTriangle
-
If the ray hits a triange
Parameters
-
vertex0: DeepImmutable<Vector3>
triangle vertex
-
vertex1: DeepImmutable<Vector3>
triangle vertex
-
vertex2: DeepImmutable<Vector3>
triangle vertex
Returns Nullable<IntersectionInfo>
intersection information if hit
-
unproject Ray ToRefSearch playground for unprojectRayToRef
-
Unproject a ray from screen space to object space
Parameters
-
sourceX: float
defines the screen space x coordinate to use
-
sourceY: float
defines the screen space y coordinate to use
-
viewportWidth: number
defines the current width of the viewport
-
viewportHeight: number
defines the current height of the viewport
-
world: DeepImmutable<Matrix>
defines the world matrix to use (can be set to Identity to go to world space)
-
view: DeepImmutable<Matrix>
defines the view matrix to use
-
projection: DeepImmutable<Matrix>
defines the projection matrix to use
Returns void
-
updateSearch playground for update
-
Update the ray from viewport position
Parameters
-
x: number
position
-
y: number
y position
-
viewportWidth: number
viewport width
-
viewportHeight: number
viewport height
-
world: DeepImmutable<Matrix>
world matrix
-
view: DeepImmutable<Matrix>
view matrix
-
projection: DeepImmutable<Matrix>
projection matrix
Returns Ray
this ray updated
-
Static Create NewSearch playground for CreateNew
-
Creates a new ray from screen space and viewport
Parameters
-
x: number
position
-
y: number
y position
-
viewportWidth: number
viewport width
-
viewportHeight: number
viewport height
-
world: DeepImmutable<Matrix>
world matrix
-
view: DeepImmutable<Matrix>
view matrix
-
projection: DeepImmutable<Matrix>
projection matrix
Returns Ray
new ray
-
Static Create New From ToSearch playground for CreateNewFromTo
-
Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be transformed to the given world matrix.
Parameters
-
origin: Vector3
The origin point
-
end: Vector3
The end point
-
Optional world: DeepImmutable<Matrix>
a matrix to transform the ray to. Default is the identity matrix.
Returns Ray
the new ray
-
Static TransformSearch playground for Transform
-
Transforms a ray by a matrix
Parameters
-
ray: DeepImmutable<Ray>
ray to transform
-
matrix: DeepImmutable<Matrix>
matrix to apply
Returns Ray
the resulting new ray
-
Static Transform ToRefSearch playground for TransformToRef
-
Transforms a ray by a matrix
Parameters
-
ray: DeepImmutable<Ray>
ray to transform
-
matrix: DeepImmutable<Matrix>
matrix to apply
-
result: Ray
ray to store result in
Returns void
-
Static ZeroSearch playground for Zero
-
Creates a ray with origin and direction of 0,0,0
Returns Ray
the new ray
Class representing a ray with position and direction