Options
All
  • Public
  • Public/Protected
  • All
Menu

Class representing a ray with position and direction

Hierarchy

  • Ray

Index

Constructors

  • Creates a new ray

    Parameters

    • origin: Vector3

      origin point

    • direction: Vector3

      direction

    • Optional length: number

      length of the ray

    Returns Ray

Properties

direction: Vector3

direction

length: number

length of the ray

origin: Vector3

origin point

Methods

  • Clone the current ray

    Returns Ray

    a new ray

  • 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

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

  • 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

  • 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

  • Checks if ray intersects a mesh. The ray is defined in WORLD space. A mesh triangle can be picked both from its front and back sides, irrespective of orientation.

    Parameters

    • mesh: DeepImmutableObject<AbstractMesh>

      the mesh to check

    • Optional fastCheck: boolean

      defines if the first intersection will be used (and not the closest)

    • Optional trianglePredicate: TrianglePickingPredicate

      defines an optional predicate used to select faces when a mesh intersection is detected

    • Optional onlyBoundingInfo: boolean

      defines a boolean indicating if picking should only happen using bounding info (false by default)

    • Optional worldToUse: Matrix

      defines the world matrix to use to get the world coordinate of the intersection point

    • Optional skipBoundingInfo: boolean

      a boolean indicating if we should skip the bounding info check

    Returns PickingInfo

    picking info of the intersection

  • 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

  • Checks if ray intersects a plane

    Parameters

    Returns Nullable<number>

    the distance away it was hit

  • 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

  • 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

  • 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

  • Creates a new ray from screen space and viewport

    Parameters

    Returns Ray

    new 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

    Returns Ray

    the new ray

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

    Returns Ray

    the new ray

Legend

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

Settings

Theme