KhronosGroup / glTF

glTF ā€“ Runtime 3D Asset Delivery
Other
7.04k stars 1.13k forks source link

Animations: Channel samplers sync #2418

Closed sp0ng3Bob closed 2 days ago

sp0ng3Bob commented 2 days ago

Hi, I was reading the specification for the glTF 2.0.1. As someone would. I don't really understand what is going on, but on the pdf's page 90, under the animation.sampler.input section it says that the values in the time accessor are increasing. Apparently always. But then the model BoxAnimated comes along and in its readme it says:

"This model features a single animation with a pair of channels that have different lengths. The "rotation" channel finishes its work before the "translation" channel is done. However, these channels are not permitted to get out of sync: The shorter channel may not loop and begin repeating until all of the channels within that animation have finished playing. Client runtimes must ensure that a single input time is given to all of the channels within a particular animation, for the animation to remain sensible."

First of all I wanna say that I tried many different things to sync the animations. Then at the end I thought of some normalised input times. So I did that, but the animation still colides or is somehow out of sync. (This was just a side info)

So, the thing that I wanna ask is: In the BoxAnimated model the input of the translation path is as follows: [1.25, 2.5, 0, 1.25]. So isn't this in conflict with the specifications? I really don't know anymore.

Enlighten me, please. I am done. Cheers.

javagl commented 2 days ago

The BoxAnimated has a single animation with two channels.


In the BoxAnimated model the input of the translation path is as follows: [1.25, 2.5, 0, 1.25]

This does not seem to be the case. Could it be that you are not extracting the right values for the accessor/bufferView here?


The "challenge" in this case (or what the README.md of this model refers to) is that the two channels of the animation cover different time ranges. One channel goes from 1.2 to 2.5. The other one goes from 0.0 to 3.70833 (whereever that value came from šŸ˜• ).

When you play this animation, you might want to imagine it as follows: Take the "smallest start time" and the "largest end time" of all channels, and let the time proceed between this start and end time. And in-between, you apply the animation that is "covered" by the respective channel - R for rotation, T for translation here:

0.0       1.25      2.5      3.70833
 |         |         |        | 
 ------------------------------
           RRRRRRRRRRR
 TTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
sp0ng3Bob commented 2 days ago

Wow. Yes. I am defenitley pulling the wrong values. That's incredible. Didn't even think about this.

I am really glad. Thank you for your time. Was stuck on this one for a week šŸ˜¬.

sp0ng3Bob commented 2 days ago

Thank you for the feedback. It was indeed very helpfull. My animation logic was actually working, I will solve the parsing problem tomorrow.

javagl commented 2 days ago

Maybe another short hint: Depending on your IDE and preferences, you might consider the https://marketplace.visualstudio.com/items?itemName=cesium.gltf-vscode for VSCode. It allows browsing through glTF and inspecting the data, which can help for debugging stuff like this.

Khronos glTF VSCode

(The https://github.com/javagl/JglTF/tree/master/jgltf-browser offers a similar functionality, but... hasn't been updated for quite a while...)