function flattenFaceAndVector(matrixWorld, face, verts, normal, point) {

            var a = verts[face.a].clone().applyMatrix4(matrixWorld);
            var b = verts[face.b].clone().applyMatrix4(matrixWorld);
            var c = verts[face.c].clone().applyMatrix4(matrixWorld);
            var p = point.clone();

            var a1 = [a.x - a.x, a.y - a.y, a.z - a.z];
            var b1 = [b.x - a.x, b.y - a.y, b.z - a.z];
            var c1 = [c.x - a.x, c.y - a.y, c.z - a.z];
            var p1 = [p.x - a.x, p.y - a.y, p.z - a.z];


            var v = vNormalize([0, 0, 1]);
            var angle = angleTo(normal, v);
            var rotAxis, rotMat;

            // todo work with epsilon?
            if (angle !== 0 && angle !== Math.PI) {

                rotAxis = getRotationAxis(normal, v);
                rotMat = getRotationMatrix(rotAxis, angle);
                b1 = vApplyMatrix3(b1, rotMat);
                c1 = vApplyMatrix3(c1, rotMat);
                p1 = vApplyMatrix3(p1, rotMat);
            }

            // return UVcoords
            return [
                [a1[0], a1[1], 0],
                [b1[0], b1[1], 0],
                [c1[0], c1[1], 0],
                [p1[0], p1[1], 0]
            ];

        }
/**
         * This method flattens a face and an additional point.
         * @param matrixWorld
         * @param face
         * @param verts
         * @param normal
         * @param point
         * @returns {*[]}
         */
This method flattens a face and an additional point.
This method flattens a face and an additional point .
function flattenFaceAndVector(matrixWorld, face, verts, normal, point) {
            var a = verts[face.a].clone().applyMatrix4(matrixWorld);
            var b = verts[face.b].clone().applyMatrix4(matrixWorld);
            var c = verts[face.c].clone().applyMatrix4(matrixWorld);
            var p = point.clone();
            var a1 = [a.x - a.x, a.y - a.y, a.z - a.z];
            var b1 = [b.x - a.x, b.y - a.y, b.z - a.z];
            var c1 = [c.x - a.x, c.y - a.y, c.z - a.z];
            var p1 = [p.x - a.x, p.y - a.y, p.z - a.z];
            var v = vNormalize([0, 0, 1]);
            var angle = angleTo(normal, v);
            var rotAxis, rotMat;
            if (angle !== 0 && angle !== Math.PI) {
                rotAxis = getRotationAxis(normal, v);
                rotMat = getRotationMatrix(rotAxis, angle);
                b1 = vApplyMatrix3(b1, rotMat);
                c1 = vApplyMatrix3(c1, rotMat);
                p1 = vApplyMatrix3(p1, rotMat);
            }
            return [
                [a1[0], a1[1], 0],
                [b1[0], b1[1], 0],
                [c1[0], c1[1], 0],
                [p1[0], p1[1], 0]
            ];
        }
function flattenFaceAndVector ( matrixWorld , face , verts , normal , point ) { var a = verts [ face . a ] . clone ( ) . applyMatrix4 ( matrixWorld ) ; var b = verts [ face . b ] . clone ( ) . applyMatrix4 ( matrixWorld ) ; var c = verts [ face . c ] . clone ( ) . applyMatrix4 ( matrixWorld ) ; var p = point . clone ( ) ; var a1 = [ a . x - a . x , a . y - a . y , a . z - a . z ] ; var b1 = [ b . x - a . x , b . y - a . y , b . z - a . z ] ; var c1 = [ c . x - a . x , c . y - a . y , c . z - a . z ] ; var p1 = [ p . x - a . x , p . y - a . y , p . z - a . z ] ; var v = vNormalize ( [ 0 , 0 , 1 ] ) ; var angle = angleTo ( normal , v ) ; var rotAxis , rotMat ; if ( angle !== 0 && angle !== Math . PI ) { rotAxis = getRotationAxis ( normal , v ) ; rotMat = getRotationMatrix ( rotAxis , angle ) ; b1 = vApplyMatrix3 ( b1 , rotMat ) ; c1 = vApplyMatrix3 ( c1 , rotMat ) ; p1 = vApplyMatrix3 ( p1 , rotMat ) ; } return [ [ a1 [ 0 ] , a1 [ 1 ] , 0 ] , [ b1 [ 0 ] , b1 [ 1 ] , 0 ] , [ c1 [ 0 ] , c1 [ 1 ] , 0 ] , [ p1 [ 0 ] , p1 [ 1 ] , 0 ] ] ; }
This method flattens a face and an additional point.
This method flattens a face and an additional point .
// todo work with epsilon? // return UVcoords