 }
 
 
-class ObjLoader {
+public class ObjLoader {
     // Represent the state of parsing
     // at any point in time
-    struct State {
+    class State {
         var objectName: NSString?
         var vertices: [Vector] = []
         var normals: [Vector] = []
         var textureCoords: [Vector] = []
         var faces: [[VertexIndex]] = []
+        var material: Material?
     }
 
     // Source markers

                if ObjLoader.isComment(m) {
                    scanner.moveToNextLine()
                    continue
                } else if ObjLoader.isVertex(m) {
                    if let v = try readVertex() {
                        state.vertices.append(v)
                    }

                    scanner.moveToNextLine()
                    continue
                } else if ObjLoader.isNormal(m) {
                    if let n = try readVertex() {
                        state.normals.append(n)
                    }

                    scanner.moveToNextLine()
                    continue
                } else if ObjLoader.isTextureCoord(m) {
                    if let vt = scanner.readTextureCoord() {
                        state.textureCoords.append(vt)
                    }

                    scanner.moveToNextLine()
                    continue
                } else if ObjLoader.isObject(m) {
                    if let s = buildShape(state.objectName, vertices: state.vertices, normals: state.normals, textureCoords: state.textureCoords, faces: state.faces) {
                        shapes.append(s)
                    }


        return marker.length == 1 && marker.characterAtIndex(0) == objectMarker
    }

    private static func isGroup(marker: NSString) -> Bool {
        return marker.length == 1 && marker.characterAtIndex(0) == groupMarker
    }

    private static func isFace(marker: NSString) -> Bool {
        return marker.length == 1 && marker.characterAtIndex(0) == faceMarker
    }

    private static func isMaterialLibrary(marker: NSString) -> Bool {
        return marker == materialLibraryMarker
    }

    private static func isUseMaterial(marker: NSString) -> Bool {
        return marker == useMaterialMarker
    }

    private func readVertex() throws -> [Double]? {
