Parse Wavefront .obj geometry file.
This parser supports multiple meshes in one file via g sections in the OBJ file.
npm install geom-parse-objimport parseObj from "geom-parse-obj";
const objString = await (await fetch("file.obj")).text();
const obj = parseObj(objString);
// => {
// positions: new Float32Array([x, y, z, x, y, z, ...])
// normals: new Float32Array([x, y, z, x, y, z, ...])
// uvs: new Float32Array([u, v, u, v, ...])
// cells: new Uint16Array([i, j, k, i, j, k, ...])
// }Parameters
- objString:
string- UTF8 encoded string with the contents of OBJ file
Returns
geometry[]: array of one or more simplicial complex geometry depending if groups are present in the file.
MIT. See license file.