w305 Posted August 30, 2018 Share Posted August 30, 2018 Hi, I'm new to using Babylon and game development in general. I've been developing an animation of a sphere that gets bigger and smaller, and changes colour depending on the current value in a preset array in my code. However, I want to be able to read in live data, which would be a series of integers or floats, in order to change the values set in my animation keys as the scene runs. I am at a bit of a loss as to how to approach this, where would I start? Is it even possible? Quote Link to comment Share on other sites More sharing options...
Guest Posted August 30, 2018 Share Posted August 30, 2018 Hey and welcome!! I would recommend stopping the current animation when you get new data and then starting a new one. Perhaps it could be easier to help you with a repro in the Playground? Quote Link to comment Share on other sites More sharing options...
DylanD Posted August 30, 2018 Share Posted August 30, 2018 you could try, making something like, Make two identical animations, use arrays to hold all the keys, then when you get that live data add it to the array of the extra animation then go to the current frame of the old animation in the new one. Then make the original animation the extra one for the next time data is inputed. This probably won't work very well if you have a lot of live data coming in a lot. Just an idea. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 30, 2018 Share Posted August 30, 2018 Why not just effect the mesh with variables on scene.registerBeforeRender http://www.babylonjs-playground.com/#U9F8D4 Quote Link to comment Share on other sites More sharing options...
w305 Posted August 31, 2018 Author Share Posted August 31, 2018 I have been wondering if scene.registerBeforeRender is what I needed. Here is my playground of what I've been doing so far: http://www.babylonjs-playground.com/#0KRZWJ#2 I think I might have finally got it working using a preset array for now to simulate reading in live data, and I've used consecutive animations, and just updating the keys each time. I don't know if this is the best implementation however, or something hacky I put together. I also want to ensure that my animations are all in step with each other, I read something about deterministic lockstep in the documentation, is that what I would need to make sure this happens? Quote Link to comment Share on other sites More sharing options...
Guest Posted August 31, 2018 Share Posted August 31, 2018 This looks good to me! What do you mean by "my animations are all in step with each other" ? As they are all started simultaneously they will be in sync as they use the same clock internally Quote Link to comment Share on other sites More sharing options...
w305 Posted September 4, 2018 Author Share Posted September 4, 2018 Awesome, sorry for the late reply but that's pretty much what I meant, I thought so but just wanted to double check just in case my animations slowly got out of sync with each other if played for a long time 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.