From 4f3fbeb96d9ce38f534d0a1224f1f8c590c70c75 Mon Sep 17 00:00:00 2001 From: Oguz Date: Mon, 4 May 2020 08:17:39 +0200 Subject: [PATCH] rm build folder --- build/Nearby-es.js | 350 ---------------------------------------- build/Nearby-module.js | 352 ---------------------------------------- build/Nearby.js | 358 ----------------------------------------- build/Nearby.min.js | 1 - 4 files changed, 1061 deletions(-) delete mode 100644 build/Nearby-es.js delete mode 100644 build/Nearby-module.js delete mode 100644 build/Nearby.js delete mode 100644 build/Nearby.min.js diff --git a/build/Nearby-es.js b/build/Nearby-es.js deleted file mode 100644 index 8a51f7d..0000000 --- a/build/Nearby-es.js +++ /dev/null @@ -1,350 +0,0 @@ -var Nearby = function Nearby(width, height, depth, binSize) { - this.limitBox = this.createBox(0, 0, 0, width, height, depth); - this.binSize = binSize; - - this.bin = new Map(); - - this.reusableResultMap = new Map(); -}; - -Nearby.prototype.createBox = function (x, y, z, width, height, depth) { - var bb = {}; - - bb.containsBox = function (box) { - return this.minX <= box.minX && box.maxX <= this.maxX && this.minY <= box.minY && box.maxY <= this.maxY && this.minZ <= box.minZ && box.maxZ <= this.maxZ; - }; - - bb.setFromCenterAndSize = function (x, y, z, width, height, depth) { - var halfWidth = width / 2; - var halfHeight = height / 2; - var halfDepth = depth / 2; - - this.minX = x - halfWidth; - this.maxX = x + halfWidth; - this.minY = y - halfHeight; - this.maxY = y + halfHeight; - this.minZ = z - halfDepth; - this.maxZ = z + halfDepth; - }; - - bb.setFromCenterAndSize(x, y, z, width, height, depth); - - return bb; -}; - -Nearby.prototype.createObject = function (id, box) { - var self = this; - - var obj = { - id: id, - box: box, - binInfo: new Map() - }; - - return obj; -}; - -Nearby.prototype.insert = function (obj) { - if (!this.limitBox.containsBox(obj.box)) { - return; - } - - var BIN_SIZE = this.binSize; - - var box = obj.box; - var minX = box.minX; - var minY = box.minY; - var minZ = box.minZ; - var maxX = box.maxX; - var maxY = box.maxY; - var maxZ = box.maxZ; - - var round = Math.round(minX / BIN_SIZE) * BIN_SIZE; - var minXLower, minXUpper; - if (round <= minX) { - minXLower = round; - minXUpper = minXLower + BIN_SIZE; - } else { - minXUpper = round; - minXLower = round - BIN_SIZE; - } - - round = Math.round(maxX / BIN_SIZE) * BIN_SIZE; - var maxXLower, maxXUpper; - if (round < maxX) { - maxXLower = round; - maxXUpper = maxXLower + BIN_SIZE; - } else { - maxXUpper = round; - maxXLower = round - BIN_SIZE; - } - if (minXLower > maxXLower) { - maxXLower = minXLower; - } - - round = Math.round(minY / BIN_SIZE) * BIN_SIZE; - var minYLower, minYUpper; - if (round <= minY) { - minYLower = round; - minYUpper = minYLower + BIN_SIZE; - } else { - minYUpper = round; - minYLower = round - BIN_SIZE; - } - - round = Math.round(maxY / BIN_SIZE) * BIN_SIZE; - var maxYLower, maxYUpper; - if (round < maxY) { - maxYLower = round; - maxYUpper = maxYLower + BIN_SIZE; - } else { - maxYUpper = round; - maxYLower = round - BIN_SIZE; - } - if (minYLower > maxYLower) { - maxYLower = minYLower; - } - - round = Math.round(minZ / BIN_SIZE) * BIN_SIZE; - var minZLower, minZUpper; - if (round <= minZ) { - minZLower = round; - minZUpper = minZLower + BIN_SIZE; - } else { - minZUpper = round; - minZLower = round - BIN_SIZE; - } - - round = Math.round(maxZ / BIN_SIZE) * BIN_SIZE; - var maxZLower, maxZUpper; - if (round < maxZ) { - maxZLower = round; - maxZUpper = maxZLower + BIN_SIZE; - } else { - maxZUpper = round; - maxZLower = round - BIN_SIZE; - } - if (minZLower > maxZLower) { - maxZLower = minZLower; - } - - for (var x = minXLower; x <= maxXLower; x += BIN_SIZE) { - for (var y = minYLower; y <= maxYLower; y += BIN_SIZE) { - for (var z = minZLower; z <= maxZLower; z += BIN_SIZE) { - if (!this.bin.has(x)) { - this.bin.set(x, new Map()); - } - if (!this.bin.get(x).has(y)) { - this.bin.get(x).set(y, new Map()); - } - if (!this.bin.get(x).get(y).has(z)) { - this.bin.get(x).get(y).set(z, new Map()); - } - this.bin.get(x).get(y).get(z).set(obj, true); - - if (!obj.binInfo.has(x)) { - obj.binInfo.set(x, new Map()); - } - if (!obj.binInfo.get(x).has(y)) { - obj.binInfo.get(x).set(y, new Map()); - } - obj.binInfo.get(x).get(y).set(z, true); - } - } - } -}; - -Nearby.prototype.query = function (x, y, z) { - var BIN_SIZE = this.binSize; - - var rX = Math.round(x / BIN_SIZE) * BIN_SIZE; - var rY = Math.round(y / BIN_SIZE) * BIN_SIZE; - var rZ = Math.round(z / BIN_SIZE) * BIN_SIZE; - - var minX, maxX; - if (rX <= x) { - minX = rX; - maxX = rX + BIN_SIZE; - } else { - maxX = rX; - minX = rX - BIN_SIZE; - } - var minY, maxY; - if (rY <= y) { - minY = rY; - maxY = rY + BIN_SIZE; - } else { - maxY = rY; - minY = rY - BIN_SIZE; - } - var minZ, maxZ; - if (rZ <= z) { - minZ = rZ; - maxZ = rZ + BIN_SIZE; - } else { - maxZ = rZ; - minZ = rZ - BIN_SIZE; - } - - var result = this.reusableResultMap; - result.clear(); - - for (var xDiff = -BIN_SIZE; xDiff <= BIN_SIZE; xDiff += BIN_SIZE) { - for (var yDiff = -BIN_SIZE; yDiff <= BIN_SIZE; yDiff += BIN_SIZE) { - for (var zDiff = -BIN_SIZE; zDiff <= BIN_SIZE; zDiff += BIN_SIZE) { - var keyX = minX + xDiff; - var keyY = minY + yDiff; - var keyZ = minZ + zDiff; - if (this.bin.has(keyX) && this.bin.get(keyX).has(keyY)) { - var res = this.bin.get(keyX).get(keyY).get(keyZ); - if (res) { - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; - - try { - for (var _iterator = res.keys()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var obj = _step.value; - - result.set(obj, true); - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } - } - } - } - } - } - - return result; -}; - -Nearby.prototype.delete = function (obj) { - var binInfo = obj.binInfo; - - var _iteratorNormalCompletion2 = true; - var _didIteratorError2 = false; - var _iteratorError2 = undefined; - - try { - for (var _iterator2 = binInfo.keys()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { - var x = _step2.value; - var _iteratorNormalCompletion4 = true; - var _didIteratorError4 = false; - var _iteratorError4 = undefined; - - try { - for (var _iterator4 = binInfo.get(x).keys()[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { - var y = _step4.value; - var _iteratorNormalCompletion5 = true; - var _didIteratorError5 = false; - var _iteratorError5 = undefined; - - try { - for (var _iterator5 = binInfo.get(x).get(y).keys()[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) { - var z = _step5.value; - - if (this.bin.has(x) && this.bin.get(x).has(y) && this.bin.get(x).get(y).has(z)) { - this.bin.get(x).get(y).get(z).delete(obj); - if (this.bin.get(x).get(y).get(z).size == 0) { - this.bin.get(x).get(y).delete(z); - } - if (this.bin.get(x).get(y).size == 0) { - this.bin.get(x).delete(y); - } - if (this.bin.get(x).size == 0) { - this.bin.delete(x); - } - } - } - } catch (err) { - _didIteratorError5 = true; - _iteratorError5 = err; - } finally { - try { - if (!_iteratorNormalCompletion5 && _iterator5.return) { - _iterator5.return(); - } - } finally { - if (_didIteratorError5) { - throw _iteratorError5; - } - } - } - } - } catch (err) { - _didIteratorError4 = true; - _iteratorError4 = err; - } finally { - try { - if (!_iteratorNormalCompletion4 && _iterator4.return) { - _iterator4.return(); - } - } finally { - if (_didIteratorError4) { - throw _iteratorError4; - } - } - } - } - } catch (err) { - _didIteratorError2 = true; - _iteratorError2 = err; - } finally { - try { - if (!_iteratorNormalCompletion2 && _iterator2.return) { - _iterator2.return(); - } - } finally { - if (_didIteratorError2) { - throw _iteratorError2; - } - } - } - - var _iteratorNormalCompletion3 = true; - var _didIteratorError3 = false; - var _iteratorError3 = undefined; - - try { - for (var _iterator3 = binInfo.keys()[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { - var x = _step3.value; - - binInfo.delete(x); - } - } catch (err) { - _didIteratorError3 = true; - _iteratorError3 = err; - } finally { - try { - if (!_iteratorNormalCompletion3 && _iterator3.return) { - _iterator3.return(); - } - } finally { - if (_didIteratorError3) { - throw _iteratorError3; - } - } - } -}; - -Nearby.prototype.update = function (obj, x, y, z, width, height, depth) { - obj.box.setFromCenterAndSize(x, y, z, width, height, depth); - - this.delete(obj); - this.insert(obj); -}; - -export default Nearby; diff --git a/build/Nearby-module.js b/build/Nearby-module.js deleted file mode 100644 index aae192a..0000000 --- a/build/Nearby-module.js +++ /dev/null @@ -1,352 +0,0 @@ -'use strict'; - -var Nearby = function Nearby(width, height, depth, binSize) { - this.limitBox = this.createBox(0, 0, 0, width, height, depth); - this.binSize = binSize; - - this.bin = new Map(); - - this.reusableResultMap = new Map(); -}; - -Nearby.prototype.createBox = function (x, y, z, width, height, depth) { - var bb = {}; - - bb.containsBox = function (box) { - return this.minX <= box.minX && box.maxX <= this.maxX && this.minY <= box.minY && box.maxY <= this.maxY && this.minZ <= box.minZ && box.maxZ <= this.maxZ; - }; - - bb.setFromCenterAndSize = function (x, y, z, width, height, depth) { - var halfWidth = width / 2; - var halfHeight = height / 2; - var halfDepth = depth / 2; - - this.minX = x - halfWidth; - this.maxX = x + halfWidth; - this.minY = y - halfHeight; - this.maxY = y + halfHeight; - this.minZ = z - halfDepth; - this.maxZ = z + halfDepth; - }; - - bb.setFromCenterAndSize(x, y, z, width, height, depth); - - return bb; -}; - -Nearby.prototype.createObject = function (id, box) { - var self = this; - - var obj = { - id: id, - box: box, - binInfo: new Map() - }; - - return obj; -}; - -Nearby.prototype.insert = function (obj) { - if (!this.limitBox.containsBox(obj.box)) { - return; - } - - var BIN_SIZE = this.binSize; - - var box = obj.box; - var minX = box.minX; - var minY = box.minY; - var minZ = box.minZ; - var maxX = box.maxX; - var maxY = box.maxY; - var maxZ = box.maxZ; - - var round = Math.round(minX / BIN_SIZE) * BIN_SIZE; - var minXLower, minXUpper; - if (round <= minX) { - minXLower = round; - minXUpper = minXLower + BIN_SIZE; - } else { - minXUpper = round; - minXLower = round - BIN_SIZE; - } - - round = Math.round(maxX / BIN_SIZE) * BIN_SIZE; - var maxXLower, maxXUpper; - if (round < maxX) { - maxXLower = round; - maxXUpper = maxXLower + BIN_SIZE; - } else { - maxXUpper = round; - maxXLower = round - BIN_SIZE; - } - if (minXLower > maxXLower) { - maxXLower = minXLower; - } - - round = Math.round(minY / BIN_SIZE) * BIN_SIZE; - var minYLower, minYUpper; - if (round <= minY) { - minYLower = round; - minYUpper = minYLower + BIN_SIZE; - } else { - minYUpper = round; - minYLower = round - BIN_SIZE; - } - - round = Math.round(maxY / BIN_SIZE) * BIN_SIZE; - var maxYLower, maxYUpper; - if (round < maxY) { - maxYLower = round; - maxYUpper = maxYLower + BIN_SIZE; - } else { - maxYUpper = round; - maxYLower = round - BIN_SIZE; - } - if (minYLower > maxYLower) { - maxYLower = minYLower; - } - - round = Math.round(minZ / BIN_SIZE) * BIN_SIZE; - var minZLower, minZUpper; - if (round <= minZ) { - minZLower = round; - minZUpper = minZLower + BIN_SIZE; - } else { - minZUpper = round; - minZLower = round - BIN_SIZE; - } - - round = Math.round(maxZ / BIN_SIZE) * BIN_SIZE; - var maxZLower, maxZUpper; - if (round < maxZ) { - maxZLower = round; - maxZUpper = maxZLower + BIN_SIZE; - } else { - maxZUpper = round; - maxZLower = round - BIN_SIZE; - } - if (minZLower > maxZLower) { - maxZLower = minZLower; - } - - for (var x = minXLower; x <= maxXLower; x += BIN_SIZE) { - for (var y = minYLower; y <= maxYLower; y += BIN_SIZE) { - for (var z = minZLower; z <= maxZLower; z += BIN_SIZE) { - if (!this.bin.has(x)) { - this.bin.set(x, new Map()); - } - if (!this.bin.get(x).has(y)) { - this.bin.get(x).set(y, new Map()); - } - if (!this.bin.get(x).get(y).has(z)) { - this.bin.get(x).get(y).set(z, new Map()); - } - this.bin.get(x).get(y).get(z).set(obj, true); - - if (!obj.binInfo.has(x)) { - obj.binInfo.set(x, new Map()); - } - if (!obj.binInfo.get(x).has(y)) { - obj.binInfo.get(x).set(y, new Map()); - } - obj.binInfo.get(x).get(y).set(z, true); - } - } - } -}; - -Nearby.prototype.query = function (x, y, z) { - var BIN_SIZE = this.binSize; - - var rX = Math.round(x / BIN_SIZE) * BIN_SIZE; - var rY = Math.round(y / BIN_SIZE) * BIN_SIZE; - var rZ = Math.round(z / BIN_SIZE) * BIN_SIZE; - - var minX, maxX; - if (rX <= x) { - minX = rX; - maxX = rX + BIN_SIZE; - } else { - maxX = rX; - minX = rX - BIN_SIZE; - } - var minY, maxY; - if (rY <= y) { - minY = rY; - maxY = rY + BIN_SIZE; - } else { - maxY = rY; - minY = rY - BIN_SIZE; - } - var minZ, maxZ; - if (rZ <= z) { - minZ = rZ; - maxZ = rZ + BIN_SIZE; - } else { - maxZ = rZ; - minZ = rZ - BIN_SIZE; - } - - var result = this.reusableResultMap; - result.clear(); - - for (var xDiff = -BIN_SIZE; xDiff <= BIN_SIZE; xDiff += BIN_SIZE) { - for (var yDiff = -BIN_SIZE; yDiff <= BIN_SIZE; yDiff += BIN_SIZE) { - for (var zDiff = -BIN_SIZE; zDiff <= BIN_SIZE; zDiff += BIN_SIZE) { - var keyX = minX + xDiff; - var keyY = minY + yDiff; - var keyZ = minZ + zDiff; - if (this.bin.has(keyX) && this.bin.get(keyX).has(keyY)) { - var res = this.bin.get(keyX).get(keyY).get(keyZ); - if (res) { - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; - - try { - for (var _iterator = res.keys()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var obj = _step.value; - - result.set(obj, true); - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } - } - } - } - } - } - - return result; -}; - -Nearby.prototype.delete = function (obj) { - var binInfo = obj.binInfo; - - var _iteratorNormalCompletion2 = true; - var _didIteratorError2 = false; - var _iteratorError2 = undefined; - - try { - for (var _iterator2 = binInfo.keys()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { - var x = _step2.value; - var _iteratorNormalCompletion4 = true; - var _didIteratorError4 = false; - var _iteratorError4 = undefined; - - try { - for (var _iterator4 = binInfo.get(x).keys()[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { - var y = _step4.value; - var _iteratorNormalCompletion5 = true; - var _didIteratorError5 = false; - var _iteratorError5 = undefined; - - try { - for (var _iterator5 = binInfo.get(x).get(y).keys()[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) { - var z = _step5.value; - - if (this.bin.has(x) && this.bin.get(x).has(y) && this.bin.get(x).get(y).has(z)) { - this.bin.get(x).get(y).get(z).delete(obj); - if (this.bin.get(x).get(y).get(z).size == 0) { - this.bin.get(x).get(y).delete(z); - } - if (this.bin.get(x).get(y).size == 0) { - this.bin.get(x).delete(y); - } - if (this.bin.get(x).size == 0) { - this.bin.delete(x); - } - } - } - } catch (err) { - _didIteratorError5 = true; - _iteratorError5 = err; - } finally { - try { - if (!_iteratorNormalCompletion5 && _iterator5.return) { - _iterator5.return(); - } - } finally { - if (_didIteratorError5) { - throw _iteratorError5; - } - } - } - } - } catch (err) { - _didIteratorError4 = true; - _iteratorError4 = err; - } finally { - try { - if (!_iteratorNormalCompletion4 && _iterator4.return) { - _iterator4.return(); - } - } finally { - if (_didIteratorError4) { - throw _iteratorError4; - } - } - } - } - } catch (err) { - _didIteratorError2 = true; - _iteratorError2 = err; - } finally { - try { - if (!_iteratorNormalCompletion2 && _iterator2.return) { - _iterator2.return(); - } - } finally { - if (_didIteratorError2) { - throw _iteratorError2; - } - } - } - - var _iteratorNormalCompletion3 = true; - var _didIteratorError3 = false; - var _iteratorError3 = undefined; - - try { - for (var _iterator3 = binInfo.keys()[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { - var x = _step3.value; - - binInfo.delete(x); - } - } catch (err) { - _didIteratorError3 = true; - _iteratorError3 = err; - } finally { - try { - if (!_iteratorNormalCompletion3 && _iterator3.return) { - _iterator3.return(); - } - } finally { - if (_didIteratorError3) { - throw _iteratorError3; - } - } - } -}; - -Nearby.prototype.update = function (obj, x, y, z, width, height, depth) { - obj.box.setFromCenterAndSize(x, y, z, width, height, depth); - - this.delete(obj); - this.insert(obj); -}; - -module.exports = Nearby; diff --git a/build/Nearby.js b/build/Nearby.js deleted file mode 100644 index b93d407..0000000 --- a/build/Nearby.js +++ /dev/null @@ -1,358 +0,0 @@ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - (global.Nearby = factory()); -}(this, (function () { 'use strict'; - -var Nearby = function Nearby(width, height, depth, binSize) { - this.limitBox = this.createBox(0, 0, 0, width, height, depth); - this.binSize = binSize; - - this.bin = new Map(); - - this.reusableResultMap = new Map(); -}; - -Nearby.prototype.createBox = function (x, y, z, width, height, depth) { - var bb = {}; - - bb.containsBox = function (box) { - return this.minX <= box.minX && box.maxX <= this.maxX && this.minY <= box.minY && box.maxY <= this.maxY && this.minZ <= box.minZ && box.maxZ <= this.maxZ; - }; - - bb.setFromCenterAndSize = function (x, y, z, width, height, depth) { - var halfWidth = width / 2; - var halfHeight = height / 2; - var halfDepth = depth / 2; - - this.minX = x - halfWidth; - this.maxX = x + halfWidth; - this.minY = y - halfHeight; - this.maxY = y + halfHeight; - this.minZ = z - halfDepth; - this.maxZ = z + halfDepth; - }; - - bb.setFromCenterAndSize(x, y, z, width, height, depth); - - return bb; -}; - -Nearby.prototype.createObject = function (id, box) { - var self = this; - - var obj = { - id: id, - box: box, - binInfo: new Map() - }; - - return obj; -}; - -Nearby.prototype.insert = function (obj) { - if (!this.limitBox.containsBox(obj.box)) { - return; - } - - var BIN_SIZE = this.binSize; - - var box = obj.box; - var minX = box.minX; - var minY = box.minY; - var minZ = box.minZ; - var maxX = box.maxX; - var maxY = box.maxY; - var maxZ = box.maxZ; - - var round = Math.round(minX / BIN_SIZE) * BIN_SIZE; - var minXLower, minXUpper; - if (round <= minX) { - minXLower = round; - minXUpper = minXLower + BIN_SIZE; - } else { - minXUpper = round; - minXLower = round - BIN_SIZE; - } - - round = Math.round(maxX / BIN_SIZE) * BIN_SIZE; - var maxXLower, maxXUpper; - if (round < maxX) { - maxXLower = round; - maxXUpper = maxXLower + BIN_SIZE; - } else { - maxXUpper = round; - maxXLower = round - BIN_SIZE; - } - if (minXLower > maxXLower) { - maxXLower = minXLower; - } - - round = Math.round(minY / BIN_SIZE) * BIN_SIZE; - var minYLower, minYUpper; - if (round <= minY) { - minYLower = round; - minYUpper = minYLower + BIN_SIZE; - } else { - minYUpper = round; - minYLower = round - BIN_SIZE; - } - - round = Math.round(maxY / BIN_SIZE) * BIN_SIZE; - var maxYLower, maxYUpper; - if (round < maxY) { - maxYLower = round; - maxYUpper = maxYLower + BIN_SIZE; - } else { - maxYUpper = round; - maxYLower = round - BIN_SIZE; - } - if (minYLower > maxYLower) { - maxYLower = minYLower; - } - - round = Math.round(minZ / BIN_SIZE) * BIN_SIZE; - var minZLower, minZUpper; - if (round <= minZ) { - minZLower = round; - minZUpper = minZLower + BIN_SIZE; - } else { - minZUpper = round; - minZLower = round - BIN_SIZE; - } - - round = Math.round(maxZ / BIN_SIZE) * BIN_SIZE; - var maxZLower, maxZUpper; - if (round < maxZ) { - maxZLower = round; - maxZUpper = maxZLower + BIN_SIZE; - } else { - maxZUpper = round; - maxZLower = round - BIN_SIZE; - } - if (minZLower > maxZLower) { - maxZLower = minZLower; - } - - for (var x = minXLower; x <= maxXLower; x += BIN_SIZE) { - for (var y = minYLower; y <= maxYLower; y += BIN_SIZE) { - for (var z = minZLower; z <= maxZLower; z += BIN_SIZE) { - if (!this.bin.has(x)) { - this.bin.set(x, new Map()); - } - if (!this.bin.get(x).has(y)) { - this.bin.get(x).set(y, new Map()); - } - if (!this.bin.get(x).get(y).has(z)) { - this.bin.get(x).get(y).set(z, new Map()); - } - this.bin.get(x).get(y).get(z).set(obj, true); - - if (!obj.binInfo.has(x)) { - obj.binInfo.set(x, new Map()); - } - if (!obj.binInfo.get(x).has(y)) { - obj.binInfo.get(x).set(y, new Map()); - } - obj.binInfo.get(x).get(y).set(z, true); - } - } - } -}; - -Nearby.prototype.query = function (x, y, z) { - var BIN_SIZE = this.binSize; - - var rX = Math.round(x / BIN_SIZE) * BIN_SIZE; - var rY = Math.round(y / BIN_SIZE) * BIN_SIZE; - var rZ = Math.round(z / BIN_SIZE) * BIN_SIZE; - - var minX, maxX; - if (rX <= x) { - minX = rX; - maxX = rX + BIN_SIZE; - } else { - maxX = rX; - minX = rX - BIN_SIZE; - } - var minY, maxY; - if (rY <= y) { - minY = rY; - maxY = rY + BIN_SIZE; - } else { - maxY = rY; - minY = rY - BIN_SIZE; - } - var minZ, maxZ; - if (rZ <= z) { - minZ = rZ; - maxZ = rZ + BIN_SIZE; - } else { - maxZ = rZ; - minZ = rZ - BIN_SIZE; - } - - var result = this.reusableResultMap; - result.clear(); - - for (var xDiff = -BIN_SIZE; xDiff <= BIN_SIZE; xDiff += BIN_SIZE) { - for (var yDiff = -BIN_SIZE; yDiff <= BIN_SIZE; yDiff += BIN_SIZE) { - for (var zDiff = -BIN_SIZE; zDiff <= BIN_SIZE; zDiff += BIN_SIZE) { - var keyX = minX + xDiff; - var keyY = minY + yDiff; - var keyZ = minZ + zDiff; - if (this.bin.has(keyX) && this.bin.get(keyX).has(keyY)) { - var res = this.bin.get(keyX).get(keyY).get(keyZ); - if (res) { - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; - - try { - for (var _iterator = res.keys()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var obj = _step.value; - - result.set(obj, true); - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } - } - } - } - } - } - - return result; -}; - -Nearby.prototype.delete = function (obj) { - var binInfo = obj.binInfo; - - var _iteratorNormalCompletion2 = true; - var _didIteratorError2 = false; - var _iteratorError2 = undefined; - - try { - for (var _iterator2 = binInfo.keys()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { - var x = _step2.value; - var _iteratorNormalCompletion4 = true; - var _didIteratorError4 = false; - var _iteratorError4 = undefined; - - try { - for (var _iterator4 = binInfo.get(x).keys()[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { - var y = _step4.value; - var _iteratorNormalCompletion5 = true; - var _didIteratorError5 = false; - var _iteratorError5 = undefined; - - try { - for (var _iterator5 = binInfo.get(x).get(y).keys()[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) { - var z = _step5.value; - - if (this.bin.has(x) && this.bin.get(x).has(y) && this.bin.get(x).get(y).has(z)) { - this.bin.get(x).get(y).get(z).delete(obj); - if (this.bin.get(x).get(y).get(z).size == 0) { - this.bin.get(x).get(y).delete(z); - } - if (this.bin.get(x).get(y).size == 0) { - this.bin.get(x).delete(y); - } - if (this.bin.get(x).size == 0) { - this.bin.delete(x); - } - } - } - } catch (err) { - _didIteratorError5 = true; - _iteratorError5 = err; - } finally { - try { - if (!_iteratorNormalCompletion5 && _iterator5.return) { - _iterator5.return(); - } - } finally { - if (_didIteratorError5) { - throw _iteratorError5; - } - } - } - } - } catch (err) { - _didIteratorError4 = true; - _iteratorError4 = err; - } finally { - try { - if (!_iteratorNormalCompletion4 && _iterator4.return) { - _iterator4.return(); - } - } finally { - if (_didIteratorError4) { - throw _iteratorError4; - } - } - } - } - } catch (err) { - _didIteratorError2 = true; - _iteratorError2 = err; - } finally { - try { - if (!_iteratorNormalCompletion2 && _iterator2.return) { - _iterator2.return(); - } - } finally { - if (_didIteratorError2) { - throw _iteratorError2; - } - } - } - - var _iteratorNormalCompletion3 = true; - var _didIteratorError3 = false; - var _iteratorError3 = undefined; - - try { - for (var _iterator3 = binInfo.keys()[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { - var x = _step3.value; - - binInfo.delete(x); - } - } catch (err) { - _didIteratorError3 = true; - _iteratorError3 = err; - } finally { - try { - if (!_iteratorNormalCompletion3 && _iterator3.return) { - _iterator3.return(); - } - } finally { - if (_didIteratorError3) { - throw _iteratorError3; - } - } - } -}; - -Nearby.prototype.update = function (obj, x, y, z, width, height, depth) { - obj.box.setFromCenterAndSize(x, y, z, width, height, depth); - - this.delete(obj); - this.insert(obj); -}; - -return Nearby; - -}))); diff --git a/build/Nearby.min.js b/build/Nearby.min.js deleted file mode 100644 index 8f84c7d..0000000 --- a/build/Nearby.min.js +++ /dev/null @@ -1 +0,0 @@ -(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):a.Nearby=b()})(this,function(){'use strict';var a=Math.round,b=function(a,b,c,d){this.limitBox=this.createBox(0,0,0,a,b,c),this.binSize=d,this.bin=new Map,this.reusableResultMap=new Map};return b.prototype.createBox=function(a,b,c,d,e,f){var g={};return g.containsBox=function(a){return this.minX<=a.minX&&a.maxX<=this.maxX&&this.minY<=a.minY&&a.maxY<=this.maxY&&this.minZ<=a.minZ&&a.maxZ<=this.maxZ},g.setFromCenterAndSize=function(a,b,c,d,e,f){var g=d/2,h=e/2,i=f/2;this.minX=a-g,this.maxX=a+g,this.minY=b-h,this.maxY=b+h,this.minZ=c-i,this.maxZ=c+i},g.setFromCenterAndSize(a,b,c,d,e,f),g},b.prototype.createObject=function(a,b){var c=this,d={id:a,box:b,binInfo:new Map};return d},b.prototype.insert=function(b){if(this.limitBox.containsBox(b.box)){var c,d,e=this.binSize,f=b.box,g=f.minX,h=f.minY,i=f.minZ,j=f.maxX,k=f.maxY,l=f.maxZ,m=a(g/e)*e;m<=g?(c=m,d=c+e):(d=m,c=m-e),m=a(j/e)*e;var n,o;mn&&(n=c),m=a(h/e)*e;var p,q;m<=h?(p=m,q=p+e):(q=m,p=m-e),m=a(k/e)*e;var r,s;mr&&(r=p),m=a(i/e)*e;var t,u;m<=i?(t=m,u=t+e):(u=m,t=m-e),m=a(l/e)*e;var v,w;mv&&(v=t);for(var A=c;A<=n;A+=e)for(var B=p;B<=r;B+=e)for(var C=t;C<=v;C+=e)this.bin.has(A)||this.bin.set(A,new Map),this.bin.get(A).has(B)||this.bin.get(A).set(B,new Map),this.bin.get(A).get(B).has(C)||this.bin.get(A).get(B).set(C,new Map),this.bin.get(A).get(B).get(C).set(b,!0),b.binInfo.has(A)||b.binInfo.set(A,new Map),b.binInfo.get(A).has(B)||b.binInfo.get(A).set(B,new Map),b.binInfo.get(A).get(B).set(C,!0)}},b.prototype.query=function(b,c,d){var e,f,g=this.binSize,h=a(b/g)*g,i=a(c/g)*g,j=a(d/g)*g;h<=b?(e=h,f=h+g):(f=h,e=h-g);var k,l;i<=c?(k=i,l=i+g):(l=i,k=i-g);var m,n;j<=d?(m=j,n=j+g):(n=j,m=j-g);var o=this.reusableResultMap;o.clear();for(var p=-g;p<=g;p+=g)for(var q=-g;q<=g;q+=g)for(var r=-g;r<=g;r+=g){var s=e+p,t=k+q,u=m+r;if(this.bin.has(s)&&this.bin.get(s).has(t)){var v=this.bin.get(s).get(t).get(u);if(v){var w=!0,x=!1,y=void 0;try{for(var z,A,B=v.keys()[Symbol.iterator]();!(w=(z=B.next()).done);w=!0)A=z.value,o.set(A,!0)}catch(a){x=!0,y=a}finally{try{!w&&B.return&&B.return()}finally{if(x)throw y}}}}}return o},b.prototype.delete=function(a){var b=a.binInfo,c=!0,d=!1,e=void 0;try{for(var f,g=b.keys()[Symbol.iterator]();!(c=(f=g.next()).done);c=!0){var h=f.value,i=!0,j=!1,k=void 0;try{for(var l,m=b.get(h).keys()[Symbol.iterator]();!(i=(l=m.next()).done);i=!0){var n=l.value,o=!0,p=!1,q=void 0;try{for(var r,s,t=b.get(h).get(n).keys()[Symbol.iterator]();!(o=(r=t.next()).done);o=!0)s=r.value,this.bin.has(h)&&this.bin.get(h).has(n)&&this.bin.get(h).get(n).has(s)&&(this.bin.get(h).get(n).get(s).delete(a),0==this.bin.get(h).get(n).get(s).size&&this.bin.get(h).get(n).delete(s),0==this.bin.get(h).get(n).size&&this.bin.get(h).delete(n),0==this.bin.get(h).size&&this.bin.delete(h))}catch(a){p=!0,q=a}finally{try{!o&&t.return&&t.return()}finally{if(p)throw q}}}}catch(a){j=!0,k=a}finally{try{!i&&m.return&&m.return()}finally{if(j)throw k}}}}catch(a){d=!0,e=a}finally{try{!c&&g.return&&g.return()}finally{if(d)throw e}}var u=!0,v=!1,w=void 0;try{for(var y,h,A=b.keys()[Symbol.iterator]();!(u=(y=A.next()).done);u=!0)h=y.value,b.delete(h)}catch(a){v=!0,w=a}finally{try{!u&&A.return&&A.return()}finally{if(v)throw w}}},b.prototype.update=function(a,b,c,d,e,f,g){a.box.setFromCenterAndSize(b,c,d,e,f,g),this.delete(a),this.insert(a)},b}); \ No newline at end of file