What I’d like to do is to have a PhotoDome that can zoom to the mouse location.
E.g. like Google Photosphere Zoom example
When you point the mouse e.g. to the bike at the right top and use the mouse-wheel, the camera will change the FOV and the camera rotation.
So the basic idea is this:
get the point on the dome where the mouse is (before we zoom) origDomePoint
then change the FOV of the camera by some delta (e.g. 0.2)
the mouse pointer will still be at the same canvas xy-coordinates, but since we have changed the FOV it will now point to a different domePoint: newDomePoint
now we want to rotate the camera so that the origDomePoint is approximately at the mouse-pointer position again (the camera radius should stay the same)
This is where I am stuck. How can I calculate alpha and beta for the camera from the two dome-points?
This is my playground example, where the calculation is missing (see comments)
I think the best answer is let the framework do it for you. It is a very messy job. Something I have found best avoiding.
The important thing is if you know the final position the camera, then move it there. X,Y,Z positioning works for an ArcRotateCamera. Think there might be something else to call afterward, as well. The weather too good for me to check today, but I’ll bookmark this for Monday to check, if this is still open.
Thanks for the reply.
Note, that we do not want to move the camera around in the dome. The target of the camera should always remain at the centre of the dome and the radius should also remain the same. We only want to change the FOV and the camera rotation.
Do you want to zoom to the mousepoint? i.e. - when using the wheelmouse the point under the mouse should not move and be the same as it was before adding the zoom factor?
Not sure, what you mean.
I can set the cameraRadius to 0, but it does not seem to make much of a difference.
What would you recommend as alternative to FOV zoom?
Yes.
e.g. when I start to zoom, the mouse pointer is over e.g. a corner of 3 walls in the image.
Then we move the mouse-wheel and set the FOV.
I assume, that the mouse-pointer does not move during the zoom.
Now, we want to rotate the camera so that the mouse pointer is over the same corner again (or as near as possible).
This is not taking the sphere wrapping into account. There is a missing compensation, but that will take a little longer to implement. The idea is - fov is in radians, so use the fov delta to compute the right delta (in radians as well). But again - this assumes a 2d space, so within certain zoom you will see that it drifts.
Thanks, that sound reasonable. But I’m afraid I’m running out of geometry/math skills
For now I can live with samuelgirardins approximation.
But it would be great if the PhotoDome class could provide a good implementation for this feature.
Nice. Already works better than I thought it would. There’s a lot less distorsion this way but I guess it’s still a compromise of some sort. Still looks like something useable to me (until we get better ). GJ,
When the pointer is on the edges, alpha & beta are a bit more weight, to increase camera rotation. If you want something more precise remove ratioX & ratioY from code.
@TmTron, maybe try this one : mouse fov to cursor @sam | Babylon.js Playground (babylonjs.com)
I add this line : camera.inputs.remove(camera.inputs.attached.mousewheel);
I suppose when you over wheel/zoom the camera radius change even if you use big value with camera.wheelPrecision. So now by removing mousewheel from inputs could fix the bug.
The issue still persists in the new version.
I can reproduce it in this playground example.
When the cavas size is 829x744 (x/y) and I zoom in on the sphere, the zoom “jumps”