Screen xy to world coordinates

Hello everyone,

I am (I think) in the exact same issue. I need to add a sphere where the user clicks. I tried the following option :

var ballPos = BABYLON.Vector3.Unproject(
new BABYLON.Vector3(scene.pointerX,scene.pointerY,1),
engine.getRenderWidth(),
engine.getRenderHeight(),
BABYLON.Matrix.Identity(), scene.getViewMatrix(),
scene.getProjectionMatrix());

But the coordinates are really weird (like thousands or so)…

I thought about an option where I link a transparent plane end get the picked position but it’s seems a bit goofy.

Any idea ?

4 Likes