Go to file
Sean Lilley bedbb6ef96 Fix tests and jshint 2017-04-04 17:57:01 -04:00
.idea Remove typings 2017-03-15 13:19:47 -04:00
bin Support KHR_materials_common output 2017-04-04 17:55:00 -04:00
doc Updated readme 2015-10-18 23:51:01 -04:00
lib Fix tests and jshint 2017-04-04 17:57:01 -04:00
specs Fix tests and jshint 2017-04-04 17:57:01 -04:00
.editorconfig Added .editorconfig 2017-03-14 10:56:44 -04:00
.gitignore Remove typings 2017-03-15 13:19:47 -04:00
.jshintrc Updated project for publishing 2016-07-08 18:10:18 -04:00
.npmignore Remove typings 2017-03-15 13:19:47 -04:00
.travis.yml Travis coveralls fix 2017-04-04 11:24:39 -04:00
CHANGES.md Update date 2017-01-06 17:50:19 -05:00
LICENSE.md Updated LICENSE.md 2017-03-17 16:13:08 -04:00
README.md Support KHR_materials_common output 2017-04-04 17:55:00 -04:00
gulpfile.js Refactor and tests 2017-03-14 10:43:28 -04:00
index.js Upgrade for gltf-pipeline 2016-06-10 17:43:30 -04:00
package.json Added coveralls 2017-03-22 16:50:03 -04:00

README.md

OBJ2GLTF

Convert OBJ assets to glTF 1.0.

Getting Started

Install Node.js if you don't already have it, and then:

npm install --save obj2gltf

Using obj2gltf as a library:

var obj2gltf = require('obj2gltf');
var convert = obj2gltf.convert;
var options = {
    separateTextures : true // Don't embed textures in the converted glTF
}
convert('model.obj', 'model.gltf', options)
    .then(function() {
        console.log('Converted model');
    });

Using obj2gltf as a command-line tool:

node bin/obj2gltf.js model.obj

node bin/obj2gltf.js model.obj model.gltf

node bin/obj2gltf.js -i model.obj -o model.gltf

node bin/obj2gltf.js -i model.obj -o model.gltf -s

Usage

###Command line flags:

Flag Description Required
-h Display help. No
-i Path to the obj file. Yes
-o Path of the converted glTF file. No
-b Save as binary glTF. No, default false
-s Writes out separate geometry data files, shader files, and textures instead of embedding them in the glTF file. No, default false
-t Write out separate textures only. No, default false
-c Quantize positions, compress texture coordinates, and oct-encode normals. No, default false
-z Use the optimization stages in the glTF pipeline. No, default false
-n Generate normals if they are missing. No, default false
--cesium Optimize the glTF for Cesium by using the sun as a default light source. No, default false
--ao Apply ambient occlusion to the converted model. No, default false
`--kmc Output glTF with the KHR_materials_common extension. No, default false
--bypassPipeline Bypass the gltf-pipeline for debugging purposes. This option overrides many of the options above and will save the glTF with the KHR_materials_common extension. No, default false
--hasTransparency Do a more exhaustive check for texture transparency by looking at the alpha channel of each pixel. By default textures with an alpha channel are considered to be transparent. No, default false
--secure Prevent the converter from reading image or mtl files outside of the input obj directory. No, default false

Build Instructions

Run the tests:

npm run test

To run JSHint on the entire codebase, run:

npm run jsHint

To run JSHint automatically when a file is saved, run the following and leave it open in a console window:

npm run jsHint-watch

Running Test Coverage

Coverage uses istanbul. Run:

npm run coverage

For complete coverage details, open coverage/lcov-report/index.html.

The tests and coverage covers the Node.js module; it does not cover the command-line interface, which is tiny.

Generating Documentation

To generate the documentation:

npm run jsdoc

The documentation will be placed in the doc folder.

Debugging

  • To debug the tests in Webstorm, open the Gulp tab, right click the test task, and click Debug 'test'.
  • To run a single test, change the test function from it to fit.

Contributions

Pull requests are appreciated. Please use the same Contributor License Agreement (CLA) used for Cesium.


Developed by the Cesium team.