Support KHR_materials_common output

This commit is contained in:
Sean Lilley 2017-04-04 17:55:00 -04:00
parent c7b4fc3cb1
commit 02c3aa18db
3 changed files with 12 additions and 0 deletions

View File

@ -47,6 +47,7 @@ Using obj2gltf as a command-line tool:
|`-n`|Generate normals if they are missing.|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`| |`--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`| |`--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`| |`--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`| |`--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`| |`--secure`|Prevent the converter from reading image or mtl files outside of the input obj directory.|No, default `false`|

View File

@ -75,6 +75,11 @@ var argv = yargs
type: 'boolean', type: 'boolean',
default: false default: false
}, },
kmc : {
describe: 'Output glTF with the KHR_materials_common extension.',
type: 'boolean',
default: false
},
bypassPipeline : { 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.', 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', type: 'boolean',

View File

@ -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.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.generateNormals=false] Generate normals if they are missing.
* @param {Boolean} [options.ao=false] Apply ambient occlusion to the converted model. * @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.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.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. * @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 optimizeForCesium = defaultValue(options.optimizeForCesium, false);
var generateNormals = defaultValue(options.generateNormals, false); var generateNormals = defaultValue(options.generateNormals, false);
var ao = defaultValue(options.ao, false); var ao = defaultValue(options.ao, false);
var kmc = defaultValue(options.kmc, false);
var textureCompressionOptions = options.textureCompressionOptions; var textureCompressionOptions = options.textureCompressionOptions;
var bypassPipeline = defaultValue(options.bypassPipeline, false); var bypassPipeline = defaultValue(options.bypassPipeline, false);
var logger = defaultValue(options.logger, defaultLogger); var logger = defaultValue(options.logger, defaultLogger);
@ -75,6 +77,9 @@ function convert(objPath, gltfPath, options) {
var aoOptions = ao ? {} : undefined; 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 = { var pipelineOptions = {
createDirectory : false, createDirectory : false,
basePath : basePath, basePath : basePath,
@ -88,6 +93,7 @@ function convert(objPath, gltfPath, options) {
optimizeForCesium : optimizeForCesium, optimizeForCesium : optimizeForCesium,
smoothNormals : generateNormals, smoothNormals : generateNormals,
aoOptions : aoOptions, aoOptions : aoOptions,
kmcOptions : kmcOptions,
textureCompressionOptions : textureCompressionOptions textureCompressionOptions : textureCompressionOptions
}; };