diff --git a/bin/obj2gltf.js b/bin/obj2gltf.js index 00f1929..e681d18 100644 --- a/bin/obj2gltf.js +++ b/bin/obj2gltf.js @@ -13,6 +13,7 @@ if (process.argv.length < 3 || defined(argv.h) || defined(argv.help)) { console.log(' -b, --binary Output binary glTF'); console.log(' -e, --embed Embed glTF resources into a single file'); console.log(' -h, --help Display this help'); + console.log(' --ao Apply ambient occlusion to the converted model'); process.exit(0); } @@ -21,6 +22,7 @@ var outputPath = defaultValue(argv._[1], defaultValue(argv.o, argv.output)); var binary = defaultValue(defaultValue(argv.b, argv.binary), false); var embed = defaultValue(defaultValue(argv.e, argv.embed), false); var quantize = defaultValue(defaultValue(argv.q, argv.quantize), false); // Undocumented option +var ao = defaultValue(argv.ao, false); if (!defined(objFile)) { throw new Error('-i or --input argument is required. See --help for details.'); @@ -31,7 +33,8 @@ console.time('Total'); var options = { binary : binary, embed : embed, - quantize : quantize + quantize : quantize, + ao : ao }; convert(objFile, outputPath, options, function() { diff --git a/lib/convert.js b/lib/convert.js index f40245a..8ed515a 100644 --- a/lib/convert.js +++ b/lib/convert.js @@ -13,6 +13,7 @@ function convert(objFile, outputPath, options, done) { var binary = defaultValue(options.binary, false); var embed = defaultValue(options.embed, true); var quantize = defaultValue(options.quantize, false); + var ao = defaultValue(options.ao, false); if (!defined(objFile)) { throw new Error('objFile is required'); @@ -36,10 +37,12 @@ function convert(objFile, outputPath, options, done) { parseObj(objFile, inputPath, function(data) { createGltf(data, inputPath, modelName, function(gltf) { + var aoOptions = ao ? {} : undefined; var options = { binary : binary, embed : embed, quantize : quantize, + aoOptions : aoOptions, createDirectory : false, basePath : inputPath };