fn normal(tri: &stl_io::Triangle) -> stl_io::Normal {
    let p1: cgmath::Vector3<f32> = tri.vertices[0].into();
    let p2: cgmath::Vector3<f32> = tri.vertices[1].into();
    let p3: cgmath::Vector3<f32> = tri.vertices[2].into();
    let v = p2 - p1;
    let w = p3 - p1;
    let n = v.cross(w);
    let mag = n.x.abs() + n.y.abs() + n.z.abs();
    [n.x / mag, n.y / mag, n.z / mag]
}
// Calculate surface normal of triangle using cross product
// TODO: The GPU can probably do this a lot faster than we can.
// See if there is an option for offloading this.
// Probably need to use a geometry shader (not supported in Opengl ES).
Calculate surface normal of triangle using cross product
TODO: The GPU can probably do this a lot faster than we can.
See if there is an option for offloading this.
Probably need to use a geometry shader (not supported in Opengl ES).
Calculate surface normal of triangle using cross product TODO : The GPU can probably do this a lot faster than we can . See if there is an option for offloading this . Probably need to use a geometry shader ( not supported in Opengl ES ) .
fn normal(tri: &stl_io::Triangle) -> stl_io::Normal {
    let p1: cgmath::Vector3<f32> = tri.vertices[0].into();
    let p2: cgmath::Vector3<f32> = tri.vertices[1].into();
    let p3: cgmath::Vector3<f32> = tri.vertices[2].into();
    let v = p2 - p1;
    let w = p3 - p1;
    let n = v.cross(w);
    let mag = n.x.abs() + n.y.abs() + n.z.abs();
    [n.x / mag, n.y / mag, n.z / mag]
}
fn normal ( tri : & stl_io :: Triangle ) -> stl_io :: Normal { let p1 : cgmath :: Vector3 < f32 > = tri . vertices [ 0 ] . into ( ) ; let p2 : cgmath :: Vector3 < f32 > = tri . vertices [ 1 ] . into ( ) ; let p3 : cgmath :: Vector3 < f32 > = tri . vertices [ 2 ] . into ( ) ; let v = p2 - p1 ; let w = p3 - p1 ; let n = v . cross ( w ) ; let mag = n . x . abs ( ) + n . y . abs ( ) + n . z . abs ( ) ; [ n . x / mag , n . y / mag , n . z / mag ] }
Calculate surface normal of triangle using cross product
TODO: The GPU can probably do this a lot faster than we can.
Calculate surface normal of triangle using cross product TODO : The GPU can probably do this a lot faster than we can .
tri
&stl_io::Triangle