correct winding order check bug

This commit is contained in:
Rachel Hwang 2017-08-08 11:59:02 -04:00
parent 563d5243a2
commit 3293621155

View File

@ -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);
}