diff --git a/types/obj-file-parser/index.d.ts b/types/obj-file-parser/index.d.ts index 1f33d32477..fcd48013f8 100644 --- a/types/obj-file-parser/index.d.ts +++ b/types/obj-file-parser/index.d.ts @@ -3,45 +3,53 @@ // Definitions by: Ben Coleman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export default class Parser { +export as namespace ObjFileParser; + +/* Class module */ +declare class ObjFileParser { constructor(fileContents: any, defaultModelName?: any); - parse(): ObjFile; + parse(): ObjFileParser.ObjFile; } -export interface ObjFile { - models: ObjModel[]; - materialLibraries: any[]; +/* Additional exported interfaces */ +declare namespace ObjFileParser { + interface ObjFile { + models: ObjModel[]; + materialLibraries: any[]; + } + + interface ObjModel { + name: string; + vertices: Vertex[]; + textureCoords: VertexTexture[]; + vertexNormals: Vertex[]; + faces: Face[]; + } + + interface Face { + material: any; + group: string; + smoothingGroup: number; + vertices: FaceVertex[]; + } + + interface FaceVertex { + vertexIndex: number; + textureCoordsIndex: number; + vertexNormalIndex: number; + } + + interface Vertex { + x: number; + y: number; + z: number; + } + + interface VertexTexture { + u: number; + v: number; + w: number; + } } -export class ObjModel { - name: string; - vertices: Vertex[]; - textureCoords: VertexTexture[]; - vertexNormals: Vertex[]; - faces: Face[]; -} - -export class Face { - material: any; - group: string; - smoothingGroup: number; - vertices: FaceVertex[]; -} - -export class FaceVertex { - vertexIndex: number; - textureCoordsIndex: number; - vertexNormalIndex: number; -} - -export class Vertex { - x: number; - y: number; - z: number; -} - -export class VertexTexture { - u: number; - v: number; - w: number; -} +export = ObjFileParser; diff --git a/types/obj-file-parser/obj-file-parser-tests.ts b/types/obj-file-parser/obj-file-parser-tests.ts index b0459b3c32..8d3cbd6c6a 100644 --- a/types/obj-file-parser/obj-file-parser-tests.ts +++ b/types/obj-file-parser/obj-file-parser-tests.ts @@ -1,5 +1,3 @@ -import ObjFileParser, { ObjModel, ObjFile, Vertex, Face, FaceVertex } from 'obj-file-parser'; - const testObjFile = ` # cube.obj # Example object @@ -42,14 +40,14 @@ const parser = new ObjFileParser(testObjFile, 'test'); const file = parser.parse(); // get first model in file -const model: ObjModel = file.models[0]; +const model: ObjFileParser.ObjModel = file.models[0]; // gets object name const name: string = model.name; // gets first face in model -const face: Face = model.faces[0]; +const face: ObjFileParser.Face = model.faces[0]; // gets first vertex in face -const faceVert: FaceVertex = face.vertices[0]; +const faceVert: ObjFileParser.FaceVertex = face.vertices[0]; // gets vertex -const vertPoints: Vertex = model.vertices[faceVert.vertexIndex]; +const vertPoints: ObjFileParser.Vertex = model.vertices[faceVert.vertexIndex]; // gets x value of vertex const x = vertPoints.x;