src/builders/polylines.js
function addJoin(join_type, v, coordCurr, normPrev, normNext, isBeginning, context) {
    var miterVec = createMiterVec(normPrev, normNext);
    var isClockwise = (normNext[0] * normPrev[1] - normNext[1] * normPrev[0] > 0);

    if (context.texcoord_index != null) {
        zero_v[1] = v;
        one_v[1] = v;
    }

    if (isClockwise){
        addVertex(coordCurr, miterVec, miterVec, 1, v, context, 1);
        addVertex(coordCurr, normPrev, miterVec, 0, v, context, -1);

        if (!isBeginning) {
            indexPairs(1, context);
        }

        addFan(coordCurr,
            // extrusion vector of first vertex
            Vector.neg(normPrev),
            // controls extrude distance of pivot vertex
            miterVec,
            // extrusion vector of last vertex
            Vector.neg(normNext),
            // line normal (unused here)
            miterVec,
            // uv coordinates
            zero_v, one_v, zero_v,
            false, (join_type === JOIN_TYPE.bevel), context
        );

        addVertex(coordCurr, miterVec, miterVec, 1, v, context, 1);
        addVertex(coordCurr, normNext, miterVec, 0, v, context, -1);
    } else {
        addVertex(coordCurr, normPrev, miterVec, 1, v, context, 1);
        addVertex(coordCurr, miterVec, miterVec, 0, v, context, -1);

        if (!isBeginning) {
            indexPairs(1, context);
        }

        addFan(coordCurr,
            // extrusion vector of first vertex
            normPrev,
            // extrusion vector of pivot vertex
            Vector.neg(miterVec),
            // extrusion vector of last vertex
            normNext,
            // line normal for offset
            miterVec,
            // uv coordinates
            one_v, zero_v, one_v,
            false, (join_type === JOIN_TYPE.bevel), context
        );

        addVertex(coordCurr, normNext, miterVec, 1, v, context, 1);
        addVertex(coordCurr, miterVec, miterVec, 0, v, context, -1);
    }
}
function addJoin(join_type, v, coordCurr, normPrev, normNext, isBeginning, context) {
    var miterVec = createMiterVec(normPrev, normNext);
    var isClockwise = (normNext[0] * normPrev[1] - normNext[1] * normPrev[0] > 0);

    if (context.texcoord_index != null) {
        zero_v[1] = v;
        one_v[1] = v;
    }

    if (isClockwise){
        addVertex(coordCurr, miterVec, miterVec, 1, v, context, 1);
        addVertex(coordCurr, normPrev, miterVec, 0, v, context, -1);

        if (!isBeginning) {
            indexPairs(1, context);
        }

        addFan(coordCurr,
            // extrusion vector of first vertex
            Vector.neg(normPrev),
            // controls extrude distance of pivot vertex
            miterVec,
            // extrusion vector of last vertex
            Vector.neg(normNext),
            // line normal (unused here)
            miterVec,
            // uv coordinates
            zero_v, one_v, zero_v,
            false, (join_type === JOIN_TYPE.bevel), context
        );

        addVertex(coordCurr, miterVec, miterVec, 1, v, context, 1);
        addVertex(coordCurr, normNext, miterVec, 0, v, context, -1);
    } else {
        addVertex(coordCurr, normPrev, miterVec, 1, v, context, 1);
        addVertex(coordCurr, miterVec, miterVec, 0, v, context, -1);

        if (!isBeginning) {
            indexPairs(1, context);
        }

        addFan(coordCurr,
            // extrusion vector of first vertex
            normPrev,
            // extrusion vector of pivot vertex
            Vector.neg(miterVec),
            // extrusion vector of last vertex
            normNext,
            // line normal for offset
            miterVec,
            // uv coordinates
            one_v, zero_v, one_v,
            false, (join_type === JOIN_TYPE.bevel), context
        );

        addVertex(coordCurr, normNext, miterVec, 1, v, context, 1);
        addVertex(coordCurr, miterVec, miterVec, 0, v, context, -1);
    }
}
function addJoin ( join_type , v , coordCurr , normPrev , normNext , isBeginning , context ) { var miterVec = createMiterVec ( normPrev , normNext ) ; var isClockwise = ( normNext [ 0 ] * normPrev [ 1 ] - normNext [ 1 ] * normPrev [ 0 ] > 0 ) ; if ( context . texcoord_index != null ) { zero_v [ 1 ] = v ; one_v [ 1 ] = v ; } if ( isClockwise ) { addVertex ( coordCurr , miterVec , miterVec , 1 , v , context , 1 ) ; addVertex ( coordCurr , normPrev , miterVec , 0 , v , context , - 1 ) ; if ( ! isBeginning ) { indexPairs ( 1 , context ) ; } addFan ( coordCurr , // extrusion vector of first vertex Vector . neg ( normPrev ) , // controls extrude distance of pivot vertex miterVec , // extrusion vector of last vertex Vector . neg ( normNext ) , // line normal (unused here) miterVec , // uv coordinates zero_v , one_v , zero_v , false , ( join_type === JOIN_TYPE . bevel ) , context ) ; addVertex ( coordCurr , miterVec , miterVec , 1 , v , context , 1 ) ; addVertex ( coordCurr , normNext , miterVec , 0 , v , context , - 1 ) ; } else { addVertex ( coordCurr , normPrev , miterVec , 1 , v , context , 1 ) ; addVertex ( coordCurr , miterVec , miterVec , 0 , v , context , - 1 ) ; if ( ! isBeginning ) { indexPairs ( 1 , context ) ; } addFan ( coordCurr , // extrusion vector of first vertex normPrev , // extrusion vector of pivot vertex Vector . neg ( miterVec ) , // extrusion vector of last vertex normNext , // line normal for offset miterVec , // uv coordinates one_v , zero_v , one_v , false , ( join_type === JOIN_TYPE . bevel ) , context ) ; addVertex ( coordCurr , normNext , miterVec , 1 , v , context , 1 ) ; addVertex ( coordCurr , miterVec , miterVec , 0 , v , context , - 1 ) ; } }
Add a bevel or round join
Add a bevel or round join