Ray

Description

class Ray

Constructor

new Ray(origin, direction, length)

Parameters

Name Type Description
origin Vector3
direction Vector3
optional length number

Members

origin : Vector3

direction : Vector3

length : number

Methods

intersectsBoxMinMax(minimum, maximum) boolean

Parameters

Name Type Description
minimum Vector3
maximum Vector3

intersectsBox(box) boolean

Parameters

Name Type Description
box BoundingBox

intersectsSphere(sphere) boolean

Parameters

Name Type Description
sphere BoundingSphere

intersectsTriangle(vertex0, vertex1, vertex2) Nullable<IntersectionInfo>

Parameters

Name Type Description
vertex0 Vector3
vertex1 Vector3
vertex2 Vector3

intersectsPlane(plane) Nullable<number>

Parameters

Name Type Description
plane Plane

intersectsMesh(mesh, fastCheck) PickingInfo

Parameters

Name Type Description
mesh AbstractMesh
optional fastCheck boolean

intersectsMeshes(meshes, fastCheck, results) Array<PickingInfo>

Parameters

Name Type Description
meshes Array<AbstractMesh>
optional fastCheck boolean
optional results Array<PickingInfo>

intersectionSegment(sega, segb, threshold) number

Intersection test between the ray and a given segment whithin a given tolerance (threshold)

@return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection

Parameters

Name Type Description
sega Vector3 the first point of the segment to test the intersection against
segb 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

update(x, y, viewportWidth, viewportHeight, world, view, projection) Ray

Parameters

Name Type Description
x number
y number
viewportWidth number
viewportHeight number
world Matrix
view Matrix

static Zero() Ray

static CreateNew(x, y, viewportWidth, viewportHeight, world, view, projection) Ray

Parameters

Name Type Description
x number
y number
viewportWidth number
viewportHeight number
world Matrix
view Matrix

static CreateNewFromTo(origin, end, world) Ray

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

Name Type Description
origin Vector3 The origin point
end Vector3 The end point
optional world Matrix a matrix to transform the ray to. Default is the identity matrix.

static Transform(ray, matrix) Ray

Parameters

Name Type Description
ray Ray
matrix Matrix

static TransformToRef(ray, matrix, result) void

Parameters

Name Type Description
ray Ray
matrix Matrix
result Ray