Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
@4bitlabs/quadtree
Advanced tools
A simple 2D quadtree (2×2 spatial division) for fast, efficient spatial queries
@4bitlabs/quadtree
A simple 2D quadtree (2×2 spatial division) for fast, efficient spatial queries.
$ npm install --save @4bitlabs/quadtree
$ yarn add @4bitlabs/quadtree
$ pnpm add @4bitlabs/quadtree
Full documentation for the library can be found here
An easy way to use this within a browser is to use the built-in DOMRect
class, consider:
import { quadtree, type Bounds } from '@4bitlabs/quadtree';
const rectBounds = (r: DOMRect) => [r.left, r.top, r.right, r.bottom];
const space = quadtree<DOMRect>([0, 0, 1000, 1000], rectBounds);
space.insert(new DOMRect(25, 25, 50, 50));
const matches = space.search([20, 20, 80, 80]);
Or with custom objects:
import { quadtree, type Bounds } from '@4bitlabs/quadtree';
class Shape {
bounds(): Bounds {
/* TODO implement return bounds */
return [0, 0, 0, 0];
}
}
const space = quadtree<Shape>([0, 0, 1000, 1000], Shape.prototype.bounds);
space.insert(new Shape());
const matches = space.search([20, 20, 80, 80]);
quadtree()
accept a third argument of options
:
option | Description | Defaults |
---|---|---|
maxDepth | The maximum depth/subdivisions that the graph will divide. | 7 |
maxChildren | The maximum number of objects in a node before it will split | 10 |
const space = quadtree<DOMRect>([0, 0, 1000, 1000], rectBounds, {
maxDepth: 5,
maxChildren: 50,
});
FAQs
A simple 2D quadtree (2×2 spatial division) for fast, efficient spatial queries
The npm package @4bitlabs/quadtree receives a total of 10 weekly downloads. As such, @4bitlabs/quadtree popularity was classified as not popular.
We found that @4bitlabs/quadtree demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.