Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Ray

Class representing a ray with position and direction

Hierarchy

  • Ray

Index

Constructors

constructor

  • Creates a new ray

    Parameters

    • origin: Vector3

      origin point

    • direction: Vector3

      direction

    • Optional length: number

      length of the ray

    Returns Ray

Properties

directionSearch playground for direction

direction: Vector3

direction

lengthSearch playground for length

length: number

length of the ray

originSearch playground for origin

origin: Vector3

origin point

Methods

cloneSearch playground for clone

  • Clone the current ray

    Returns Ray

    a new ray

intersectionSegmentSearch playground for intersectionSegment

  • Intersection test between the ray and a given segment within 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

intersectsAxisSearch 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.

intersectsBoxSearch 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

intersectsBoxMinMaxSearch playground for intersectsBoxMinMax

  • Checks if the ray intersects a box This does not account for the ray length by design to improve perfs.

    Parameters

    Returns boolean

    if the box was hit

intersectsMeshSearch 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 intersection

intersectsMeshesSearch 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

intersectsPlaneSearch playground for intersectsPlane

  • Checks if ray intersects a plane

    Parameters

    Returns Nullable<number>

    the distance away it was hit

intersectsSphereSearch 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

intersectsTriangleSearch playground for intersectsTriangle

unprojectRayToRefSearch 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

    • Optional enableDistantPicking: boolean

      defines if picking should handle large values for mesh position/scaling (false by default)

    Returns Ray

    this ray updated

Static CreateNewSearch playground for CreateNew

  • Creates a new ray from screen space and viewport

    Parameters

    Returns Ray

    new ray

Static CreateNewFromToSearch 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

    Returns Ray

    the resulting new ray

Static TransformToRefSearch playground for TransformToRef

  • Transforms a ray by a matrix

    Parameters

    Returns void

Static ZeroSearch playground for Zero

  • Creates a ray with origin and direction of 0,0,0

    Returns Ray

    the new ray

Legend

  • Constructor
  • Property
  • Method
  • Property
  • Method
  • Inherited property
  • Inherited method
  • Static property
  • Static method