I am currently developing a project using THREEjs and would like to organize it in the following manner:
class Blah
scene : new THREE.Scene()
renderer : new THREE.WebGLRenderer()
camera : new THREE.PerspectiveCamera()
render : ( renderables )->
renderables.forEach ( renderable )->
renderable()
@renderer.render( @scene, @camera )
foo = new Blah()
animateMovie =->
requestAnimationFrame( animateMovie )
foo.render([baz.update, bar.update])
In the above code snippet, the render
method accepts an array of functions to update. I am curious whether having a loop inside the animateMovie
function, which is recursively called using requestAnimationFrame
, could potentially lead to a stack overflow. Additionally, I am concerned about any performance issues that may arise from implementing this approach.