mecanicus Posted July 10, 2017 Share Posted July 10, 2017 Hello, I integrated a slider to change the speedRatio of the animation but it made restart the animation at the first key frame too. How I have to make to change only the speedRatio. http://www.babylonjs-playground.com/#2BLI9T#2 Sorry for my english Quote Link to comment Share on other sites More sharing options...
mecanicus Posted July 10, 2017 Author Share Posted July 10, 2017 the correct link http://www.babylonjs-playground.com/#7ZDKA0#1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted July 10, 2017 Share Posted July 10, 2017 Hi Mec. That is a very good question. Not sure if possible. I play: http://www.babylonjs-playground.com/#7ZDKA0#3 In line 97, I pause the animation upon slider-change, then set new .speedRatio value, then activate 1.5 sec timer (line 102), then un-pause. Still, when un-paused after 1.5 secs... mesh "jumps" to new position. hmm. Darn. BJS Animations of THIS type... are 2-step. #1 - calculated and created, #2 - runned. Changing values "live" (real time) is difficult, because animation is already calculated and created. It's "interpolation" has already been "derived" or "grown". (That's how I understand it, but I am wrong quite often) (Fellow helpers: Mec wants speedRatio change without mesh-jumping. Mec wants a nice, smooth animation speed control.) Sorry that I have no solution, yet. I'll keep thinking and testing. Others will likely have more ideas and will comment soon. Quote Link to comment Share on other sites More sharing options...
Hersir Posted July 10, 2017 Share Posted July 10, 2017 I had similar situation but as my animation was generated I recreated it on speed change from current point Quote Link to comment Share on other sites More sharing options...
mecanicus Posted July 10, 2017 Author Share Posted July 10, 2017 i modify the code line 44 before change : scene.beginAnimation(box1, 0, 100, true, 1); var anim = scene.beginAnimation(box1, 0, 100, true, 1); and line 89 anim.speedRatio = slider.value; It's seem better but there is some shaking when i change the value http://www.babylonjs-playground.com/#URWHS4 Quote Link to comment Share on other sites More sharing options...
mecanicus Posted July 10, 2017 Author Share Posted July 10, 2017 I try this I replaced onValueChangedObservable by onPointerOutObservable http://www.babylonjs-playground.com/#VVAYQ3 no shaking, but a delay before change of speed Quote Link to comment Share on other sites More sharing options...
mecanicus Posted July 10, 2017 Author Share Posted July 10, 2017 Thank's Wingnut for your idea my solution is : slider.onValueChangedObservable.add(function() { anim.pause(); anim.speedRatio = slider.value; }); And after slider.onPointerUpObservable.add(function() { anim.restart(); }); the stop time is reduced Then the jump is a minor inconvenience for my project http://www.babylonjs-playground.com/#ZK9Q08 Thank's for your answers Quote Link to comment Share on other sites More sharing options...
Raggar Posted July 10, 2017 Share Posted July 10, 2017 Here's another way of doing it: http://www.babylonjs-playground.com/#7ZDKA0#4 mecanicus 1 Quote Link to comment Share on other sites More sharing options...
mecanicus Posted July 10, 2017 Author Share Posted July 10, 2017 Actually it's better thank you 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.