Ray

Ray

A class to represent a ray.

Constructor

new Ray(originopt, directionopt)

Constructs a new ray

Parameters:
Name Type Attributes Default Description
origin Vector3 <optional>
Vector3.ZERO

Origin of the ray.

direction Vector3 <optional>
Vector3.UNIT_Z

Direction of the ray.

Methods

clone() → {Ray}

Clone the ray

copy(source)

Make the ray a copy of source

Parameters:
Name Type Description
source Ray

distanceSquared(point, storeopt) → {number}

Parameters:
Name Type Attributes Description
point Vector3

Point to be used.

store Vector3 <optional>

The closest point is stored in this param

getDistanceToPrimitive(worldVertices) → {number}

Parameters:
Name Type Description
worldVertices Array.<Vector3>

An array (size 3 or 4) of vectors describing a polygon

intersects(polygonVertices, doPlanaropt, locationStoreopt, skipBackSide) → {boolean}

Check for intersection of this ray and and a quad or triangle

Parameters:
Name Type Attributes Description
polygonVertices Array.<Vector3>

3 or 4 vector3s defining a triangle or quad

doPlanar boolean <optional>

If true, the plane defined by the shape. Otherwise, just inside the shape

locationStore Vector3 <optional>

Vector3 to store the intersection point in.

skipBackSide boolean

intersectsPlane(plane, locationStoreopt) → {boolean}

Parameters:
Name Type Attributes Description
plane Plane

Plane to be used.

locationStore Vector3 <optional>

If this ray intersects the plane, the world location of the point of intersection is stored in this vector.

intersectsTriangle(pointA, pointB, pointC, doPlanaropt, locationStoreopt, skipBackSideopt) → {boolean}

Ray vs triangle implementation.

Parameters:
Name Type Attributes Description
pointA Vector2

Triangle's first point

pointB Vector2

Triangle's second point

pointC Vector2

Triangle's third point

doPlanar boolean <optional>

If true, the plane defined by the shape. Otherwise, just inside the shape

locationStore Vector3 <optional>

Vector3 to store the intersection point in.

skipBackSide boolean <optional>