iri Posted December 6, 2018 Share Posted December 6, 2018 Hi) I use this example https://www.babylonjs-playground.com/#72C7CT#3. But in this example we have all trajectory in first step. I tried to change this example for my question: https://www.babylonjs-playground.com/#X0MDYG. In this example I see animation of the last segment of my all path. How can I change this situation and see animation from my first point to the last. This situation occurs when we initially do not know the entire trajectory. We only know the current and previous trajectory node. Could anybody help me? Quote Link to comment Share on other sites More sharing options...
bghgary Posted December 6, 2018 Share Posted December 6, 2018 The way the playground is currently set up, each call to 'heartFlight' will replace the previous animation and thus you only have the last animation. I've fixed it with the following playground, but I don't know if that's what you are trying to do since I removed the while loop. https://www.babylonjs-playground.com/#X0MDYG#1 Are you perhaps trying to trace a path while points are being added? If so, using animations may not be the right approach. Quote Link to comment Share on other sites More sharing options...
iri Posted December 7, 2018 Author Share Posted December 7, 2018 12 hours ago, bghgary said: Are you perhaps trying to trace a path while points are being added? If so, using animations may not be the right approach. Yes, you are right. Points are added to my path. And I want animate some moving from the one point to another... Quote Link to comment Share on other sites More sharing options...
bghgary Posted December 7, 2018 Share Posted December 7, 2018 Animations are intended to have a static set of keys. You might be able to create a queue of animations and then play them back to back as you add points to your path, but I'm not very sure if that's is any easier than just moving the object manually. iri 1 Quote Link to comment Share on other sites More sharing options...
brianzinn Posted December 7, 2018 Share Posted December 7, 2018 You can also add onAnimationEnd param: scene.beginAnimation(vehicle, 0, length, false, 10, () => { heartFlight(vehicle, move_trajectory, index + 1); }); https://www.babylonjs-playground.com/#X0MDYG#2 If you added any points during the animation, they would get added to the end. You would need code to restart a completed animation or perhaps a queue push/pop as @bghgary suggests. I added some smoothing, so the speed is consistent on different length path segments. If you don't want a steady speed then you can look at slerp on total length or rebuilding animation when points are added (start at current pos) and using the built-in easing functions. cheers. iri and bghgary 1 1 Quote Link to comment Share on other sites More sharing options...
iri Posted December 10, 2018 Author Share Posted December 10, 2018 Thank you, guys) I will try it) 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.