New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

obj-file-parser

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

obj-file-parser

Wavefront 3D Object File (.OBJ) Parser

latest
Source
npmnpm
Version
0.6.2
Version published
Weekly downloads
317
58.5%
Maintainers
1
Weekly downloads
 
Created
Source

npm version Build Status

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

npm install --save obj-file-parser

Usage

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

Keywords

obj

FAQs

Package last updated on 23 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts