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
-
stream
is a read stream -
cb
is a callback that gets executed once the stream is parsed. Theresult
object is a structure with the following data:vertexPositions
an array of vertex position datavertexNormals
an array of vertex normal datavertexUVs
an array of vertex UV coordinatesfacePositions
an array of indices for face positionsfaceNormals
an array of indices for face normalsfaceUVs
an array of indices for face texture coordinates
(c) 2013 Mikola Lysenko. MIT License