parse-wavefront-obj

1.0.3 • Public • Published

parse-wavefront-obj

Wavefront OBJ parser

Parses a Wavefront OBJ string or buffer. If you're looking for a stream parser check this.

Supports vertex normals and UV coordinates. Doesn't support material libraries (though I'm open to PRs), nor multiple meshes embedded in the same file.

Install

$ npm install parse-wavefront-obj

Usage

var parseOBJ = require('parse-wavefront-obj');
var fs = require('fs');
 
var buf = fs.readFileSync('mesh.obj');
var mesh = parseOBJ(buf);
 
console.log(mesh);
/*
{
  positions: [...],
  cells: [...],
 
  // The following attributes are available when defined 
  // in the original file
 
  vertexUVs: [...],     // array of UV coordinates
  faceUVs: [...],       // array of UV indices
  vertexNormals: [...], // array of vertex normals
  faceNormals: [...],   // array of normal indices
  name: 'foo'           // mesh name
}
*/

Readme

Keywords

Package Sidebar

Install

npm i parse-wavefront-obj

Weekly Downloads

78

Version

1.0.3

License

MIT

Last publish

Collaborators

  • oparisy
  • thibauts