babbleon Posted November 20, 2018 Share Posted November 20, 2018 Hello all, I am rendering out some images which get posted back to my server and I'm having issues with the function firing more frequently than it should. I have two loops; loop1 & loop2... which should call the createThumbnail() function 9 times in total and then stop rendering. However, if you have a look at the console you will see that it gets called 36 times in total (1+2+3+4+5+6+7+8). Here's a PG: https://playground.babylonjs.com/#I4SUSQ I think I'm doing something silly & obvious, but can't see it... any help would be very welcome. Thank you, Quote Link to comment Share on other sites More sharing options...
eps Posted November 20, 2018 Share Posted November 20, 2018 ? Have you changed the PG, because it only loops 9 times atm... That's using Safari on a MacBook. Quote Link to comment Share on other sites More sharing options...
babbleon Posted November 20, 2018 Author Share Posted November 20, 2018 Hi @eps, Thank you for looking at this. Please see attached a screenshot of the console, the first loop calls the function once, the second one twice, the third one - 3 times etc... Using Chrome 69 on Ubuntu. Quote Link to comment Share on other sites More sharing options...
eps Posted November 20, 2018 Share Posted November 20, 2018 ? That's just the index of the loops.... not the number of times they are called. This is doing what you're expecting. Well it's just calling it 8 times but that's probably due to the AfterEvent not firing the way you have the code. What are you trying to achieve? It seems a little over-complicated. Quote Link to comment Share on other sites More sharing options...
babbleon Posted November 20, 2018 Author Share Posted November 20, 2018 (edited) Here's a tweaked PG.. the numbers in the blue circles on the previous attachment are duplicated lines on the console. https://playground.babylonjs.com/#I4SUSQ#1 ... this shows what I thought, that for example 'loop1: 3 loop2 3' is called eight times. I am ultimately trying to achieve a series of images to be saved to my server; loop1 might be an array of camera locations and loop2 might be an array of material colours. Edited November 20, 2018 by babbleon clarity Quote Link to comment Share on other sites More sharing options...
Sebavan Posted November 20, 2018 Share Posted November 20, 2018 This is due to the fact you are registering more and more tasks on the observable on each loop and they are running async. so on 1 1 you put a callback in the observable runninng next frame on 1 2 you add a new one so 2 captures ill happen next frame and so on... Why not using smthg more direct like https://playground.babylonjs.com/#I4SUSQ#2 ? babbleon 1 Quote Link to comment Share on other sites More sharing options...
babbleon Posted November 20, 2018 Author Share Posted November 20, 2018 Brilliant, @Sebavan - thank you very much.. this is exactly what I should have done! ? 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.