Skip to content

Zoom to mouse cursor position #698

@Treebu-Extension

Description

@Treebu-Extension

Describe the bug
I'm trying to zoom to cursor pointer position with ForceGraph3D. I found this solution : https://codepen.io/duhaime/pen/poJLdyd that modify the function this.zoomCamera and it work perfectly well, but when I rotate the camera (with right click)), the zoom is then broken.

I guess the issue is that it has to correctly transforming the cursor position into the world space based on the current camera rotation.
When you rotate the camera, the mouse position should be calculated in the context of the new camera view (taking into account the camera's position and orientation). The zoom should then be applied in a way that takes into account the current camera perspective, not the initial world position.

Anyone knows how to do it ?

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://codepen.io/duhaime/pen/poJLdyd
  2. Zoom in & out to cursor position -> it works
  3. Rotate camera
  4. Zoom in & out to cursor position -> it's broken

Expected behavior
I should be able to zoom in / zoom out to cursor poistion whatever the camera orientation is.

Desktop (please complete the following information):

  • Windows
  • Brave

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions