kdgrass
KDBush with flat API, which turns out to be even faster.
const kdgrass = let grass = ;let ids1 = grass; // bbox search - minX, minY, maxX, maxYlet ids2 = grass; // radius search - x, y, radius
API
let grass = kdgrass(points, nodeSize?)
Creates an index from the given points.
points
: Input array of points in[x, y, x, y, ...]
form.nodeSize
: Size of the KD-tree node,64
by default. Higher means faster indexing but slower search, and vise versa.
let index = ;
grass.range(minX, minY, maxX, maxY)
Finds all items within the given bounding box and returns an array of indices that refer to the items in the original points
input array.
let results = index;
grass.within(x, y, radius)
Finds all items within a given radius from the query point and returns an array of indices.
let results = index;