intersectObject method

List<Intersection> intersectObject(
  1. Object3D object, [
  2. bool recursive = false,
  3. List<Intersection>? intersects
])

object — The object to check for intersection with the ray.

recursive — If true, it also checks all descendants. Otherwise it only checks intersection with the object. Default is true.

intersects — (optional) target to set the result. Otherwise a new List is instantiated. If set, you must clear this list prior to each call (i.e., list.length = 0;).

Checks all intersection between the ray and the object with or without the descendants. Intersections are returned sorted by distance, closest first. A list of intersections is returned...

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 DoubleSide.

Implementation

List<Intersection> intersectObject(Object3D object, [bool recursive = false, List<Intersection>? intersects]) {
  final ints = intersects ?? [];
  intersectObject4(object, this, ints, recursive);
  ints.sort(ascSort);
  return ints;
}