Renaming files

This commit is contained in:
Sean Lilley 2017-04-12 16:55:03 -04:00
parent cc8fee19c4
commit 37febbcd93
14 changed files with 44 additions and 44 deletions

View File

@ -27,7 +27,7 @@ Using obj2gltf as a command-line tool:
## Usage ## Usage
###Command line flags: ### Command line flags:
|Flag|Description|Required| |Flag|Description|Required|
|----|-----------|--------| |----|-----------|--------|
@ -62,7 +62,7 @@ To run JSHint automatically when a file is saved, run the following and leave it
npm run jsHint-watch npm run jsHint-watch
``` ```
### Running Test Coverage ## Running Test Coverage
Coverage uses [istanbul](https://github.com/gotwarlost/istanbul). Run: Coverage uses [istanbul](https://github.com/gotwarlost/istanbul). Run:
``` ```
@ -81,7 +81,7 @@ npm run jsdoc
The documentation will be placed in the `doc` folder. The documentation will be placed in the `doc` folder.
### Debugging ## Debugging
* To debug the tests in Webstorm, open the Gulp tab, right click the `test` task, and click `Debug 'test'`. * To debug the tests in Webstorm, open the Gulp tab, right click the `test` task, and click `Debug 'test'`.
* To run a single test, change the test function from `it` to `fit`. * To run a single test, change the test function from `it` to `fit`.

View File

@ -3,11 +3,11 @@
var Cesium = require('cesium'); var Cesium = require('cesium');
var path = require('path'); var path = require('path');
var yargs = require('yargs'); var yargs = require('yargs');
var convert = require('../lib/convert'); var obj2gltf = require('../lib/obj2gltf');
var defined = Cesium.defined; var defined = Cesium.defined;
var defaults = convert.defaults; var defaults = obj2gltf.defaults;
var args = process.argv; var args = process.argv;
@ -124,7 +124,7 @@ var options = {
console.time('Total'); console.time('Total');
convert(objPath, gltfPath, options) obj2gltf(objPath, gltfPath, options)
.then(function() { .then(function() {
console.timeEnd('Total'); console.timeEnd('Total');
}) })

View File

@ -1 +1 @@
module.exports = require('./lib/convert'); module.exports = require('./lib/obj2gltf');

View File

@ -4,8 +4,8 @@ var path = require('path');
var Promise = require('bluebird'); var Promise = require('bluebird');
var ArrayStorage = require('./ArrayStorage'); var ArrayStorage = require('./ArrayStorage');
var loadImage = require('./image'); var loadImage = require('./loadImage');
var loadMtl = require('./mtl'); var loadMtl = require('./loadMtl');
var readLines = require('./readLines'); var readLines = require('./readLines');
var ComponentDatatype = Cesium.ComponentDatatype; var ComponentDatatype = Cesium.ComponentDatatype;

View File

@ -4,8 +4,8 @@ var fsExtra = require('fs-extra');
var GltfPipeline = require('gltf-pipeline').Pipeline; var GltfPipeline = require('gltf-pipeline').Pipeline;
var path = require('path'); var path = require('path');
var Promise = require('bluebird'); var Promise = require('bluebird');
var createGltf = require('./gltf'); var createGltf = require('./createGltf');
var loadObj = require('./obj'); var loadObj = require('./loadObj');
var writeUris = require('./writeUris'); var writeUris = require('./writeUris');
var fsExtraOutputJson = Promise.promisify(fsExtra.outputJson); var fsExtraOutputJson = Promise.promisify(fsExtra.outputJson);
@ -14,7 +14,7 @@ var defaultValue = Cesium.defaultValue;
var defined = Cesium.defined; var defined = Cesium.defined;
var DeveloperError = Cesium.DeveloperError; var DeveloperError = Cesium.DeveloperError;
module.exports = convert; module.exports = obj2gltf;
/** /**
* Converts an obj file to a glTF file. * Converts an obj file to a glTF file.
@ -37,8 +37,8 @@ module.exports = convert;
* @param {Boolean} [options.secure=false] Prevent the converter from reading image or mtl files outside of the input obj directory. * @param {Boolean} [options.secure=false] Prevent the converter from reading image or mtl files outside of the input obj directory.
* @param {Logger} [options.logger] A callback function for handling logged messages. Defaults to console.log. * @param {Logger} [options.logger] A callback function for handling logged messages. Defaults to console.log.
*/ */
function convert(objPath, gltfPath, options) { function obj2gltf(objPath, gltfPath, options) {
var defaults = convert.defaults; var defaults = obj2gltf.defaults;
options = defaultValue(options, {}); options = defaultValue(options, {});
var binary = defaultValue(options.binary, defaults.binary); var binary = defaultValue(options.binary, defaults.binary);
@ -113,7 +113,7 @@ function convert(objPath, gltfPath, options) {
}) })
.then(function(gltf) { .then(function(gltf) {
if (bypassPipeline) { if (bypassPipeline) {
return convert._outputJson(gltfPath, gltf); return obj2gltf._outputJson(gltfPath, gltf);
} else { } else {
return GltfPipeline.processJSONToDisk(gltf, gltfPath, pipelineOptions); return GltfPipeline.processJSONToDisk(gltf, gltfPath, pipelineOptions);
} }
@ -121,9 +121,9 @@ function convert(objPath, gltfPath, options) {
} }
/** /**
* Default values that will be used when calling convert(options) unless specified in the options object. * Default values that will be used when calling obj2gltf(options) unless specified in the options object.
*/ */
convert.defaults = { obj2gltf.defaults = {
/** /**
* Gets or sets whether the model will be saved as binary glTF. * Gets or sets whether the model will be saved as binary glTF.
* @type Boolean * @type Boolean
@ -210,7 +210,7 @@ convert.defaults = {
* *
* @private * @private
*/ */
convert._outputJson = fsExtraOutputJson; obj2gltf._outputJson = fsExtraOutputJson;
/** /**
* A callback function that logs messages. * A callback function that logs messages.

View File

@ -42,6 +42,7 @@
"istanbul": "^0.4.5", "istanbul": "^0.4.5",
"jasmine": "^2.5.3", "jasmine": "^2.5.3",
"jasmine-spec-reporter": "^3.2.0", "jasmine-spec-reporter": "^3.2.0",
"jsdoc": "^3.4.3",
"jshint": "^2.9.4", "jshint": "^2.9.4",
"jshint-stylish": "^2.2.1", "jshint-stylish": "^2.2.1",
"open": "^0.0.5", "open": "^0.0.5",

View File

@ -3,10 +3,10 @@ var Cesium = require('cesium');
var fsExtra = require('fs-extra'); var fsExtra = require('fs-extra');
var path = require('path'); var path = require('path');
var Promise = require('bluebird'); var Promise = require('bluebird');
var convert = require('../../lib/convert'); var obj2gltf = require('../../lib/obj2gltf');
var createGltf = require('../../lib/gltf'); var createGltf = require('../../lib/createGltf');
var loadImage = require('../../lib/image'); var loadImage = require('../../lib/loadImage');
var loadObj = require('../../lib/obj'); var loadObj = require('../../lib/loadObj');
var Material = require('../../lib/Material'); var Material = require('../../lib/Material');
var writeUris = require('../../lib/writeUris'); var writeUris = require('../../lib/writeUris');
@ -22,7 +22,7 @@ var groupGltfUrl = 'specs/data/box-objects-groups-materials/box-objects-groups-m
var diffuseTextureUrl = 'specs/data/box-textured/cesium.png'; var diffuseTextureUrl = 'specs/data/box-textured/cesium.png';
var transparentDiffuseTextureUrl = 'specs/data/box-complex-material/diffuse.png'; var transparentDiffuseTextureUrl = 'specs/data/box-complex-material/diffuse.png';
var defaultOptions = convert.defaults; var defaultOptions = obj2gltf.defaults;
var checkTransparencyOptions = clone(defaultOptions); var checkTransparencyOptions = clone(defaultOptions);
checkTransparencyOptions.checkTransparency = true; checkTransparencyOptions.checkTransparency = true;

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
var Cesium = require('cesium'); var Cesium = require('cesium');
var convert = require('../../lib/convert'); var obj2gltf = require('../../lib/obj2gltf');
var loadImage = require('../../lib/image'); var loadImage = require('../../lib/loadImage');
var clone = Cesium.clone; var clone = Cesium.clone;
var WebGLConstants = Cesium.WebGLConstants; var WebGLConstants = Cesium.WebGLConstants;
@ -13,7 +13,7 @@ var gifImage = 'specs/data/box-complex-material/ambient.gif';
var grayscaleImage = 'specs/data/box-complex-material/alpha.png'; var grayscaleImage = 'specs/data/box-complex-material/alpha.png';
var transparentImage = 'specs/data/box-complex-material/diffuse.png'; var transparentImage = 'specs/data/box-complex-material/diffuse.png';
var defaultOptions = convert.defaults; var defaultOptions = obj2gltf.defaults;
describe('image', function() { describe('image', function() {
it('loads png image', function(done) { it('loads png image', function(done) {

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
var path = require('path'); var path = require('path');
var loadMtl = require('../../lib/mtl'); var loadMtl = require('../../lib/loadMtl');
var complexMaterialUrl = 'specs/data/box-complex-material/box-complex-material.mtl'; var complexMaterialUrl = 'specs/data/box-complex-material/box-complex-material.mtl';
var multipleMaterialsUrl = 'specs/data/box-multiple-materials/box-multiple-materials.mtl'; var multipleMaterialsUrl = 'specs/data/box-multiple-materials/box-multiple-materials.mtl';

View File

@ -1,19 +1,18 @@
'use strict'; 'use strict';
var GltfPipeline = require('gltf-pipeline').Pipeline; var GltfPipeline = require('gltf-pipeline').Pipeline;
var path = require('path'); var path = require('path');
var convert = require('../../lib/convert'); var obj2gltf = require('../../lib/obj2gltf');
var writeUris = require('../../lib/writeUris'); var writeUris = require('../../lib/writeUris');
var objPath = 'specs/data/box-textured/box-textured.obj'; var objPath = 'specs/data/box-textured/box-textured.obj';
var gltfPath = 'specs/data/box-textured/box-textured.gltf'; var gltfPath = 'specs/data/box-textured/box-textured.gltf';
var glbPath = 'specs/data/box-textured/box-textured.glb'; var glbPath = 'specs/data/box-textured/box-textured.glb';
var objPathNonExistent = 'specs/data/non-existent.obj'; var objPathNonExistent = 'specs/data/non-existent.obj';
var objExternalResourcesPath = 'specs/data/box-external-resources/box-external-resources.obj';
describe('convert', function() { describe('obj2gltf', function() {
it('converts an obj to gltf', function(done) { it('converts an obj to gltf', function(done) {
var spy = spyOn(GltfPipeline, 'processJSONToDisk'); var spy = spyOn(GltfPipeline, 'processJSONToDisk');
expect(convert(objPath, gltfPath) expect(obj2gltf(objPath, gltfPath)
.then(function() { .then(function() {
var args = spy.calls.first().args; var args = spy.calls.first().args;
var gltf = args[0]; var gltf = args[0];
@ -26,7 +25,7 @@ describe('convert', function() {
it('uses default gltf-pipeline options', function(done) { it('uses default gltf-pipeline options', function(done) {
var spy = spyOn(GltfPipeline, 'processJSONToDisk'); var spy = spyOn(GltfPipeline, 'processJSONToDisk');
expect(convert(objPath, gltfPath) expect(obj2gltf(objPath, gltfPath)
.then(function() { .then(function() {
var args = spy.calls.first().args; var args = spy.calls.first().args;
var options = args[2]; var options = args[2];
@ -69,10 +68,10 @@ describe('convert', function() {
textureCompressionOptions : textureCompressionOptions, textureCompressionOptions : textureCompressionOptions,
checkTransparency : true, checkTransparency : true,
secure : true, secure : true,
logger : convert.defaults.logger logger : obj2gltf.defaults.logger
}; };
expect(convert(objPath, gltfPath, options) expect(obj2gltf(objPath, gltfPath, options)
.then(function() { .then(function() {
var args = spy.calls.first().args; var args = spy.calls.first().args;
var options = args[2]; var options = args[2];
@ -98,7 +97,7 @@ describe('convert', function() {
it('saves as binary if gltfPath has a .glb extension', function(done) { it('saves as binary if gltfPath has a .glb extension', function(done) {
var spy = spyOn(GltfPipeline, 'processJSONToDisk'); var spy = spyOn(GltfPipeline, 'processJSONToDisk');
expect(convert(objPath, glbPath) expect(obj2gltf(objPath, glbPath)
.then(function() { .then(function() {
var args = spy.calls.first().args; var args = spy.calls.first().args;
var options = args[2]; var options = args[2];
@ -107,31 +106,31 @@ describe('convert', function() {
}); });
it('bypassPipeline flag bypasses gltf-pipeline', function(done) { it('bypassPipeline flag bypasses gltf-pipeline', function(done) {
spyOn(convert, '_outputJson'); spyOn(obj2gltf, '_outputJson');
spyOn(GltfPipeline, 'processJSONToDisk'); spyOn(GltfPipeline, 'processJSONToDisk');
var options = { var options = {
bypassPipeline : true bypassPipeline : true
}; };
expect(convert(objPath, gltfPath, options) expect(obj2gltf(objPath, gltfPath, options)
.then(function() { .then(function() {
expect(convert._outputJson).toHaveBeenCalled(); expect(obj2gltf._outputJson).toHaveBeenCalled();
expect(GltfPipeline.processJSONToDisk).not.toHaveBeenCalled(); expect(GltfPipeline.processJSONToDisk).not.toHaveBeenCalled();
}), done).toResolve(); }), done).toResolve();
}); });
it('rejects if obj path does not exist', function(done) { it('rejects if obj path does not exist', function(done) {
expect(convert(objPathNonExistent, gltfPath), done).toRejectWith(Error); expect(obj2gltf(objPathNonExistent, gltfPath), done).toRejectWith(Error);
}); });
it('throws if objPath is undefined', function() { it('throws if objPath is undefined', function() {
expect(function() { expect(function() {
convert(undefined, gltfPath); obj2gltf(undefined, gltfPath);
}).toThrowDeveloperError(); }).toThrowDeveloperError();
}); });
it('rejects if gltfPath is undefined', function() { it('rejects if gltfPath is undefined', function() {
expect(function() { expect(function() {
convert(objPath, undefined); obj2gltf(objPath, undefined);
}).toThrowDeveloperError(); }).toThrowDeveloperError();
}); });
}); });

View File

@ -2,8 +2,8 @@
var Cesium = require('cesium'); var Cesium = require('cesium');
var path = require('path'); var path = require('path');
var Promise = require('bluebird'); var Promise = require('bluebird');
var convert = require('../../lib/convert'); var loadObj = require('../../lib/loadObj');
var loadObj = require('../../lib/obj'); var obj2gltf = require('../../lib/obj2gltf');
var clone = Cesium.clone; var clone = Cesium.clone;
var RuntimeError = Cesium.RuntimeError; var RuntimeError = Cesium.RuntimeError;
@ -59,7 +59,7 @@ function getImagePath(objPath, relativePath) {
return path.resolve(path.dirname(objPath), relativePath); return path.resolve(path.dirname(objPath), relativePath);
} }
var defaultOptions = convert.defaults; var defaultOptions = obj2gltf.defaults;
describe('obj', function() { describe('obj', function() {
it('loads obj with positions, normals, and uvs', function(done) { it('loads obj with positions, normals, and uvs', function(done) {