diff --git a/lib/loadObj.js b/lib/loadObj.js index 7359ff9..eb5131b 100644 --- a/lib/loadObj.js +++ b/lib/loadObj.js @@ -350,15 +350,17 @@ function loadObj(objPath, options) { } var scratch3 = new Cartesian3(); + var scratch4 = new Cartesian3(); + var scratch5 = new Cartesian3(); // Checks if winding order matches the given normal. function checkWindingCorrect(positionIndex1, positionIndex2, positionIndex3, normal) { var A = get3DPoint(positionIndex1, scratch1); var B = get3DPoint(positionIndex2, scratch2); var C = get3DPoint(positionIndex3, scratch3); - Cartesian3.subtract(B, A, B); - Cartesian3.subtract(C, A, C); - var cross = Cartesian3.cross(A, C, scratch1); + var BA = Cartesian3.subtract(B, A, scratch4); + var CA = Cartesian3.subtract(C, A, scratch5); + var cross = Cartesian3.cross(BA, CA, scratch3); return (Cartesian3.dot(normal, cross) >= 0); }