With babylon, I know I can find a button with this sort of code
b = scene.getNodeByName("planeForADT").material.emissiveTexture.getDescendants().find(d => d.name === "buttonName")
And I see a method called getLocalCoordinates(vector2), but that doesn’t looks like it will return the correct data (it gets control space from global space, and ive tried it, it looks to be scaled control space).
How can i get the global coordinates (and ultimately screen coordinates) from a button’s local coordinates?
The babylon playground seems to be completely accurate, but in our app, we’re using CreatePlane, and AdvancedDynamicTexture.CreateForMesh, and the centerX/centerY coordinates don’t seem to correspond to the actual screen position at all.
Actual coords roughly: 886 x 553
centerX/Y 352,539
Would you please provide a PG next time you asking a question? It’ll help to avoid misunderstanding of your problem.
So if your GUI is on a plane the control coordinates are relative to that plane so you just need to add screen cordinates of that plane to the coordinates of the control. You won’t need that funky piece of code at all.
Yes I’ll supply a more complete example in the future. I thought this was mainly a question of “where in the API is this”. I see that you definitely gotta do it the long way (coords/world widths x world transform x camera x projection).