Skip to content

Commit

Permalink
Don't remove empty node if it contains extensions or extras
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Oct 30, 2018
1 parent 1eef4d6 commit 294cd56
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
3 changes: 2 additions & 1 deletion lib/updateVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
25 changes: 23 additions & 2 deletions specs/lib/updateVersionSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down Expand Up @@ -543,6 +555,13 @@ describe('updateVersion', function() {
0, 0, 1, 0,
0, 0, 0, 1
]
},
lightNode: {
extensions: {
KHR_materials_common: {
light: 'directionalLight'
}
}
}
},
programs: {
Expand All @@ -562,7 +581,8 @@ describe('updateVersion', function() {
defaultScene: {
nodes: [
'rootTransform',
'emptyNodeParent'
'emptyNodeParent',
'lightNode'
]
}
},
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 294cd56

Please sign in to comment.