geom-parse-obj
v2.0.0
Published
Parse Wavefront .obj geometry files.
Downloads
27
Maintainers
Readme
geom-parse-obj
Parse Wavefront .obj geometry file.
This parser supports multiple meshes in one file via g
sections in the OBJ file.
Installation
npm install geom-parse-obj
Usage
import 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, ...])
// }
API
parseObj(objString): geometry[]
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.
License
MIT. See license file.