diff --git a/README.md b/README.md index 7b7dc08..eae15e4 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ Using obj2gltf as a command-line tool: |`-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`| diff --git a/bin/obj2gltf.js b/bin/obj2gltf.js index 654d9f8..b1657a3 100644 --- a/bin/obj2gltf.js +++ b/bin/obj2gltf.js @@ -75,6 +75,11 @@ var argv = yargs type: 'boolean', default: false }, + kmc : { + describe: 'Output glTF with the KHR_materials_common extension.', + type: 'boolean', + default: false + }, bypassPipeline : { describe: '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.', type: 'boolean', diff --git a/lib/convert.js b/lib/convert.js index 405c5ce..e8ce59b 100644 --- a/lib/convert.js +++ b/lib/convert.js @@ -30,6 +30,7 @@ module.exports = convert; * @param {Boolean} [options.optimizeForCesium=false] Optimize the glTF for Cesium by using the sun as a default light source. * @param {Boolean} [options.generateNormals=false] Generate normals if they are missing. * @param {Boolean} [options.ao=false] Apply ambient occlusion to the converted model. + * @param {Boolean} [options.kmc=false] Output glTF with the KHR_materials_common extension. * @param {Boolean} [options.textureCompressionOptions] Options sent to the compressTextures stage of gltf-pipeline. * @param {Boolean} [options.bypassPipeline=false] 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. * @param {Boolean} [options.hasTransparency=false] Do a more exhaustive check for texture transparency by looking at the alpha channel of each pixel. @@ -46,6 +47,7 @@ function convert(objPath, gltfPath, options) { var optimizeForCesium = defaultValue(options.optimizeForCesium, false); var generateNormals = defaultValue(options.generateNormals, false); var ao = defaultValue(options.ao, false); + var kmc = defaultValue(options.kmc, false); var textureCompressionOptions = options.textureCompressionOptions; var bypassPipeline = defaultValue(options.bypassPipeline, false); var logger = defaultValue(options.logger, defaultLogger); @@ -75,6 +77,9 @@ function convert(objPath, gltfPath, options) { var aoOptions = ao ? {} : undefined; + // TODO: gltf-pipeline uses the same kmc options for each material and doesn't recognize the transparent flag + var kmcOptions = kmc ? {} : undefined; + var pipelineOptions = { createDirectory : false, basePath : basePath, @@ -88,6 +93,7 @@ function convert(objPath, gltfPath, options) { optimizeForCesium : optimizeForCesium, smoothNormals : generateNormals, aoOptions : aoOptions, + kmcOptions : kmcOptions, textureCompressionOptions : textureCompressionOptions };