Class: QNode

QNode

new QNode (bounds) → {QNode}

Default Constructor

Node System for the QNode, a QNode can have either no child nodes or 4 child nodes.

Parameters:
Name Type Description
bounds Array Max bounds of World Space
Source:
Returns:
New instance of QNode
Type
QNode

Members

this.bounds :Array

Array for the QNode's boundaries
Type:
  • Array
Source:

this.nodes :Array

Array of child nodes
Type:
  • Array
Source:

this.objects :Array

Array of objects within the quadrant
Type:
  • Array
Source:

Methods

split () → {void}

Splits up the node into 4 equally sized nodes where each node corresponds to one quadrant of the original node. All objects from the original node are then put into the new node(s).
Parameters:
Name Type Description
otherBounds Array The bounds of an Object
Source:
Returns:
Type
void

testBounds (otherBounds) → {bool}

Checks to see if the supplied otherBounds overlap with the bounds of the node that this method is called on.
Parameters:
Name Type Description
otherBounds Array The bounds of an Object
Source:
Returns:
Returns true or false
Type
bool

getQuadrants (bounds) → {quadrants}

Checks the QNode’s children (if they exist) to see which quadrants the given bounds (from an object) fall in.
Parameters:
Name Type Description
bounds Array The bounds of an Object
Source:
Returns:
Returns an array of indices of the nodes the bounds fall in [minX, minY, maxX, maxY]
Type
Array

_getObjectBounds (object) → {bounds}

Calculates the bounds of the given object since some methods in QNode needs to calculate this.
Parameters:
Name Type Description
object Object Object to calculate bounds
Source:
Returns:
Returns an array of the bounds
Type
Array