 }
 
 
-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

        }
    }

    private static func normalizeIndex(index: Int?, count: Int) -> Int? {
        guard let i = index else {
            return nil

    // Init an objloader with the
    // source of the .obj file as a string
    //
    public init(source: String, basePath: NSString) {
        scanner = ObjScanner(source: source)
        self.basePath = basePath
    }

    // Read the specified source.
    // This operation is singled threaded and
    // should not be invoked again before
    // the call has returned
    public func read() throws -> [Shape] {
        var shapes: [Shape] = []

        resetState()
