DynamicTree <T>
Index
Constructors
Properties
Methods
Constructors
constructor
Type parameters
- T: ColliderProxy<Entity<any>>
Parameters
_config: Required<{ boundsPadding?: number; velocityMultiplier?: number }>
worldBounds: BoundingBox = ...
Returns DynamicTree<T>
Properties
publicnodes
Type declaration
[key number]: TreeNode<T>
publicroot
publicworldBounds
Methods
publicdebug
Parameters
Returns void
publicgetHeight
Returns the internal height of the tree, shorter trees are better. Performance drops as the tree grows
Returns number
publicgetNodes
Returns TreeNode<T>[]
publicquery
Queries the Dynamic Axis Aligned Tree for bodies that could be colliding with the provided body.
In the query callback, it will be passed a potential collider. Returning true from this callback indicates that you are complete with your query and you do not want to continue. Returning false will continue searching the tree until all possible colliders have been returned.
Parameters
collider: T
callback: (other: T) => boolean
Returns void
publicrayCastQuery
Queries the Dynamic Axis Aligned Tree for bodies that could be intersecting. By default the raycast query uses an infinitely long ray to test the tree specified by
max
.In the query callback, it will be passed a potential body that intersects with the raycast. Returning true from this callback indicates that your are complete with your query and do not want to continue. Return false will continue searching the tree until all possible bodies that would intersect with the ray have been returned.
Parameters
ray: Ray
max: number = Infinity
callback: (other: T) => boolean
Returns void
publictrackCollider
Tracks a body in the dynamic tree
Parameters
collider: T
Returns void
publicuntrackCollider
Untracks a body from the dynamic tree
Parameters
collider: T
Returns void
publicupdateCollider
Updates the dynamic tree given the current bounds of each body being tracked
Parameters
collider: T
Returns boolean
The DynamicTrees provides a spatial partitioning data structure for quickly querying for overlapping bounding boxes for all tracked bodies. The worst case performance of this is O(n*log(n)) where n is the number of bodies in the tree.
Internally the bounding boxes are organized as a balanced binary tree of bounding boxes, where the leaf nodes are tracked bodies. Every non-leaf node is a bounding box that contains child bounding boxes.