Skip to content

Commit

Permalink
Version 5.2.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
vanruesc committed Feb 11, 2019
1 parent e8ab77d commit 670f9b6
Show file tree
Hide file tree
Showing 10 changed files with 13,265 additions and 11,382 deletions.
93 changes: 60 additions & 33 deletions build/sparse-octree.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* sparse-octree v5.1.1 build Wed Feb 06 2019
* sparse-octree v5.2.0 build Mon Feb 11 2019
* https://github.com/vanruesc/sparse-octree
* Copyright 2019 Raoul van Rüschen, Zlib
*/
Expand Down Expand Up @@ -5143,81 +5143,101 @@
}

function _findNearestPoint(point, maxDistance, skipSelf, octant) {
var points = octant.points;
var children = octant.children;
var result = null;
var bestDist = maxDistance;
var bestDistance = maxDistance;
var i, l;
var p, distSq;
var sortedChildren;
var child, childResult;

if (children !== null) {
sortedChildren = children.map(function (child) {
if (octant.children !== null) {
var sortedChildren = octant.children.map(function (child) {
return {
octant: child,
distance: child.distanceToCenterSquared(point)
};
}).sort(function (a, b) {
return a.distance - b.distance;
});
var child, intermediateResult;

for (i = 0, l = sortedChildren.length; i < l; ++i) {
child = sortedChildren[i].octant;

if (child.contains(point, bestDist)) {
childResult = _findNearestPoint(point, bestDist, skipSelf, child);
if (child.contains(point, bestDistance)) {
intermediateResult = _findNearestPoint(point, bestDistance, skipSelf, child);

if (childResult !== null) {
distSq = childResult.point.distanceToSquared(point);
if (intermediateResult !== null) {
bestDistance = intermediateResult.distance;
result = intermediateResult;

if ((!skipSelf || distSq > 0.0) && distSq < bestDist) {
bestDist = distSq;
result = childResult;
if (bestDistance === 0.0) {
break;
}
}
}
}
} else if (points !== null) {
} else if (octant.points !== null) {
var points = octant.points;
var index = -1;
var distance;

for (i = 0, l = points.length; i < l; ++i) {
p = points[i];
distSq = point.distanceToSquared(p);
if (points[i].equals(point)) {
if (!skipSelf) {
bestDistance = 0.0;
index = i;
break;
}
} else {
distance = point.distanceTo(points[i]);

if ((!skipSelf || distSq > 0.0) && distSq < bestDist) {
bestDist = distSq;
result = {
point: p.clone(),
data: octant.data[i]
};
if (distance < bestDistance) {
bestDistance = distance;
index = i;
}
}
}

if (index >= 0) {
result = {
point: points[index],
data: octant.data[index],
distance: bestDistance
};
}
}

return result;
}

function _findPoints(point, radius, skipSelf, octant, result) {
var points = octant.points;
var children = octant.children;
var rSq = radius * radius;
var i, l;
var p, distSq;
var child;

if (children !== null) {
var child;

for (i = 0, l = children.length; i < l; ++i) {
child = children[i];

if (child.contains(point, radius)) {
_findPoints(point, radius, skipSelf, child, result);
}
}
} else if (points !== null) {
} else if (octant.points !== null) {
var points = octant.points;
var rSq = radius * radius;
var p;

for (i = 0, l = points.length; i < l; ++i) {
p = points[i];
distSq = point.distanceToSquared(p);

if ((!skipSelf || distSq > 0.0) && distSq <= rSq) {
if (p.equals(point)) {
if (!skipSelf) {
result.push({
point: p.clone(),
data: octant.data[i]
});
}
} else if (p.distanceToSquared(point) <= rSq) {
result.push({
point: p.clone(),
data: octant.data[i]
Expand Down Expand Up @@ -5278,7 +5298,14 @@
value: function findNearestPoint(point) {
var maxDistance = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
var skipSelf = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
return _findNearestPoint(point, maxDistance, skipSelf, this.root);

var result = _findNearestPoint(point, maxDistance, skipSelf, this.root);

if (result !== null) {
result.point = result.point.clone();
}

return result;
}
}, {
key: "findPoints",
Expand Down
4 changes: 2 additions & 2 deletions build/sparse-octree.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sparse-octree",
"version": "5.1.1",
"version": "5.2.0",
"description": "A sparse octree data structure.",
"homepage": "https://github.com/vanruesc/sparse-octree",
"main": "build/sparse-octree.js",
Expand Down
91 changes: 59 additions & 32 deletions public/demo/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion public/demo/index.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 670f9b6

Please sign in to comment.