import {rotateRxRyRz}   from '../rotation';
import {project}        from '../projection';
import {clockwise}      from '../clockwise';

export function triangles(data, options, point, angles){

    for (var i = data.length - 1; i >= 0; i--) {

        var tri         = data[i];

        var p1          = tri[0];
        var p2          = tri[1];
        var p3          = tri[2];

        p1.rotated      = rotateRxRyRz({x : point.x(p1), y : point.y(p1), z : point.z(p1)}, angles);
        p2.rotated      = rotateRxRyRz({x : point.x(p2), y : point.y(p2), z : point.z(p2)}, angles);
        p3.rotated      = rotateRxRyRz({x : point.x(p3), y : point.y(p3), z : point.z(p3)}, angles);

        p1.projected    = project(p1.rotated, options);
        p2.projected    = project(p2.rotated, options);
        p3.projected    = project(p3.rotated, options);

        tri.cw          = clockwise(tri);
        tri.centroid    = { x: (p1.rotated.x + p2.rotated.x + p3.rotated.x)/3, y: (p1.rotated.y + p2.rotated.y + p3.rotated.y)/3, z: (p1.rotated.z + p2.rotated.z + p3.rotated.z)/3};
    }
    return data;
}

@@ -258,19 +258,16 @@
 ri      
-   
 = data%5Bi
@@ -287,27 +287,24 @@
 ar p1       
-   
 = tri%5B0%5D;%0A  
@@ -318,27 +318,24 @@
 ar p2       
-   
 = tri%5B1%5D;%0A  
@@ -349,27 +349,24 @@
 ar p3       
-   
 = tri%5B2%5D;%0A%0A 
@@ -377,35 +377,32 @@
    p1.rotated   
-   
 = rotateRxRyRz(%7B
@@ -475,35 +475,32 @@
    p2.rotated   
-   
 = rotateRxRyRz(%7B
@@ -581,19 +581,16 @@
 tated   
-   
 = rotate
@@ -672,35 +672,32 @@
    p1.projected 
-   
 = project(p1.rot
@@ -725,35 +725,32 @@
    p2.projected 
-   
 = project(p2.rot
@@ -786,19 +786,16 @@
 ojected 
-   
 = projec
@@ -840,19 +840,16 @@
 w       
-   
 = clockw
@@ -879,19 +879,16 @@
 entroid 
-   
 = %7B x: (

convert tabs to spaces