new Octree(x, y, z, widthX, widthY, height, maxObjects, maxLevels, level)
Octree Constructor
Parameters:
Name | Type | Argument | Default | Description |
---|---|---|---|---|
x |
number | The bottom-back coordinate of the octree. |
||
y |
number | The bottom-back coordinate of the octree. |
||
z |
number | The bottom-back coordinate of the octree. |
||
widthX |
number | The width X (breadth) of the octree. |
||
widthY |
number | The width Y (depth) of the octree. |
||
height |
number | The height (Z) of the octree. |
||
maxObjects |
number |
<optional> |
10 | The maximum number of objects per node. |
maxLevels |
number |
<optional> |
4 | The maximum number of levels to iterate to. |
level |
number |
<optional> |
0 | Which level is this? |
Members
-
bounds
-
level
-
maxLevels
-
maxObjects
-
nodes
-
objects
Methods
-
clear()
-
Clear the octree.
-
getIndex(cube) → {number}
-
Determine which node the object belongs to.
Parameters:
Name Type Description cube
Phaser.Plugin.Isometric.Cube | object The bounds in which to check.
Returns:
index - Index of the subnode (0-7), or -1 if cube cannot completely fit within a subnode and is part of the parent node.
- Type
- number
-
insert(body)
-
Insert the object into the node. If the node exceeds the capacity, it will split and add all objects to their corresponding subnodes.
Parameters:
Name Type Description body
Phaser.Plugin.Isometric.Body | Phaser.Plugin.Isometric.Cube | object The Body object to insert into the octree. Can be any object so long as it exposes x, y, z, frontX, frontY and top properties.
-
populate(group)
-
Populates this octree with the children of the given Group. In order to be added the child must exist and have a body property.
Parameters:
Name Type Description group
Phaser.Group The Group to add to the octree.
-
populateHandler(sprite)
-
Handler for the populate method.
Parameters:
Name Type Description sprite
Phaser.Plugin.Isometric.IsoSprite | object The Sprite to check.
-
reset(x, y, z, widthX, widthY, height, maxObjects, maxLevels, level)
-
Resets the QuadTree.
Parameters:
Name Type Argument Default Description x
number The bottom-back coordinate of the octree.
y
number The bottom-back coordinate of the octree.
z
number The bottom-back coordinate of the octree.
widthX
number The width X (breadth) of the octree.
widthY
number The width Y (depth) of the octree.
height
number The height (Z) of the octree.
maxObjects
number <optional>
10 The maximum number of objects per node.
maxLevels
number <optional>
4 The maximum number of levels to iterate to.
level
number <optional>
0 Which level is this?
-
retrieve(source) → {array}
-
Return all objects that could collide with the given IsoSprite or Cube.
Parameters:
Name Type Description source
Phaser.Plugin.Isometric.IsoSprite | Phaser.Plugin.Isometric.Cube The source object to check the Octree against. Either a IsoSprite or Cube.
Returns:
- Array with all detected objects.
- Type
- array
-
split()
-
Split the node into 8 subnodes