A simple 2D ennetree (3×3 spatial division) for fast, efficient spatial queries.

Ennetree split illustration

An easy way to use this within a browser is to use the built-in DOMRect class, consider:

import { ennetree, type Bounds } from '@4bitlabs/ennetree';

const rectBounds = (r: DOMRect) => [r.left, r.top, r.right, r.bottom];

const space = ennetree<DOMRect>([0, 0, 1000, 1000], rectBounds);
space.insert(new DOMRect(25, 25, 50, 50));

const matches = space.search([20, 20, 80, 80]);

ennetree

Index

Interfaces

Type Aliases

Functions