| 1 | import Quad from "./quad.js";
|
|---|
| 2 |
|
|---|
| 3 | export default function(callback) {
|
|---|
| 4 | var quads = [], q, node = this._root, child, x0, y0, x1, y1;
|
|---|
| 5 | if (node) quads.push(new Quad(node, this._x0, this._y0, this._x1, this._y1));
|
|---|
| 6 | while (q = quads.pop()) {
|
|---|
| 7 | if (!callback(node = q.node, x0 = q.x0, y0 = q.y0, x1 = q.x1, y1 = q.y1) && node.length) {
|
|---|
| 8 | var xm = (x0 + x1) / 2, ym = (y0 + y1) / 2;
|
|---|
| 9 | if (child = node[3]) quads.push(new Quad(child, xm, ym, x1, y1));
|
|---|
| 10 | if (child = node[2]) quads.push(new Quad(child, x0, ym, xm, y1));
|
|---|
| 11 | if (child = node[1]) quads.push(new Quad(child, xm, y0, x1, ym));
|
|---|
| 12 | if (child = node[0]) quads.push(new Quad(child, x0, y0, xm, ym));
|
|---|
| 13 | }
|
|---|
| 14 | }
|
|---|
| 15 | return this;
|
|---|
| 16 | }
|
|---|