this function is executed on each animation frame
function animate() {
    // render
    controls.update();

    if (ready) {
      renderer.render(sceneRTT, camera, rtTexture, true);
      renderer.render(sceneScreen, camera);
    }

    stats.update();

    // request new frame
    requestAnimationFrame(function() {
      animate();
    });
  }