PIXI.SpatialHash

class SpatialHash

2D spatial hashing implementation that provides a mechanism to quickly searching objects intersecting a rectangle.

The spatial hash divides the world space into square "cell" or "buckets". Each display-object added is tracked by which cells they intersect with.

See: http://www.cs.ucf.edu/~jmesit/publications/scsc%202005.pdf

Constructor


new PIXI.SpatialHash(cellSize: number) → {}
Parameters:
Name Type Default Description
cellSize number 256

the size of the 2D cells in the hash

Summary


Methods from SpatialHash

this
put(object: Node, bounds)

Puts the display-object into the hash.

void
remove(object: Node)

Removes the display-object from the hash.

void
reset()

Reset and clear the spatial hash.

Set<Node>
search(bounds: PIXI.Rectangle)

Searches for all the display-objects that intersect with the given rectangle bounds.

void
update(object: Node, bounds)

Public Methods


put SpatialHash.ts:31
put(object: Node, bounds) → {this}

Puts the display-object into the hash.

Parameters:
Name Type Description
object Node
bounds

the bounds of the object. This is automatically calculated using getBounds.

Returns:
Type Description
this
remove SpatialHash.ts:55
remove(object: Node) → {void}

Removes the display-object from the hash.

Parameters:
Name Type Description
object Node
Returns:
Type Description
void
reset SpatialHash.ts:115
reset() → {void}

Reset and clear the spatial hash.

Returns:
Type Description
void
update SpatialHash.ts:68
update(object: Node, bounds) → {void}

Updates this spatial hash to account for any changes in the display-object's bounds. This is equivalent to removing & then adding the object again.

Parameters:
Name Type Description
object Node
bounds
Returns:
Type Description
void

Powered by webdoc!