# Rotation around center of screen

Hello JME users,

I want to implement a way to rotate the camera around the center of the screen regardless if there's nothing there. We have implemented a way to rotate the camera around an object by making the object's position be the center of rotation. However, how would I go about calculating what are the 3D coordinates for the center of the screen when there's no object around like in an open space?

Any help will be appreciated!

So far the only way I can think of is by getting the camera position and adding random numbers to it  which is a very silly way to do it I think.

Thanks.

Is this similar to what you are looking for?

Thanks for the code Nymon. Awesome job doing this demo.

However, is not quite what I'm looking for. If I understood correctly, when you rotate (orbit) around the scene you are using the same location center (targetPostion: [X=-25.0, Y=70.0, Z=-45.0]) for all camera rotation (orbiting/ when you move around scene while holding down the right button).

What I want to do is to calculate the target position (center of orbit/rotation) to be whatever is on the center of the screen.

For example:

In the drawing below let "00000" represent the Node in the scene. In this case, I would like to rotate the camera around point x in the screen instead of the Node "00000".

|                                                    |
|                                                    |
|                                                    |
|                                                    |
|                                                    |
|00000                x                            |
|                                                    |
|                                                    |
|                                                    |
|                                                    |

What I don't know is how to calculate x..

Am I overlooking anything at your code Nymon?

thanks

I am going to reply to my own post.

Nymon: Your demo is indeed what I wanted to do with camera rotation. It took me a while to figure out that you are updating the targetPosition when moving camera around . Thanks.

Yup, glad you can use it.