File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -330,13 +330,22 @@ function loadObj(objPath, options) {
330330
331331 // Given the cartesian 2 vertices of a polygon, determine if convex
332332 function isConvex ( positions2D ) {
333+ var length = position2D . length ;
333334 var turnDirection = getTurnDirection ( positions2D [ 0 ] , positions2D [ 1 ] , positions2D [ 2 ] ) ;
334- for ( var i = 1 ; i < positions2D . length - 2 ; ++ i ) {
335+ for ( var i = 1 ; i < length - 2 ; ++ i ) {
335336 var currentTurnDirection = getTurnDirection ( positions2D [ i ] , positions2D [ i + 1 ] , positions2D [ i + 2 ] ) ;
336337 if ( turnDirection * currentTurnDirection < 0 ) {
337338 return false ;
338339 }
339340 }
341+ var currentTurnDirection = getTurnDirection ( position2D [ length - 2 ] , position2D [ length - 1 ] , position2D [ 0 ] ) ;
342+ if ( turnDirection * currentTurnDirection < 0 ) {
343+ return false ;
344+ }
345+ currentTurnDirection = getTurnDirection ( position2D [ length - 1 ] , position2D [ 0 ] , position2D [ 1 ] ) ;
346+ if ( turnDirection * currentTurnDirection < 0 ) {
347+ return false ;
348+ }
340349 return true ;
341350 }
342351
You can’t perform that action at this time.
0 commit comments