obj2gltf/bin/obj2gltf.js

38 lines
1.2 KiB
JavaScript
Raw Normal View History

2015-10-16 17:32:23 -04:00
#!/usr/bin/env node
"use strict";
2016-06-09 13:33:08 -04:00
var argv = require('yargs').argv;
var Cesium = require('Cesium');
var defined = Cesium.defined;
var defaultValue = Cesium.defaultValue;
var convert = require('../lib/convert');
2015-10-16 17:32:23 -04:00
if (process.argv.length < 3 || defined(argv.h) || defined(argv.help)) {
2016-06-09 13:33:08 -04:00
console.log('Usage: ./bin/obj2gltf.js [INPUT] [OPTIONS]');
2015-10-16 17:32:23 -04:00
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');
2015-10-20 09:55:15 -04:00
console.log(' -e, --embed Embed glTF resources into a single file');
2015-10-16 17:32:23 -04:00
console.log(' -h, --help Display this help');
process.exit(0);
}
var objFile = defaultValue(argv._[0], defaultValue(argv.i, argv.input));
2015-10-19 13:35:28 -04:00
var outputPath = defaultValue(argv._[1], defaultValue(argv.o, argv.output));
2016-06-09 13:33:08 -04:00
var binary = defaultValue(argv.b, argv.binary);
var embed = defaultValue(argv.e, argv.embed);
2015-10-16 17:32:23 -04:00
if (!defined(objFile)) {
2016-06-09 13:33:08 -04:00
throw new Error('-i or --input argument is required. See --help for details.');
2015-10-16 17:32:23 -04:00
}
2016-06-09 13:33:08 -04:00
console.time('Total');
2015-10-19 13:35:28 -04:00
2016-06-09 13:33:08 -04:00
var options = {
binary : binary,
embed : embed
};
2015-10-16 17:32:23 -04:00
2016-06-09 13:33:08 -04:00
convert(objFile, outputPath, options, function() {
console.timeEnd('Total');
2015-10-16 17:32:23 -04:00
});