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

Global Animation with different track-length #13

Closed
Mat2095 opened this issue Dec 29, 2023 · 10 comments
Closed

Global Animation with different track-length #13

Mat2095 opened this issue Dec 29, 2023 · 10 comments
Labels
bug Something isn't working

Comments

@Mat2095
Copy link
Contributor

Mat2095 commented Dec 29, 2023

xAvsrWaplr.mp4

When testing the new version with the air-elemental, I noticed one problem: the "shells" pause after each rotation, while they should rotate continuously. The issue seems to be that the skeletal-animation has tracks of different duration and THREE.js sets the duration for the whole clip to the maximum of the tracks, so the shorter tracks have to wait for the longer ones to finish.

For this instance I could fix it by simply adding a separate clip for each track, like this:

three-m2loader/M2Loader.js

Lines 425 to 426 in 7fe01af

const clip = new AnimationClip( 'GlobalSkeletonAnimation_' + j, - 1, [ ... globalTracks[ j ] ] );
sequenceManager.addAnimationToGlobalSequence( clip, group, j );

replace with

        for ( let t = 0; t < globalTracks[ j ].length; t++) {
          const clip = new AnimationClip( 'GlobalSkeletonAnimation_' + j + '_' + t, - 1, [  globalTracks[ j ][ t ] ] );
          sequenceManager.addAnimationToGlobalSequence( clip, group, j );
        }

However I have no idea if that has implications. Probably that should be done for other global animations as well. The airelemental also uses multiple GlobalTextureTransform-Animations, but they all only have a single track, so no issue there. And for non-global animations, all tracks (excluding ones with length 0) have the same length for the airelemental, but I have no idea if that is always the case, and whether tracks should loop individually if tracks do have different lengths.

@Mat2095
Copy link
Contributor Author

Mat2095 commented Dec 29, 2023

nyCdkJNYDl.mp4

When disabling the non-global sequence and removing all texture-transform-animations, the issue becomes much clearer.

@Mugen87
Copy link
Owner

Mugen87 commented Dec 30, 2023

I'm not sure I understand the issue yet^^.

the "shells" pause after each rotation, while they should rotate continuously. The issue seems to be that the skeletal-animation has tracks of different duration and THREE.js sets the duration for the whole clip to the maximum of the tracks, so the shorter tracks have to wait for the longer ones to finish.

With "shells" I assume you refer to the rotating (cloudy) parts of the elemental, right? These are not effected by skeletal animation at all. You can easily check this by not calling manager.playSequence() for this asset. The effect is only created by (global) texture transformation sequences.

When disabling the non-global sequence and removing all texture-transform-animations, the issue becomes much clearer.

For testing I have not called manager.playSequence() so only global sequences are played. However, these sequences are exclusively texture transform animation. If I exclude them as well, the asset is static.

Can you provide more details how I have to update the loader to achieve the result in your second video? For example I commented out all addAnimationToSequence() and addAnimationToGlobalSequence() calls except for GlobalTextureTransform_ clips. However, that does not seem sufficient.

@Mat2095
Copy link
Contributor Author

Mat2095 commented Dec 30, 2023

Yes, those big cloudy parts. When looking from above, there is one striking feature, one of the angles is >180°, here in the top-right:
ClipboarderTemp-2cfa46

Prior to M2Loader 3.0 there were no global skeletal animations visible, but now there is one. When using the Dragonflight model and printing globalSequence from here:

const globalSequence = this._globalSequenceMap.get( id );

I get an array with 9 elements. The first 8 are global texture-transformations with one track each, the last one is a skeletal-animation with 12 tracks.
ClipboarderTemp-35b664

When looking from above, the texture animations rotate counter-clockwise, the skeletal-animation rotates clockwise, but slower.

To achieve the result in the second video, I removed this line from the loader to not have global texture-transformations:

sequenceManager.addAnimationToGlobalSequence( clip, material.map, j );

and did not call manager.playSequence() to only have the global sequences play.

@Mat2095
Copy link
Contributor Author

Mat2095 commented Dec 30, 2023

Hm, I just played around with the index.html and I noticed a problem with the controls:
initially when loading the airelemental, the global sequences (both texture and skeletal) play fine. But when I change the non-global sequence and then back again, the global-skeletal animation stops working, but the global-texture-animations continue to work. Maybe that is why you can't see the skeletal-animation I am talking about?

@Mugen87
Copy link
Owner

Mugen87 commented Dec 30, 2023

When using the Dragonflight model and printing globalSequence from here:

I guess we are using different version of the airelemental asset. What version do you see when you debug header.version? Mine is 272.

@Mat2095
Copy link
Contributor Author

Mat2095 commented Dec 30, 2023

It's 272 for me as well. I just re-downloaded the files from wow.tools.
I've created a test-repo: https://github.com/Mat2095/m2loader_test
Simply opening the index.html results in my second video from this thread.
The only changes I made to M2Loader.js are the one mentioned above and two console-logs for header.version and globalSequence, which in this case only has a single entry since the global texture-animations aren't present.

@Mugen87
Copy link
Owner

Mugen87 commented Dec 30, 2023

Thanks for the additional information. I did indeed overlook the global sequence that animates the skeleton. And indeed the tracks unfortunately have different time values. I'll file a commit with a fix!

@Mugen87 Mugen87 added the bug Something isn't working label Dec 30, 2023
@Mugen87
Copy link
Owner

Mugen87 commented Dec 30, 2023

Does 48bef61 fix the issue?

Tracks should now assigned to the correct global timeline. Besides, I've realized it doesn't make sense to select and play individual global sequences. I think in WoW these sequences are assumed to be played together all the time. Hence, there is now playGlobalSequences() and stopGlobalSequences() on manager level.

@Mat2095
Copy link
Contributor Author

Mat2095 commented Dec 30, 2023

Ah yes, it works perfectly now. Thank you for the fix!
I was wondering too, that all but the first global sequence didn't actually do anything. And other viewers don't have an option to select different global sequences, so it seemed a bit off.

@Mat2095 Mat2095 closed this as completed Dec 30, 2023
@Mugen87
Copy link
Owner

Mugen87 commented Dec 30, 2023

Awesome! I'll publish 4.0.0 then!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants