API reference

Every public class, method, and event in @codexo/exojs. Generated from source.

C

classQuadtree

@codexo/exojs / math / stable

Generic recursive spatial index used by the engine's `InteractionSystem` to accelerate per-frame hit-testing of scene nodes. Items are inserted with their axis-aligned bounding box; the tree automatically subdivides into four quadrants (NW/NE/SW/SE) when a node accumulates more than `maxItems` entries and the current depth is below `maxDepth`. Items that span multiple quadrants are kept at the current node rather than duplicated. The tree is persistent: `insert` and `remove` modify the tree in place without full rebuilds. Call `clear()` for bulk reset, or `destroy()` to release all memory including child rectangles.

0
props
6
methods
0
events
Import
import { Quadtree } from '@codexo/exojs'

Generic recursive spatial index used by the engine's `InteractionSystem` to accelerate per-frame hit-testing of scene nodes.

Items are inserted with their axis-aligned bounding box; the tree automatically subdivides into four quadrants (NW/NE/SW/SE) when a node accumulates more than `maxItems` entries and the current depth is below `maxDepth`. Items that span multiple quadrants are kept at the current node rather than duplicated.

The tree is persistent: `insert` and `remove` modify the tree in place without full rebuilds. Call `clear()` for bulk reset, or `destroy()` to release all memory including child rectangles.

Constructors1
Methods6
clear(): void
Remove all items and collapse all child nodes. Child Quadtree instances are retained but reset.
destroy(): void
Insert item into the tree. If this node is full and below maxDepth, it subdivides first. Items whose bounds span multiple child quadrants are stored at the current node to avoid duplication.
Returns all items whose bounds contain the point (x, y). The optional results parameter allows callers to provide a pre-allocated array that will be reused across calls. The array is **appended to** (not replaced), so callers should reset it (e.g. buf.length = 0) before passing it in when a fresh result set is needed. The same array reference is returned. Omitting results allocates a new array on every call. For hot paths (e.g. per-frame hit-testing) prefer passing a persistent buffer to avoid allocation pressure.
Remove the first occurrence of item from this subtree by object identity. Returns true if the item was found and removed, false otherwise. This is an O(n) walk of every node in the affected subtree; prefer clear() for bulk removal.
Source