diff --git a/index.js b/index.js index 0d519a4..5f2bd1f 100644 --- a/index.js +++ b/index.js @@ -12,7 +12,7 @@ const canvasBound = new BoundingBox( ) const bound = new BoundingBox(0, 0, renderer.width + 20, renderer.height + 20) const quadtree = new QuadTree(bound, 3); -const aabbtree = new AabbTree(new Vector2(15, 15)) +const aabbtree = new AabbTree() const GRID_NUMBER = 20 const grid = new HashGrid( renderer.width / GRID_NUMBER, renderer.height / GRID_NUMBER, diff --git a/src/aabbtree.js b/src/aabbtree.js index 9977bdb..41631a6 100644 --- a/src/aabbtree.js +++ b/src/aabbtree.js @@ -50,13 +50,9 @@ export class AabbTree { */ _pool = new Pool(0, () => new AabbTreeNode()) /** - * - * @param {Vector2} padding + * @type {AabbTreeNode | null} */ - constructor(padding = new Vector2(0, 0)) { - this.root = null - this.padding = padding - } + root = null /** * @private * @param {AabbTreeNode |null} node @@ -140,9 +136,6 @@ export class AabbTree { client.node = node node.bounds.copy(bound) - Vector2.prototype.sub.call(node.bounds.min, this.padding) - Vector2.prototype.add.call(node.bounds.max, this.padding) - if (!this.root) { this.root = node return true