Rotate with camara around center of viewport in 3D

Godot Version

4.2.1 Stable

Question

Hi All

How to rotate ‘everything’ around the center of what is displayed in the viewport?
I’m relative new to Godot and I’m trying to create a camera movement script for moving a camera in 3D. It should function like in Transport Fever.

Move Forward/Left/Right/Backwards:

  • Keyboard: with ‘WASD’
  • Mouse: right mouse button and mouse movement

Pan/Tilt:

  • Keyboard: ‘QERF’
  • Mouse: middle mouse button and mouse movement

Zoom:

  • Keyboard: ‘ZX’
  • Mouse: scroll up/down

For now I’m first working on the keyboard controls later I will add the mouse movement. The movement is already working. I solved this by moving with global_position += global_transform.basis.x + 1 (plus/minus according to the movement in X and Z plane), but I’m struggling with the panning.

I want to pivot around ‘everything’ what is actually displayed within the display. The pivot point shall be the center of the current ‘view’. How to accomplish this? Any hint (degrees or radians doesn’t matter) is helpful.

Thanks in advance

Ludo