This library is an ESM module for parsing Wavefront OBJ files into a JavaScript structure suitable for further processing or rendering.
This library is not really maintained.
It can parse edges and faces, but ignores the other commands and throws on some I haven't set to be ignored yet. I don't know if I will develop it further to handle this better.
import parse from 'https://tomashubelbauer.github.io/esm-obj/index.js';const mesh = parse(text);The return values is an object with the following shape:
minXis the smallest X coordinate value of any vertex foundmaxXis the largest X coordinate value of any vertex foundminYis the smallest Y coordinate value of any vertex foundmaxYis the largest Y coordinate value of any vertex foundminZis the smallest Z coordinate value of any vertex foundmaxZis the largest Z coordinate value of any vertex foundshapesis an array of objects, one of:- Edge:
typeisedgefromis the 'from' vertex - an array of X, Y, Z coordinate valuestois the 'to' vertex - an array of X, Y, Z coordinate values
- Face:
typeisfacepointsis an array of vertices that connect up to form the face polygon- The loop of the vertices is not closed (first != last)
- The points are represented using an array of X, Y, Z coordinate values
- Edge: