John Does Posted October 23, 2015 Share Posted October 23, 2015 I have no particular problem,but I was wondering... Wouldnt I be able to use the while statement instead of using the built-in animation. And if the while statement were to work, wouldnt be faster than the built-in animation? Quote Link to comment Share on other sites More sharing options...
RaananW Posted October 23, 2015 Share Posted October 23, 2015 Hi John, I assume you mean that this code will work faster?while(running) { scene.render();}There are many reasons why this would never work, mainly due to JS's engine architecture. The same reasons why requestAnimationFrame was introduced to browsers.If this is what you mean, I can try explaining shortly why it won't work. Quote Link to comment Share on other sites More sharing options...
jerome Posted October 23, 2015 Share Posted October 23, 2015 mmh...I agree wih Raanan. The global architecture is asynchronous and event driven.This means that things are triggered according to some event spawnings : the next frame must be displayed, the user moved the mouse, this image file is downloaded, or internal ones : these physics were computed, this cam collision computation is done, etc.And each thing try be computed as fast as possible in order not to delay the others that will happen in turn. If it lasts too much, the others will only when it's finished anyway. Imagine if it never finishes ... the others will never start. The engine is then stopped, doing endlessly only one thing. If you inject a while loop in this big architecture, you may add an infinite loop into this big evented construction, it is to say something that never ends, or that lasts too much, and prevents all the other process to start in time. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted October 23, 2015 Share Posted October 23, 2015 Hi JD and other friends. http://playground.babylonjs.com/#1OKDH8 ( a playground to play with ) Personally, I, also, cannot see why lines 31-36 animator doesn't work. Seems it should. But I know very little about the JS "threading model" or whatever it's called. The lines 40-44 animator works fine once activated. (and de-activate 31-36 as well) JD, you ask good questions, and welcome to the forum. PS: I once did an animation using a switch/case system (with delays between phases). The animated object keeps track of which phase of the animation it is in/at. http://playground.babylonjs.com/#35CPC#33 . Not very good programming on my part, but it got the job done, and it didn't use any Babylon.Animation. This demo, and two similar ones... are listed in our Babylon Primer. Party on, guys! 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.