blaze-2d
Version:
A fast and simple WebGL 2 2D game engine written in TypeScript
55 lines (54 loc) • 1.65 kB
TypeScript
import AABB from "./aabb";
export default class AABBNode {
/**
* An {@link AABB} containing the node's children, if the node has no children then this {@link AABB} contains the {@link CollisionObject}.
*/
aabb: AABB;
parent: AABBNode;
left: AABBNode;
right: AABBNode;
childrenCrossed: boolean;
/**
* Create a {@link AABBNode} from a {@link AABB}.
*
* @param aabb The node's AABB
*/
constructor(aabb: AABB);
/**
* Create a {@link AABBNode} from left and right child nodes.
*
* @param left The node's left child
* @param right The node's right child
* @param margin The margin to use when creating the fat AABB
*/
constructor(left: AABBNode, right: AABBNode, margin: number);
/**
* Determines wether or not this node is a leaf node.
*
* @returns Wether or not this node is a leaf node
*/
isLeaf(): boolean;
/**
* Updates the node's {@link AABB}.
*
* If the node is a leaf node the {@link AABB} is created from the current `aabb`'s `obj`.
*
* Otherwise the {@link AABB} is the union of the node's children's AABBs.
*
* @param margin The margin to use when creating the fat AABB
*/
updateAABB(margin: number): void;
/**
* Replaces one of the node's children with a new node.
*
* @param oldChild The old child to replace
* @param newChild The new child
*/
replaceChild(oldChild: AABBNode, newChild: AABBNode): void;
/**
* Gets this node's sibling.
*
* @returns this node's sibling
*/
sibling(): AABBNode | undefined;
}