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:
minX
is the smallest X coordinate value of any vertex foundmaxX
is the largest X coordinate value of any vertex foundminY
is the smallest Y coordinate value of any vertex foundmaxY
is the largest Y coordinate value of any vertex foundminZ
is the smallest Z coordinate value of any vertex foundmaxZ
is the largest Z coordinate value of any vertex foundshapes
is an array of objects, one of:
type
is edge
from
is the ‘from’ vertex - an array of X, Y, Z coordinate valuesto
is the ‘to’ vertex - an array of X, Y, Z coordinate valuestype
is face
points
is an array of vertices that connect up to form the face polygon