From d5b9bc6806ea51490eed10ce56f550cf9459bb80 Mon Sep 17 00:00:00 2001 From: Tristan VALCKE Date: Sun, 22 Jan 2017 18:21:06 +0100 Subject: [PATCH] Improve Triangle closure performance --- src/math/Triangle.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/math/Triangle.js b/src/math/Triangle.js index bb36acd48b..a2d81da157 100644 --- a/src/math/Triangle.js +++ b/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; -- GitLab