Constructor
new SpatialHashGrid(width, height, xGrids, yGridsopt)
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
width | Number | width of HashGrid | ||
height | Number | height of HashGrid | ||
xGrids | int | number of grid separations on the x-axis | ||
yGrids | int | <optional> | null | optional param number of grid separations on the y-axis, defaults to same as xGrids |
- Source
Methods
add(item)
Adds an item to the HashGrid.
Name | Type | Description |
---|---|---|
item | HashGridItem |
- Source
deleteItem(item)
Delete item from HashGrid.
Name | Type | Description |
---|---|---|
item | HashGridItem |
- Source
findNear(item, range) → {Array.<HashGridItem>}
Finds the nearby items for a given item, and updates the queryId.
Name | Type | Default | Description |
---|---|---|---|
item | HashGridItem | ||
range | Array.<Number> | null | optional param that overrides the |
- Source
- Type:
- Array.<HashGridItem>
updateItem(item)
Updates the grid positions of the item within the HashGrid. This function MUST be called after any position change.
Name | Type | Description |
---|---|---|
item | HashGridItem |
- Source
values() → {Array.<HashGridItem>}
Returns a unique list of all HashGridItems the HashGrid.
- Source
- Type:
- Array.<HashGridItem>