dot big bang

Developer API
Menu

Class Ray

All
  • Public
  • Public/Protected
  • All

Hierarchy

  • Ray

Index

Constructors

constructor

  • Creates a new Ray.

    Parameters

    • Optional origin: Vector3

      The origin of the ray. Default is (0, 0, 0).

    • Optional direction: Vector3

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

    Returns Ray

Properties

direction

direction: Vector3

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

origin

origin: Vector3

The origin of the ray.

Methods

applyMatrix4

  • Transform this ray by the provided matrix.

    Parameters

    Returns Ray

at

  • Gets the point along this ray that is t units away from its origin.

    Parameters

    • t: number

      The distance along the ray to retrieve a position for.

    • Optional optionalTarget: Vector3

      The result will be copied into this Vector3.

    Returns Vector3

clone

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

    Returns Ray

closestPointToPoint

  • Gets the point along this ray that is closest to the provided point.

    Parameters

    • point: Vector3

      The point to get the closest approach to.

    • Optional optionalTarget: Vector3

      The result will be copied into this Vector3.

    Returns Vector3

copy

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

    Parameters

    Returns Ray

distanceSqToPoint

  • distanceSqToPoint(point: Vector3): number
  • Gets the squared distance of the closest approach between this ray and the provided point.

    Parameters

    • point: Vector3

      The point to compute the squared distance to.

    Returns number

distanceSqToSegment

  • Gets the squared distance between this ray and a line segment expressed as a pair of points v0 and v1.

    Parameters

    • v0: Vector3

      The start of the line segment.

    • v1: Vector3

      The end of the line segment.

    • Optional optionalPointOnRay: Vector3

      If this is provided, it receives the point on this ray that is closest to the segment.

    • Optional optionalPointOnSegment: Vector3

      if this is provided, it receives the point on the line segment that is closest to this ray.

    Returns number

distanceToPlane

  • distanceToPlane(plane: Plane): number
  • Get the distance from this ray's origin to the plane, or null if this ray doesn't intersect the plane.

    Parameters

    • plane: Plane

      The plane to get the distance to.

    Returns number

distanceToPoint

  • distanceToPoint(point: Vector3): number
  • Gets the distance of the closest approach between this ray and the provided point.

    Parameters

    • point: Vector3

      The point to compute the distance to.

    Returns number

equals

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

    Parameters

    • ray: Ray

      The ray to compare this one to.

    Returns Ray

intersectBox

  • Intersect this ray with box, returning the intersection point or null if there is no intersection.

    Parameters

    • box: Box3

      The box to intersect with.

    • Optional optionalTarget: Vector3

      The result will be copied into this Vector3.

    Returns Vector3

intersectPlane

  • Intersect this ray with plane, returning the intersection point or null if there is no intersection.

    Parameters

    • plane: Plane

      The plane to intersect with.

    • Optional optionalTarget: Vector3

      The result will be copied into this Vector3.

    Returns Vector3

intersectSphere

  • Intersect this ray with sphere, returning the intersection point or null if there is no intersection.

    Parameters

    • sphere: Sphere

      The sphere to intersect with.

    • Optional optionalTarget: Vector3

      The result will be copied into this Vector3.

    Returns Vector3

intersectTriangle

  • Intersect this ray with the triangle expressed with the triplet of points a, b and c, returning the intersection point or null if there is no intersection.

    Parameters

    • a: Vector3

      The first point making up the triangle.

    • b: Vector3

      The second point making up the triangle.

    • c: Vector3

      The third point making up the triangle.

    • backfaceCulling: boolean

      Whether to use backface culling.

    • Optional optionalTarget: Vector3

      The result will be copied into this Vector3.

    Returns Vector3

intersectsBox

  • intersectsBox(box: Box3): boolean
  • Return true if this ray intersects with the box.

    Parameters

    • box: Box3

      The box to intersect with.

    Returns boolean

intersectsPlane

  • intersectsPlane(plane: Plane): boolean
  • Return true if this ray intersects with the plane.

    Parameters

    • plane: Plane

      The plane to intersect with.

    Returns boolean

intersectsSphere

  • intersectsSphere(sphere: Sphere): boolean
  • Return true if this ray intersects with the sphere.

    Parameters

    • sphere: Sphere

      The sphere to intersect with.

    Returns boolean

lookAt

  • Adjusts the direction of this ray to point to the point v. This ray's origin is unaffected.

    Parameters

    Returns Ray

recast

  • recast(t: number): Ray
  • Shift the origin of this ray along its direction by the given distance (from the current origin).

    Parameters

    • t: number

      The distance along the ray to move the origin.

    Returns Ray

set

  • Sets this ray's origin and direction to the provided ones.

    Parameters

    • origin: Vector3

      The origin of the ray.

    • direction: Vector3

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

    Returns Ray