src/Tools/babylon.earcut.js
// check whether a polygon node forms a valid ear with adjacent nodes
check whether a polygon node forms a valid ear with adjacent nodes
check whether a polygon node forms a valid ear with adjacent nodes
function isEar(ear) {
        var a = ear.prev, b = ear, c = ear.next;
        if (area(a, b, c) >= 0)
            return false; 
        var p = ear.next.next;
        while (p !== ear.prev) {
            if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
                area(p.prev, p, p.next) >= 0)
                return false;
            p = p.next;
        }
        return true;
    }
function isEar ( ear ) { var a = ear . prev , b = ear , c = ear . next ; if ( area ( a , b , c ) >= 0 ) return false ; var p = ear . next . next ; while ( p !== ear . prev ) { if ( pointInTriangle ( a . x , a . y , b . x , b . y , c . x , c . y , p . x , p . y ) && area ( p . prev , p , p . next ) >= 0 ) return false ; p = p . next ; } return true ; }
check whether a polygon node forms a valid ear with adjacent nodes
check whether a polygon node forms a valid ear with adjacent nodes
// reflex, can't be an ear // now make sure we don't have other points inside the potential ear