Class: Ray

og/math/Ray~Ray

new Ray(origin, direction)

Represents a ray that extends infinitely from the provided origin in the provided direction.
Name Type Description
origin og.Vec3 The origin of the ray.
direction og.Vec3 The direction of the ray.

Members

static,constantmodule:og/math/Ray~Ray.AWAY

static,constantmodule:og/math/Ray~Ray.INPLANE

static,constantmodule:og/math/Ray~Ray.INSIDE

static,constantmodule:og/math/Ray~Ray.OUTSIDE

directionog.Vec3

The direction of the ray.

originog.Vec3

The origin of the ray.

Methods

getPoint(distance){og.Vec3}

Computes the point along the ray on the distance.
Name Type Description
distance number Point distance.
Returns:
Type Description
og.Vec3

hitPlane(v0, v1, v2, res){number}

Gets a ray hit a plane result. If the ray cross the plane returns 1 - og.Ray.INSIDE otherwise returns 0 - og.Ray.OUTSIDE.
Name Type Description
v0 og.Vec3 First plane point.
v1 og.Vec3 Second plane point.
v2 og.Vec3 Third plane point.
res og.Vec3 Hit point object pointer that stores hit result.
Returns:
Type Description
number

hitSphere(sphere){og.Vec3}

Returns a ray hit sphere coordiante. If there isn't hit returns null.
Name Type Description
sphere og.bv.Sphere Sphere object.
Returns:
Type Description
og.Vec3

hitTriangle(v0, v1, v2, res){number}

Returns ray hit a triange result.
Name Type Description
v0 og.Vec3 First triangle corner coordinate.
v1 og.Vec3 Second triangle corner coordinate.
v2 og.Vec3 Third triangle corner coordinate.
res og.Vec3 Hit point object pointer that stores hit result.
Returns:
Type Description
number - Hit code, could 0 - og.Ray.OUTSIDE, 1 - og.Ray.INSIDE, 2 - og.Ray.INPLANE and 3 - og.Ray.AWAY(ray goes away from triangle).

set(origin, direction){og.Ray}

Sets a ray parameters.
Name Type Description
origin og.Vec3 The origin of the ray.
direction og.Vec3 The direction of the ray.
Returns:
Type Description
og.Ray