A simple parser for .OBJ mesh files.
var fs = require("fs")
var parseOBJ = require("parse-obj")
parseOBJ(fs.createReadStream("mesh.obj"), function(err, result) {
if(err) {
throw new Error("Error parsing OBJ file: " + err)
}
console.log("Got mesh: ", result)
})Parses a read stream into a .OBJ format mesh
-
streamis a read stream -
cbis a callback that gets executed once the stream is parsed. Theresultobject is a structure with the following data:vertexPositionsan array of vertex position datavertexNormalsan array of vertex normal datavertexUVsan array of vertex UV coordinatesfacePositionsan array of indices for face positionsfaceNormalsan array of indices for face normalsfaceUVsan array of indices for face texture coordinates
(c) 2013 Mikola Lysenko. MIT License