Math3D. Ray3D

Ray3D - A start point and a direction, what screenToRay returns and the raycast helpers take

  • The direction need not be unit length, the distances that come back are in units of it

Constructor

new Ray3D(originopt, directionopt)

Create a ray

Parameters:
NameTypeAttributesDescription
originVector3<optional>
directionVector3<optional>

Defaults to -Z, forward

Example
const ray = render3D.screenToRay(mousePosScreen);
const distance = raycastPlane(ray, vec3(), vec3(0, 1, 0));
if (distance !== undefined)
    ball.pos3D = ray.getPosition(distance);

Members

direction

Properties
TypeDescription
Vector3

Which way it goes

origin

Properties
TypeDescription
Vector3

Where the ray starts

Methods

copy() → {Ray3D}

Returns a new ray that is a copy of this

Returns:
Type: 
Ray3D

getPosition(distance) → {Vector3}

Returns the point a distance along the ray

Parameters:
NameTypeDescription
distancenumber

What the raycast helpers return

Returns:
Type: 
Vector3