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 discrepency between ids and names in AnimationCollection #5815

Merged
merged 4 commits into from
Sep 8, 2017

Conversation

lilleyse
Copy link
Contributor

@lilleyse lilleyse commented Sep 7, 2017

Bug brought up on the forum: https://groups.google.com/forum/#!topic/cesium-dev/XDhrq2ejwR4

ModelAnimationCollection.add expects options.name to be an animation name, but with the switch to glTF 2 the function only worked if options.name was the array index. The changes here add back support for adding animations by name and not index. Part of this was cleaning up other areas of the animation code that were still stuck in the glTF 1.0 mindset.

@cesium-concierge
Copy link

@lilleyse, thanks for the pull request! Maintainers, we have a signed CLA from @lilleyse, so you can review this at any time.

I noticed that CHANGES.md has not been updated. If this change updates the public API in any way, fixes a bug, or makes any non-trivial update, please add a bullet point to CHANGES.md and comment on this pull request so we know it was updated. For more info, see the Pull Request Guidelines.

I am a bot who helps you make Cesium awesome! Thanks again.

@lilleyse
Copy link
Contributor Author

lilleyse commented Sep 7, 2017

In the long term in would be better if the add function took the index instead of the name, but that would require a breaking change. Hard to tell if it's worth it.

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 7, 2017

Code looks OK at quick glance.

@ggetz could you please review and test?

See #927 - I think id vs. name issues in Cesium go back several years before 2.0.

@pjcozzi pjcozzi requested a review from ggetz September 7, 2017 00:32
@ggetz
Copy link
Contributor

ggetz commented Sep 7, 2017

@lilleyse What's a good way to test this? Is the animated aircraft model sufficient?

@lilleyse
Copy link
Contributor Author

lilleyse commented Sep 7, 2017

Sure, any animated model will work.

Copy link
Contributor

@ggetz ggetz left a comment

Choose a reason for hiding this comment

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

Looks good, thanks @lilleyse !

@emackey
Copy link
Contributor

emackey commented Sep 7, 2017

This appears to be a breaking change, as specifying the index no longer works. The name is required now.

@emackey
Copy link
Contributor

emackey commented Sep 7, 2017

Also note that the name is optional in glTF 2, so we need a way to specify by index.

Copy link
Contributor

@emackey emackey left a comment

Choose a reason for hiding this comment

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

For backwards compatibility, name must accept either an index or a name. Previously, this field only accepted an index, in spite of its name. Some models, such as "BrainStem", don't name their animations, as names are optional.

@lilleyse
Copy link
Contributor Author

lilleyse commented Sep 7, 2017

Specifying the index only worked by accident, which was more of a bug from the 1.0-2.0 transition. For glTF 1.0 it expected the id, which updateVersion now moves to the name property. I don't think this change breaks any existing models.

I also thought about overloading name, but it seemed possibly confusing.

@emackey
Copy link
Contributor

emackey commented Sep 7, 2017

This change does break code that @hpinkos recently merged into another project.

Agreed that it was only working "by accident" and probably only for 2 releases or so.

But to be clear, with this change there is no way to individually toggle the animations in the BrainStem model (which incidentally shouldn't be using individual animations, but that's beside the point, the point is that animations don't require names anymore in glTF 2.0, only indicies).

@lilleyse
Copy link
Contributor Author

lilleyse commented Sep 7, 2017

I guess what I mean is apps built before 1.36 shouldn't be broken, but anything after that passes in index instead of the name to get around the slightly weird behavior here would be broken.

[EDIT: saw your updated comment, I think we agree]

I'm alright with the overloaded behavior, I'll make that change in a bit.

@emackey
Copy link
Contributor

emackey commented Sep 7, 2017

I'm OK if you don't want to overload, and make the index a separate parameter. It doesn't break any old code, only new code. But some sort of option for specifying the index is required, because glTF models no longer require names.

@lilleyse
Copy link
Contributor Author

lilleyse commented Sep 7, 2017

@emackey @ggetz @hpinkos updated. I went with the options.index approach.

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 8, 2017

@emackey please merge when ready.

Copy link
Contributor

@emackey emackey left a comment

Choose a reason for hiding this comment

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

Awesome, thanks. Tests pass, and I confirmed that both new options work as intended. I tried each option on Cesium Air (glTF 1.0), BrainStem (glTF 2.0 without names), and AnimatedMorphSphere (glTF 2.0 with names).

Only wrinkle is, Cesium allows you to specify both an index and a name in the same call. When this is done, the index "wins" over the name, but it works fine. Is this behavior OK? I'm OK with everything else. Thanks!

@emackey emackey merged commit 4427001 into master Sep 8, 2017
@cesium-concierge
Copy link

Congratulations on closing the issue! I found these Cesium forum links in the comments above:

https://groups.google.com/forum/#!topic/cesium-dev/XDhrq2ejwR4

If this issue affects any of these threads, please post a comment like the following:

The issue at #5815 has just been closed and may resolve your issue. Look for the change in the next stable release of Cesium or get it now in the master branch on GitHub https://github.com/AnalyticalGraphicsInc/cesium.

I am a bot who helps you make Cesium awesome! Thanks again.

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