From 86c604826c2843cf986fe2a9381557ac58f7adf7 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Thu, 18 May 2017 09:32:06 -0400 Subject: [PATCH 01/17] Treat alpha as 1.0 - Tr --- lib/loadMtl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/loadMtl.js b/lib/loadMtl.js index 6d3f506..5b5c72b 100644 --- a/lib/loadMtl.js +++ b/lib/loadMtl.js @@ -66,7 +66,7 @@ function loadMtl(mtlPath) { material.alpha = parseFloat(value); } else if (/^Tr /i.test(line)) { value = line.substring(3).trim(); - material.alpha = parseFloat(value); + material.alpha = 1.0 - parseFloat(value); } else if (/^map_Ka /i.test(line)) { material.ambientTexture = path.resolve(mtlDirectory, line.substring(7).trim()); } else if (/^map_Ke /i.test(line)) { From f62e2bd6cf89f337be3878fd1b34a2bacab4cf9d Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Thu, 18 May 2017 09:37:45 -0400 Subject: [PATCH 02/17] Fix test --- specs/data/box-complex-material/box-complex-material.mtl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/data/box-complex-material/box-complex-material.mtl b/specs/data/box-complex-material/box-complex-material.mtl index 3f69a9e..5c598ff 100644 --- a/specs/data/box-complex-material/box-complex-material.mtl +++ b/specs/data/box-complex-material/box-complex-material.mtl @@ -9,7 +9,7 @@ Ks 0.500000 0.500000 0.500000 Ke 0.100000 0.100000 0.100000 Ni 1.000000 d 0.900000 -Tr 0.900000 +Tr 0.100000 map_Ka ambient.gif map_Ke emission.jpg map_Kd diffuse.png From f141c2d9c94da90843594a8f683bc3395caa3249 Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Fri, 19 May 2017 11:37:33 -0400 Subject: [PATCH 03/17] Update npm dependencies A few npm dependencies were major versions behind, so this updates `yargs`, `fs-extra`, and `jasmin-spec-reporter` to their latest versions. The major change here is `fs-extra`, which now has promise implementations of all functions by default, this means there's no reason to manually `Promisify` a function any more, the result is less code overall. There is one important edge case, `fs-extra` uses built-in native Node promises, which do not have a `finally` function. If you start a promise change with an `fs-extra` function, you need to wrap it in `Promise.resolve` in order to make use of finally at the end (assuming you are using finally at all, if not you don't need to worry about it. The upside is that your code will always error if you forget to do this. --- lib/loadImage.js | 4 +--- lib/obj2gltf.js | 11 +---------- lib/writeUris.js | 13 ++----------- package.json | 6 +++--- specs/lib/createGltfSpec.js | 6 ++---- specs/lib/obj2gltfSpec.js | 8 ++++---- 6 files changed, 13 insertions(+), 35 deletions(-) diff --git a/lib/loadImage.js b/lib/loadImage.js index 8a3b686..c238a27 100644 --- a/lib/loadImage.js +++ b/lib/loadImage.js @@ -5,8 +5,6 @@ var path = require('path'); var PNG = require('pngjs').PNG; var Promise = require('bluebird'); -var fsExtraReadFile = Promise.promisify(fsExtra.readFile); - var defined = Cesium.defined; var WebGLConstants = Cesium.WebGLConstants; @@ -23,7 +21,7 @@ module.exports = loadImage; * @private */ function loadImage(imagePath, options) { - return fsExtraReadFile(imagePath) + return fsExtra.readFile(imagePath) .then(function(data) { var extension = path.extname(imagePath).toLowerCase(); diff --git a/lib/obj2gltf.js b/lib/obj2gltf.js index 260df96..33f6e89 100644 --- a/lib/obj2gltf.js +++ b/lib/obj2gltf.js @@ -10,8 +10,6 @@ var createGltf = require('./createGltf'); var loadObj = require('./loadObj'); var writeUris = require('./writeUris'); -var fsExtraOutputJson = Promise.promisify(fsExtra.outputJson); - var defaultValue = Cesium.defaultValue; var defined = Cesium.defined; var DeveloperError = Cesium.DeveloperError; @@ -121,7 +119,7 @@ function obj2gltf(objPath, gltfPath, options) { }) .then(function(gltf) { if (bypassPipeline) { - return obj2gltf._outputJson(gltfPath, gltf); + return fsExtra.outputJson(gltfPath, gltf); } else { return GltfPipeline.processJSONToDisk(gltf, gltfPath, pipelineOptions); } @@ -237,13 +235,6 @@ obj2gltf.defaults = { } }; -/** - * Exposed for testing - * - * @private - */ -obj2gltf._outputJson = fsExtraOutputJson; - /** * Exposed for testing * diff --git a/lib/writeUris.js b/lib/writeUris.js index 1a578fd..5987a72 100644 --- a/lib/writeUris.js +++ b/lib/writeUris.js @@ -5,8 +5,6 @@ var mime = require('mime'); var path = require('path'); var Promise = require('bluebird'); -var fsExtraOutputFile = Promise.promisify(fsExtra.outputFile); - var RuntimeError = Cesium.RuntimeError; module.exports = writeUris; @@ -88,7 +86,7 @@ function writeSeparateBuffer(gltf, resourcesDirectory, name) { var bufferUri = name + '.bin'; buffer.uri = bufferUri; var bufferPath = path.join(resourcesDirectory, bufferUri); - return writeUris._outputFile(bufferPath, source); + return fsExtra.outputFile(bufferPath, source); } function writeSeparateTextures(gltf, resourcesDirectory) { @@ -99,7 +97,7 @@ function writeSeparateTextures(gltf, resourcesDirectory) { var imageUri = image.name + extras.extension; image.uri = imageUri; var imagePath = path.join(resourcesDirectory, imageUri); - return writeUris._outputFile(imagePath, extras.source); + return fsExtra.outputFile(imagePath, extras.source); }, {concurrency : 10}); } @@ -119,10 +117,3 @@ function writeEmbeddedTextures(gltf) { } } } - -/** - * Exposed for testing. - * - * @private - */ -writeUris._outputFile = fsExtraOutputFile; diff --git a/package.json b/package.json index 338fc7c..0d37800 100644 --- a/package.json +++ b/package.json @@ -29,12 +29,12 @@ "bluebird": "^3.4.7", "cesium": "^1.31.0", "event-stream": "^3.3.4", - "fs-extra": "^2.0.0", + "fs-extra": "^3.0.1", "gltf-pipeline": "^0.1.0-alpha11", "mime": "^1.3.4", "pngjs": "^3.0.1", "uuid": "^3.0.1", - "yargs": "^7.0.1" + "yargs": "^8.0.1" }, "devDependencies": { "coveralls": "^2.12.0", @@ -42,7 +42,7 @@ "gulp-jshint": "^2.0.4", "istanbul": "^0.4.5", "jasmine": "^2.5.3", - "jasmine-spec-reporter": "^3.2.0", + "jasmine-spec-reporter": "^4.1.0", "jsdoc": "^3.4.3", "jshint": "^2.9.4", "jshint-stylish": "^2.2.1", diff --git a/specs/lib/createGltfSpec.js b/specs/lib/createGltfSpec.js index b90d5bc..1e750ee 100644 --- a/specs/lib/createGltfSpec.js +++ b/specs/lib/createGltfSpec.js @@ -13,8 +13,6 @@ var writeUris = require('../../lib/writeUris'); var clone = Cesium.clone; var WebGLConstants = Cesium.WebGLConstants; -var fsExtraReadJson = Promise.promisify(fsExtra.readJson); - var boxObjUrl = 'specs/data/box/box.obj'; var groupObjUrl = 'specs/data/box-objects-groups-materials/box-objects-groups-materials.obj'; var boxGltfUrl = 'specs/data/box/box.gltf'; @@ -49,11 +47,11 @@ describe('createGltf', function() { .then(function(data) { groupObjData = data; }), - fsExtraReadJson(boxGltfUrl) + fsExtra.readJson(boxGltfUrl) .then(function(gltf) { boxGltf = gltf; }), - fsExtraReadJson(groupGltfUrl) + fsExtra.readJson(groupGltfUrl) .then(function(gltf) { groupGltf = gltf; }), diff --git a/specs/lib/obj2gltfSpec.js b/specs/lib/obj2gltfSpec.js index a25ca3f..d2aa73d 100644 --- a/specs/lib/obj2gltfSpec.js +++ b/specs/lib/obj2gltfSpec.js @@ -19,8 +19,8 @@ describe('obj2gltf', function() { expect(obj2gltf._getTempDirectory()).toContain(os.tmpdir()); tempDirectory = path.join(os.tmpdir(), 'testPath'); spyOn(obj2gltf, '_getTempDirectory').and.returnValue(tempDirectory); - spyOn(obj2gltf, '_outputJson'); - spyOn(writeUris, '_outputFile'); + spyOn(fsExtra, 'outputJson'); + spyOn(fsExtra, 'outputFile'); spyOn(fsExtra, 'remove'); }); @@ -100,7 +100,7 @@ describe('obj2gltf', function() { textureCompressionOptions : textureCompressionOptions, preserve : false }); - expect(writeUris._outputFile.calls.count()).toBe(2); // Saves out .png and .bin + expect(fsExtra.outputFile.calls.count()).toBe(2); // Saves out .png and .bin }), done).toResolve(); }); @@ -119,7 +119,7 @@ describe('obj2gltf', function() { }; expect(obj2gltf(objPath, gltfPath, options) .then(function() { - expect(obj2gltf._outputJson).toHaveBeenCalled(); + expect(fsExtra.outputJson).toHaveBeenCalled(); expect(GltfPipeline.processJSONToDisk).not.toHaveBeenCalled(); }), done).toResolve(); }); From c8adca33245de26ab827dd173084d4eff44d2632 Mon Sep 17 00:00:00 2001 From: Ottavio Hartman Date: Mon, 12 Jun 2017 11:42:37 -0400 Subject: [PATCH 04/17] Replace JSHint with ESLint shareable config --- .eslintrc.json | 3 + .idea/inspectionProfiles/Project_Default.xml | 2 +- .idea/jsLinters/jshint.xml | 83 -------------------- .jshintrc | 60 -------------- .npmignore | 2 +- .travis.yml | 2 +- README.md | 8 +- gulpfile.js | 23 +++--- index.js | 1 + package.json | 9 +-- specs/.eslintrc.json | 9 +++ specs/.jshintrc | 5 -- specs/matchers/addDefaultMatchers.js | 4 +- specs/matchers/customizeJasmine.js | 3 +- specs/matchers/equals.js | 3 +- specs/matchers/equalsMethodEqualityTester.js | 3 +- 16 files changed, 45 insertions(+), 175 deletions(-) create mode 100644 .eslintrc.json delete mode 100644 .idea/jsLinters/jshint.xml delete mode 100644 .jshintrc create mode 100644 specs/.eslintrc.json delete mode 100644 specs/.jshintrc diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..fcf4081 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "cesium/node" +} diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index eff7139..c6cc8c8 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -1,6 +1,6 @@ \ No newline at end of file diff --git a/.idea/jsLinters/jshint.xml b/.idea/jsLinters/jshint.xml deleted file mode 100644 index aed467c..0000000 --- a/.idea/jsLinters/jshint.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index bdff25a..0000000 --- a/.jshintrc +++ /dev/null @@ -1,60 +0,0 @@ -{ - "bitwise": false, - "camelcase": false, - "curly": true, - "eqeqeq": true, - "forin": true, - "freeze": true, - "immed": true, - "latedef": "nofunc", - "newcap": true, - "noarg": true, - "nonbsp": true, - "nonew": true, - "plusplus": false, - "quotmark": false, - "undef": true, - "unused": "strict", - "strict": true, - "asi": false, - "boss": false, - "debug": false, - "eqnull": false, - "moz": false, - "evil": false, - "expr": false, - "funcscope": false, - "globalstrict": false, - "iterator": false, - "lastsemic": false, - "laxbreak": false, - "laxcomma": false, - "loopfunc": false, - "multistr": true, - "noyield": false, - "notypeof": false, - "proto": false, - "scripturl": false, - "shadow": false, - "sub": false, - "supernew": false, - "validthis": false, - "browser": false, - "browserify": false, - "couch": false, - "devel": true, - "dojo": false, - "jasmine": false, - "jquery": false, - "mocha": true, - "mootools": false, - "node": true, - "nonstandard": false, - "prototypejs": false, - "qunit": false, - "rhino": false, - "shelljs": false, - "worker": false, - "wsh": false, - "yui": false -} diff --git a/.npmignore b/.npmignore index 26f16d5..8d9d85c 100644 --- a/.npmignore +++ b/.npmignore @@ -6,7 +6,7 @@ /test /output .editorconfig -.jshintrc +.eslintrc.json .npmignore .travis.yml gulpfile.js diff --git a/.travis.yml b/.travis.yml index a066d24..8e939a3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ node_js: - "4" - "6" script: - - npm run jsHint -- --failTaskOnError + - npm run eslint -- --failTaskOnError - npm run test -- --failTaskOnError --suppressPassed after_success: diff --git a/README.md b/README.md index 565a4bb..0d9e3cd 100644 --- a/README.md +++ b/README.md @@ -55,13 +55,13 @@ Run the tests: ``` npm run test ``` -To run JSHint on the entire codebase, run: +To run ESLint on the entire codebase, run: ``` -npm run jsHint +npm run eslint ``` -To run JSHint automatically when a file is saved, run the following and leave it open in a console window: +To run ESLint automatically when a file is saved, run the following and leave it open in a console window: ``` -npm run jsHint-watch +npm run eslint-watch ``` ## Running Test Coverage diff --git a/gulpfile.js b/gulpfile.js index 8d12058..01c8b5c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -4,7 +4,7 @@ var Cesium = require('cesium'); var child_process = require('child_process'); var fsExtra = require('fs-extra'); var gulp = require('gulp'); -var gulpJshint = require('gulp-jshint'); +var eslint = require('gulp-eslint'); var Jasmine = require('jasmine'); var JasmineSpecReporter = require('jasmine-spec-reporter').SpecReporter; var open = require('open'); @@ -20,23 +20,26 @@ var environmentSeparator = process.platform === 'win32' ? ';' : ':'; var nodeBinaries = path.join(__dirname, 'node_modules', '.bin'); process.env.PATH += environmentSeparator + nodeBinaries; -var jsHintFiles = ['**/*.js', '!node_modules/**', '!coverage/**', '!doc/**']; +var esLintFiles = ['**/*.js', '!node_modules/**', '!coverage/**', '!doc/**']; var specFiles = ['**/*.js', '!node_modules/**', '!coverage/**', '!doc/**', '!bin/**']; -gulp.task('jsHint', function () { - var stream = gulp.src(jsHintFiles) - .pipe(gulpJshint()) - .pipe(gulpJshint.reporter('jshint-stylish')); - +gulp.task('eslint', function () { + var stream = gulp.src(esLintFiles) + .pipe(eslint()) + .pipe(eslint.format()); if (argv.failTaskOnError) { - stream = stream.pipe(gulpJshint.reporter('fail')); + stream = stream.pipe(eslint.failAfterError()); } return stream; }); -gulp.task('jsHint-watch', function () { - gulp.watch(jsHintFiles, ['jsHint']); +gulp.task('eslint-watch', function() { + gulp.watch(esLintFiles).on('change', function(event) { + gulp.src(event.path) + .pipe(eslint()) + .pipe(eslint.format()); + }); }); gulp.task('test', function (done) { diff --git a/index.js b/index.js index f0c4b18..b157a83 100644 --- a/index.js +++ b/index.js @@ -1 +1,2 @@ +'use strict'; module.exports = require('./lib/obj2gltf'); diff --git a/package.json b/package.json index 0d37800..40fd641 100644 --- a/package.json +++ b/package.json @@ -38,21 +38,20 @@ }, "devDependencies": { "coveralls": "^2.12.0", + "eslint-config-cesium": "^1.0.0", "gulp": "^3.9.1", - "gulp-jshint": "^2.0.4", + "gulp-eslint": "^4.0.0", "istanbul": "^0.4.5", "jasmine": "^2.5.3", "jasmine-spec-reporter": "^4.1.0", "jsdoc": "^3.4.3", - "jshint": "^2.9.4", - "jshint-stylish": "^2.2.1", "open": "^0.0.5", "requirejs": "^2.3.3" }, "scripts": { "jsdoc": "jsdoc ./lib -R ./README.md -d doc", - "jsHint": "gulp jsHint", - "jsHint-watch": "gulp jsHint-watch", + "eslint": "gulp eslint", + "eslint-watch": "gulp eslint-watch", "test": "gulp test", "test-watch": "gulp test-watch", "coverage": "gulp coverage", diff --git a/specs/.eslintrc.json b/specs/.eslintrc.json new file mode 100644 index 0000000..92eb4d1 --- /dev/null +++ b/specs/.eslintrc.json @@ -0,0 +1,9 @@ +{ + "extends": "../.eslintrc.json", + "env": { + "jasmine": true + }, + "rules": { + "no-unused-vars": "off" + } +} diff --git a/specs/.jshintrc b/specs/.jshintrc deleted file mode 100644 index d921aae..0000000 --- a/specs/.jshintrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": "../.jshintrc", - "jasmine": true, - "unused": false -} diff --git a/specs/matchers/addDefaultMatchers.js b/specs/matchers/addDefaultMatchers.js index a1c6410..7a6dcc2 100644 --- a/specs/matchers/addDefaultMatchers.js +++ b/specs/matchers/addDefaultMatchers.js @@ -1,6 +1,6 @@ //This file is a copy of https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Specs/addDefaultMatchers.js -/*global define*/ -/*jshint unused:false*/ +/*eslint strict: ["error", "function"]*/ +/*eslint-env amd*/ define([ './equals', 'Cesium/Core/defined', diff --git a/specs/matchers/customizeJasmine.js b/specs/matchers/customizeJasmine.js index 8630965..a7b51c2 100644 --- a/specs/matchers/customizeJasmine.js +++ b/specs/matchers/customizeJasmine.js @@ -1,4 +1,5 @@ -/*global define*/ +/*eslint strict: ["error", "function"]*/ +/*eslint-env amd*/ define([ './addDefaultMatchers', './equalsMethodEqualityTester' diff --git a/specs/matchers/equals.js b/specs/matchers/equals.js index 99203d0..3ce5e26 100644 --- a/specs/matchers/equals.js +++ b/specs/matchers/equals.js @@ -1,5 +1,6 @@ //This file is a copy of https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Specs/equals.js -/*global define*/ +/*eslint strict: ["error", "function"]*/ +/*eslint-env amd*/ define([ 'Cesium/Core/FeatureDetection' ], function( diff --git a/specs/matchers/equalsMethodEqualityTester.js b/specs/matchers/equalsMethodEqualityTester.js index b9fd40e..4b61895 100644 --- a/specs/matchers/equalsMethodEqualityTester.js +++ b/specs/matchers/equalsMethodEqualityTester.js @@ -1,5 +1,6 @@ //This file is a copy of https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Specs/equalsMethodEqualityTester.js -/*global define*/ +/*eslint strict: ["error", "function"]*/ +/*eslint-env amd*/ define([ 'Cesium/Core/defined' ], function( From f2c3e05d8f98293764ef1f96b7f5104400fc5f75 Mon Sep 17 00:00:00 2001 From: Ottavio Hartman Date: Mon, 12 Jun 2017 15:10:35 -0400 Subject: [PATCH 05/17] Enable no-unused-vars and fix eslint errors --- specs/.eslintrc.json | 3 --- specs/lib/obj2gltfSpec.js | 1 - specs/matchers/addDefaultMatchers.js | 1 + 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/specs/.eslintrc.json b/specs/.eslintrc.json index 92eb4d1..297a41b 100644 --- a/specs/.eslintrc.json +++ b/specs/.eslintrc.json @@ -2,8 +2,5 @@ "extends": "../.eslintrc.json", "env": { "jasmine": true - }, - "rules": { - "no-unused-vars": "off" } } diff --git a/specs/lib/obj2gltfSpec.js b/specs/lib/obj2gltfSpec.js index d2aa73d..6ef53b0 100644 --- a/specs/lib/obj2gltfSpec.js +++ b/specs/lib/obj2gltfSpec.js @@ -5,7 +5,6 @@ var os = require('os'); var path = require('path'); var Promise = require('bluebird'); 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'; diff --git a/specs/matchers/addDefaultMatchers.js b/specs/matchers/addDefaultMatchers.js index 7a6dcc2..a883689 100644 --- a/specs/matchers/addDefaultMatchers.js +++ b/specs/matchers/addDefaultMatchers.js @@ -1,6 +1,7 @@ //This file is a copy of https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Specs/addDefaultMatchers.js /*eslint strict: ["error", "function"]*/ /*eslint-env amd*/ +/*eslint-disable no-unused-vars*/ define([ './equals', 'Cesium/Core/defined', From 23d243cda9d0b5295dea1dd71e67d7dbcd40decc Mon Sep 17 00:00:00 2001 From: Patrick Cozzi Date: Wed, 14 Jun 2017 07:38:15 -0400 Subject: [PATCH 06/17] Update LICENSE.md so GitHub reports Apache 2.0 license --- LICENSE.md | 205 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 201 insertions(+), 4 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index 9ca92f4..c8c9a9f 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,10 +1,207 @@ -Copyright 2016 Analytical Graphics, Inc. +Copyright 2016-2017 Analytical Graphics, Inc. and Contributors -Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ -http://www.apache.org/licenses/LICENSE-2.0 + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2016-2017 Analytical Graphics, Inc. and Contributors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. -Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Third-Party Code ================ From d2e5df2d77c346d767ceb2eae14742e6b5f40364 Mon Sep 17 00:00:00 2001 From: Patrick Cozzi Date: Wed, 14 Jun 2017 08:22:41 -0400 Subject: [PATCH 07/17] Fix typo --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 40fd641..f7dd61e 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "license": "Apache-2.0", "contributors": [ { - "name": "Analytical Graphics, Inc., and Contributors", + "name": "Analytical Graphics, Inc. and Contributors", "url": "https://github.com/AnalyticalGraphicsInc/obj2gltf/graphs/contributors" } ], From d1ac5816d4f37d4c2032723f829079b1e0aa1b44 Mon Sep 17 00:00:00 2001 From: Rachel Hwang Date: Tue, 13 Jun 2017 14:22:54 -0400 Subject: [PATCH 08/17] make mip-mapping on by default --- CHANGES.md | 1 + lib/createGltf.js | 2 +- specs/lib/createGltfSpec.js | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 160e98d..598251c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,7 @@ Change Log ### 1.1.1 2017-04-25 * Fixed `CHANGES.md` formatting. +* Change texture sampling to use NEAREST_MIPMAP_LINEAR by default [#83](https://github.com/AnalyticalGraphicsInc/obj2gltf/pull/83). ### 1.1.0 2017-04-25 diff --git a/lib/createGltf.js b/lib/createGltf.js index 33191c8..fbcce60 100644 --- a/lib/createGltf.js +++ b/lib/createGltf.js @@ -126,7 +126,7 @@ function createGltf(objData) { if (Object.keys(images).length > 0) { gltf.samplers[samplerId] = { magFilter : WebGLConstants.LINEAR, - minFilter : WebGLConstants.LINEAR, + minFilter : WebGLConstants.NEAREST_MIPMAP_LINEAR, wrapS : WebGLConstants.REPEAT, wrapT : WebGLConstants.REPEAT }; diff --git a/specs/lib/createGltfSpec.js b/specs/lib/createGltfSpec.js index 1e750ee..04b4b1c 100644 --- a/specs/lib/createGltfSpec.js +++ b/specs/lib/createGltfSpec.js @@ -143,7 +143,7 @@ describe('createGltf', function() { expect(gltf.samplers.sampler).toEqual({ magFilter : WebGLConstants.LINEAR, - minFilter : WebGLConstants.LINEAR, + minFilter : WebGLConstants.NEAREST_MIPMAP_LINEAR, wrapS : WebGLConstants.REPEAT, wrapT : WebGLConstants.REPEAT }); From dbe455fe14e84bf9c285b004c495b50018d778f1 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Wed, 14 Jun 2017 20:00:48 -0400 Subject: [PATCH 09/17] Fix CHANGES.md --- CHANGES.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 598251c..b19fe47 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,10 +1,13 @@ Change Log ========== +### Next release + +* Change texture sampling to use NEAREST_MIPMAP_LINEAR by default [#83](https://github.com/AnalyticalGraphicsInc/obj2gltf/pull/83). + ### 1.1.1 2017-04-25 * Fixed `CHANGES.md` formatting. -* Change texture sampling to use NEAREST_MIPMAP_LINEAR by default [#83](https://github.com/AnalyticalGraphicsInc/obj2gltf/pull/83). ### 1.1.0 2017-04-25 From 7946fecbeb69566bd560984dafb395c9f42f8447 Mon Sep 17 00:00:00 2001 From: Ottavio Hartman Date: Tue, 20 Jun 2017 13:24:03 -0400 Subject: [PATCH 10/17] Replace Istanbul with NYC --- .gitignore | 1 + README.md | 2 +- gulpfile.js | 6 +++--- package.json | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 8e46cf7..6e76bb2 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ doc output test *.tgz +.nyc_output diff --git a/README.md b/README.md index 0d9e3cd..7b5e786 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ npm run eslint-watch ## Running Test Coverage -Coverage uses [istanbul](https://github.com/gotwarlost/istanbul). Run: +Coverage uses [nyc](https://github.com/istanbuljs/nyc). Run: ``` npm run coverage ``` diff --git a/gulpfile.js b/gulpfile.js index 01c8b5c..2cfbded 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -70,9 +70,9 @@ gulp.task('test-watch', function () { gulp.task('coverage', function () { fsExtra.removeSync('coverage/server'); - child_process.execSync('istanbul' + - ' cover' + - ' --include-all-sources' + + child_process.execSync('nyc' + + ' --all' + + ' --reporter=lcov' + ' --dir coverage' + ' -x "specs/**" -x "coverage/**" -x "doc/**" -x "bin/**" -x "index.js" -x "gulpfile.js"' + ' node_modules/jasmine/bin/jasmine.js' + diff --git a/package.json b/package.json index f7dd61e..b091061 100644 --- a/package.json +++ b/package.json @@ -41,10 +41,10 @@ "eslint-config-cesium": "^1.0.0", "gulp": "^3.9.1", "gulp-eslint": "^4.0.0", - "istanbul": "^0.4.5", "jasmine": "^2.5.3", "jasmine-spec-reporter": "^4.1.0", "jsdoc": "^3.4.3", + "nyc": "^11.0.2", "open": "^0.0.5", "requirejs": "^2.3.3" }, From d728340ad42d40058d3749cfe695acd64ac70bb4 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Thu, 22 Jun 2017 20:56:32 -0400 Subject: [PATCH 11/17] Keep diffuse intact so that shader generation for generateNormals works correctly --- lib/createGltf.js | 8 ++++---- lib/obj2gltf.js | 3 ++- specs/lib/createGltfSpec.js | 38 ++++++++++++++++++------------------- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/lib/createGltf.js b/lib/createGltf.js index fbcce60..f7bc747 100644 --- a/lib/createGltf.js +++ b/lib/createGltf.js @@ -17,7 +17,7 @@ module.exports = createGltf; * * @private */ -function createGltf(objData) { +function createGltf(objData, options) { var nodes = objData.nodes; var materials = objData.materials; var images = objData.images; @@ -67,7 +67,7 @@ function createGltf(objData) { return 'texture_' + getImageId(imagePath); } - function createMaterial(material, hasNormals) { + function createMaterial(material, hasNormals, options) { var ambient = defaultValue(defaultValue(getTextureId(material.ambientTexture), material.ambientColor)); var diffuse = defaultValue(defaultValue(getTextureId(material.diffuseTexture), material.diffuseColor)); var emission = defaultValue(defaultValue(getTextureId(material.emissionTexture), material.emissionColor)); @@ -95,7 +95,7 @@ function createGltf(objData) { var doubleSided = transparent; - if (!hasNormals) { + if (!hasNormals && !options.generateNormals) { // Constant technique only factors in ambient and emission sources - set emission to diffuse emission = diffuse; diffuse = [0, 0, 0, 1]; @@ -303,7 +303,7 @@ function createGltf(objData) { } if (!defined(gltfMaterial)) { - gltf.materials[materialId] = createMaterial(material, hasNormals); + gltf.materials[materialId] = createMaterial(material, hasNormals, options); } gltfMeshPrimitives.push({ diff --git a/lib/obj2gltf.js b/lib/obj2gltf.js index 33f6e89..14a1bfd 100644 --- a/lib/obj2gltf.js +++ b/lib/obj2gltf.js @@ -61,6 +61,7 @@ function obj2gltf(objPath, gltfPath, options) { var outputUpAxis = defaultValue(options.outputUpAxis, defaults.outputUpAxis); var logger = defaultValue(options.logger, defaults.logger); + options.generateNormals = generateNormals; options.separate = separate; options.separateTextures = separateTextures; options.checkTransparency = checkTransparency; @@ -112,7 +113,7 @@ function obj2gltf(objPath, gltfPath, options) { return loadObj(objPath, options) .then(function(objData) { - return createGltf(objData); + return createGltf(objData, options); }) .then(function(gltf) { return writeUris(gltf, gltfPath, resourcesDirectory, options); diff --git a/specs/lib/createGltfSpec.js b/specs/lib/createGltfSpec.js index 04b4b1c..992c9cb 100644 --- a/specs/lib/createGltfSpec.js +++ b/specs/lib/createGltfSpec.js @@ -67,7 +67,7 @@ describe('createGltf', function() { }); it('simple gltf', function(done) { - var gltf = createGltf(boxObjData); + var gltf = createGltf(boxObjData, defaultOptions); expect(writeUris(gltf, boxGltfUrl, path.dirname(boxGltfUrl), defaultOptions) .then(function() { expect(gltf).toEqual(boxGltf); @@ -75,7 +75,7 @@ describe('createGltf', function() { }); it('multiple nodes, meshes, and primitives', function(done) { - var gltf = createGltf(groupObjData); + var gltf = createGltf(groupObjData, defaultOptions); expect(writeUris(gltf, groupGltfUrl, path.dirname(groupGltfUrl), defaultOptions) .then(function() { @@ -97,7 +97,7 @@ describe('createGltf', function() { it('sets default material values', function() { boxObjData.materials.Material = new Material(); - var gltf = createGltf(boxObjData); + var gltf = createGltf(boxObjData, defaultOptions); var material = gltf.materials.Material; var kmc = material.extensions.KHR_materials_common; var values = kmc.values; @@ -116,7 +116,7 @@ describe('createGltf', function() { boxObjData.materials.Material = material; boxObjData.images[diffuseTextureUrl] = diffuseTexture; - var gltf = createGltf(boxObjData); + var gltf = createGltf(boxObjData, defaultOptions); var kmc = gltf.materials.Material.extensions.KHR_materials_common; var texture = gltf.textures.texture_cesium; var image = gltf.images.cesium; @@ -154,7 +154,7 @@ describe('createGltf', function() { material.alpha = 0.4; boxObjData.materials.Material = material; - var gltf = createGltf(boxObjData); + var gltf = createGltf(boxObjData, defaultOptions); var kmc = gltf.materials.Material.extensions.KHR_materials_common; expect(kmc.values.diffuse).toEqual([0.5, 0.5, 0.5, 0.4]); @@ -171,7 +171,7 @@ describe('createGltf', function() { boxObjData.images[diffuseTextureUrl] = diffuseTexture; - var gltf = createGltf(boxObjData); + var gltf = createGltf(boxObjData, defaultOptions); var kmc = gltf.materials.Material.extensions.KHR_materials_common; expect(kmc.values.diffuse).toEqual('texture_cesium'); @@ -187,7 +187,7 @@ describe('createGltf', function() { boxObjData.images[transparentDiffuseTextureUrl] = transparentDiffuseTexture; - var gltf = createGltf(boxObjData); + var gltf = createGltf(boxObjData, defaultOptions); var kmc = gltf.materials.Material.extensions.KHR_materials_common; expect(kmc.values.diffuse).toBe('texture_diffuse'); @@ -202,7 +202,7 @@ describe('createGltf', function() { material.specularShininess = 0.1; boxObjData.materials.Material = material; - var gltf = createGltf(boxObjData); + var gltf = createGltf(boxObjData, defaultOptions); var kmc = gltf.materials.Material.extensions.KHR_materials_common; expect(kmc.technique).toBe('PHONG'); @@ -219,7 +219,7 @@ describe('createGltf', function() { boxObjData.images[diffuseTextureUrl] = diffuseTexture; - var gltf = createGltf(boxObjData); + var gltf = createGltf(boxObjData, defaultOptions); var kmc = gltf.materials.Material.extensions.KHR_materials_common; expect(kmc.technique).toBe('CONSTANT'); @@ -231,7 +231,7 @@ describe('createGltf', function() { material.diffuseTexture = diffuseTextureUrl; boxObjData.materials.Material = material; - var gltf = createGltf(boxObjData); + var gltf = createGltf(boxObjData, defaultOptions); var kmc = gltf.materials.Material.extensions.KHR_materials_common; expect(kmc.values.diffuse).toEqual([0.5, 0.5, 0.5, 1.0]); @@ -241,7 +241,7 @@ describe('createGltf', function() { boxObjData.nodes[0].meshes[0].primitives[0].material = undefined; // Creates a material called "default" - var gltf = createGltf(boxObjData); + var gltf = createGltf(boxObjData, defaultOptions); expect(gltf.materials.default).toBeDefined(); var kmc = gltf.materials.default.extensions.KHR_materials_common; expect(kmc.values.diffuse).toEqual([0.5, 0.5, 0.5, 1.0]); @@ -251,7 +251,7 @@ describe('createGltf', function() { boxObjData.materials = {}; // Uses the original name of the material - var gltf = createGltf(boxObjData); + var gltf = createGltf(boxObjData, defaultOptions); var kmc = gltf.materials.Material.extensions.KHR_materials_common; expect(kmc.values.diffuse).toEqual([0.5, 0.5, 0.5, 1.0]); @@ -262,7 +262,7 @@ describe('createGltf', function() { boxObjData.nodes.push(duplicateBoxObjData.nodes[0]); boxObjData.nodes[1].meshes[0].normals.length = 0; - var gltf = createGltf(boxObjData); + var gltf = createGltf(boxObjData, defaultOptions); var kmc1 = gltf.materials.Material.extensions.KHR_materials_common; var kmc2 = gltf.materials.Material_constant.extensions.KHR_materials_common; @@ -275,7 +275,7 @@ describe('createGltf', function() { boxObjData.nodes.push(duplicateBoxObjData.nodes[0]); boxObjData.nodes[0].meshes[0].normals.length = 0; - var gltf = createGltf(boxObjData); + var gltf = createGltf(boxObjData, defaultOptions); var kmc1 = gltf.materials.Material.extensions.KHR_materials_common; var kmc2 = gltf.materials.Material_shaded.extensions.KHR_materials_common; @@ -286,7 +286,7 @@ describe('createGltf', function() { it('runs without normals', function() { boxObjData.nodes[0].meshes[0].normals.length = 0; - var gltf = createGltf(boxObjData); + var gltf = createGltf(boxObjData, defaultOptions); var attributes = gltf.meshes[Object.keys(gltf.meshes)[0]].primitives[0].attributes; expect(attributes.POSITION).toBeDefined(); expect(attributes.NORMAL).toBeUndefined(); @@ -296,7 +296,7 @@ describe('createGltf', function() { it('runs without uvs', function() { boxObjData.nodes[0].meshes[0].uvs.length = 0; - var gltf = createGltf(boxObjData); + var gltf = createGltf(boxObjData, defaultOptions); var attributes = gltf.meshes[Object.keys(gltf.meshes)[0]].primitives[0].attributes; expect(attributes.POSITION).toBeDefined(); expect(attributes.NORMAL).toBeDefined(); @@ -307,7 +307,7 @@ describe('createGltf', function() { boxObjData.nodes[0].meshes[0].normals.length = 0; boxObjData.nodes[0].meshes[0].uvs.length = 0; - var gltf = createGltf(boxObjData); + var gltf = createGltf(boxObjData, defaultOptions); var attributes = gltf.meshes[Object.keys(gltf.meshes)[0]].primitives[0].attributes; expect(attributes.POSITION).toBeDefined(); expect(attributes.NORMAL).toBeUndefined(); @@ -347,7 +347,7 @@ describe('createGltf', function() { var indicesLength = mesh.primitives[0].indices.length; var vertexCount = mesh.positions.length / 3; - var gltf = createGltf(boxObjData); + var gltf = createGltf(boxObjData, defaultOptions); var primitive = gltf.meshes[Object.keys(gltf.meshes)[0]].primitives[0]; var indicesAccessor = gltf.accessors[primitive.indices]; expect(indicesAccessor.count).toBe(indicesLength); @@ -361,7 +361,7 @@ describe('createGltf', function() { it('ambient of [1, 1, 1] is treated as [0, 0, 0]', function() { boxObjData.materials.Material.ambientColor = [1.0, 1.0, 1.0, 1.0]; - var gltf = createGltf(boxObjData); + var gltf = createGltf(boxObjData, defaultOptions); var ambient = gltf.materials.Material.extensions.KHR_materials_common.values.ambient; expect(ambient).toEqual([0.0, 0.0, 0.0, 1.0]); From d2eee3e4c56a4a0e536f4a9c013697b23a753ac4 Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Fri, 23 Jun 2017 10:34:21 -0400 Subject: [PATCH 12/17] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index b19fe47..63efc16 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,7 @@ Change Log ### Next release * Change texture sampling to use NEAREST_MIPMAP_LINEAR by default [#83](https://github.com/AnalyticalGraphicsInc/obj2gltf/pull/83). +* Fixed normal generation. ### 1.1.1 2017-04-25 From 644c281e9cd4adff09223d24650aa4145cd95b9b Mon Sep 17 00:00:00 2001 From: Ottavio Hartman Date: Fri, 23 Jun 2017 13:42:34 -0400 Subject: [PATCH 13/17] Switch from gulp-eslint to the ESLint CLI. Switch to eslint-config-cesium 2.0. --- .eslintignore | 3 +++ .gitignore | 1 + .travis.yml | 2 +- gulpfile.js | 21 --------------------- lib/obj2gltf.js | 3 +-- package.json | 7 +++---- 6 files changed, 9 insertions(+), 28 deletions(-) create mode 100644 .eslintignore diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..0c85304 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,3 @@ +node_modules/** +coverage/** +doc/** diff --git a/.gitignore b/.gitignore index 6e76bb2..f7e2d78 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ npm-debug.log .idea/tasks.xml # Generate data +.eslintcache coverage doc output diff --git a/.travis.yml b/.travis.yml index 8e939a3..4264c75 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ node_js: - "4" - "6" script: - - npm run eslint -- --failTaskOnError + - npm run eslint - npm run test -- --failTaskOnError --suppressPassed after_success: diff --git a/gulpfile.js b/gulpfile.js index 2cfbded..773c8b9 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -4,7 +4,6 @@ var Cesium = require('cesium'); var child_process = require('child_process'); var fsExtra = require('fs-extra'); var gulp = require('gulp'); -var eslint = require('gulp-eslint'); var Jasmine = require('jasmine'); var JasmineSpecReporter = require('jasmine-spec-reporter').SpecReporter; var open = require('open'); @@ -20,28 +19,8 @@ var environmentSeparator = process.platform === 'win32' ? ';' : ':'; var nodeBinaries = path.join(__dirname, 'node_modules', '.bin'); process.env.PATH += environmentSeparator + nodeBinaries; -var esLintFiles = ['**/*.js', '!node_modules/**', '!coverage/**', '!doc/**']; var specFiles = ['**/*.js', '!node_modules/**', '!coverage/**', '!doc/**', '!bin/**']; -gulp.task('eslint', function () { - var stream = gulp.src(esLintFiles) - .pipe(eslint()) - .pipe(eslint.format()); - if (argv.failTaskOnError) { - stream = stream.pipe(eslint.failAfterError()); - } - - return stream; -}); - -gulp.task('eslint-watch', function() { - gulp.watch(esLintFiles).on('change', function(event) { - gulp.src(event.path) - .pipe(eslint()) - .pipe(eslint.format()); - }); -}); - gulp.task('test', function (done) { var jasmine = new Jasmine(); jasmine.loadConfigFile('specs/jasmine.json'); diff --git a/lib/obj2gltf.js b/lib/obj2gltf.js index 14a1bfd..86cac90 100644 --- a/lib/obj2gltf.js +++ b/lib/obj2gltf.js @@ -121,9 +121,8 @@ function obj2gltf(objPath, gltfPath, options) { .then(function(gltf) { if (bypassPipeline) { return fsExtra.outputJson(gltfPath, gltf); - } else { - return GltfPipeline.processJSONToDisk(gltf, gltfPath, pipelineOptions); } + return GltfPipeline.processJSONToDisk(gltf, gltfPath, pipelineOptions); }) .finally(function() { return cleanup(resourcesDirectory, options); diff --git a/package.json b/package.json index b091061..62487b3 100644 --- a/package.json +++ b/package.json @@ -38,9 +38,9 @@ }, "devDependencies": { "coveralls": "^2.12.0", - "eslint-config-cesium": "^1.0.0", + "eslint": "^4.1.1", + "eslint-config-cesium": "^2.0.0", "gulp": "^3.9.1", - "gulp-eslint": "^4.0.0", "jasmine": "^2.5.3", "jasmine-spec-reporter": "^4.1.0", "jsdoc": "^3.4.3", @@ -50,8 +50,7 @@ }, "scripts": { "jsdoc": "jsdoc ./lib -R ./README.md -d doc", - "eslint": "gulp eslint", - "eslint-watch": "gulp eslint-watch", + "eslint": "eslint \"./**/*.js\" --cache --quiet", "test": "gulp test", "test-watch": "gulp test-watch", "coverage": "gulp coverage", From 24513be7b8f9370a0bb6707a21b8c7ada0b57a98 Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Wed, 28 Jun 2017 08:34:42 -0400 Subject: [PATCH 14/17] Clean up .gitignore and .npmignore There were some outdated and missing entries. --- .gitignore | 2 -- .npmignore | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index f7e2d78..53cace9 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,5 @@ npm-debug.log .eslintcache coverage doc -output -test *.tgz .nyc_output diff --git a/.npmignore b/.npmignore index 8d9d85c..ae3d01d 100644 --- a/.npmignore +++ b/.npmignore @@ -1,12 +1,12 @@ /.idea /coverage /doc -/output /specs -/test -/output .editorconfig +.eslintcache +.eslintignore .eslintrc.json +.nyc_output .npmignore .travis.yml gulpfile.js From 912ab5edff3e9b80d19f3ae0b068d9eb581d4325 Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Wed, 28 Jun 2017 13:15:56 -0400 Subject: [PATCH 15/17] Remove dependency on event-stream Node has built in functions for reading lines from a file, so there's no need to depend on `event-stream` just for it. --- LICENSE.md | 29 ----------------------------- lib/readLines.js | 19 ++++++++++--------- package.json | 1 - 3 files changed, 10 insertions(+), 39 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index c8c9a9f..9fdda01 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -246,35 +246,6 @@ http://cesiumjs.org/ See https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md -### event-stream - -https://www.npmjs.com/package/event-stream - -> The MIT License (MIT) -> -> Copyright (c) 2011 Dominic Tarr -> -> Permission is hereby granted, free of charge, -> to any person obtaining a copy of this software and -> associated documentation files (the "Software"), to -> deal in the Software without restriction, including -> without limitation the rights to use, copy, modify, -> merge, publish, distribute, sublicense, and/or sell -> copies of the Software, and to permit persons to whom -> the Software is furnished to do so, -> subject to the following conditions: -> -> The above copyright notice and this permission notice -> shall be included in all copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -> OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -> IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR -> ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -> TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -> SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - ### fs-extra https://www.npmjs.com/package/fs-extra diff --git a/lib/readLines.js b/lib/readLines.js index 4178147..073b85c 100644 --- a/lib/readLines.js +++ b/lib/readLines.js @@ -1,7 +1,7 @@ 'use strict'; -var eventStream = require('event-stream'); var fsExtra = require('fs-extra'); var Promise = require('bluebird'); +var readline = require('readline'); module.exports = readLines; @@ -15,13 +15,14 @@ module.exports = readLines; * @private */ function readLines(path, callback) { - return new Promise(function(resolve, reject) { - fsExtra.createReadStream(path) - .on('error', reject) - .on('end', resolve) - .pipe(eventStream.split()) - .pipe(eventStream.mapSync(function (line) { - callback(line); - })); + return new Promise(function (resolve, reject) { + var stream = fsExtra.createReadStream(path); + stream.on('error', reject); + stream.on('end', resolve); + + var lineReader = readline.createInterface({ + input: stream + }); + lineReader.on('line', callback); }); } diff --git a/package.json b/package.json index 62487b3..072e2d1 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,6 @@ "dependencies": { "bluebird": "^3.4.7", "cesium": "^1.31.0", - "event-stream": "^3.3.4", "fs-extra": "^3.0.1", "gltf-pipeline": "^0.1.0-alpha11", "mime": "^1.3.4", From 3df055c42ab86fc023449fe99470f9e9d5e35f2d Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Tue, 11 Jul 2017 11:32:04 -0400 Subject: [PATCH 16/17] Rework fragile tests --- .../box-objects-groups-materials.gltf | 492 ------------------ specs/data/box/box.gltf | 178 ------- specs/lib/createGltfSpec.js | 65 ++- 3 files changed, 30 insertions(+), 705 deletions(-) delete mode 100644 specs/data/box-objects-groups-materials/box-objects-groups-materials.gltf delete mode 100644 specs/data/box/box.gltf diff --git a/specs/data/box-objects-groups-materials/box-objects-groups-materials.gltf b/specs/data/box-objects-groups-materials/box-objects-groups-materials.gltf deleted file mode 100644 index 1714d03..0000000 --- a/specs/data/box-objects-groups-materials/box-objects-groups-materials.gltf +++ /dev/null @@ -1,492 +0,0 @@ -{ - "accessors": { - "accessor_0": { - "bufferView": "bufferView_vertex", - "byteOffset": 0, - "byteStride": 0, - "componentType": 5126, - "count": 24, - "min": [ - -1, - -1, - -6 - ], - "max": [ - 1, - 1, - -4 - ], - "type": "VEC3" - }, - "accessor_1": { - "bufferView": "bufferView_vertex", - "byteOffset": 288, - "byteStride": 0, - "componentType": 5126, - "count": 24, - "min": [ - -1, - -1, - -1 - ], - "max": [ - 1, - 1, - 1 - ], - "type": "VEC3" - }, - "accessor_2": { - "bufferView": "bufferView_vertex", - "byteOffset": 576, - "byteStride": 0, - "componentType": 5126, - "count": 24, - "min": [ - 0, - 0 - ], - "max": [ - 1, - 1 - ], - "type": "VEC2" - }, - "accessor_3": { - "bufferView": "bufferView_index", - "byteOffset": 0, - "byteStride": 0, - "componentType": 5123, - "count": 18, - "min": [ - 0 - ], - "max": [ - 11 - ], - "type": "SCALAR" - }, - "accessor_4": { - "bufferView": "bufferView_index", - "byteOffset": 36, - "byteStride": 0, - "componentType": 5123, - "count": 18, - "min": [ - 12 - ], - "max": [ - 23 - ], - "type": "SCALAR" - }, - "accessor_5": { - "bufferView": "bufferView_vertex", - "byteOffset": 768, - "byteStride": 0, - "componentType": 5126, - "count": 24, - "min": [ - 4, - -1, - -1 - ], - "max": [ - 6, - 1, - 1 - ], - "type": "VEC3" - }, - "accessor_6": { - "bufferView": "bufferView_vertex", - "byteOffset": 1056, - "byteStride": 0, - "componentType": 5126, - "count": 24, - "min": [ - -1, - -1, - -1 - ], - "max": [ - 1, - 1, - 1 - ], - "type": "VEC3" - }, - "accessor_7": { - "bufferView": "bufferView_vertex", - "byteOffset": 1344, - "byteStride": 0, - "componentType": 5126, - "count": 24, - "min": [ - 0, - 0 - ], - "max": [ - 1, - 1 - ], - "type": "VEC2" - }, - "accessor_8": { - "bufferView": "bufferView_index", - "byteOffset": 72, - "byteStride": 0, - "componentType": 5123, - "count": 18, - "min": [ - 0 - ], - "max": [ - 11 - ], - "type": "SCALAR" - }, - "accessor_9": { - "bufferView": "bufferView_index", - "byteOffset": 108, - "byteStride": 0, - "componentType": 5123, - "count": 18, - "min": [ - 12 - ], - "max": [ - 23 - ], - "type": "SCALAR" - }, - "accessor_10": { - "bufferView": "bufferView_vertex", - "byteOffset": 1536, - "byteStride": 0, - "componentType": 5126, - "count": 24, - "min": [ - -1, - -1, - -1 - ], - "max": [ - 1, - 1, - 1 - ], - "type": "VEC3" - }, - "accessor_11": { - "bufferView": "bufferView_vertex", - "byteOffset": 1824, - "byteStride": 0, - "componentType": 5126, - "count": 24, - "min": [ - -1, - -1, - -1 - ], - "max": [ - 1, - 1, - 1 - ], - "type": "VEC3" - }, - "accessor_12": { - "bufferView": "bufferView_vertex", - "byteOffset": 2112, - "byteStride": 0, - "componentType": 5126, - "count": 24, - "min": [ - 0, - 0 - ], - "max": [ - 1, - 1 - ], - "type": "VEC2" - }, - "accessor_13": { - "bufferView": "bufferView_index", - "byteOffset": 144, - "byteStride": 0, - "componentType": 5123, - "count": 18, - "min": [ - 0 - ], - "max": [ - 11 - ], - "type": "SCALAR" - }, - "accessor_14": { - "bufferView": "bufferView_index", - "byteOffset": 180, - "byteStride": 0, - "componentType": 5123, - "count": 18, - "min": [ - 12 - ], - "max": [ - 23 - ], - "type": "SCALAR" - } - }, - "asset": { - "generator": "obj2gltf", - "profile": { - "api": "WebGL", - "version": "1.0" - }, - "version": "1.0" - }, - "buffers": { - "buffer": { - "byteLength": 2520, - "uri": "data:application/octet-stream;base64,AACAvwAAgL8AAIDAAACAvwAAgD8AAIDAAACAvwAAgD8AAMDAAACAvwAAgL8AAMDAAACAvwAAgL8AAMDAAACAvwAAgD8AAMDAAACAPwAAgD8AAMDAAACAPwAAgL8AAMDAAACAPwAAgL8AAMDAAACAPwAAgD8AAMDAAACAPwAAgD8AAIDAAACAPwAAgL8AAIDAAACAPwAAgL8AAIDAAACAPwAAgD8AAIDAAACAvwAAgD8AAIDAAACAvwAAgL8AAIDAAACAvwAAgL8AAMDAAACAPwAAgL8AAMDAAACAPwAAgL8AAIDAAACAvwAAgL8AAIDAAACAPwAAgD8AAMDAAACAvwAAgD8AAMDAAACAvwAAgD8AAIDAAACAPwAAgD8AAIDAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAIA/AACAPwAAgD8AAAAAAAAAAAAAAAAAAAAAAACAPwAAgD8AAIA/AACAPwAAAAAAAAAAAAAAAAAAAAAAAIA/AACAPwAAgD8AAIA/AAAAAAAAAAAAAAAAAAAAAAAAgD8AAIA/AACAPwAAgD8AAAAAAAAAAAAAAAAAAAAAAACAPwAAgD8AAIA/AACAPwAAAAAAAAAAAAAAAAAAAAAAAIA/AACAPwAAgD8AAIA/AAAAAAAAAAAAAAAAAACAQAAAgL8AAIA/AACAQAAAgD8AAIA/AACAQAAAgD8AAIC/AACAQAAAgL8AAIC/AACAQAAAgL8AAIC/AACAQAAAgD8AAIC/AADAQAAAgD8AAIC/AADAQAAAgL8AAIC/AADAQAAAgL8AAIC/AADAQAAAgD8AAIC/AADAQAAAgD8AAIA/AADAQAAAgL8AAIA/AADAQAAAgL8AAIA/AADAQAAAgD8AAIA/AACAQAAAgD8AAIA/AACAQAAAgL8AAIA/AACAQAAAgL8AAIC/AADAQAAAgL8AAIC/AADAQAAAgL8AAIA/AACAQAAAgL8AAIA/AADAQAAAgD8AAIC/AACAQAAAgD8AAIC/AACAQAAAgD8AAIA/AADAQAAAgD8AAIA/AACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAIA/AACAPwAAgD8AAAAAAAAAAAAAAAAAAAAAAACAPwAAgD8AAIA/AACAPwAAAAAAAAAAAAAAAAAAAAAAAIA/AACAPwAAgD8AAIA/AAAAAAAAAAAAAAAAAAAAAAAAgD8AAIA/AACAPwAAgD8AAAAAAAAAAAAAAAAAAAAAAACAPwAAgD8AAIA/AACAPwAAAAAAAAAAAAAAAAAAAAAAAIA/AACAPwAAgD8AAIA/AAAAAAAAAAAAAAAAAACAvwAAgL8AAIA/AACAvwAAgD8AAIA/AACAvwAAgD8AAIC/AACAvwAAgL8AAIC/AACAvwAAgL8AAIC/AACAvwAAgD8AAIC/AACAPwAAgD8AAIC/AACAPwAAgL8AAIC/AACAPwAAgL8AAIC/AACAPwAAgD8AAIC/AACAPwAAgD8AAIA/AACAPwAAgL8AAIA/AACAPwAAgL8AAIA/AACAPwAAgD8AAIA/AACAvwAAgD8AAIA/AACAvwAAgL8AAIA/AACAvwAAgL8AAIC/AACAPwAAgL8AAIC/AACAPwAAgL8AAIA/AACAvwAAgL8AAIA/AACAPwAAgD8AAIC/AACAvwAAgD8AAIC/AACAvwAAgD8AAIA/AACAPwAAgD8AAIA/AACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAIA/AACAPwAAgD8AAAAAAAAAAAAAAAAAAAAAAACAPwAAgD8AAIA/AACAPwAAAAAAAAAAAAAAAAAAAAAAAIA/AACAPwAAgD8AAIA/AAAAAAAAAAAAAAAAAAAAAAAAgD8AAIA/AACAPwAAgD8AAAAAAAAAAAAAAAAAAAAAAACAPwAAgD8AAIA/AACAPwAAAAAAAAAAAAAAAAAAAAAAAIA/AACAPwAAgD8AAIA/AAAAAAAAAAAAAAAAAAABAAIAAAACAAMABAAFAAYABAAGAAcACAAJAAoACAAKAAsADAANAA4ADAAOAA8AEAARABIAEAASABMAFAAVABYAFAAWABcAAAABAAIAAAACAAMABAAFAAYABAAGAAcACAAJAAoACAAKAAsADAANAA4ADAAOAA8AEAARABIAEAASABMAFAAVABYAFAAWABcAAAABAAIAAAACAAMABAAFAAYABAAGAAcACAAJAAoACAAKAAsADAANAA4ADAAOAA8AEAARABIAEAASABMAFAAVABYAFAAWABcA" - } - }, - "bufferViews": { - "bufferView_vertex": { - "buffer": "buffer", - "byteLength": 2304, - "byteOffset": 0, - "target": 34962 - }, - "bufferView_index": { - "buffer": "buffer", - "byteLength": 216, - "byteOffset": 2304, - "target": 34963 - } - }, - "extensionsUsed": [ - "KHR_materials_common" - ], - "images": {}, - "materials": { - "Blue": { - "extensions": { - "KHR_materials_common": { - "technique": "PHONG", - "transparent": false, - "doubleSided": false, - "values": { - "ambient": [ - 0, - 0, - 0, - 1 - ], - "diffuse": [ - 0, - 0, - 0.64, - 1 - ], - "emission": [ - 0, - 0, - 0, - 1 - ], - "specular": [ - 0.5, - 0.5, - 0.5, - 1 - ], - "shininess": 96.078431, - "transparency": 1, - "transparent": false, - "doubleSided": false - } - } - } - }, - "Green": { - "extensions": { - "KHR_materials_common": { - "technique": "PHONG", - "transparent": false, - "doubleSided": false, - "values": { - "ambient": [ - 0, - 0, - 0, - 1 - ], - "diffuse": [ - 0, - 0.64, - 0, - 1 - ], - "emission": [ - 0, - 0, - 0, - 1 - ], - "specular": [ - 0.5, - 0.5, - 0.5, - 1 - ], - "shininess": 96.078431, - "transparency": 1, - "transparent": false, - "doubleSided": false - } - } - } - }, - "Red": { - "extensions": { - "KHR_materials_common": { - "technique": "PHONG", - "transparent": false, - "doubleSided": false, - "values": { - "ambient": [ - 0, - 0, - 0, - 1 - ], - "diffuse": [ - 0.64, - 0, - 0, - 1 - ], - "emission": [ - 0, - 0, - 0, - 1 - ], - "specular": [ - 0.5, - 0.5, - 0.5, - 1 - ], - "shininess": 96.078431, - "transparency": 1, - "transparent": false, - "doubleSided": false - } - } - } - } - }, - "meshes": { - "CubeBlue_CubeBlue_Blue": { - "name": "CubeBlue_CubeBlue_Blue", - "primitives": [ - { - "attributes": { - "POSITION": "accessor_0", - "NORMAL": "accessor_1", - "TEXCOORD_0": "accessor_2" - }, - "indices": "accessor_3", - "material": "Blue", - "mode": 4 - }, - { - "attributes": { - "POSITION": "accessor_0", - "NORMAL": "accessor_1", - "TEXCOORD_0": "accessor_2" - }, - "indices": "accessor_4", - "material": "Green", - "mode": 4 - } - ] - }, - "CubeGreen_CubeGreen_Green": { - "name": "CubeGreen_CubeGreen_Green", - "primitives": [ - { - "attributes": { - "POSITION": "accessor_5", - "NORMAL": "accessor_6", - "TEXCOORD_0": "accessor_7" - }, - "indices": "accessor_8", - "material": "Green", - "mode": 4 - }, - { - "attributes": { - "POSITION": "accessor_5", - "NORMAL": "accessor_6", - "TEXCOORD_0": "accessor_7" - }, - "indices": "accessor_9", - "material": "Red", - "mode": 4 - } - ] - }, - "CubeRed_CubeRed_Red": { - "name": "CubeRed_CubeRed_Red", - "primitives": [ - { - "attributes": { - "POSITION": "accessor_10", - "NORMAL": "accessor_11", - "TEXCOORD_0": "accessor_12" - }, - "indices": "accessor_13", - "material": "Red", - "mode": 4 - }, - { - "attributes": { - "POSITION": "accessor_10", - "NORMAL": "accessor_11", - "TEXCOORD_0": "accessor_12" - }, - "indices": "accessor_14", - "material": "Blue", - "mode": 4 - } - ] - } - }, - "nodes": { - "Cube": { - "name": "Cube", - "meshes": [ - "CubeBlue_CubeBlue_Blue", - "CubeGreen_CubeGreen_Green", - "CubeRed_CubeRed_Red" - ] - } - }, - "samplers": {}, - "scene": "scene", - "scenes": { - "scene": { - "nodes": [ - "Cube" - ] - } - }, - "textures": {} -} diff --git a/specs/data/box/box.gltf b/specs/data/box/box.gltf deleted file mode 100644 index 112389c..0000000 --- a/specs/data/box/box.gltf +++ /dev/null @@ -1,178 +0,0 @@ -{ - "accessors": { - "accessor_0": { - "bufferView": "bufferView_vertex", - "byteOffset": 0, - "byteStride": 0, - "componentType": 5126, - "count": 24, - "min": [ - -1, - -1, - -1 - ], - "max": [ - 1, - 1, - 1 - ], - "type": "VEC3" - }, - "accessor_1": { - "bufferView": "bufferView_vertex", - "byteOffset": 288, - "byteStride": 0, - "componentType": 5126, - "count": 24, - "min": [ - -1, - -1, - -1 - ], - "max": [ - 1, - 1, - 1 - ], - "type": "VEC3" - }, - "accessor_2": { - "bufferView": "bufferView_vertex", - "byteOffset": 576, - "byteStride": 0, - "componentType": 5126, - "count": 24, - "min": [ - 0, - 0 - ], - "max": [ - 1, - 1 - ], - "type": "VEC2" - }, - "accessor_3": { - "bufferView": "bufferView_index", - "byteOffset": 0, - "byteStride": 0, - "componentType": 5123, - "count": 36, - "min": [ - 0 - ], - "max": [ - 23 - ], - "type": "SCALAR" - } - }, - "asset": { - "generator": "obj2gltf", - "profile": { - "api": "WebGL", - "version": "1.0" - }, - "version": "1.0" - }, - "buffers": { - "buffer": { - "byteLength": 840, - "uri": "data:application/octet-stream;base64,AACAvwAAgL8AAIA/AACAvwAAgD8AAIA/AACAvwAAgD8AAIC/AACAvwAAgL8AAIC/AACAvwAAgL8AAIC/AACAvwAAgD8AAIC/AACAPwAAgD8AAIC/AACAPwAAgL8AAIC/AACAPwAAgL8AAIC/AACAPwAAgD8AAIC/AACAPwAAgD8AAIA/AACAPwAAgL8AAIA/AACAPwAAgL8AAIA/AACAPwAAgD8AAIA/AACAvwAAgD8AAIA/AACAvwAAgL8AAIA/AACAvwAAgL8AAIC/AACAPwAAgL8AAIC/AACAPwAAgL8AAIA/AACAvwAAgL8AAIA/AACAPwAAgD8AAIC/AACAvwAAgD8AAIC/AACAvwAAgD8AAIA/AACAPwAAgD8AAIA/AACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAIA/AACAPwAAgD8AAAAAAAAAAAAAAAAAAAAAAACAPwAAgD8AAIA/AACAPwAAAAAAAAAAAAAAAAAAAAAAAIA/AACAPwAAgD8AAIA/AAAAAAAAAAAAAAAAAAAAAAAAgD8AAIA/AACAPwAAgD8AAAAAAAAAAAAAAAAAAAAAAACAPwAAgD8AAIA/AACAPwAAAAAAAAAAAAAAAAAAAAAAAIA/AACAPwAAgD8AAIA/AAAAAAAAAAAAAAAAAAABAAIAAAACAAMABAAFAAYABAAGAAcACAAJAAoACAAKAAsADAANAA4ADAAOAA8AEAARABIAEAASABMAFAAVABYAFAAWABcA" - } - }, - "bufferViews": { - "bufferView_vertex": { - "buffer": "buffer", - "byteLength": 768, - "byteOffset": 0, - "target": 34962 - }, - "bufferView_index": { - "buffer": "buffer", - "byteLength": 72, - "byteOffset": 768, - "target": 34963 - } - }, - "extensionsUsed": [ - "KHR_materials_common" - ], - "images": {}, - "materials": { - "Material": { - "extensions": { - "KHR_materials_common": { - "technique": "PHONG", - "transparent": false, - "doubleSided": false, - "values": { - "ambient": [ - 0, - 0, - 0, - 1 - ], - "diffuse": [ - 0.64, - 0.64, - 0.64, - 1 - ], - "emission": [ - 0, - 0, - 0, - 1 - ], - "specular": [ - 0.5, - 0.5, - 0.5, - 1 - ], - "shininess": 96.078431, - "transparency": 1, - "transparent": false, - "doubleSided": false - } - } - } - } - }, - "meshes": { - "Cube-Mesh": { - "name": "Cube-Mesh", - "primitives": [ - { - "attributes": { - "POSITION": "accessor_0", - "NORMAL": "accessor_1", - "TEXCOORD_0": "accessor_2" - }, - "indices": "accessor_3", - "material": "Material", - "mode": 4 - } - ] - } - }, - "nodes": { - "Cube": { - "name": "Cube", - "meshes": [ - "Cube-Mesh" - ] - } - }, - "samplers": {}, - "scene": "scene", - "scenes": { - "scene": { - "nodes": [ - "Cube" - ] - } - }, - "textures": {} -} \ No newline at end of file diff --git a/specs/lib/createGltfSpec.js b/specs/lib/createGltfSpec.js index 992c9cb..afd0963 100644 --- a/specs/lib/createGltfSpec.js +++ b/specs/lib/createGltfSpec.js @@ -1,22 +1,17 @@ 'use strict'; var Cesium = require('cesium'); -var fsExtra = require('fs-extra'); -var path = require('path'); var Promise = require('bluebird'); 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'); var clone = Cesium.clone; var WebGLConstants = Cesium.WebGLConstants; var boxObjUrl = 'specs/data/box/box.obj'; var groupObjUrl = 'specs/data/box-objects-groups-materials/box-objects-groups-materials.obj'; -var boxGltfUrl = 'specs/data/box/box.gltf'; -var groupGltfUrl = 'specs/data/box-objects-groups-materials/box-objects-groups-materials.gltf'; var diffuseTextureUrl = 'specs/data/box-textured/cesium.png'; var transparentDiffuseTextureUrl = 'specs/data/box-complex-material/diffuse.png'; @@ -28,8 +23,6 @@ describe('createGltf', function() { var boxObjData; var duplicateBoxObjData; var groupObjData; - var boxGltf; - var groupGltf; var diffuseTexture; var transparentDiffuseTexture; @@ -47,14 +40,6 @@ describe('createGltf', function() { .then(function(data) { groupObjData = data; }), - fsExtra.readJson(boxGltfUrl) - .then(function(gltf) { - boxGltf = gltf; - }), - fsExtra.readJson(groupGltfUrl) - .then(function(gltf) { - groupGltf = gltf; - }), loadImage(diffuseTextureUrl, defaultOptions) .then(function(image) { diffuseTexture = image; @@ -66,32 +51,42 @@ describe('createGltf', function() { ]).then(done); }); - it('simple gltf', function(done) { + it('simple gltf', function() { var gltf = createGltf(boxObjData, defaultOptions); - expect(writeUris(gltf, boxGltfUrl, path.dirname(boxGltfUrl), defaultOptions) - .then(function() { - expect(gltf).toEqual(boxGltf); - }), done).toResolve(); + + expect(Object.keys(gltf.materials).length).toBe(1); + expect(Object.keys(gltf.nodes).length).toBe(1); + expect(Object.keys(gltf.meshes).length).toBe(1); + + var primitives = gltf.meshes['Cube-Mesh'].primitives; + var primitive = primitives[0]; + var attributes = primitive.attributes; + var positionAccessor = gltf.accessors[attributes.POSITION]; + var normalAccessor = gltf.accessors[attributes.NORMAL]; + var uvAccessor = gltf.accessors[attributes.TEXCOORD_0]; + var indexAccessor = gltf.accessors[primitive.indices]; + + expect(primitives.length).toBe(1); + expect(positionAccessor.count).toBe(24); + expect(normalAccessor.count).toBe(24); + expect(uvAccessor.count).toBe(24); + expect(indexAccessor.count).toBe(36); }); - it('multiple nodes, meshes, and primitives', function(done) { + it('multiple nodes, meshes, and primitives', function() { var gltf = createGltf(groupObjData, defaultOptions); - expect(writeUris(gltf, groupGltfUrl, path.dirname(groupGltfUrl), defaultOptions) - .then(function() { - expect(gltf).toEqual(groupGltf); - expect(Object.keys(gltf.materials).length).toBe(3); - expect(Object.keys(gltf.nodes).length).toBe(1); - expect(Object.keys(gltf.meshes).length).toBe(3); + expect(Object.keys(gltf.materials).length).toBe(3); + expect(Object.keys(gltf.nodes).length).toBe(1); + expect(Object.keys(gltf.meshes).length).toBe(3); - // Check for two primitives in each mesh - for (var id in gltf.meshes) { - if (gltf.meshes.hasOwnProperty(id)) { - var mesh = gltf.meshes[id]; - expect(mesh.primitives.length).toBe(2); - } - } - }), done).toResolve(); + // Check for two primitives in each mesh + for (var id in gltf.meshes) { + if (gltf.meshes.hasOwnProperty(id)) { + var mesh = gltf.meshes[id]; + expect(mesh.primitives.length).toBe(2); + } + } }); it('sets default material values', function() { From 8701c877678acb0d667e3be80ac50391e4683c8a Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Tue, 11 Jul 2017 11:42:35 -0400 Subject: [PATCH 17/17] Bumped to 1.2.0 --- .npmignore | 1 + CHANGES.md | 6 +++--- package.json | 30 +++++++++++++++--------------- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/.npmignore b/.npmignore index ae3d01d..3480bce 100644 --- a/.npmignore +++ b/.npmignore @@ -2,6 +2,7 @@ /coverage /doc /specs +/test .editorconfig .eslintcache .eslintignore diff --git a/CHANGES.md b/CHANGES.md index 63efc16..a2f9393 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,10 +1,10 @@ Change Log ========== -### Next release +### 1.2.0 2017-07-11 -* Change texture sampling to use NEAREST_MIPMAP_LINEAR by default [#83](https://github.com/AnalyticalGraphicsInc/obj2gltf/pull/83). -* Fixed normal generation. +* Change texture sampling to use `NEAREST_MIPMAP_LINEAR` by default [#83](https://github.com/AnalyticalGraphicsInc/obj2gltf/pull/83). +* Fixed lighting when generating normals. [#89](https://github.com/AnalyticalGraphicsInc/obj2gltf/pull/89) ### 1.1.1 2017-04-25 diff --git a/package.json b/package.json index 072e2d1..6ebf148 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obj2gltf", - "version": "1.1.1", + "version": "1.2.0", "description": "Convert OBJ model format to glTF", "license": "Apache-2.0", "contributors": [ @@ -26,24 +26,24 @@ "node": ">=4.0.0" }, "dependencies": { - "bluebird": "^3.4.7", - "cesium": "^1.31.0", + "bluebird": "^3.5.0", + "cesium": "^1.35.2", "fs-extra": "^3.0.1", - "gltf-pipeline": "^0.1.0-alpha11", - "mime": "^1.3.4", - "pngjs": "^3.0.1", - "uuid": "^3.0.1", - "yargs": "^8.0.1" + "gltf-pipeline": "^1.0.0", + "mime": "^1.3.6", + "pngjs": "^3.2.0", + "uuid": "^3.1.0", + "yargs": "^8.0.2" }, "devDependencies": { - "coveralls": "^2.12.0", - "eslint": "^4.1.1", - "eslint-config-cesium": "^2.0.0", + "coveralls": "^2.13.1", + "eslint": "^4.2.0", + "eslint-config-cesium": "^2.0.1", "gulp": "^3.9.1", - "jasmine": "^2.5.3", - "jasmine-spec-reporter": "^4.1.0", - "jsdoc": "^3.4.3", - "nyc": "^11.0.2", + "jasmine": "^2.6.0", + "jasmine-spec-reporter": "^4.1.1", + "jsdoc": "^3.5.1", + "nyc": "^11.0.3", "open": "^0.0.5", "requirejs": "^2.3.3" },