I used a new Babylon.js 5 feature camera.zoomToMouseLocation. It works as expected until I zoom to the mesh(change camera target and radius). Zoom speed becomes significantly faster(Sometimes after the second zoom). And sometimes zoom out starts to work slowly, but the actual camera radius changes, I can see that after camera rotation, the camera reposition is far from the origin before rotation.
I found the function, that I think is responsible for the behavior _zoomToMouse. I think changing the target here may cause the issue vec.subtract(camera.target) as the target is new.
I have a lack of math knowledge, so would be very grateful if somebody could explain to me what’s happening.
@clovett I would be very grateful if you help me with this one.
I found that zoom works well if the target is 0, 0, 0. But if you set it to 100, 100, 100 for example and change the radius then this variable values let directionToZoomLocation = vec.subtract(camera.target); becomes much bigger. I think this is an issue, but can’t come with as solution.
How can I overcome this?
First off, welcome to the community @ci4anish! I am able to repro the type of behavior that you’re seeing though I’m not 100% sure as to the logic myself. It looks like the target is moving around pretty wildly. I’m not going to be in the office for a few days so if there’s no resolution on this, I’ll take a look when I get back and see what I can do.
The issue ws the hit plane that was incorrectly calculated. notice that in certain cases it will feel a bit off, as the target will be set in the middle of the sphere-array and not a specific array. The target changes on each frame, so this is an expected side-effect.