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

Fix bug where gltfPipeline was not writingSources in all cases #94

Merged
merged 6 commits into from
Jun 22, 2016

Conversation

JoshuaStorm
Copy link

Addresses #93

gltfPipeline now writeSources properly when using processJSON or processFile. Had to move some logic around which caused a bit more copy-pasted code instead of just reusing the processJSON method as we were before, but it was only a few lines so it should be fine.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.004%) to 94.139% when pulling a9d6f99 on notWritingSource into c86e629 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.004%) to 94.139% when pulling a9d6f99 on notWritingSource into c86e629 on master.

readGltf(gltfPath, options, function(gltf) {
processJSON(gltf, outputPath, options, function() {
process.nextTick(function() {
expect(spy.calls.count()).toEqual(4);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JoshuaStorm Can you add a check in these tests making sure that source actually does get updated? Maybe make a change to it while it is in pipeline extras then decode the uri after and compare.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually disregard this, it isn't necessary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the right idea for testing this.

@lasalvavida
Copy link
Contributor

This looks good to me. @lilleyse is there a good use case to test this with to make sure it works properly?

var basePath = path.dirname(outputPath);
async.each(['buffers', 'images', 'shaders'], function(name) {
writeSource(gltf, basePath, name, embed, embedImage, callback);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need a callback for when the async finishes, and instead you should send in asyncCallback to writeSource. Check out how writeGltf handles this.

@lilleyse
Copy link
Contributor

This looks good to me. @lilleyse is there a good use case to test this with to make sure it works properly?

Mainly just your other comment, running a gltf through processJson or processFile and seeing that its data changed.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 93.97% when pulling e288636 on notWritingSource into c86e629 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 93.97% when pulling e288636 on notWritingSource into c86e629 on master.

@JoshuaStorm
Copy link
Author

Hit a bit of a snag, but this good for another look now.

@likangning93
Copy link
Contributor

Does this ensure that writeSources also happens for the data flow that ends up going through writeBinaryGltf? I think that was also an issue, but I might have missed something.

@@ -24,7 +24,7 @@ function writeSource(gltf, basePath, name, embed, embedImage, callback) {
var extension = object.extras._pipeline.extension;

// Write the source object as a data or file uri depending on the embed flag
if (embed && (embedImage || name !== 'images')) {
if (embed && (embedImage || name !== 'images') || basePath === undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Cesium.defined here.

@lilleyse
Copy link
Contributor

Does this ensure that writeSources also happens for the data flow that ends up going through writeBinaryGltf? I think that was also an issue, but I might have missed something.

writeBinaryGltf and writeFile should both handle writing extras._pipeline.source back to the gltf, the changes in this PR only deal with the function that return a gltf as JSON.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 93.97% when pulling 75fa5d0 on notWritingSource into c86e629 on master.

@JoshuaStorm
Copy link
Author

Updated.

writeBinaryGltf and writeFile should both handle writing extras._pipeline.source back to the gltf, the changes in this PR only deal with the function that return a gltf as JSON.

Is there currently an issue with writeBinaryGltf not having a writeSource step? I could look at that issue next.

@lilleyse
Copy link
Contributor

Is there currently an issue with writeBinaryGltf not having a writeSource step? I could look at that issue next.

No issue with that, it's working fine for me.

var initialUri = gltf['buffers'].CesiumTexturedBoxTest.uri;
processJSON(gltf, options, function () {
var finalUri = gltf['buffers'].CesiumTexturedBoxTest.uri;
expect(initialUri).not.toEqual(finalUri);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The initial uri will be a filepath to the .bin file, so the comparison will always pass. A quick fix for these 2 tests is to read from gltfEmbeddedPath instead of gltfPath.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 93.97% when pulling d6970eb on notWritingSource into c86e629 on master.

@JoshuaStorm
Copy link
Author

These are good for review whenever you're ready

@lilleyse
Copy link
Contributor

Looks good to me!

@lilleyse lilleyse merged commit 9356817 into master Jun 22, 2016
@lilleyse lilleyse deleted the notWritingSource branch June 22, 2016 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants