Unproject mouse to 3d world on z=variable

Based on this answer - how would I have to modify it to get the position in 3d space on z = 200 (or some other variable) instead of z = 0?

I’m trying to resize geometry as you would resize square in Adobe illustrator. In order to do that I need to know the difference between mousemove in 3d space on plane where my geometry is. Maybe there is another/better way of resizing geometry by dragging edge?

It seems this is explained in the post.

If you need the point “under the mouse” and in the plane z = targetZ , replace the distance computation with:

var distance = ( targetZ - camera.position.z ) / vec.z;

So targetZ would be 200 in your case.

Thank you.
I guess I’m not very smart. I spend a few hours trying to figure it out while it was right there.

Is that answer still applicable? I’ve seen other posts suggesting that the unproject is being phased out

Seems to be live and kicking - this method is the only way to do this without having to care about camera type, why would they get rid of it?

1 Like