Merge pull request #126 from AnalyticalGraphicsInc/fix-output-name

Fix output name
This commit is contained in:
Shehzan Mohammed 2018-01-12 07:15:14 -08:00 committed by GitHub
commit c33694d85a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 16 deletions

View File

@ -4,6 +4,7 @@ Change Log
### 2.2.0 ???
* Fixed handling of `usemtl` when appearing before an `o` or `g` token. [#121](https://github.com/AnalyticalGraphicsInc/obj2gltf/pull/121)
* Fixed output name when running from the command line. [#126](https://github.com/AnalyticalGraphicsInc/obj2gltf/pull/126)
### 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:
```
npm install --save obj2gltf
npm install -g obj2gltf
```
### 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:

View File

@ -6,6 +6,7 @@ var path = require('path');
var yargs = require('yargs');
var obj2gltf = require('../lib/obj2gltf');
var defaultValue = Cesium.defaultValue;
var defined = Cesium.defined;
var defaults = obj2gltf.defaults;
@ -123,18 +124,13 @@ if (defined(argv.metallicRoughnessOcclusionTexture) && defined(argv.specularGlos
var objPath = argv.input;
var gltfPath = argv.output;
var name = path.basename(objPath, path.extname(objPath));
if (!defined(gltfPath)) {
gltfPath = path.join(path.dirname(objPath), name + '.gltf');
}
var filename = defaultValue(gltfPath, objPath);
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);
var overridingTextures = {
@ -147,7 +143,7 @@ var overridingTextures = {
};
var options = {
binary : argv.binary,
binary : binary,
separate : argv.separate,
separateTextures : argv.separateTextures,
checkTransparency : argv.checkTransparency,
@ -164,7 +160,7 @@ console.time('Total');
obj2gltf(objPath, options)
.then(function(gltf) {
if (argv.binary) {
if (binary) {
// gltf is a glb buffer
return fsExtra.outputFile(gltfPath, gltf);
}