Merge pull request #3 from AnalyticalGraphicsInc/embed

Rename combine to embed
This commit is contained in:
Sean Lilley 2015-10-21 09:33:55 -04:00
commit e1bee3b587
3 changed files with 11 additions and 11 deletions

View File

@ -19,7 +19,7 @@ Run `node bin/obj2gltf.js` and pass it the path to an OBJ file.
|----|-----------|--------| |----|-----------|--------|
|`-i`|Path to the input OBJ file.| :white_check_mark: Yes| |`-i`|Path to the input OBJ file.| :white_check_mark: Yes|
|`-o`|Directory or filename for the exported glTF file.|No| |`-o`|Directory or filename for the exported glTF file.|No|
|`-c`|Combine glTF resources, including images, into the exported glTF file.|No, default `false`| |`-e`|Embed 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 allows more explicit control.|No| |`-t`|Shading technique. Possible values are `lambert`, `phong`, `blinn`, and `constant`. The shading technique is typically determined by the MTL file, but this allows more explicit control.|No|
|`-h`|Display help|No| |`-h`|Display help|No|

View File

@ -16,7 +16,7 @@ if (process.argv.length < 3 || defined(argv.h) || defined(argv.help)) {
console.log(' -i, --input Path to obj file'); console.log(' -i, --input Path to obj file');
console.log(' -o, --output Directory or filename for the exported glTF file'); console.log(' -o, --output Directory or filename for the exported glTF file');
console.log(' -b, --binary Output binary glTF'); console.log(' -b, --binary Output binary glTF');
console.log(' -c, --combine Combine glTF resources into a single file'); console.log(' -e, --embed Embed glTF resources into a single file');
console.log(' -t, --technique Shading technique. Possible values are lambert, phong, blinn, constant'); console.log(' -t, --technique Shading technique. Possible values are lambert, phong, blinn, constant');
console.log(' -h, --help Display this help'); console.log(' -h, --help Display this help');
process.exit(0); process.exit(0);
@ -25,7 +25,7 @@ if (process.argv.length < 3 || defined(argv.h) || defined(argv.help)) {
var objFile = defaultValue(argv._[0], defaultValue(argv.i, argv.input)); var objFile = defaultValue(argv._[0], defaultValue(argv.i, argv.input));
var outputPath = defaultValue(argv._[1], defaultValue(argv.o, argv.output)); var outputPath = defaultValue(argv._[1], defaultValue(argv.o, argv.output));
var binary = defaultValue(defaultValue(argv.b, argv.binary), false); var binary = defaultValue(defaultValue(argv.b, argv.binary), false);
var combine = defaultValue(defaultValue(argv.c, argv.combine), false); var embed = defaultValue(defaultValue(argv.e, argv.embed), false);
var technique = defaultValue(argv.t, argv.technique); var technique = defaultValue(argv.t, argv.technique);
if (!defined(objFile)) { if (!defined(objFile)) {
@ -59,7 +59,7 @@ fs.mkdir(outputPath, function(){
parseObj(objFile, inputPath, function(data) { parseObj(objFile, inputPath, function(data) {
console.timeEnd('Parse Obj'); console.timeEnd('Parse Obj');
console.time('Create glTF'); console.time('Create glTF');
createGltf(data, modelName, inputPath, outputPath, binary, combine, technique, function() { createGltf(data, modelName, inputPath, outputPath, binary, embed, technique, function() {
console.timeEnd('Create glTF'); console.timeEnd('Create glTF');
console.timeEnd('Total'); console.timeEnd('Total');
}); });

View File

@ -13,7 +13,7 @@ var modelMaterialsCommon = require('./modelMaterialsCommon');
module.exports = createGltf; module.exports = createGltf;
function getImages(inputPath, outputPath, combine, materials, done) { function getImages(inputPath, outputPath, embed, materials, done) {
var images = []; var images = [];
for (var name in materials) { for (var name in materials) {
@ -44,7 +44,7 @@ function getImages(inputPath, outputPath, combine, materials, done) {
var copyPath = path.join(outputPath, baseName); var copyPath = path.join(outputPath, baseName);
imageInfo(imagePath, function(info) { imageInfo(imagePath, function(info) {
var uri; var uri;
if (combine) { if (embed) {
uri = 'data:application/octet-stream;base64,' + info.data.toString('base64'); uri = 'data:application/octet-stream;base64,' + info.data.toString('base64');
} else { } else {
uri = baseName; uri = baseName;
@ -56,7 +56,7 @@ function getImages(inputPath, outputPath, combine, materials, done) {
uri : uri uri : uri
}; };
if (combine) { if (embed) {
callback(); callback();
} else if (path.relative(imagePath, copyPath) !== '') { } else if (path.relative(imagePath, copyPath) !== '') {
fsExtra.copy(imagePath, copyPath, {clobber : true}, function (err) { fsExtra.copy(imagePath, copyPath, {clobber : true}, function (err) {
@ -75,7 +75,7 @@ function getImages(inputPath, outputPath, combine, materials, done) {
}); });
} }
function createGltf(data, modelName, inputPath, outputPath, binary, combine, technique, done) { function createGltf(data, modelName, inputPath, outputPath, binary, embed, technique, done) {
var vertexCount = data.vertexCount; var vertexCount = data.vertexCount;
var vertexArray = data.vertexArray; var vertexArray = data.vertexArray;
var positionMin = data.positionMin; var positionMin = data.positionMin;
@ -84,7 +84,7 @@ function createGltf(data, modelName, inputPath, outputPath, binary, combine, tec
var materialGroups = data.materialGroups; var materialGroups = data.materialGroups;
var materials = data.materials; var materials = data.materials;
getImages(inputPath, outputPath, combine, materials, function(images) { getImages(inputPath, outputPath, embed, materials, function(images) {
var i, j, name; var i, j, name;
var sizeOfFloat32 = 4; var sizeOfFloat32 = 4;
@ -228,7 +228,7 @@ function createGltf(data, modelName, inputPath, outputPath, binary, combine, tec
gltf.samplers[samplerId] = {}; // Use default values gltf.samplers[samplerId] = {}; // Use default values
var bufferUri; var bufferUri;
if (combine) { if (embed) {
bufferUri = 'data:application/octet-stream;base64,' + buffer.toString('base64'); bufferUri = 'data:application/octet-stream;base64,' + buffer.toString('base64');
} else { } else {
bufferUri = binaryRelPath; bufferUri = binaryRelPath;
@ -417,7 +417,7 @@ function createGltf(data, modelName, inputPath, outputPath, binary, combine, tec
if (error) { if (error) {
throw error; throw error;
} }
if (combine) { if (embed) {
done(); done();
} else { } else {
// Save .bin file // Save .bin file