Parse Wavefront .obj geometry file.
Notes:
g
sections in the OBJ fileparseObj(str)
Parameters:
str
- UTF8 encoded string with the contents of OBJ file
Returns:
geometry
or [geometry, geometry, ...]
(depending if groups are present inside the file)
geometry = {
positions: [[x, y, z], [x, y, z], ...], // array of positions
normals: [[x, y, z], [x, y, z], ...], // array of normals
uvs: [[u, v], [u, v], ...], // array of tex coords
cells: [[i, j, k], [i, j, k], ...] // array of triangles or polygons
}
var parseObj = require('geom-parse-obj');
var fs = require('fs')
var objStr = fs.readFileSync(__dirname + '/geometry.obj', 'utf8')
var obj = parseObj(objStr)
console.log(obj.positions) // -> [[0, 0, 0], [1, 0, 1], ...]
parse-obj by Mikola Lysenko
MIT, see LICENSE.md for details.