I am performing lengthy operations in a loop - and I want to render the scene after certain milestones in the operations, or at a minimum update the UI - instead of firing up the Console in the browser, have logs about the operations taking place displayed in the UI.
function longOperation() {
labelComponents.forEach(function(lc) {
var lp = getLabelPlane(lc);
lp.locallyTranslate(new BABYLON.Vector3(0.2, 0, 0));
// lengthy call
getBusy();
// render scene at end of each iteration
// does not render after each iteration, instead it renders after everything is done
scene.render();
});
}
I am doing a bit of work every frame to ensure it fits in the 16ms frame budget, basically here filling 10 elements of a native array per frame but you could replace by any work you need to do.
Also please note a web worker can be better for really lengthy operations.
Can you take a look at my playground - 20 position manipulations - would be nice for the scene to render 20 times and adjust each individual position instead of queue the rendering up and doing all of them at once.