Camera panning on global axis

Hello guys,

I am working on the user inputs of a scene and wonder how to bind the panning of the arcRotateCamera to a global axis.

Imagine there is an object in the center of the scene and the camera should focus it all the time. The user should be able to pan along the y axis to set the camera target to the bottom or top of the object. But

You can test it in this pg: https://playground.babylonjs.com/#W3HQP7#3

  1. Load the scene and rotate around the object. You can see that the camera is always targeted to the center of the object.

  2. Load the scene, pan so the object is higher and rotate around the object. You can see that the object isn’t centered anymore.

The problem here is that panning doesn’t only adjust the y value of camera.target but also x & z. How am I able to keep x & z always 0?

My apporach is this, but it isn’t smooth & accurate: https://playground.babylonjs.com/#W3HQP7#4

It should simply behave like moving the object up and down but without moving the object but the camera.

ping @PolygonalSun

Maybe this would help?

Read more here:

Thanks for your response.

I already came across this example. The problem ist that it kills the rotation for beta as well as the inertia. I would prefer to use as most code of the usual arcRotateCamera as possible so nothing gets messed up.

EDIT:

Instead of adapting the camera target due to the pointer input I used the onViewMatrixChangedObservable: https://playground.babylonjs.com/#W3HQP7#6. Way smoother. Anyway I open to other ideas :slight_smile:

Just out of curiosity, do you want the object to continue to move up and down the y-axis when looking at it from above (creating a zoom in/out effect)?