geom-parse-obj
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

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.

Package Sidebar

Install

npm i geom-parse-obj

Weekly Downloads

2

Version

2.0.0

License

MIT

Unpacked Size

9.35 kB

Total Files

6

Last publish

Collaborators

  • vorg