ray-aabb-slab
Find the intersection between a ray and an axis-aligned bounding box (AABB) in 2 or 3 dimensional space.
ported from https://tavianator.com/fast-branchless-raybounding-box-intersections/
install
npm install ray-aabb-slab
use
var isect = // the origin of the rayvar origin = -10 0 0; // the direction of the rayvar direction = 1 0 0; // inverted directionvar idir = 10 / direction0 10 / direction1 10 / direction2; // aabbvar aabb = -1 -1 -1 1 1 1; // will contain the entry/exit `t` values if there is an intersectionvar out = 0 0; if console; console /* outputs:entry -1 0 0exit 1 0 0*/