new TopDownBVHNode(parent, objects)
Node of a top down BVH.
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
parent |
Grape2D.TopDownBVHNode |
<nullable> |
Parent node, or null, it it's the root node. |
objects |
!Array.<Grape2D.Object2D> | Objects to be added to the node. |
- Source:
Members
-
<private> bv :Grape2D.Shape
-
Bounding volume.
Type:
- Source:
-
<private> depth :number
-
Depth of the current node.
Type:
- number
- Source:
-
<private> leaf :boolean
-
True if it's a leaf (end point of a tree), false if it's a node.
Type:
- boolean
- Source:
-
<private> left :Grape2D.TopDownBVHNode
-
Left child of a node.
Type:
- Source:
-
<private> objects :!Array.<Grape2D.Object2D>
-
Objects of a leaf.
Type:
- !Array.<Grape2D.Object2D>
- Source:
-
<private> parent :Grape2D.TopDownBVHNode
-
Parent node.
Type:
- Source:
-
<private> right :Grape2D.TopDownBVHNode
-
Right child of a node.
Type:
- Source:
Methods
-
compute(objects)
-
Makes this instance a leaf or a node.
Parameters:
Name Type Description objects
!Array.<Grape2D.Object2D> List of objects to separate through the node. - Source:
-
getBoundingVolume() → {Grape2D.Shape}
-
Gets the bounding volume.
- Source:
Returns:
The bounding volume.- Type
- Grape2D.Shape
-
getDepth() → {number}
-
Gets the depth of the node, in the context of the tree.
- Source:
Returns:
Depth of the node.- Type
- number
-
getLeft() → {Grape2D.TopDownBVHNode}
-
Gets the left side of the node.
- Source:
Returns:
Left side node, or null, if it's a leaf. -
getObjects() → {!Array.<Grape2D.Object2D>}
-
Gets the objects, if it's a leaf.
- Source:
Returns:
List of the objects.- Type
- !Array.<Grape2D.Object2D>
-
getParent() → {Grape2D.TopDownBVHNode}
-
Gets the parent.
- Source:
Returns:
The parent, or null if it's the root. -
getRight() → {Grape2D.TopDownBVHNode}
-
Gets the right side of the node.
- Source:
Returns:
Right side node, or null, if it's a leaf. -
isLeaf() → {boolean}
-
Checks if it's a leaf
- Source:
Returns:
True if it's a leaf.- Type
- boolean
-
query(shape) → {!Array.<Grape2D.Object2D>}
-
Queries a shape or a point to find if it is colliding. If so, returns the Grape2D.Object2D that are colliding with the shape.
Parameters:
Name Type Description shape
Grape2D.Shape | Grape2D.Vector Shape of to query. - Source:
Returns:
Objects that are colliding with the shape.- Type
- !Array.<Grape2D.Object2D>