Jump to content

Alter sphere animation depending on live input data


w305
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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?

 

Link to comment
Share on other sites

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.  :) 

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...