Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't remove empty node if it contains extensions or extras #431

Merged
merged 2 commits into from
Nov 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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