getMesh :: Model -> Mesh
getMesh model = newMesh
    & meshName .~ (model ^. modelName)
    & meshNormals .~ normals
    & meshVertices .~ vertices
    & meshFaces .~ faces
    & meshMaterialIndex .~ Just 0
  where
    vertices = foldl (\ vp facet -> vp V.++ (facet ^. facetVertices))
        V.empty (model ^. modelFacets)

    normals = foldl (\ vn facet -> V.snoc vn (facet ^. facetNormal))
        V.empty (model ^. modelFacets)

    faces = V.imap (\ i _ -> Face (V.fromList [3 * i, 3 * i + 1, 3 * i + 2 ]))
        (V.take (V.length vertices `div` 3) vertices)

-- | Checks which wheter file has binary or ascii representation.
getMesh :: Model -> Mesh
getMesh model = newMesh
    & meshName .~ (model ^. modelName)
    & meshNormals .~ normals
    & meshVertices .~ vertices
    & meshFaces .~ faces
    & meshMaterialIndex .~ Just 0
  where
    vertices = foldl (\ vp facet -> vp V.++ (facet ^. facetVertices))
        V.empty (model ^. modelFacets)

    normals = foldl (\ vn facet -> V.snoc vn (facet ^. facetNormal))
        V.empty (model ^. modelFacets)

    faces = V.imap (\ i _ -> Face (V.fromList [3 * i, 3 * i + 1, 3 * i + 2 ]))
        (V.take (V.length vertices `div` 3) vertices)

-- | Checks which wheter file has binary or ascii representation.
getMesh model = newMesh
    & meshName .~ (model ^. modelName)
    & meshNormals .~ normals
    & meshVertices .~ vertices
    & meshFaces .~ faces
    & meshMaterialIndex .~ Just 0
  where
    vertices = foldl (\ vp facet -> vp V.++ (facet ^. facetVertices))
        V.empty (model ^. modelFacets)

    normals = foldl (\ vn facet -> V.snoc vn (facet ^. facetNormal))
        V.empty (model ^. modelFacets)

    faces = V.imap (\ i _ -> Face (V.fromList [3 * i, 3 * i + 1, 3 * i + 2 ]))
        (V.take (V.length vertices `div` 3) vertices)

-- | Checks which wheter file has binary or ascii representation.