Browse Source

Improve Triangle closure performance

Tristan VALCKE 8 years ago
parent
commit
d5b9bc6806
1 changed files with 4 additions and 10 deletions
  1. 4 10
      src/math/Triangle.js

+ 4 - 10
src/math/Triangle.js

@@ -193,19 +193,13 @@ Object.assign( Triangle.prototype, {
 
 	closestPointToPoint: function () {
 
-		var plane, edgeList, projectedPoint, closestPoint;
+		var plane = new Plane();
+		var edgeList = [ new Line3(), new Line3(), new Line3() ];
+		var projectedPoint = new Vector3();
+		var closestPoint = new Vector3();
 
 		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;