I want to obtain the 2D coordinates of a mouse-click action on a plotly go 3D mesh. There were a number of issues that I saw in plotly js but no solution in plotly python. My goal is to obtain the 3D coordinates of the point using the 2D coordinates on the mesh and the current camera of the plot. Is there a way to obtain the 2D coordinates?
HI @ac13 what exactly are you referring to, when mentioning
If I understand this correctly, you want to do some kind of projection or similar with the camera vectors?
I assume you are talking about
dash, right? Could you provide a MRE?
Hello, thanks for the response.
I would utilize the coordinates using a dash callback, but I’m not referring to dash specifically in this question.
My question is about the plotly graph_objects Mesh3d class.
When I display a mesh using this class, by a code such as this:
x=self.x, y=self.y, z=self.z,
i=self.i, j=self.j, k=self.k,
I get the mesh rendered from a certain camera position and orientation, like this:
Here, I am using the trimesh capsule primitive.
This specific camera can be obtained in a callback like this:
camera = fig['layout']['scene']['camera']
hoverinfo set as
all, when I hover over the mesh, I would get the closest vertex coordinates of the face over which my mouse is currently. Then, surely
plotly knows the exact 2D coordinates of my mouse location and finds the closest vertex of the mesh which is visible in the current camera. I want to know this 2D coordinate, so that using the current camera I can obtain the exact 3D coordinates of the point over which my mouse hovers/clicks and not the coordinates of the nearest mesh vertex.