var i = 0, s; setInterval(function(){ i+=0.02; s = Math.sin(i) camera.focalLength = 0.8 + s * 0.2; player.rotate(s * 0.02 - 0.01); }, 16);