{"name":"ray-3d","version":"1.0.2","description":"a high-level ray picking helper for 3D intersection","main":"index.js","license":"MIT","author":{"name":"Matt DesLauriers","email":"dave.des@gmail.com","url":"https://github.com/mattdesl"},"dependencies":{"gl-vec3":"^1.0.3","ray-plane-intersection":"^1.0.0","ray-sphere-intersection":"^1.0.0","ray-triangle-intersection":"^1.0.3"},"devDependencies":{"tape":"^4.0.0"},"scripts":{"test":"node test.js"},"keywords":["pick","picking","ray","camera","unproject","project","hit","test","collision","intersect","intersection","intersects","mouse","touch"],"repository":{"type":"git","url":"git://github.com/Jam3/ray-3d.git"},"homepage":"https://github.com/Jam3/ray-3d","bugs":{"url":"https://github.com/Jam3/ray-3d/issues"},"gitHead":"8868be5fb7993868aeb412c9ce77accd1cb12d96","_id":"ray-3d@1.0.2","_shasum":"f4815e8df63252b2271cf1b0dad259bbe30f5ffd","_from":".","_npmVersion":"2.1.18","_nodeVersion":"0.10.32","_npmUser":{"name":"mattdesl","email":"dave.des@gmail.com"},"dist":{"shasum":"f4815e8df63252b2271cf1b0dad259bbe30f5ffd","tarball":"http://registry-npm.ywwl.com/ray-3d/download/ray-3d-1.0.2.tgz","integrity":"sha512-HzBBlecS29WL+qkFZZPYUCLwWLlBWKZXZt39dXA7ifdgWjxaWeKVnEmFvkSjMvGCZoqSglkjkwyM4t5IwaY0OQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID9wfNlKalFDJ07DgJ5YAx7BgrkzcW78wD0pJFLkS1iUAiEA2pcSFFyNjD+mj6GTspeDRxXRSA4UPCatpNxaKB7wN4Q="}],"size":2574,"noattachment":false,"key":"/ray-3d/-/ray-3d-1.0.2.tgz"},"maintainers":[{"name":"mattdesl","email":"dave.des@gmail.com"}],"directories":{},"readme":"# ray-3d\n\n[![experimental](http://badges.github.io/stability-badges/dist/experimental.svg)](http://github.com/badges/stability-badges)\n\nA high-level ray picking helper for 3D intersection, built from modular pieces.\n\n```js\nvar Ray = require('ray-3d')\n\nvar ray = new Ray(origin, direction)\n\nif (ray.intersectsSphere(center, radius)) {\n  console.log(\"Hit a sphere!\")\n}\n```\n\nFeatures:\n\n- `intersectsSphere`\n- `intersectsPlane`\n- `intersectsTriangle`\n- `intersectsTriangleCell`\n- `intersectsAABB` (Axis-Aligned Bounding Box)\n\nThe API is still experimental, and missing some features:\n\n- `ray-ray-intersection`\n- `ray-mesh-intersection` (simplicial complex)\n\n## Usage\n\n[![NPM](https://nodei.co/npm/ray-3d.png)](https://www.npmjs.com/package/ray-3d)\n\n#### `ray = new Ray([origin, direction])`\n\nCreates a new `Ray` with optional `origin` and `direction`, both arrays in the form `[x, y, z]`. \n\n`origin` defaults to `[0, 0, 0]` and `direction` defaults to `[0, 0, -1]`.\n\n#### `ray.set(origin, direction)`\n\nAssigns this ray's `origin` and `direction` to the given values.\n\n#### `ray.copy(otherRay)`\n\nCopies the `origin` and `direction` from the `otherRay` into this ray.\n\n#### `otherRay = ray.clone()`\n\nDeep clones this ray into a new `Ray` instance.\n\n---\n\n### intersections\n\nAll intersection methods return the collision point `[x, y, z]` if one occurred, which is re-used across calls to avoid GC thrashing. \n\nIf no collision occurred, the methods return `null`.\n\n#### `ray.intersectsPlane(normal, distance)`\n\nWhether this ray intersects the plane with the unit `normal` [x, y, z] and `distance` from origin.\n\n#### `ray.intersectsSphere(center, radius)`\n\nWhether this ray intersects with the sphere at `center` [x, y, z] and `radius`.\n\n#### `ray.intersectsTriangle(triangle)`\n\nWhether this ray intersects with the `triangle`:\n\n```\n[ [x1, y1, z1], [x2, y2, z2], [x3, y3, z3] ]\n```\n\n#### `ray.intersectsTriangleCell(cell, positions)`\n\nWhether this ray intersects with the triangle cell, where `cell` is a face like so:\n\n```\n[ a, b, c ]\n```\n\nWhere `[ a, b, c ]` are indices into the `positions` array:\n\n```\n[ [x1, y1, z1], [x2, y2, z2] ... ]\n```\n\nThis is useful for indexed meshes and simplicial complexes like [icosphere](https://www.npmjs.com/package/icosphere).\n\n#### `ray.intersectsBox(aabb)`\n\nWhether this ray intersects with the [Axis-Aligned Bounding Box](http://www.gamasutra.com/view/feature/131833/when_two_hearts_collide_.php) `aabb`:\n\n```\n[ [x1, y1, z1], [x2, y2, z2] ]\n```\n\n## See Also\n\n- [camera-unproject](https://www.npmjs.com/package/camera-unproject)\n- [camera-project](https://www.npmjs.com/package/camera-project)\n- [camera-picking-ray](https://www.npmjs.com/package/camera-picking-ray)\n- [ray-sphere-intersection](https://www.npmjs.com/package/ray-sphere-intersection)\n- [ray-plane-intersection](https://www.npmjs.com/package/ray-plane-intersection)\n- [ray-triangle-intersection](https://www.npmjs.com/package/ray-triangle-intersection)\n- [ray-aabb-intersection](https://www.npmjs.com/package/ray-aabb-intersection)\n\n## License\n\nMIT, see [LICENSE.md](http://github.com/Jam3/ray-3d/blob/master/LICENSE.md) for details.\n","publish_time":1431710438677,"_cnpm_publish_time":1431710438677,"dist-tags":{"latest":"1.1.1"}}