From 32936211551bc39d2b10295235c42a14ec95a36f Mon Sep 17 00:00:00 2001 From: Rachel Hwang Date: Tue, 8 Aug 2017 11:59:02 -0400 Subject: [PATCH] correct winding order check bug --- lib/loadObj.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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); }