nodejs module to parse WaveFront Object (.obj) files to javascript and/or JSON
npm install objtojsobjtojs
=======
A nodejs module to parses WaveFront Object (.obj) files to javascript or JSON.
Overview
--------
Parse WaveFront Object file (.obj) to a javascript object and/or JSON.
Option to save the parsed data to a JSON file which will also break down the data to segments and save each segment to it's own JSON file.
Installation
------------
> npm install objtojs
Dependencies
------------
mtltojs
Usage:
-------
Returns a js object and optional JSON.
var parser = require("objtojs");
``javascript
`
// Async call
parser.parse(file, function(err, data){
// do stuff with data
});
`
or
javascript
`
//Synchronous call
var data = parser.parseSync("C:/3d/materials/sample.obj");
parse(file[,options], callback)
Methods
-------
parse - Is an async method which takes in a filepath and optional options object. Returns a js objected of the parsed data. Options to save JSON and log information to a file. For options See below
parseSync(file[,options])
parseSync - Is a synchronous call which takes the same arguments as the asynchronous parse call..
parse(file, options, callback)
Parameters
----------
These are the parameters for methods...
and parseSync(file, options)
bool
file -
options - (default: false) - flag to retain comments when parsing the file.bool
verbose - (default: false) - flag to write parsing details to the nodejs console.bool
logging - (default: false) - flag to write and save parsing details to a log file.bool
returnJSON - (default: false) - flag to have the a JSON string of the parsed object returned with the js object.bool
saveJSON - (default: false) - flag to save the parsed data as a JSON string to file.
bool
parseMTLFile - (default: false) - flag to parse material file referenced in the object file.bool
returnMTLJSON - (default: false) - flag to return parsed material file data as JSON. NOTE: This flag is ignored if parseMTLFile is false.bool
saveMTLJSON - (default: false) - flag to save the parsed material file data as JSON. NOTE: This flag is ignored if parseMTLFile is false.
`
Default Option object if the options parameter is omitted...
javascript
``
options = {
parseComments: false,
verbose: false,
logging: false,
returnJSON: false,
saveJSON: false,
parseMTLFile: false,
returnMTLJSON: false,
saveMTLJSON: false
}
License
-------
MIT