From 294cd5663d2b64b3a6b9fb622bfcc3082c64b737 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Tue, 30 Oct 2018 13:35:42 -0400 Subject: [PATCH 1/2] Don't remove empty node if it contains extensions or extras --- CHANGES.md | 4 ++++ lib/updateVersion.js | 3 ++- specs/lib/updateVersionSpec.js | 25 +++++++++++++++++++++++-- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 110ff1b5..a60c505f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,10 @@ Change Log ========== +### 2.0.2 - ????-??-?? + +* Fixed a bug where nodes containing extensions or extras where being removed in the glTF 1.0 to 2.0 upgrade stage. [#431](https://github.com/AnalyticalGraphicsInc/gltf-pipeline/pull/431) + ### 2.0.1 - 2018-09-19 * Fixed a bug where the buffer `byteOffset` was not set properly when updating 1.0 accessor types to 2.0 allowed values. [#418](https://github.com/AnalyticalGraphicsInc/gltf-pipeline/pull/418) diff --git a/lib/updateVersion.js b/lib/updateVersion.js index b94bcf03..d7e03a1b 100644 --- a/lib/updateVersion.js +++ b/lib/updateVersion.js @@ -835,7 +835,8 @@ function isNodeEmpty(node) { (!defined(node.translation) || Cartesian3.fromArray(node.translation).equals(Cartesian3.ZERO)) && (!defined(node.scale) || Cartesian3.fromArray(node.scale).equals(new Cartesian3(1.0, 1.0, 1.0))) && (!defined(node.rotation) || Cartesian4.fromArray(node.rotation).equals(new Cartesian4(0.0, 0.0, 0.0, 1.0))) && - (!defined(node.matrix) || Matrix4.fromColumnMajorArray(node.matrix).equals(Matrix4.IDENTITY)); + (!defined(node.matrix) || Matrix4.fromColumnMajorArray(node.matrix).equals(Matrix4.IDENTITY)) && + !defined(node.extensions && !defined(node.extras)); } function deleteNode(gltf, nodeId) { diff --git a/specs/lib/updateVersionSpec.js b/specs/lib/updateVersionSpec.js index b23131f0..643e2e32 100644 --- a/specs/lib/updateVersionSpec.js +++ b/specs/lib/updateVersionSpec.js @@ -325,6 +325,18 @@ describe('updateVersion', function() { 'WEB3D_quantized_attributes', 'UNKOWN_EXTENSION' ], + extensions: { + KHR_materials_common: { + lights: { + directionalLight: { + directional: { + color: [1, 0, 0] + }, + type: 'directional' + } + } + } + }, meshes: { mesh: { primitives: [ @@ -543,6 +555,13 @@ describe('updateVersion', function() { 0, 0, 1, 0, 0, 0, 0, 1 ] + }, + lightNode: { + extensions: { + KHR_materials_common: { + light: 'directionalLight' + } + } } }, programs: { @@ -562,7 +581,8 @@ describe('updateVersion', function() { defaultScene: { nodes: [ 'rootTransform', - 'emptyNodeParent' + 'emptyNodeParent', + 'lightNode' ] } }, @@ -631,7 +651,8 @@ describe('updateVersion', function() { expect(getNodeByName(gltf, 'nonEmptyNodeParent')).toBeDefined(); expect(getNodeByName(gltf, 'emptyNodeParent')).toBeUndefined(); expect(getNodeByName(gltf, 'emptyNode')).toBeUndefined(); - expect(gltf.scenes[0].nodes.length).toBe(1); + expect(getNodeByName(gltf, 'lightNode')).toBeDefined(); + expect(gltf.scenes[0].nodes.length).toBe(2); // Expect material values to be moved to material KHR_techniques_webgl extension var material = gltf.materials[0]; From dc9b5244e2f0098d728ede1339fded133d7469b6 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Thu, 1 Nov 2018 14:47:23 -0400 Subject: [PATCH 2/2] Fix --- lib/updateVersion.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/updateVersion.js b/lib/updateVersion.js index d7e03a1b..73b30450 100644 --- a/lib/updateVersion.js +++ b/lib/updateVersion.js @@ -836,7 +836,7 @@ function isNodeEmpty(node) { (!defined(node.scale) || Cartesian3.fromArray(node.scale).equals(new Cartesian3(1.0, 1.0, 1.0))) && (!defined(node.rotation) || Cartesian4.fromArray(node.rotation).equals(new Cartesian4(0.0, 0.0, 0.0, 1.0))) && (!defined(node.matrix) || Matrix4.fromColumnMajorArray(node.matrix).equals(Matrix4.IDENTITY)) && - !defined(node.extensions && !defined(node.extras)); + !defined(node.extensions) && !defined(node.extras); } function deleteNode(gltf, nodeId) {