intersectObjects method

List<Intersection> intersectObjects(
  1. List<Object3D> objects,
  2. bool recursive, [
  3. List<Intersection>? intersects
])

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

recursive — If true, it also checks all descendants of the objects. Otherwise it only checks intersection with the objects. 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 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.

Implementation

List<Intersection> intersectObjects(List<Object3D> objects, bool recursive, [List<Intersection>? intersects]) {
  intersects ??= List<Intersection>.from([]);

  for (int i = 0, l = objects.length; i < l; i++) {
    intersectObject4(objects[i], this, intersects, recursive);
  }

  intersects.sort(ascSort);

  return intersects;
}