Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
A high-level ray picking helper for 3D intersection, built from modular pieces.
var Ray = require('ray-3d')
var ray = new Ray(origin, direction)
if (ray.intersectsSphere(center, radius)) {
console.log("Hit a sphere!")
}
Features:
intersectsSphere
intersectsPlane
intersectsTriangle
intersectsTriangleCell
intersectsAABB
(Axis-Aligned Bounding Box)The API is still experimental, and missing some features:
ray-ray-intersection
ray-mesh-intersection
(simplicial complex)ray = new Ray([origin, direction])
Creates a new Ray
with optional origin
and direction
, both arrays in the form [x, y, z]
.
origin
defaults to [0, 0, 0]
and direction
defaults to [0, 0, -1]
.
ray.set(origin, direction)
Assigns this ray's origin
and direction
to the given values.
ray.copy(otherRay)
Copies the origin
and direction
from the otherRay
into this ray.
otherRay = ray.clone()
Deep clones this ray into a new Ray
instance.
All intersection methods return the collision point [x, y, z]
if one occurred, which is re-used across calls to avoid GC thrashing.
If no collision occurred, the methods return null
.
ray.intersectsPlane(normal, distance)
Whether this ray intersects the plane with the unit normal
[x, y, z] and distance
from origin.
ray.intersectsSphere(center, radius)
Whether this ray intersects with the sphere at center
[x, y, z] and radius
.
ray.intersectsTriangle(triangle)
Whether this ray intersects with the triangle
:
[ [x1, y1, z1], [x2, y2, z2], [x3, y3, z3] ]
ray.intersectsTriangleCell(cell, positions)
Whether this ray intersects with the triangle cell, where cell
is a face like so:
[ a, b, c ]
Where [ a, b, c ]
are indices into the positions
array:
[ [x1, y1, z1], [x2, y2, z2] ... ]
This is useful for indexed meshes and simplicial complexes like icosphere.
ray.intersectsBox(aabb)
Whether this ray intersects with the Axis-Aligned Bounding Box aabb
:
[ [x1, y1, z1], [x2, y2, z2] ]
MIT, see LICENSE.md for details.
FAQs
a high-level ray picking helper for 3D intersection
The npm package ray-3d receives a total of 550 weekly downloads. As such, ray-3d popularity was classified as not popular.
We found that ray-3d demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.