Alex_on_the_web Posted December 6, 2013 Share Posted December 6, 2013 Hello! I am currently trying to make my runRenderLoop wrapper stupid-proof, so I want to stop it before issuing a new runRenderLoop() with my render callback. Sadly, I find my preformance drop everytime I 'restart' the renderloop. The scene seems to be rendered as many times as I do calls on my wrapper. This is confirmed by visuals, as things get laggy, and by chrome's timeline, as it says Animation Frame Fired x N, where N increases everytime I restart. Here is my wrapper function I call. function startRender() { if (!babylonEngine) { init(); } if (babylonEngine._runningLoop){ babylonEngine.stopRenderLoop(); // debugger shows I hit this point on restart, it goes into Babylon code, where it nullifies the callback, and clears this flag } var renderFunction = function (x) { scene.render(); }; babylonEngine.runRenderLoop(renderFunction); } SCENEBABYLON.startRender = startRender; I hope I've not missed anything trivial to begin with, and not wasting your time. Thanks for the answers Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 6, 2013 Share Posted December 6, 2013 It could be linked to timing. Because when you call scene.stopRenderLoop, a current render can be in progress. And because you reset a renderFunction right after the current registered render will see a renderFunction and so will continue to pull new frames I'm not sure to be clear, alas BTW, why not returning directly when startRender is called twice or more? Quote Link to comment Share on other sites More sharing options...
Alex_on_the_web Posted December 8, 2013 Author Share Posted December 8, 2013 BTW, why not returning directly when startRender is called twice or more? You see, I thought, if there will be more things created, and / or arranged before starting the render (restarting the scene, so to say) it would be nice to restart the render, instead of just throwing away the restart request. But on a second thought, the render function will not really change, so it may as well stay in place. Thanks for the advice, I'll look into 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.