Browse Source

Revert "Improve Triangle closure performance"

This reverts commit d5b9bc6806ea51490eed10ce56f550cf9459bb80.
Joe Fox 8 years ago
parent
commit
4d821e3f32
1 changed files with 10 additions and 4 deletions
  1. 10 4
      src/math/Triangle.js

+ 10 - 4
src/math/Triangle.js

@@ -191,13 +191,19 @@ Object.assign( Triangle.prototype, {
 
 	closestPointToPoint: function () {
 
-		var plane = new Plane();
-		var edgeList = [ new Line3(), new Line3(), new Line3() ];
-		var projectedPoint = new Vector3();
-		var closestPoint = new Vector3();
+		var plane, edgeList, projectedPoint, closestPoint;
 
 		return function closestPointToPoint( point, optionalTarget ) {
 
+			if ( plane === undefined ) {
+
+				plane = new Plane();
+				edgeList = [ new Line3(), new Line3(), new Line3() ];
+				projectedPoint = new Vector3();
+				closestPoint = new Vector3();
+
+			}
+
 			var result = optionalTarget || new Vector3();
 			var minDistance = Infinity;