diff --git a/README.md b/README.md index 18570c2..58ef467 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,31 @@ npm install ``` Run `node ./bin/obj2gltf.js` and pass it the path to an OBJ file. +## Usage + +###Command line flags: + +|Flag|Description|Required| +|----|-----------|--------| +|`-i`|Path to the input OBJ file.| :white_check_mark: Yes| +|`-o`|Directory or filename for the exported glTF file.|No| +|`-c`|Combine glTF resources, including images, into the exported glTF file.|No, default `false`| +|`-t`|Shading technique. Possible values are `lambert`, `phong`, `blinn`, and `constant`. The shading technique is typically determined by the MTL file, but this is good for more explicit control.|No| +|`-h`|Display help|No| + +###Examples: + +`node ./bin/obj2gltf.js model.obj` + +`node ./bin/obj2gltf.js model.obj model.gltf` + +`node ./bin/obj2gltf.js -i model.obj -o model.gltf` + +`node ./bin/obj2gltf.js -i model.obj -o model.gltf -c -t phong` + ## Limitations -This tool is still in development. We plan on adding additional features like gzip compression, binary glTF export, normal generation, and a testing suite. +This tool is still in development. We plan on adding additional features like gzip compression, binary glTF export, and a testing suite. Pull requests are appreciated. Please use the same [Contributor License Agreement (CLA)](https://github.com/AnalyticalGraphicsInc/cesium/blob/master/CONTRIBUTING.md) used for [Cesium](http://cesiumjs.org/). diff --git a/bin/obj2gltf.js b/bin/obj2gltf.js index 0e589dc..e405daa 100644 --- a/bin/obj2gltf.js +++ b/bin/obj2gltf.js @@ -18,8 +18,8 @@ if (process.argv.length < 3 || defined(argv.h) || defined(argv.help)) { console.log(' -i, --input Path to obj file'); console.log(' -o, --output Directory or filename for the exported glTF file'); console.log(' -b, --binary Output binary glTF'); - console.log(' -c --combine Combine glTF resources into a single file'); - console.log(' -t --technique Shading technique. Possible values are lambert, phong, blinn, constant'); + console.log(' -c, --combine Combine glTF resources into a single file'); + console.log(' -t, --technique Shading technique. Possible values are lambert, phong, blinn, constant'); console.log(' -h, --help Display this help'); process.exit(0); } diff --git a/lib/modelMaterialsCommon.js b/lib/modelMaterialsCommon.js index bdf084f..4ed1942 100644 --- a/lib/modelMaterialsCommon.js +++ b/lib/modelMaterialsCommon.js @@ -430,7 +430,7 @@ function generateTechnique(gltf, khrMaterialsCommon, attributes, lightParameters fragmentLightingBlock += ' ambientLight += vec3(0.1, 0.1, 0.1);\n'; } - if (!hasNonAmbientLights) { + if (!hasNonAmbientLights && (lightingModel !== 'CONSTANT')) { fragmentLightingBlock += ' vec3 l = normalize(czm_sunDirectionEC);\n'; fragmentLightingBlock += ' diffuseLight += vec3(1.0, 1.0, 1.0) * max(dot(normal,l), 0.);\n';