[SOLVED] How to get a line in 3D world corresponding to a canvas pixel?

I want a 3D object in the world to go the a location corresponding to a position on the canvas clicked by the user. In fact there are multiple positions possible all resulting in the object displayed at that position. The solution will be a line.

So when clicked on the canvas, I get the mouse coordinates. And I would like to calculate the line in the 3D world corresponding to that clicked canvas position.

Searching the forum I can find solutions using raycasting using the physics library. Is it really that difficult? Isn’t there a more simple solution for this?

Aah, I searched again and I see there is a screenToWorld function.

I totally missed that! Maybe I’m overworked. Did lots of PLayCanvas coding the last days :wink:

1 Like