|
@@ -82,19 +82,18 @@ function lineToLineClosestPoints( line1, line2, target1 = null, target2 = null )
|
|
|
|
|
|
class Octree {
|
|
|
|
|
|
-
|
|
|
constructor( box ) {
|
|
|
|
|
|
- this.triangles = [];
|
|
|
this.box = box;
|
|
|
+ this.bounds = new Box3();
|
|
|
+
|
|
|
this.subTrees = [];
|
|
|
+ this.triangles = [];
|
|
|
|
|
|
}
|
|
|
|
|
|
addTriangle( triangle ) {
|
|
|
|
|
|
- if ( ! this.bounds ) this.bounds = new Box3();
|
|
|
-
|
|
|
this.bounds.min.x = Math.min( this.bounds.min.x, triangle.a.x, triangle.b.x, triangle.c.x );
|
|
|
this.bounds.min.y = Math.min( this.bounds.min.y, triangle.a.y, triangle.b.y, triangle.c.y );
|
|
|
this.bounds.min.z = Math.min( this.bounds.min.z, triangle.a.z, triangle.b.z, triangle.c.z );
|
|
@@ -524,6 +523,18 @@ class Octree {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ clear() {
|
|
|
+
|
|
|
+ this.box = null;
|
|
|
+ this.bounds.makeEmpty();
|
|
|
+
|
|
|
+ this.subTrees.length = 0;
|
|
|
+ this.triangles.length = 0;
|
|
|
+
|
|
|
+ return this;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
export { Octree };
|