Pass camera to animate function

Hi there!

I have multiple cameras in the scene between which I’m switching back and forth. I’m trying to use only one animate loop since it’s basically the same for all cameras.

Sadly, I get an error when running this: ‘THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.’

Seems like the parameter passing doesn’t work.
Hope someone can help! :slight_smile:

When requestAnimationFrame() calls animate(), the cam parameter represent a time value. Check out the MDN for more information:

The callback function is passed one single argument, a DOMHighResTimeStamp similar to the one returned by performance.now() , indicating the point in time when requestAnimationFrame() starts to execute callback functions.

1 Like

Thank you for your reply! :slight_smile: So it is not possible?

No, you can’t pass the camera as a parameter to your animation loop.

1 Like

That’s a bummer. Thank you for your replay! :raised_hands: