Merge branch 'master' into alpha-texture

This commit is contained in:
Sean Lilley 2018-01-19 10:44:37 -05:00 committed by GitHub
commit 260b3e67e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 16 deletions

View File

@ -5,6 +5,7 @@ Change Log
* Added ability to load alpha textures. [#124](https://github.com/AnalyticalGraphicsInc/obj2gltf/pull/124) * Added ability to load alpha textures. [#124](https://github.com/AnalyticalGraphicsInc/obj2gltf/pull/124)
* Fixed handling of `usemtl` when appearing before an `o` or `g` token. [#123](https://github.com/AnalyticalGraphicsInc/obj2gltf/pull/123) * Fixed handling of `usemtl` when appearing before an `o` or `g` token. [#123](https://github.com/AnalyticalGraphicsInc/obj2gltf/pull/123)
* Fixed output name when running from the command line. [#126](https://github.com/AnalyticalGraphicsInc/obj2gltf/pull/126)
### 2.1.0 2017-12-28 ### 2.1.0 2017-12-28

View File

@ -6,16 +6,16 @@ Convert OBJ assets to [glTF](https://www.khronos.org/gltf) 2.0.
Install [Node.js](https://nodejs.org/en/) if you don't already have it, and then: Install [Node.js](https://nodejs.org/en/) if you don't already have it, and then:
``` ```
npm install --save obj2gltf npm install -g obj2gltf
``` ```
### Using obj2gltf as a command-line tool: ### Using obj2gltf as a command-line tool:
`node bin/obj2gltf.js -i model.obj` `obj2gltf -i model.obj`
`node bin/obj2gltf.js -i model.obj -o model.gltf` `obj2gltf -i model.obj -o model.gltf`
`node bin/obj2gltf.js -i model.obj -o model.glb` `obj2gltf -i model.obj -o model.glb`
### Using obj2gltf as a library: ### Using obj2gltf as a library:

View File

@ -6,6 +6,7 @@ var path = require('path');
var yargs = require('yargs'); var yargs = require('yargs');
var obj2gltf = require('../lib/obj2gltf'); var obj2gltf = require('../lib/obj2gltf');
var defaultValue = Cesium.defaultValue;
var defined = Cesium.defined; var defined = Cesium.defined;
var defaults = obj2gltf.defaults; var defaults = obj2gltf.defaults;
@ -126,18 +127,13 @@ if (defined(argv.metallicRoughnessOcclusionTexture) && defined(argv.specularGlos
var objPath = argv.input; var objPath = argv.input;
var gltfPath = argv.output; var gltfPath = argv.output;
var name = path.basename(objPath, path.extname(objPath));
if (!defined(gltfPath)) { var filename = defaultValue(gltfPath, objPath);
gltfPath = path.join(path.dirname(objPath), name + '.gltf'); var name = path.basename(filename, path.extname(filename));
} var outputDirectory = path.dirname(filename);
var binary = argv.binary || path.extname(filename).toLowerCase() === '.glb';
var extension = binary ? '.glb' : '.gltf';
var outputDirectory = path.dirname(gltfPath);
var extension = path.extname(gltfPath).toLowerCase();
if (argv.binary || extension === '.glb') {
argv.binary = true;
extension = '.glb';
}
gltfPath = path.join(outputDirectory, name + extension); gltfPath = path.join(outputDirectory, name + extension);
var overridingTextures = { var overridingTextures = {
@ -151,7 +147,7 @@ var overridingTextures = {
}; };
var options = { var options = {
binary : argv.binary, binary : binary,
separate : argv.separate, separate : argv.separate,
separateTextures : argv.separateTextures, separateTextures : argv.separateTextures,
checkTransparency : argv.checkTransparency, checkTransparency : argv.checkTransparency,
@ -168,7 +164,7 @@ console.time('Total');
obj2gltf(objPath, options) obj2gltf(objPath, options)
.then(function(gltf) { .then(function(gltf) {
if (argv.binary) { if (binary) {
// gltf is a glb buffer // gltf is a glb buffer
return fsExtra.outputFile(gltfPath, gltf); return fsExtra.outputFile(gltfPath, gltf);
} }