Targeting the OrbitControls to a 3D object position other than origin

I am trying to orbit around an object which is not exactly at the origin of the world. When I try to target the orbitControls to an object which is at some random location, then by default behavior, the object is moved at the center of the canvas and camera moves around it appearing like the targeted object is at the origin.

Image when green cube is targeted by orbitcontrols and green cube appears at origin as it actually is.

Image when blue cube is targeted by orbitcontrols and blue cube appears at the origin which it is not.

Same with red cube.

I want the object to appear where it is and camera to orbit around it avoiding the targeted object to appear at the origin. I have seen some websites with such behavior.

Please let me know how can we implement this?

OrbitControls can only orbit around the .target.

While the built-in controls may not be exactly what you are looking for - it should be enough to just modify this part, to make them not place the target in the centre of the screen automatically. :thinking: