API Docs for: 0.3.0
Show:

QuadTree Class

Constructor

QuadTree

(
  • An
  • pointQuad
  • maxDepth
  • maxChildren
)

Parameters:

  • An Object

    object representing the bounds of the top level of the QuadTree. The object should contain the following properties : x, y, width, height

  • pointQuad Boolean

    Whether the QuadTree will contain points (true), or items with bounds (width / height)(false). Default value is false.

  • maxDepth Number

    The maximum number of levels that the quadtree will create. Default is 4.

  • maxChildren Number

    The maximum number of children that a node can contain before it is split into sub-nodes.

Item Index

Properties

Methods

clear

()

Clears all nodes and children from the QuadTree

insert

(
  • item
)

Inserts an item into the QuadTree.

Parameters:

  • item Object | Array

    The item or Array of items to be inserted into the QuadTree. The item should expose x, y properties that represents its position in 2D space.

retrieve

(
  • item
)

Retrieves all items / points in the same node as the specified item / point. If the specified item overlaps the bounds of a node, then all children in both nodes will be returned.

Parameters:

  • item Object

    An object representing a 2D coordinate point (with x, y properties), or a shape with dimensions (x, y, width, height) properties.

Properties

root

Node

The root node of the QuadTree which covers the entire area being segmented.