Your browser does not support HTML5 canvas. Fork me on GitHub

Available Packages:

Raycast

Source

function ray2d.castToCircle(vec2 center, real radius) returns doubleresult2d

Source

Finds the intersection point(s) of the ray and a circle. Returns tuple doubleresult2d(first, second).

function ray3d.castToDisk(vec3 center, vec3 normal, real radius) returns result3d

Source

Finds the intersection point of the ray and a plane disk where center - the center of the disk normal - a vector perpendicular to the disk's plane radius - the disk's radius Returns tuple result3d(intersects, point, distance, backface).

function ray2d.castToLine(vec2 p1, vec2 p2) returns result2d

Source

Finds the intersection point of the ray and a line defined by 2 points. Returns tuple result2d(intersects, point, distance).

function ray3d.castToPlane(vec3 point, vec3 normal) returns result3d

Source

Finds the intersection point of the ray and a plane where point - a point on the plane normal - a vector perpendicular to the plane Returns tuple result3d(intersects, point, distance, backface).

function ray2d.castToRay(vec2 origin, vec2 direction) returns result2d

Source

Finds the intersection point of the ray and another ray. Returns tuple result2d(intersects, point, distance).

function ray2d.castToSegment(vec2 p1, vec2 p2) returns result2d

Source

Finds the intersection point of the ray and a line segment defined by 2 points. Returns tuple result2d(intersects, point, distance).

function ray3d.castToSphere(vec3 center, real radius) returns doubleresult3d

Source

Finds the intersection point(s) of the ray and a sphere. Returns tuple doubleresult3d(first, second).

function ray3d.castToTriangle(vec3 p1, vec3 p2, vec3 p3) returns result3d

Source

Finds the intersection point of the ray and a triangle in 3D space defined by 3 points. Returns tuple result3d(intersects, point, distance, backface) where 'backface' depends on the order of the given points.

function doubleresult2d(result2d first, result2d second) returns doubleresult2d

Source

Double 2D intersection result. 'first' is nearest to the ray's origin.

function doubleresult3d(result3d first, result3d second) returns doubleresult3d

Source

Double 3D intersection result. 'first' is nearest to the ray's origin.

function vec2.project(ray2d ray) returns result2d

Source

Projects the point onto a ray. Returns tuple result2d(intersects, point, distance).

function vec3.project(ray3d ray) returns result3d

Source

Projects the point onto a ray. Returns tuple result3d(intersects, point, distance, backface) where 'backface' is always false.

function ray2d(vec2 origin, vec2 direction) returns ray2d

Source

An infinite 2D ray origin - the point which the ray comes from direction - directional vector

function ray3d(vec3 origin, vec3 direction) returns ray3d

Source

An infinite 3D ray origin - the point which the ray comes from direction - directional vector

function result2d(boolean intersects, vec2 point, real distance) returns result2d

Source

2D intersection result intersects - 'true' if the intersection point exists point - the intersection point or ZERO2 distance - distance between the ray's origin and the intersection point

function result3d(boolean intersects, vec3 point, real distance, boolean backface) returns result3d

Source

3D intersection result intersects - 'true' if the intersection point exists point - the intersection point or ZERO2 distance - distance between the ray's origin and the intersection point backface - `true` if the surface at the intersection point is faced away from the ray's origin