Sac Posted June 12, 2017 Share Posted June 12, 2017 Hi All, I'm new here, So first of all, Kudos to all working in BJS. I'm impressed. And Kudos to the community, as I can see it is a very active community. Coming to my problem, I have a babylon file, which contains a set of meshes, each having its own key-framed animations. After a lot of trial and error, I could animate them using scene.beginAnimation(mesh, 1, 100, false, 0.6, function() {}); And Iam not sure what values I need to give for speedratio, I tried with 1 and couple of other numbers and right now on 0.6. Yay ! now it is working. It Played. Now I have two problems or worries, 1. I had to cycle through a loop to animate the each of these meshes found inside this file, while I have attached them all into one parent (empty) node, so that I thought if I can say BeginAnimation on that mesh, the rest of the child will play the keyframes... but nothing happened... so I had to end up cycling through the whole set of meshes in the scene and animate them if the the names match. 2. Now I tried to reverse the animation cycle, to play it backwards, all it does is jumps back to the first frame. I tried different way, I gave different combinations like below, changed from as 100, and to as 1, changed speedratio as -0.6, but no effect. scene.beginAnimation(mesh, 100, 1, false, -0.6, function() {} ); looking for some enlightenment on both of these. Thanks and Keep up the good work. Quote Link to comment Share on other sites More sharing options...
Sac Posted June 13, 2017 Author Share Posted June 13, 2017 Hi, I searched everywhere before I posted it here. Couldn't find any clear solution for it. Honestly, I'm little disappointed to see no replies.... any pointer will be very helpful. I was also thinking of storing each of the of the key frames into a array and then reversing it and storing in the next cells of the array to imitate it, but it is a process heavy solution for a simple reverse and a simple send animate command to the parent and all children will animate kind of a solution Quote Link to comment Share on other sites More sharing options...
brianzinn Posted June 13, 2017 Share Posted June 13, 2017 We have posts in this forum for reversing animations (search google "babylonjs scene beginanimation reverse" - 3rd link for me). Here is a PG: http://www.babylonjs-playground.com/#1LNWLE#3 Here is the forum post from wingnut: Quote Link to comment Share on other sites More sharing options...
Sac Posted June 14, 2017 Author Share Posted June 14, 2017 Thank you Brian, Somehow I didn't get this in my search. I always search before posting Quote Link to comment Share on other sites More sharing options...
Sac Posted June 14, 2017 Author Share Posted June 14, 2017 Just checked the code, This is exactly what I thought I should do, if there is no answer for a simple way, like how I expected by reversing the frame order or by negating the speedRatio. in BeginAnimation Thanks very much again. Wingnut 1 Quote Link to comment Share on other sites More sharing options...
brianzinn Posted June 14, 2017 Share Posted June 14, 2017 Well, at least it's an example of how to do it the way you were thinking. It kind of makes sense that if the 'from' is lower than 'to' that BJS could use that to play the animation backwards. I was just showing you my search, since you mentioned you had searched - I think it helps if 'babylonjs' is an early search term. Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted June 14, 2017 Share Posted June 14, 2017 Hi @Sac reversing the keyFrames and a negative speed value should achieve this. http://www.babylonjs-playground.com/#1LNWLE#11 scene.beginAnimation(rabbit, 100, 0, true, -0.4); Edit; something is a bit weird, only seems to work if looping. Edit_2; reverse animation without loop is now working thanks to @Adam; http://www.babylonjs-playground.com/#1LNWLE#12 Quote Link to comment Share on other sites More sharing options...
Sac Posted June 14, 2017 Author Share Posted June 14, 2017 Just now, aWeirdo said: Hi @Sac reversing the keyFrames and a negative speed value should achieve this. http://www.babylonjs-playground.com/#1LNWLE#11 scene.beginAnimation(rabbit, 100, 0, true, -0.4); Edit; something is a bit weird, only seems to work if looping right now. Weird, it was not working for me will try again. Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted June 14, 2017 Share Posted June 14, 2017 @Sac It seems to only work when looping, as you pointed out earlier, it jumps to frame 0 instantly on the first run and the animation is ended, so when not looping, nothing actually happens. Quote Link to comment Share on other sites More sharing options...
Sac Posted June 14, 2017 Author Share Posted June 14, 2017 ok, I was not looping, because I didnt want it to loop... Quote Link to comment Share on other sites More sharing options...
adam Posted June 14, 2017 Share Posted June 14, 2017 I'll be submitting a fix for this tonight. aWeirdo 1 Quote Link to comment Share on other sites More sharing options...
Sac Posted June 14, 2017 Author Share Posted June 14, 2017 Just now, adam said: I'll be submitting a fix for this tonight. Yay ! Great ! Quote Link to comment Share on other sites More sharing options...
adam Posted June 15, 2017 Share Posted June 15, 2017 PR submitted Quote Link to comment Share on other sites More sharing options...
Sac Posted June 15, 2017 Author Share Posted June 15, 2017 3 hours ago, adam said: PR submitted Perfect, So we can take it when the next update gets released right ? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 15, 2017 Share Posted June 15, 2017 Correct (I'll published in a couple of hours) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.