Skip to content

Commit

Permalink
Update loadObj.js
Browse files Browse the repository at this point in the history
  • Loading branch information
sabiqusi authored and PrincessGod committed Jul 18, 2018
1 parent 948a132 commit 0e0d32f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/loadObj.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,22 @@ function loadObj(objPath, options) {

// Given the cartesian 2 vertices of a polygon, determine if convex
function isConvex(positions2D) {
var length = position2D.length;
var turnDirection = getTurnDirection(positions2D[0], positions2D[1], positions2D[2]);
for (var i=1; i < positions2D.length-2; ++i) {
for (var i=1; i < length-2; ++i) {
var currentTurnDirection = getTurnDirection(positions2D[i], positions2D[i+1], positions2D[i+2]);
if (turnDirection * currentTurnDirection < 0) {
return false;
}
}
var currentTurnDirection = getTurnDirection(position2D[length-2], position2D[length-1], position2D[0]);
if (turnDirection * currentTurnDirection < 0) {
return false;
}
currentTurnDirection = getTurnDirection(position2D[length-1], position2D[0], position2D[1]);
if (turnDirection * currentTurnDirection < 0) {
return false;
}
return true;
}

Expand Down

0 comments on commit 0e0d32f

Please sign in to comment.