# obj-file-parser

> Wavefront 3D Object File (.OBJ) Parser

Latest version **0.6.2** (published 2023-01-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install obj-file-parser
pnpm add obj-file-parser
yarn add obj-file-parser
bun add obj-file-parser
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.6.2 |
| Published | 2023-01-23 |
| First published | 2017-08-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/obj-file-parser) |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 13.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 40 |
| Author | Wesley Unwin |
| Maintainers | wesunwin |
| Keywords | obj, file, 3D, parser, wavefront, mtl |

## Links

- npm: https://www.npmjs.com/package/obj-file-parser
- Repository: https://github.com/WesUnwin/obj-file-parser
- Homepage: https://github.com/WesUnwin/obj-file-parser#readme
- Issues: https://github.com/WesUnwin/obj-file-parser/issues
- npm.io page: https://npm.io/package/obj-file-parser

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.6.2 (latest) — 2023-01-23
- 0.6.1 — 2023-01-08
- 0.6.0 — 2023-01-08
- 0.5.3 — 2021-03-14
- 0.5.2 — 2021-03-14
- 0.5.1 — 2020-09-11
- 0.5.0 — 2017-08-20
- 0.4.0 — 2017-08-20
- 0.3.0 — 2017-08-15
- 0.2.0 — 2017-08-14
- 0.1.1 — 2017-08-14
- 0.1.0 — 2017-08-14
- 0.0.0 — 2017-08-13

## README

[![npm version](https://badge.fury.io/js/obj-file-parser.svg)](https://badge.fury.io/js/obj-file-parser)
[![Build Status](https://travis-ci.org/WesUnwin/obj-file-parser.svg?branch=master)](https://travis-ci.org/WesUnwin/obj-file-parser)

# obj-file-parser
Open source, re-usable Wavefront 3D object file (.OBJ) parser written
in javascript and distributed freely as an NPM package.


## Features

  * Support for (.OBJ) files only, see mtl-file-parser for mtl files
  * Case insensitive, flexible parser
  * Simple JS object output
  * Polygon group support
  * Smoothing group support
  * ES5 syntax for support across virtually all platforms
  * No dependencies

## Installation

```javascript
npm install --save obj-file-parser
```

## Usage

```javascript
const OBJFile = require('obj-file-parser');

const fileContents =
  'v 0 0 0 \n' +
  'v 0 1 0 \n' +
  'v 1 0 0 \n' +
  'f 1 2 3';

const objFile = new OBJFile(fileContents);

const output = objFile.parse(); // see description below
```


## Output
The extracted model data and list of material library references
are returned in the following format:

```
{
  models: [
    {
      name: 'unit_cube',
      vertices: [
        { x: 1.0, 2.0, 3.0 },
        ...
      ],
      textureCoords: [
        { u: 1.0, v: 2.0, w: 3.0 },
        ...
      ],
      vertexNormals: [
        { x: 1.0, y: 2.0, z: 3.0 },
        ...
      ],
      faces: [
        {
          material: 'brick',
          group: 'group1',
          smoothingGroup: 0,
          vertices: [
            { vertexIndex: 1, textureCoordsIndex: 1, vertexNormalIndex: 1 },
            ...
          ]
        }
      ]
    },
    {
      ...
    }
  ],

  materialLibraries: [
    'mat_lib1.mtl',
    ...
  ]
}
```

## More to come
obj-file-parser is being actively maintained and developed. Comments, feedback and bug reports
always welcome.

## Donation
Help me make this obj-file-parser and other tools better!

[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.me/WesUnwin)

---
_Source: https://npm.io/package/obj-file-parser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
