Skip to content

vorg/geom-parse-obj

Repository files navigation

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.

About

Parse OBJ geometry files

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •