Ray

Class representing a ray with position and direction

Hierarchy

  • Ray

Index

Constructors

constructor

Find examples in Playground
  • Creates a new ray

    Parameters

    • origin: Vector3

      origin point

    • direction: Vector3

      direction

    • Optional length: number

      length of the ray

    Returns Ray

Properties

direction

Find examples in Playground
direction: Vector3

direction

length

Find examples in Playground
length: number

length of the ray

origin

Find examples in Playground
origin: Vector3

origin point

Methods

intersectionSegment

Find examples in Playground
  • intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number
  • Intersection test between the ray and a given segment whithin a given tolerance (threshold)

    Parameters

    • 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

    Returns number

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

intersectsBox

Find examples in Playground
  • Checks if the ray intersects a box

    Parameters

    Returns boolean

    if the box was hit

intersectsBoxMinMax

Find examples in Playground
  • Checks if the ray intersects a box

    Parameters

    Returns boolean

    if the box was hit

intersectsMesh

Find examples in Playground
  • Checks if ray intersects a mesh

    Parameters

    • mesh: AbstractMesh

      the mesh to check

    • Optional fastCheck: boolean

      if only the bounding box should checked

    Returns PickingInfo

    picking info of the intersecton

intersectsMeshes

Find examples in Playground
  • Checks if ray intersects a mesh

    Parameters

    • meshes: Array<AbstractMesh>

      the meshes to check

    • Optional fastCheck: boolean

      if only the bounding box should checked

    • Optional results: Array<PickingInfo>

      array to store result in

    Returns Array<PickingInfo>

    Array of picking infos

intersectsPlane

Find examples in Playground
  • Checks if ray intersects a plane

    Parameters

    • plane: Plane

      the plane to check

    Returns Nullable<number>

    the distance away it was hit

intersectsSphere

Find examples in Playground
  • If the ray hits a sphere

    Parameters

    Returns boolean

    true if it hits the sphere

intersectsTriangle

Find examples in Playground
  • If the ray hits a triange

    Parameters

    Returns Nullable<IntersectionInfo>

    intersection information if hit

update

Find examples in Playground
  • update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray
  • Update the ray from viewport position

    Parameters

    • x: number

      position

    • y: number

      y position

    • viewportWidth: number

      viewport width

    • viewportHeight: number

      viewport height

    • world: Matrix

      world matrix

    • view: Matrix

      view matrix

    • projection: Matrix

      projection matrix

    Returns Ray

    this ray updated

Static CreateNew

Find examples in Playground
  • CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray
  • 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: Matrix

      world matrix

    • view: Matrix

      view matrix

    • projection: Matrix

      projection matrix

    Returns Ray

    new ray

Static CreateNewFromTo

Find examples in Playground
  • 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: Matrix

      a matrix to transform the ray to. Default is the identity matrix.

    Returns Ray

    the new ray

Static Transform

Find examples in Playground
  • Transforms a ray by a matrix

    Parameters

    • ray: Ray

      ray to transform

    • matrix: Matrix

      matrix to apply

    Returns Ray

    the resulting new ray

Static TransformToRef

Find examples in Playground
  • TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void
  • Transforms a ray by a matrix

    Parameters

    • ray: Ray

      ray to transform

    • matrix: Matrix

      matrix to apply

    • result: Ray

      ray to store result in

    Returns void

Static Zero

Find examples in Playground
  • Creates a ray with origin and direction of 0,0,0

    Returns Ray

    the new ray

Generated using TypeDoc