Class Ray

The Ray implements a ray in 3D space represented with an origin and direction. The class follows the 'copy-on-write' pattern, which means that every operation such as Ray.multiplyScalar returns a copy of the ray with updates values. It also implies that the values of the ray cannot be directly modified.

The concept of immutability improves sharing of objects as all types in TypeScript are assigned by identity, instead of by-value (e.g. a copy) as in other programming languages like C.

Constructors

Properties

_direction: Vector3
_origin: Vector3

Accessors

  • get direction(): Vector3
  • Returns Vector3

  • set direction(value): void
  • Parameters

    Returns void

  • get origin(): Vector3
  • Returns Vector3

  • set origin(value): void
  • Parameters

    Returns void

Methods

  • Copies all properties defined by the prototype of Ray from other to this instance.

    Parameters

    Returns Ray

  • Clones this instance and returns a new Ray with identical values.

    Returns Ray

  • Transforms the ray by the specified matrix. If the matrix is affine use transformAffine as it is faster.

    Parameters

    Returns Ray

  • Transforms the ray by the specified affine matrix.

    Parameters

    Returns Ray

  • Determines if this Ray instance is equal to the other instance.

    Parameters

    Returns boolean

  • Multiplies this ray by a scalar and returns a point along the ray.

    Parameters

    • t: number

      How far along the ray to retrieve the point.

    Returns Vector3

    Point along the ray t units away from the origin.

  • Returns a string representation of an object.

    Returns string

  • Determines if both Ray instances are equal.

    Parameters

    Returns boolean

  • Multiples a ray by a scalar and retrieves a point along the ray.

    Parameters

    • ray: Immutable<Ray>

      Ray to transform.

    • t: number

      How far along the ray to retrieve the point.

    Returns Vector3

    Point along the ray t units away from the origin.

  • Transforms the ray by the specified affine matrix.

    Parameters

    Returns Ray

    The transformed Ray

  • Transforms the ray by the specified matrix. If the matrix is affine use transformAffine as it is faster.

    Parameters

    Returns Ray

    The transformed Ray