I have a question about optimization.
Is it more efficient to stick a function in the render loop that every frame checks for data changes to the scene that need to be loaded - in this case from a DB through async, though maybe irrelevent to this question. Or is it more efficient to somehow rig up an event handler to monitor a que array for data that needs loaded?
Option 1:
function checkForLoadingQueChanges(){
// some code here that calls the DB when que has data inside
// null que when all is loaded
}
var que = new Array;
engine.runRenderLoop(() => {
checkForLoadingQueChanges(); // loads node changes qued in our node loading que.
scene.render();
});
Option 2:
var que = new Array;
Somehow in my initialization add a event handler to monitor the array for changes…
It seems logical event handlers would be a better option, but I don’t know how to monitor an array specifically using event handlers to fire a function when the array changes. I feel like you would still have to check that array every frame to know a change existed for the event handler to fire. So would it be more efficient?
Thoughts?