LittleJS 1.30.0

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(origin, direction)math3d.js:651

Create a ray

origin Vector3 optional
direction Vector3 optional

Defaults to -Z, forward

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

Members

Methods

Members

Which way it goes

Where the ray starts

Methods

Returns a new ray that is a copy of this

getPosition(distance) → Vector3math3d.js:669

Returns the point a distance along the ray

distance number

What the raycast helpers return