Quadtree 1.2.6 now uses the ES6 feature Set to remove duplicates faster than ever (was O(n^2), now O(n)).
Heart of the test code:
var amount = 1000000;
var myObjects = [];
for(var i=0; i<amount;i++) {
myObjects.push({
x: randMinMax(0, 800-maxObjectSize),
y: randMinMax(0, 600-maxObjectSize),
width: randMinMax(4, maxObjectSize),
height: randMinMax(4, maxObjectSize)
});
}
var myTree = new Quadtree({
x: 0,
y: 0,
width: 800,
height: 600
}, 10, 4);
for(var i=0; i<amount;i++) {
myOldTree.insert(myObjects[i]);
}
//time measure starts here
var start = window.performance.now();
var candidates = myOldTree.retrieve(myCursor);
//time measure ends here
var end = window.performance.now();
var time = end - start;
To see the full example code please check the page source or visit GitHub.