This creates a new raycaster object.
The origin vector where the ray casts from.
The direction vector that gives direction to the ray. Should be normalized.
All results returned are further away than near. Near can't be negative. Default value is 0.
All results returned are closer then far. Far can't be lower then near . Default value is Infinity.
The camera to use when raycasting against view-dependent objects such as billboarded objects like Sprites. This field can be set manually or is set when calling "setFromCamera". Defaults to null.
The far factor of the raycaster. This value indicates which objects can be discarded based on the distance. This value shouldn't be negative and should be larger than the near property.
Used by Raycaster to selectively ignore 3D objects when performing intersection tests. The following code example ensures that only 3D objects on layer 1 will be honored by the instance of Raycaster. raycaster.layers.set( 1 ); object.layers.enable( 1 );
The near factor of the raycaster. This value indicates which objects can be discarded based on the distance. This value shouldn't be negative and should be smaller than the far property.
An object with the following properties: Where threshold is the precision of the raycaster when intersecting objects, in world units.
The Ray used for the raycasting.
Checks all intersection between the ray and the object with or without the descendants. Intersections are returned sorted by distance, closest first. An array of intersections is returned... [ { distance, point, face, faceIndex, object }, ... ] distance - Second set of U,V coordinates at point of intersection instanceId – The index number of the instance where the ray intersects the InstancedMesh Raycaster delegates to the raycast method of the passed object, when evaluating whether the ray intersects the object or not. This allows meshes to respond differently to ray casting than lines and pointclouds. Note that for meshes, faces must be pointed towards the origin of the .ray in order to be detected; intersections of the ray passing through the back of a face will not be detected. To raycast against both faces of an object, you'll want to set the material's side property to THREE.DoubleSide.
The object to check for intersection with the ray.
If true, it also checks all descendants. Otherwise it only checks intersection with the object. Default is true.
target to set the result. Otherwise a new Array is instantiated. If set, you must clear this array prior to each call (i.e., array.length = 0;).
Checks all intersection between the ray and the objects with or without the descendants. Intersections are returned sorted by distance, closest first. Intersections are of the same form as those returned by .intersectObject.
The objects to check for intersection with the ray.
If true, it also checks all descendants of the objects. Otherwise it only checks intersection with the objects. Default is true.
target to set the result. Otherwise a new Array is instantiated. If set, you must clear this array prior to each call (i.e., array.length = 0;).
Generated using TypeDoc
This class is designed to assist with raycasting. Raycasting is used for mouse picking (working out what objects in the 3d space the mouse is over) amongst other things.
Examples
Raycasting to a Mesh | Raycasting to a Mesh in using an OrthographicCamera | Raycasting to a Mesh with BufferGeometry | Raycasting to a InstancedMesh | Raycasting to a Line | Raycasting to Points | Terrain raycasting | Raycasting to paint voxels | Raycast to a Texture
Code Example