Class: Ray

og.math.Ray

new og.math.Ray(origin, direction)

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

Members

static,constantog.math.Ray.AWAY

static,constantog.math.Ray.INPLANE

static,constantog.math.Ray.INSIDE

static,constantog.math.Ray.OUTSIDE

directionog.math.Vector3

The direction of the ray.
The origin of the ray.

Methods

getPoint(distance){og.math.Vector3}

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

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

Gets a ray hit a plane result. If the ray cross the plane returns 1 - og.math.Ray.INSIDE otherwise returns 0 - og.math.Ray.OUTSIDE.
Name Type Description
v0 og.math.Vector3 First plane point.
v1 og.math.Vector3 Second plane point.
v2 og.math.Vector3 Third plane point.
res og.math.Vector3 Hit point object pointer that stores hit result.
Returns:
Type Description
number
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.math.Vector3

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

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

set(origin, direction){og.math.Ray}

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