Skip to content

Raycaster

new Raycaster(origin?: Vector3, direction?: Vector3, near?: number, far?: number)

THREE equivalent: THREE.Raycaster

Casts a ray through the scene and collects intersections with Mesh, Line, LineSegments, LineLoop, and Points objects.

Name Type Description
ray Ray The underlying Ray (origin + direction).
near number Minimum intersection distance. Default 0.
far number Maximum intersection distance. Default Infinity.
threshold number Distance tolerance for Line and Points intersection tests. Default 1.
camera Camera|undefined Camera used by setFromCamera.
layers Layers Restricts which scene objects are tested.
Method Description
set(origin: Vector3, direction: Vector3): this Manually sets the ray origin and direction.
setFromCamera(coords: { x: number, y: number }, camera: Camera): this Builds the ray from NDC coordinates [-1, 1] and a camera.
intersectObject(object: Node, recursive?: boolean, intersects?: Intersection[]): Intersection[] Tests one object (and optionally its subtree) against the ray. Returns intersections sorted by distance.
intersectObjects(objects: Node[], recursive?: boolean, intersects?: Intersection[]): Intersection[] Tests an array of objects. Returns all intersections sorted by distance.