mesh.raycast
Where a ray first meets the mesh, with the face it hits.
Usage
mesh.raycast(ray: Ray): MeshHit | nullParameters
rayRayOrigin and direction; the direction need not have unit length. Required. In model.
Returns
The hit (t in units of the ray direction’s length, point, face normal, face as a prim set), or null for a miss, a zero direction or a non-finite origin.
Guarantees
- hit.point equals Ray.pointAt(ray, hit.t)
- hit.face names a face of this mesh
- The same result on every machine.
Example
const hit = Mesh.box().value.raycast(Ray.of(Point3.of(0, 0, 5), Vector3.of(0, 0, -1)))
hit.t // → 4.5