jacomyal/sigma.js

Methods to set and get camera coordinates as graph coordinates

Opened this issue · 4 comments

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.

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).

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.

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

That would be great :)