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

[animation-mixer] Animation cannot be set and unpaused in the same change #354

Open
EPurwanto opened this issue Apr 7, 2021 · 2 comments

Comments

@EPurwanto
Copy link

EPurwanto commented Apr 7, 2021

I have an animation that I need to start paused on the first frame with animation-mixer="timescale: 0;"

After some events, I want to set the animation clip to play and unpause it, by calling el.setAttribute("animation-mixer", {clip: "some_clip", timeScale: 1}), however there is a data.timeScale !== 1 check in the playAction function that ignores the change to timeScale.

I'm not sure if it would be better to change that check to data.timeScale !== action.effectiveTimeScale, remove it entirely, or change the update function to apply timescale changes there.

For now, I'm working around the issue by setting the clip in the starting settings as animation-mixer="clip: some_clip; timescale: 0;, but that only works because I know what clip I want to play.

@n5ro
Copy link
Collaborator

n5ro commented Apr 20, 2021

hmm... can you share a simplified bare minimum example, and we can try to test out your different ideas? I am also open to a voice call and a screen share to work on this. I think you can dm me (is that possible on github? not sure. If not you can also join this discord http://thexrweb.com and present the same issue there and we can continue trying to work on it from there.) we could try.

@EPurwanto
Copy link
Author

EPurwanto commented Apr 26, 2021

I've set up an example that demonstrates what I mean. https://codesandbox.io/s/adoring-chatelet-f3cgl

the following keys are used
z,x,c: Set the timescale to 0, 0.5 or 1
1-4: Set the clip to "Linear *", "Step *", "CubicSpline *" or just "*"
alt + 1-4: Set the clip and timescale = 0
ctrl + 1-4: Set the clip and timescale = 0.5
shift + 1-4: Set the clip and timescale = 1

From playing around with it, it seems the situation is a little different than I originally thought. It seems like individual animations are remembering the last timescale assigned to them. Here are some examples I noticed misbehaving, with the key presses required.

Example 1:

  1. [4] Play all the animations
  2. [z] Set timescale to 0
  3. [1] Play the Linear Animations
  4. [c] Set timescale to 1. Animation 1 will play correctly
  5. [2] Play the Step Animations. These will not be playing, despite timescale being set to 1.
  6. [3] Play the CubicSpline Animations. These will not be playing, despite timescale being set to 1.

Example 2

  1. [1] Play the Linear Animations
  2. [z] Set timescale to 0
  3. [shift + 1] Play the Linear Animations and set timescale to 1. This will play correctly.
  4. [z] Set timescale to 0
  5. [2] Play the Step Animations
  6. [shift + 1] Play the Linear Animations and set timescale to 1. This will not play.

Both issues also occur if you use 0.5 and 1 for the timeScales, instead of 0 and 1. (key presses [4, x, 1, c, 2, 3] and [1, x, shift + 1, x, 2, shift + 1])

However they work as expected if you use 0 and 0.5 (key presses [4, z, 1, x, 2, 3] and [1, z, ctrl + 1, z, 2, ctrl + 1]).

Once you have broken the animation, you cannot restore it by setting timescale = 1 via [c] or [shift + 1-4]. You have to set timescale = 0 or 0.5 first, and then you can set it back to 1.

@vincentfretin vincentfretin changed the title Animation cannot be set and unpaused in the same change [animation-mixer] Animation cannot be set and unpaused in the same change Dec 7, 2022
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

No branches or pull requests

2 participants