Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Methods to set and get camera coordinates as graph coordinates #1464

Open
StockerGaming opened this issue Sep 13, 2024 · 4 comments
Open

Methods to set and get camera coordinates as graph coordinates #1464

StockerGaming opened this issue Sep 13, 2024 · 4 comments

Comments

@StockerGaming
Copy link

It would be helpful to be able to read and set the coordinates of the camera with graph space coordinates in addition to the currently in-place framedGraph coordinates.

@jacomyal
Copy link
Owner

There is a documentation page describing the different coordinate systems used by sigma.

The camera's coordinates are in the "viewport" system, while the nodes positions are described in the "graph" system.

You can use const graphPoint = sigma.viewportToGraph({ x, y }) (as in this story) or const viewportPoint = sigma.graphToViewport({ x, y }) (as in this other story).

@StockerGaming
Copy link
Author

Many thanks for the response. I think that I miscommunicated what I meant. I meant the coordinates contained within the camera state, which one can read and manipulate with renderer.getCamera().getState() and renderer.getCamera().setState(). In my case I could get by by writing renderer.viewportToFramedGraph(renderer.graphToViewport(coordinates)), yet I suspect that some accuracy loss occurs here (which is not critical in the context I am using it for). Some people might appreciate a direct conversion function between those two coordinate systems.

Many thanks.

@jacomyal jacomyal reopened this Sep 16, 2024
@StockerGaming
Copy link
Author

StockerGaming commented Sep 16, 2024

I will make a pull request for this if you don't mind

@jacomyal
Copy link
Owner

That would be great :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants