From 37febbcd93faef501c6b7e8c0805051f39b67a28 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Wed, 12 Apr 2017 16:55:03 -0400 Subject: [PATCH] Renaming files --- README.md | 6 ++--- bin/obj2gltf.js | 6 ++--- index.js | 2 +- lib/{gltf.js => createGltf.js} | 0 lib/{image.js => loadImage.js} | 0 lib/{mtl.js => loadMtl.js} | 0 lib/{obj.js => loadObj.js} | 4 +-- lib/{convert.js => obj2gltf.js} | 18 ++++++------- package.json | 1 + specs/lib/gltfSpec.js | 10 +++---- specs/lib/imageSpec.js | 6 ++--- specs/lib/mtlSpec.js | 2 +- specs/lib/{convertSpec.js => obj2gltfSpec.js} | 27 +++++++++---------- specs/lib/objSpec.js | 6 ++--- 14 files changed, 44 insertions(+), 44 deletions(-) rename lib/{gltf.js => createGltf.js} (100%) rename lib/{image.js => loadImage.js} (100%) rename lib/{mtl.js => loadMtl.js} (100%) rename lib/{obj.js => loadObj.js} (99%) rename lib/{convert.js => obj2gltf.js} (94%) rename specs/lib/{convertSpec.js => obj2gltfSpec.js} (86%) diff --git a/README.md b/README.md index 0773c26..ebf5cd4 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Using obj2gltf as a command-line tool: ## Usage -###Command line flags: +### Command line flags: |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 ``` -### Running Test Coverage +## Running Test Coverage 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. -### Debugging +## Debugging * 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`. diff --git a/bin/obj2gltf.js b/bin/obj2gltf.js index 52e4c0e..8e77725 100644 --- a/bin/obj2gltf.js +++ b/bin/obj2gltf.js @@ -3,11 +3,11 @@ var Cesium = require('cesium'); var path = require('path'); var yargs = require('yargs'); -var convert = require('../lib/convert'); +var obj2gltf = require('../lib/obj2gltf'); var defined = Cesium.defined; -var defaults = convert.defaults; +var defaults = obj2gltf.defaults; var args = process.argv; @@ -124,7 +124,7 @@ var options = { console.time('Total'); -convert(objPath, gltfPath, options) +obj2gltf(objPath, gltfPath, options) .then(function() { console.timeEnd('Total'); }) diff --git a/index.js b/index.js index 02ae37e..f0c4b18 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -module.exports = require('./lib/convert'); +module.exports = require('./lib/obj2gltf'); diff --git a/lib/gltf.js b/lib/createGltf.js similarity index 100% rename from lib/gltf.js rename to lib/createGltf.js diff --git a/lib/image.js b/lib/loadImage.js similarity index 100% rename from lib/image.js rename to lib/loadImage.js diff --git a/lib/mtl.js b/lib/loadMtl.js similarity index 100% rename from lib/mtl.js rename to lib/loadMtl.js diff --git a/lib/obj.js b/lib/loadObj.js similarity index 99% rename from lib/obj.js rename to lib/loadObj.js index cfd1d7c..09c8afc 100644 --- a/lib/obj.js +++ b/lib/loadObj.js @@ -4,8 +4,8 @@ var path = require('path'); var Promise = require('bluebird'); var ArrayStorage = require('./ArrayStorage'); -var loadImage = require('./image'); -var loadMtl = require('./mtl'); +var loadImage = require('./loadImage'); +var loadMtl = require('./loadMtl'); var readLines = require('./readLines'); var ComponentDatatype = Cesium.ComponentDatatype; diff --git a/lib/convert.js b/lib/obj2gltf.js similarity index 94% rename from lib/convert.js rename to lib/obj2gltf.js index 5e26300..0326a0e 100644 --- a/lib/convert.js +++ b/lib/obj2gltf.js @@ -4,8 +4,8 @@ var fsExtra = require('fs-extra'); var GltfPipeline = require('gltf-pipeline').Pipeline; var path = require('path'); var Promise = require('bluebird'); -var createGltf = require('./gltf'); -var loadObj = require('./obj'); +var createGltf = require('./createGltf'); +var loadObj = require('./loadObj'); var writeUris = require('./writeUris'); var fsExtraOutputJson = Promise.promisify(fsExtra.outputJson); @@ -14,7 +14,7 @@ var defaultValue = Cesium.defaultValue; var defined = Cesium.defined; var DeveloperError = Cesium.DeveloperError; -module.exports = convert; +module.exports = obj2gltf; /** * 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 {Logger} [options.logger] A callback function for handling logged messages. Defaults to console.log. */ -function convert(objPath, gltfPath, options) { - var defaults = convert.defaults; +function obj2gltf(objPath, gltfPath, options) { + var defaults = obj2gltf.defaults; options = defaultValue(options, {}); var binary = defaultValue(options.binary, defaults.binary); @@ -113,7 +113,7 @@ function convert(objPath, gltfPath, options) { }) .then(function(gltf) { if (bypassPipeline) { - return convert._outputJson(gltfPath, gltf); + return obj2gltf._outputJson(gltfPath, gltf); } else { 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. * @type Boolean @@ -210,7 +210,7 @@ convert.defaults = { * * @private */ -convert._outputJson = fsExtraOutputJson; +obj2gltf._outputJson = fsExtraOutputJson; /** * A callback function that logs messages. diff --git a/package.json b/package.json index 4ea0e01..b15b7d1 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "istanbul": "^0.4.5", "jasmine": "^2.5.3", "jasmine-spec-reporter": "^3.2.0", + "jsdoc": "^3.4.3", "jshint": "^2.9.4", "jshint-stylish": "^2.2.1", "open": "^0.0.5", diff --git a/specs/lib/gltfSpec.js b/specs/lib/gltfSpec.js index b139ada..84d3692 100644 --- a/specs/lib/gltfSpec.js +++ b/specs/lib/gltfSpec.js @@ -3,10 +3,10 @@ var Cesium = require('cesium'); var fsExtra = require('fs-extra'); var path = require('path'); var Promise = require('bluebird'); -var convert = require('../../lib/convert'); -var createGltf = require('../../lib/gltf'); -var loadImage = require('../../lib/image'); -var loadObj = require('../../lib/obj'); +var obj2gltf = require('../../lib/obj2gltf'); +var createGltf = require('../../lib/createGltf'); +var loadImage = require('../../lib/loadImage'); +var loadObj = require('../../lib/loadObj'); var Material = require('../../lib/Material'); 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 transparentDiffuseTextureUrl = 'specs/data/box-complex-material/diffuse.png'; -var defaultOptions = convert.defaults; +var defaultOptions = obj2gltf.defaults; var checkTransparencyOptions = clone(defaultOptions); checkTransparencyOptions.checkTransparency = true; diff --git a/specs/lib/imageSpec.js b/specs/lib/imageSpec.js index 452a8c0..bb55745 100644 --- a/specs/lib/imageSpec.js +++ b/specs/lib/imageSpec.js @@ -1,7 +1,7 @@ 'use strict'; var Cesium = require('cesium'); -var convert = require('../../lib/convert'); -var loadImage = require('../../lib/image'); +var obj2gltf = require('../../lib/obj2gltf'); +var loadImage = require('../../lib/loadImage'); var clone = Cesium.clone; 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 transparentImage = 'specs/data/box-complex-material/diffuse.png'; -var defaultOptions = convert.defaults; +var defaultOptions = obj2gltf.defaults; describe('image', function() { it('loads png image', function(done) { diff --git a/specs/lib/mtlSpec.js b/specs/lib/mtlSpec.js index 3673d7c..e0e112d 100644 --- a/specs/lib/mtlSpec.js +++ b/specs/lib/mtlSpec.js @@ -1,6 +1,6 @@ 'use strict'; 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 multipleMaterialsUrl = 'specs/data/box-multiple-materials/box-multiple-materials.mtl'; diff --git a/specs/lib/convertSpec.js b/specs/lib/obj2gltfSpec.js similarity index 86% rename from specs/lib/convertSpec.js rename to specs/lib/obj2gltfSpec.js index 2d0476e..b152f9f 100644 --- a/specs/lib/convertSpec.js +++ b/specs/lib/obj2gltfSpec.js @@ -1,19 +1,18 @@ 'use strict'; var GltfPipeline = require('gltf-pipeline').Pipeline; var path = require('path'); -var convert = require('../../lib/convert'); +var obj2gltf = require('../../lib/obj2gltf'); var writeUris = require('../../lib/writeUris'); var objPath = 'specs/data/box-textured/box-textured.obj'; var gltfPath = 'specs/data/box-textured/box-textured.gltf'; var glbPath = 'specs/data/box-textured/box-textured.glb'; 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) { var spy = spyOn(GltfPipeline, 'processJSONToDisk'); - expect(convert(objPath, gltfPath) + expect(obj2gltf(objPath, gltfPath) .then(function() { var args = spy.calls.first().args; var gltf = args[0]; @@ -26,7 +25,7 @@ describe('convert', function() { it('uses default gltf-pipeline options', function(done) { var spy = spyOn(GltfPipeline, 'processJSONToDisk'); - expect(convert(objPath, gltfPath) + expect(obj2gltf(objPath, gltfPath) .then(function() { var args = spy.calls.first().args; var options = args[2]; @@ -69,10 +68,10 @@ describe('convert', function() { textureCompressionOptions : textureCompressionOptions, checkTransparency : true, secure : true, - logger : convert.defaults.logger + logger : obj2gltf.defaults.logger }; - expect(convert(objPath, gltfPath, options) + expect(obj2gltf(objPath, gltfPath, options) .then(function() { var args = spy.calls.first().args; var options = args[2]; @@ -98,7 +97,7 @@ describe('convert', function() { it('saves as binary if gltfPath has a .glb extension', function(done) { var spy = spyOn(GltfPipeline, 'processJSONToDisk'); - expect(convert(objPath, glbPath) + expect(obj2gltf(objPath, glbPath) .then(function() { var args = spy.calls.first().args; var options = args[2]; @@ -107,31 +106,31 @@ describe('convert', function() { }); it('bypassPipeline flag bypasses gltf-pipeline', function(done) { - spyOn(convert, '_outputJson'); + spyOn(obj2gltf, '_outputJson'); spyOn(GltfPipeline, 'processJSONToDisk'); var options = { bypassPipeline : true }; - expect(convert(objPath, gltfPath, options) + expect(obj2gltf(objPath, gltfPath, options) .then(function() { - expect(convert._outputJson).toHaveBeenCalled(); + expect(obj2gltf._outputJson).toHaveBeenCalled(); expect(GltfPipeline.processJSONToDisk).not.toHaveBeenCalled(); }), done).toResolve(); }); 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() { expect(function() { - convert(undefined, gltfPath); + obj2gltf(undefined, gltfPath); }).toThrowDeveloperError(); }); it('rejects if gltfPath is undefined', function() { expect(function() { - convert(objPath, undefined); + obj2gltf(objPath, undefined); }).toThrowDeveloperError(); }); }); diff --git a/specs/lib/objSpec.js b/specs/lib/objSpec.js index e8ac642..7535c83 100644 --- a/specs/lib/objSpec.js +++ b/specs/lib/objSpec.js @@ -2,8 +2,8 @@ var Cesium = require('cesium'); var path = require('path'); var Promise = require('bluebird'); -var convert = require('../../lib/convert'); -var loadObj = require('../../lib/obj'); +var loadObj = require('../../lib/loadObj'); +var obj2gltf = require('../../lib/obj2gltf'); var clone = Cesium.clone; var RuntimeError = Cesium.RuntimeError; @@ -59,7 +59,7 @@ function getImagePath(objPath, relativePath) { return path.resolve(path.dirname(objPath), relativePath); } -var defaultOptions = convert.defaults; +var defaultOptions = obj2gltf.defaults; describe('obj', function() { it('loads obj with positions, normals, and uvs', function(done) {