AB95 Posted January 12, 2017 Share Posted January 12, 2017 Hi everyone, there might be a way of doing this but I must be missing something... I have a scene which consists of different meshes having different animations, all of the animation only run once. Basically, I would like to be able to "reload" the scene without actually reloading it, which I try to reset all the meshes' animations by pausing all unfinished meshes' animatable, set their animation's frame back to zero, and restart each of the animatable again. This method work when all of the animatables in scene have not reached their last frame. It won't work on those animatable who had reached its last frame, which their frame will be set to zero, but not able to be restarted. A simplified scene that showing my approach, as you will see the restart button doesn't work when the animation has reached its last frame. http://www.babylonjs-playground.com/#OQENJ Any help would be appreciated, thank you! Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted January 12, 2017 Share Posted January 12, 2017 Hi @AB95 According to the documentation, http://doc.babylonjs.com/tutorials/Animations (just above the "controlling animations" section, the basic functions are listed. the correct use would be animation.reset();http://www.babylonjs-playground.com/#OQENJ#2 JohnK 1 Quote Link to comment Share on other sites More sharing options...
JohnK Posted January 12, 2017 Share Posted January 12, 2017 You can begin the animation again http://www.babylonjs-playground.com/#OQENJ#1 AB95 1 Quote Link to comment Share on other sites More sharing options...
AB95 Posted January 12, 2017 Author Share Posted January 12, 2017 Hi @aWeirdo and @JohnK Thanks for both of your quick response! JohnK method works for me -- only if my issue is within the playground scene, the thing is, sry for the simplified scene, I realise I should have pointed out some part that make me resist in using scene.beginAnimation, the reason is that I had another animation within the callback of the first animatable: http://www.babylonjs-playground.com/#OQENJ#5 which using scene.beginAnimationI() will cause the animatable within the first animatable's callback being called without the first animatable completes its animation (you should be able to observe the second animatable start before the first animatable finish, by pressing the restart button before the box finish its animation). I try to I explain my problem as clear as possible, thanks for the help! Quote Link to comment Share on other sites More sharing options...
AB95 Posted January 12, 2017 Author Share Posted January 12, 2017 ok, I think I solved the problem, to prevent the callback being called, I just set the first animatable's callback to null every times I want to restart the entire scene animation, reset the second animatables back to frame zero as well. http://www.babylonjs-playground.com/#OQENJ#7 GameMonetize 1 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.