World coordinates to screen XY

How can I convert mesh coordinates to screen XY coordinates? (Want to display a GUI text on these coordinates)

Hi IHux… sorry for the slow weekend replies. I don’t have an answer for that, but I do have another way.

https://playground.babylonjs.com/#4PLF3P
or…
https://playground.babylonjs.com/#4PLF3P#1 (allows click on rect1 to toggle it OFF - lines 33-36)

Click canvas anywhere. Lots of “mess” in that playground, but… also some handy code at lines 70-75.

By chance, are you trying to absolute-position some HTML-gui at the point of click? If so, just say so, and we’ll do a little re-designing, as-needed (adjust HTML top/left GUI position, compensating for canvas element top-left corner and canvas width/height).

Absolute positioning HTML atop webGL canvas… is… hmm… “sketchy”? Just the same, here’s a playground that creates a HTML menu and does abs-positioning at lines 37-39… something to experiment-with, if needed. https://www.babylonjs-playground.com/#3U658N#20

Here’s another PG I found. I’m not sure what they are doing with those little cross-hairs or with that strange code, but… it’s something. :slight_smile: It seems that the terms project and unproject are somehow important.

I hope I’ve been helpful. Stay tuned… the ACTUAL answer is nearby, too, just not from me.

4 Likes

Hi @Wingnut thank you for you time. The last PG is exactly that I’m looking for. You were helpful for sure :slight_smile:

2 Likes