{"id":20778165,"url":"https://github.com/stackgl/ray-aabb-intersection","last_synced_at":"2025-04-30T18:42:11.282Z","repository":{"id":66140275,"uuid":"43350131","full_name":"stackgl/ray-aabb-intersection","owner":"stackgl","description":"Determine the point of intersection between a ray and axis-aligned bounding box (AABB)","archived":false,"fork":false,"pushed_at":"2015-10-19T00:51:20.000Z","size":208,"stargazers_count":23,"open_issues_count":1,"forks_count":6,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-04-15T00:04:06.393Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://stack.gl/ray-aabb-intersection/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stackgl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-29T06:51:07.000Z","updated_at":"2024-05-08T15:25:23.000Z","dependencies_parsed_at":"2023-02-19T23:15:42.029Z","dependency_job_id":null,"html_url":"https://github.com/stackgl/ray-aabb-intersection","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackgl%2Fray-aabb-intersection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackgl%2Fray-aabb-intersection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackgl%2Fray-aabb-intersection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stackgl%2Fray-aabb-intersection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stackgl","download_url":"https://codeload.github.com/stackgl/ray-aabb-intersection/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251764457,"owners_count":21640064,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-17T13:19:41.814Z","updated_at":"2025-04-30T18:42:11.254Z","avatar_url":"https://github.com/stackgl.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ray-aabb-intersection\n\n[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)\n\nDetermine the point of intersection between a ray and axis-aligned bounding box (AABB). Theoretically works in an arbitrary number of dimensions!\n\nMany thanks to [**@BSVino**](http://github.com/BSVino) for providing the [original C++ implementation](https://github.com/BSVino/MathForGameDevelopers/blob/line-box-intersection/math/collision.cpp) and [accompanying](https://www.youtube.com/watch?v=USjbg5QXk3g) [videos](https://www.youtube.com/watch?v=3vONlLYtHUE).\n\n[**view demo**](http://stack.gl/ray-aabb-intersection/)\n\n## Usage\n\n[![NPM](https://nodei.co/npm/ray-aabb-intersection.png)](https://www.npmjs.com/package/ray-aabb-intersection)\n\n### `out = intersection(out, origin, dir, aabb)`\n\nDetermines if the given ray `(origin, direction)` intersects with the `aabb`.\n\nIf no intersection occurs, returns `null`. Otherwise, the intersection point is stored in `out` and then returned.\n\n``` javascript\nconst origin = new Float32Array([0, 4, 0])\nconst dir = new Float32Array([0, 1, 0])\nconst out = new Float32Array(3)\n\nconst aabb = [\n  [-1, -1, -1],\n  [+1, +1, +1]\n]\n\nintersection(out, origin, dir, aabb)\n```\n\n### `d = intersection.distance(origin, dir, aabb)`\n\nReturns the distance from the given ray `(origin, direction)` to the supplied `aabb`. If no intersection occurs, returns `Infinity`.\n\nNote that the `direction` vector should be normalized.\n\n## See Also\n\n* [ray-aabb](http://github.com/tmpvar/ray-aabb)\n* [ray-sphere-intersection](http://github.com/mattdesl/ray-sphere-intersection)\n* [ray-plane-intersection](http://github.com/mattdesl/ray-plane-intersection)\n* [ray-triangle-intersection](http://github.com/substack/ray-triangle-intersection)\n* [camera-picking-ray](https://github.com/Jam3/camera-picking-ray)\n\n## License\n\nMIT, see [LICENSE.md](http://github.com/stackgl/ray-aabb-intersection/blob/master/LICENSE.md) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackgl%2Fray-aabb-intersection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstackgl%2Fray-aabb-intersection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstackgl%2Fray-aabb-intersection/lists"}