Class ThreeSpatialHashGrid

A spatial hash is a 2 or 3 dimensional extension of the hash table. The basic idea of a hash table is that you take a piece of data (the 'key'), run it through some function (the 'hash function') to produce a new value (the 'hash'), and then use the hash as an index into a set of slots ('cells').

Author

André Wisén

Copyright

MIT

Hierarchy

Constructors

  • Create a SpatialHashGrid object using a fixed sized grid.

    Parameters

    • bounds: Bounds

      The min/max the grid will operate on. I.e. if the world goes from -1000, -1000 to 1000, 1000, then this should be [-1000, -1000], [1000, 1000].

    • dimensions: Vector2

      How many cells along each dimensional axis. I.e. if the world is 100 units wide and we have 5 cells, then each cell will span 100/5=20 units.

    • debug: boolean = false

    Returns ThreeSpatialHashGrid

Properties

clients: Client[]

Clients in the grid.

group: Group

Add the group to the scene if you want to display debug information.

Methods

  • Calculate the bounding box of the object.

    Parameters

    • object: Object3D<Event>

    Returns Box3

  • Create a THREE.GridHelper | GridHelper to display the grid.

    Parameters

    • bounds: Bounds

      The min/max the grid will operate on. I.e. if the world goes from -1000, -1000 to 1000, 1000, then this should be [-1000, -1000], [1000, 1000].

    Returns void

  • Get nearby objects.

    Parameters

    • position: Vector3

      World position of the lookup.

    • bounds: Vector2

      Bounds of the lookup

    Returns Client[]

    Array of nearby clients (!). Not objects.

Generated using TypeDoc