Remove triangle winding order check

This commit is contained in:
Sean Lilley 2020-03-27 09:41:37 -04:00
parent 3283239024
commit b69281573f
1 changed files with 1 additions and 31 deletions

View File

@ -256,18 +256,6 @@ function loadObj(objPath, options) {
return Cartesian3.fromElements(px, py, pz, result);
}
function getNormal(index, result) {
const nx = globalNormals.get(index * 3);
const ny = globalNormals.get(index * 3 + 1);
const nz = globalNormals.get(index * 3 + 2);
return Cartesian3.fromElements(nx, ny, nz, result);
}
const scratch1 = new Cartesian3();
const scratch2 = new Cartesian3();
const scratch3 = new Cartesian3();
const scratch4 = new Cartesian3();
const scratch5 = new Cartesian3();
const scratchCenter = new Cartesian3();
const scratchAxis1 = new Cartesian3();
const scratchAxis2 = new Cartesian3();
@ -276,23 +264,6 @@ function loadObj(objPath, options) {
const scratchVertexIndices = [];
const scratchPoints = [];
function checkWindingCorrect(positionIndex1, positionIndex2, positionIndex3, normalIndex) {
if (!defined(normalIndex)) {
// If no face normal, we have to assume the winding is correct.
return true;
}
const normal = getNormal(normalIndex, scratchNormal);
const A = getPosition(positionIndex1, scratch1);
const B = getPosition(positionIndex2, scratch2);
const C = getPosition(positionIndex3, scratch3);
const BA = Cartesian3.subtract(B, A, scratch4);
const CA = Cartesian3.subtract(C, A, scratch5);
const cross = Cartesian3.cross(BA, CA, scratch3);
return (Cartesian3.dot(normal, cross) >= 0);
}
function addTriangle(index1, index2, index3, correctWinding) {
if (correctWinding) {
primitive.indices.push(index1);
@ -314,11 +285,10 @@ function loadObj(objPath, options) {
checkPrimitive(uvs, faceNormals);
if (vertices.length === 3) {
const isWindingCorrect = checkWindingCorrect(positions[0], positions[1], positions[2], normals[0]);
const index1 = addVertex(vertices[0], positions[0], uvs[0], normals[0]);
const index2 = addVertex(vertices[1], positions[1], uvs[1], normals[1]);
const index3 = addVertex(vertices[2], positions[2], uvs[2], normals[2]);
addTriangle(index1, index2, index3, isWindingCorrect);
addTriangle(index1, index2, index3, true);
} else { // Triangulate if the face is not a triangle
const points = scratchPoints;
const vertexIndices = scratchVertexIndices;