浏览代码

Revert "Improve Triangle closure performance"

This reverts commit d5b9bc6806ea51490eed10ce56f550cf9459bb80.
Joe Fox 8 年之前
父节点
当前提交
4d821e3f32
共有 1 个文件被更改,包括 10 次插入4 次删除
  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;