### Hierarchy

- SpatialHash

## Index

### Constructors

- constructor

### Properties

- dirtyTest
- simpleTest

### Methods

- add
- addContainer
- cull
- getAverageSize
- getBuckets
- getLargest
- getNumberOfBuckets
- getSparseness
- getWorldBounds
- insert
- invisible
- neighbors
- query
- queryCallback
- queryCallbackAll
- remove
- removeContainer
- removeFromHash
- stats
- updateObject
- updateObjects

## Constructors

### constructor

- new SpatialHash(options?: SpatialHashOptions): SpatialHash

- - Defined in code/spatial-hash.ts:66

  creates a spatial-hash cull Note, options.dirtyTest defaults to false. To greatly improve performance set to true and set displayObject.dirty=true when the displayObject changes)

  #### Parameters

  - ##### Optional options: SpatialHashOptions

  #### Returns SpatialHash

## Properties

### dirtyTest

dirtyTest: boolean = true

- Defined in code/spatial-hash.ts:51

dirtyTest toggle

### simpleTest

simpleTest: boolean = true

- Defined in code/spatial-hash.ts:48

simpleTest toggle

## Methods

### add

- add(object: DisplayObjectWithCulling, staticObject?: boolean): DisplayObjectWithCulling

- - Defined in code/spatial-hash.ts:103

  add an object to be culled side effect: adds object.spatialHashes to track existing hashes

  #### Parameters

  - ##### object: DisplayObjectWithCulling

  - ##### Optional staticObject: boolean

  #### Returns DisplayObjectWithCulling

  object

### addContainer

- addContainer(container: ContainerWithCulling, staticObject?: boolean): void

- - Defined in code/spatial-hash.ts:132

  add an array of objects to be culled

  #### Parameters

  - ##### container: ContainerWithCulling

  - ##### Optional staticObject: boolean

  #### Returns void

### cull

- cull(AABB: AABB, skipUpdate?: boolean, callback?: (object: DisplayObjectWithCulling) => boolean): number

- - Defined in code/spatial-hash.ts:180

  update the hashes and cull the items in the list

  #### Parameters

  - ##### AABB: AABB

  - ##### Optional skipUpdate: boolean

  - ##### Optional callback: (object: DisplayObjectWithCulling) => boolean

    - - (object: DisplayObjectWithCulling): boolean

      - #### Parameters

        - ##### object: DisplayObjectWithCulling

        #### Returns boolean

  #### Returns number

  number of buckets in results

### getAverageSize

- getAverageSize(): number

- - Defined in code/spatial-hash.ts:518

  helper function to evaluate hash table

  #### Returns number

  - the average number of entries in each bucket

### getBuckets

- getBuckets(minimum?: number): string[]

- - Defined in code/spatial-hash.ts:301

  returns an array of buckets with >= minimum of objects in each bucket

  #### Parameters

  - ##### minimum: number = 1

  #### Returns string[]

  array of buckets

### getLargest

- getLargest(): number

- - Defined in code/spatial-hash.ts:530

  helper function to evaluate the hash table

  #### Returns number

  - the largest sized bucket

### getNumberOfBuckets

- getNumberOfBuckets(): number

- - Defined in code/spatial-hash.ts:510

  helper function to evaluate hash table

  #### Returns number

  - the number of buckets in the hash table

### getSparseness

- getSparseness(AABB?: AABB): number

- - Defined in code/spatial-hash.ts:563

  helper function to evaluate the hash table

  #### Parameters

  - ##### Optional AABB: AABB

  #### Returns number

  - sparseness percentage (i.e., buckets with at least 1 element divided by total possible buckets)

### getWorldBounds

- getWorldBounds(): SpatialHashBounds

- - Defined in code/spatial-hash.ts:544

  gets quadrant bounds

  #### Returns SpatialHashBounds

### insert

- insert(object: DisplayObjectWithCulling, key: string): void

- - Defined in code/spatial-hash.ts:331

  insert object into the spatial hash automatically called from updateObject()

  #### Parameters

  - ##### object: DisplayObjectWithCulling

  - ##### key: string

  #### Returns void

### invisible

- invisible(): void

- - Defined in code/spatial-hash.ts:198

  set all objects in hash to visible=false

  #### Returns void

### neighbors

- neighbors(object: DisplayObjectWithCulling): DisplayObjectWithCulling[]

- - Defined in code/spatial-hash.ts:359

  get all neighbors that share the same hash as object

  #### Parameters

  - ##### object: DisplayObjectWithCulling

    in the spatial hash

  #### Returns DisplayObjectWithCulling[]

  - of objects that are in the same hash as object

### query

- query(AABB: AABB, simpleTest?: boolean): DisplayObjectWithCulling[]

- - Defined in code/spatial-hash.ts:371

  returns an array of objects contained within bounding box

  #### Parameters

  - ##### AABB: AABB

    bounding box to search

  - ##### simpleTest: boolean = true

  #### Returns DisplayObjectWithCulling[]

  - search results

### queryCallback

- queryCallback(AABB: AABB, callback: (object: DisplayObjectWithCulling) => boolean, simpleTest?: boolean): boolean

- - Defined in code/spatial-hash.ts:450

  iterates through objects contained within bounding box stops iterating if the callback returns true

  #### Parameters

  - ##### AABB: AABB

    bounding box to search

  - ##### callback: (object: DisplayObjectWithCulling) => boolean

    - - (object: DisplayObjectWithCulling): boolean

      - #### Parameters

        - ##### object: DisplayObjectWithCulling

        #### Returns boolean

  - ##### simpleTest: boolean = true

  #### Returns boolean

  - true if callback returned early

### queryCallbackAll

- queryCallbackAll(AABB: AABB, simpleTest?: boolean, callback: (object: DisplayObjectWithCulling) => boolean): DisplayObjectWithCulling[]

- - Defined in code/spatial-hash.ts:409

  returns an array of objects contained within bounding box with a callback on each non-culled object this function is different from queryCallback, which cancels the query when a callback returns true

  #### Parameters

  - ##### AABB: AABB

    bounding box to search

  - ##### simpleTest: boolean = true

  - ##### callback: (object: DisplayObjectWithCulling) => boolean

    function to run for each non-culled object

    - - (object: DisplayObjectWithCulling): boolean

      - #### Parameters

        - ##### object: DisplayObjectWithCulling

        #### Returns boolean

  #### Returns DisplayObjectWithCulling[]

  - search results

### remove

- remove(object: DisplayObjectWithCulling): DisplayObjectWithCulling

- - Defined in code/spatial-hash.ts:121

  remove an object added by add()

  #### Parameters

  - ##### object: DisplayObjectWithCulling

  #### Returns DisplayObjectWithCulling

  object

### removeContainer

- removeContainer(container: ContainerWithCulling): ContainerWithCulling

- - Defined in code/spatial-hash.ts:164

  remove an array added by addContainer()

  #### Parameters

  - ##### container: ContainerWithCulling

  #### Returns ContainerWithCulling

  container

### removeFromHash

- removeFromHash(object: DisplayObjectWithCulling): void

- - Defined in code/spatial-hash.ts:345

  removes object from the hash table should be called when removing an object automatically called from updateObject()

  #### Parameters

  - ##### object: DisplayObjectWithCulling

  #### Returns void

### stats

- stats(): SpatialHashStats

- - Defined in code/spatial-hash.ts:482

  Get stats

  #### Returns SpatialHashStats

### updateObject

- updateObject(object: DisplayObjectWithCulling): void

- - Defined in code/spatial-hash.ts:261

  update the has of an object automatically called from updateObjects()

  #### Parameters

  - ##### object: DisplayObjectWithCulling

  #### Returns void

### updateObjects

- updateObjects(): void

- - Defined in code/spatial-hash.ts:215

  update the hashes for all objects automatically called from update() when skipUpdate=false

  #### Returns void

Generated using TypeDoc