Class Ray
Hierarchy
- Ray
Index
Constructors
constructor
Properties
directionSearch playground for direction
direction
lengthSearch playground for length
length of the ray
originSearch playground for origin
origin point
Methods
cloneSearch playground for clone
Clone the current ray
Returns Ray
a new ray
intersection SegmentSearch playground for intersectionSegment
Intersection test between the ray and a given segment within a given tolerance (threshold)
Parameters
sega: DeepImmutableObject<Vector3>
the first point of the segment to test the intersection against
segb: DeepImmutableObject<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: DeepImmutableObject<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 length by design to improve perfs.
Parameters
minimum: DeepImmutableObject<Vector3>
bound of the box
maximum: DeepImmutableObject<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: DeepImmutableObject<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 intersection
intersects MeshesSearch playground for intersectsMeshes
Checks if ray intersects a mesh
Parameters
meshes: DeepImmutableObject<AbstractMesh>[]
the meshes to check
Optional fastCheck: boolean
defines if the first intersection will be used (and not the closest)
Optional results: PickingInfo[]
array to store result in
Returns PickingInfo[]
Array of picking infos
intersects PlaneSearch playground for intersectsPlane
Checks if ray intersects a plane
Parameters
plane: DeepImmutableObject<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: DeepImmutableObject<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: DeepImmutableObject<Vector3>
triangle vertex
vertex1: DeepImmutableObject<Vector3>
triangle vertex
vertex2: DeepImmutableObject<Vector3>
triangle vertex
Returns Nullable<IntersectionInfo>
intersection information if hit
unproject Ray To RefSearch playground for unprojectRayToRef
Unproject a ray from screen space to object space
Parameters
sourceX: number
defines the screen space x coordinate to use
sourceY: number
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: DeepImmutableObject<Matrix>
defines the world matrix to use (can be set to Identity to go to world space)
view: DeepImmutableObject<Matrix>
defines the view matrix to use
projection: DeepImmutableObject<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: DeepImmutableObject<Matrix>
world matrix
view: DeepImmutableObject<Matrix>
view matrix
projection: DeepImmutableObject<Matrix>
projection matrix
Optional enableDistantPicking: boolean
defines if picking should handle large values for mesh position/scaling (false by default)
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: DeepImmutableObject<Matrix>
world matrix
view: DeepImmutableObject<Matrix>
view matrix
projection: DeepImmutableObject<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: DeepImmutableObject<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: DeepImmutableObject<Ray>
ray to transform
matrix: DeepImmutableObject<Matrix>
matrix to apply
Returns Ray
the resulting new ray
Static Transform To RefSearch playground for TransformToRef
Transforms a ray by a matrix
Parameters
ray: DeepImmutableObject<Ray>
ray to transform
matrix: DeepImmutableObject<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