-
Notifications
You must be signed in to change notification settings - Fork 3
jsBVH.search()
jsBVH.search ( options )
intervals1 : required : An array. Each entry is a pair of numbers representing the interval along a single dimension in the tree.
return_nodes : optional : A boolean. Defaults to false. Set to true to return an array of leaf nodes instead of an array of the objects contained within the leaf nodes.
return_array : optional : An array. Defaults to an empty array. The search function will append any objects found to this array.
comparators : options : An object. Defaults to { overlap_intervals: jsBVH.Interval.overlap_intervals, contains_intervals: jsBVH.Interval.contains_intervals } . Use this to override the default comparators to implement different search geometries. Default geometries is an n-dimensional “cube”.
An array of objects that overlap or touch area.
Search a 10×15 area that starts at position 12×23 in a 2-dimensional BVH:
var myObjects = myBVH.search( { intervals: [{a:12, b:10}, {a:23, b:15}] });
1 Intervals are any array with length equal to the number of dimensions that contains object literals with two values {a, b}. The object itself is not saved or used directly but a copy is made.
Examples:
1-D:
Intervals = [{a,b}];
2-D:
Intervals = [{a,b},{a,b}];
3-D:
Intervals = [{a,b},{a,b},{a,b}];