new module:og/math/Ray.Ray(origin, direction)
Name | Type | Description |
---|---|---|
origin |
Vec3 | The origin of the ray. |
direction |
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
-
-
directionVec3
-
The direction of the ray.
-
originVec3
-
The origin of the ray.
Methods
-
getPoint(distance){Vec3}
-
Computes the point along the ray on the distance.
Name Type Description distance
number Point distance. Returns:
Type Description 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
Vec3 First plane point. v1
Vec3 Second plane point. v2
Vec3 Third plane point. res
Vec3 Hit point object pointer that stores hit result. Returns:
Type Description number -
hitSphere(sphere){Vec3}
-
Returns a ray hit sphere coordiante. If there isn't hit returns null.
Name Type Description sphere
Sphere Sphere object. Returns:
Type Description Vec3 -
hitTriangle(v0, v1, v2, res){number}
-
Returns ray hit a triange result.
Name Type Description v0
Vec3 First triangle corner coordinate. v1
Vec3 Second triangle corner coordinate. v2
Vec3 Third triangle corner coordinate. res
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){Ray}
-
Sets a ray parameters.
Name Type Description origin
Vec3 The origin of the ray. direction
Vec3 The direction of the ray. Returns:
Type Description Ray