Class Ray

A ray that emits from an origin in a certain direction.

Hierarchy

  • Base
    • Ray

Constructors

  • Creates a new Ray.

    Parameters

    • Optional origin: Vector3

      (optional) the origin of the Ray. Default is a Vector3 at (0, 0, 0).

    • Optional direction: Vector3

      Vector3 The direction of the Ray. This must be normalized (with Vector3.normalize) for the methods to operate properly. Default is a Vector3 at (0, 0, -1).

    Returns Ray

Properties

direction: Vector3

The direction of the Ray. This must be normalized (with Vector3.normalize) for the methods to operate properly. Default is a Vector3 at (0, 0, -1).

origin: Vector3

The origin of the Ray. Default is a Vector3 at (0, 0, 0).

Accessors

  • get isBox2(): boolean
  • Returns boolean

  • get isBox3(): boolean
  • Returns boolean

  • get isColor(): boolean
  • Returns boolean

  • get isCylindrical(): boolean
  • Returns boolean

  • get isEuler(): boolean
  • Returns boolean

  • get isLine3(): boolean
  • Returns boolean

  • get isMatrix3(): boolean
  • Returns boolean

  • get isMatrix4(): boolean
  • Returns boolean

  • get isPlane(): boolean
  • Returns boolean

  • get isQuaternion(): boolean
  • Returns boolean

  • get isRay(): boolean
  • Read-only flag to check if a given object is of type Ray.

    Returns boolean

  • get isSphere(): boolean
  • Returns boolean

  • get isSpherical(): boolean
  • Returns boolean

  • get isTriangle(): boolean
  • Returns boolean

  • get isVector2(): boolean
  • Returns boolean

  • get isVector3(): boolean
  • Returns boolean

  • get isVector4(): boolean
  • Returns boolean

Methods

  • Transform this Ray by the Matrix4.

    Returns

    This instance

    Parameters

    • matrix4: Matrix4

      The Matrix4 to apply to this Ray.

    Returns Ray

  • Compute a Vector3 that is a given distance along this Ray.

    Returns

    The computed vector.

    Parameters

    • t: number

      the distance along the Ray to retrieve a position for.

    • Optional target: Vector3

      — (Optional) If defined, the result will be copied into this Vector3.

    Returns Vector3

  • Creates a new Ray with identical origin and direction to this one.

    Returns

    A new instance just like this ray.

    Returns Ray

  • Get the point along this Ray that is closest to the Vector3 provided.

    Returns

    The closest point.

    Parameters

    • point: Vector3

      the point to get the closest approach to.

    • Optional target: Vector3

      the result will be copied into this Vector3.

    Returns Vector3

  • Copies the origin and direction properties of ray into this ray.

    Returns

    This instance.

    Parameters

    • ray: Ray

      The source Ray to copy from.

    Returns Ray

  • Compute the squared distance of the closest approach between the Ray and the Vector3.

    Returns

    The squared distance.

    Parameters

    • point: Vector3

      The Vector3 to compute a distance to.

    Returns number

  • Get the squared distance between this Ray and a line segment.

    Returns

    Th distance squared.

    Parameters

    • v0: Vector3

      the start of the line segment.

    • v1: Vector3

      the end of the line segment.

    • optionalPointOnRay: Vector3

      (optional) if this is provided, it receives the point on this Ray that is closest to the segment.

    • optionalPointOnSegment: Vector3

      (optional) if this is provided, it receives the point on the line segment that is closest to this Ray.

    Returns number

  • Get the distance from origin to the Plane, or null if the Ray doesn't intersect the Plane.

    Returns

    The distance to the plane.

    Parameters

    • plane: Plane

      The Plane to get the distance to.

    Returns null | number

  • Compute the distance of the closest approach between the Ray and the point.

    Returns

    The distance.

    Parameters

    • point: Vector3

      Vector3 The Vector3 to compute a distance to.

    Returns number

  • Determine if this and the other ray have equal origin and direction.

    Returns

    True if equal.

    Parameters

    • ray: Ray

      The Ray to compare to.

    Returns boolean

  • Intersect this Ray with a Box.

    Returns

    The intersection point or null if there is no intersection.

    Parameters

    • box: Box3

      The Box3 to intersect with.

    • target: Vector3

      The result will be copied into this Vector3.

    Returns null | Vector3

  • Intersect this Ray with a Plane.

    Returns

    Tthe intersection point or null if there is no intersection.

    Parameters

    • plane: Plane

      the Plane to intersect with.

    • target: any

      the result will be copied into this Vector3.

    Returns null | Vector3

  • Intersect this Ray with a Sphere.

    Returns

    The intersection point or null if there is no intersection.

    Parameters

    • sphere: Sphere

      The Sphere to intersect with.

    • target: Vector3

      The result will be copied into this Vector3.

    Returns null | Vector3

  • Intersect this Ray with a triangle.

    Returns

    The intersection point or null if there is no intersection.

    Parameters

    • a: Vector3

      A Vector3 point making up the triangle.

    • b: Vector3

      A Vector3 point making up the triangle.

    • c: Vector3

      A Vector3 point making up the triangle.

    • backfaceCulling: boolean

      whether to use backface culling.

    • target: Vector3

      the result will be copied into this Vector3.

    Returns null | Vector3

  • Determine if this Ray intersects with the Box3.

    Returns

    True if this Ray intersects with the Box3.

    Parameters

    • box: Box3

      The Box3 to intersect with.

    Returns boolean

  • Determine if this Ray intersects with the Plane.

    Returns

    True if plane intersects this ray.

    Parameters

    • plane: Plane

      the Plane to intersect with.

    Returns boolean

  • Determine if this Ray intersects with the Sphere.

    Returns

    True if ray intersects the sphere.

    Parameters

    • sphere: Sphere

      the Sphere to intersect with.

    Returns boolean

  • Adjusts the direction of the ray to point at the vector in world coordinates.

    Returns

    This instance.

    Parameters

    • v: Vector3

      The Vector3 to look at.

    Returns Ray

  • Shift the origin of this Ray along its direction by the distance given.

    Returns

    This instance.

    Parameters

    • t: number

      The distance along the Ray to interpolate.

    Returns Ray

  • Sets this ray's origin and direction properties by copying the values from the given objects.

    Returns

    This instance.

    Parameters

    • origin: Vector3

      the origin of the Ray.

    • direction: Vector3

      the direction of the Ray. This must be normalized (with Vector3.normalize) for the methods to operate properly.

    Returns Ray