BaseQuadtree
:bounds
: RectmaxObjects
: numbermaxLevels
: numberlevel
: numbernodes
: BaseQuadtree<T>[]objects
: T[]isLeaf
(): booleanTrue if this node is a leaf node.
subdivide
() => voidSplits the node, but doesn't redistribute objects
merge
() => voidTries to merge and collapse nodes which are no longer overpopulated.
getQuadrant
(rect: Rect) =>Returns the quadrant this rect fits in or -1 if it doesn't fit any quadrant
param rect- The rect to test with.
returns The index of the quadrant fitting the rect completely, or -1 if none.
getQuadrants
(rect: Rect) => number[]Returns the quadrants this rect intersects
param rect- The rect to test with. Note that this rect is assumed to be within the node.
returns the list of quadrant indices
insert
(obj: T, bbox: Rect) => voidInserts the object with the given rectangle
param obj- The object to add
param bbox- The bounding box of the object
retrieve
(rect: Rect, retrieveCb: (obj: T) => void) => voidRetrieves all objects potentially intersecting the rectangle
param rect- The rect to test with
returns A set of objects potentially intersecting the rectangle
remove
(obj: T, fast?: boolean) => booleanRemoves the object
param obj- The object to remove
param fast- No node collapse if true
updateObject
(obj: T, bbox: Rect, fast?: boolean) => voidUpdates a single object Note that no testing is done here. Make sure the object needs to be actually updated.
param obj- The object to update
param bbox- The new bounding box
isOutside
(bbox: Rect) => booleanTrue if the rectangle is completely outside this node's bounds
param bbox- The bounding box to test
isInside
(bbox: Rect) => booleanTrue if the rectangle is completely outside this node's bounds
param bbox- The bounding box to test
clear
() => voidClears this node and collapses it
gatherPairs
(ancestorObjects: Array<T>, pairCb: (obj1: T, obj2: T) => void) => voidGathers all collision pairs in this node and child nodes
param ancestorObjects- Objects in one of the node's ancestors
param pairCb- The pairs being gathered