Orientate the camera so that a given 3d point is always at a given 2d position in the viewport

That was an interesting post indeed.

The author of the question ended up increasing the width of the rendered viewport to offset the center (see), which isn’t a acceptable solution to me.

Also, the yomotsu/camera-controls repo was mentionned along with this specific demo which is quite interesting as it offsets the camera while keeping the same orbit center.

But it’s not exactly what I want to achieve.
I want to make sure a given point in my scene is always at some specific screen space coordinates.
Imagine a common scenario like this one: you have a full-screen canvas and some html text above it covering the left side of the viewport. Then you’ll need to move the camera in a way that your focus object will be slightly offset to the right.
But I don’t want to arbitrarily offset the camera, because I need to make sure the focus object will always be at the same screen space position (for instance 25% from the right side of the page) regardless of the screen ratio.

It’s easier with an orthographic camera, but with a perspective camera it’s a different story…