It doesn't matter as long as you do it before you start actually drawing stuff, since the camera's matrix must be calculated before it is passed to any renderers. For example, with sprite batch you must update your camera at some point before calling spriteBatch.setProjectionMatrix(camera.combined);
which must come before calling spriteBatch.begin()
.
When you do it is not going to affect performance. You don't need to worry about once-per-frame stuff like this, anyway. Your CPU bottlenecks will almost certainly be where you are handling hundreds of sprites or particles and moving them around and then passing them to the batch, or in your physics simulation if you use one.
The docs for cocos3d say that it is best to do all the CPU-based stuff first and then try to do all the draw calls in quick succession, to maximize parallel use of the CPU and GPU. I don't know how much of a difference that makes, and how possible it is to follow this guideline in libgdx. But if it does help, then the way you would achieve this in libgdx is by making sure your sprite batch has a capacity at least as big as the most sprites you would ever give it in one frame (so it doesn't have to flush itself before you get to the call to end()
). And if you are doing 3D drawing with ModelBatch and DecalBatch, you would actually want to do that right before calling spriteBatch.end()
and after having already added all your sprites to the batch.