Get 3d cursor location from mouse position

by cursorer   Last Updated July 11, 2019 17:15 PM

I need to find out the location of the 3d cursor given the mouse position. That is: if the user were to click at the position (x, y) on 3d viewport, what would be the location of the 3d cursor in 3d space.

This is not the same as getting the location from calls to region_2d_to_vector_3d and region_2d_to_location_3d because the cursor location calculation also considers object locations.

This thread discusses the issue, but the question is related to 3d cursor location without any object under it. I need to find out the location when there IS an object (even an object with geometry that does not allow ray-casting).

Related Questions

View3D operations problem

Updated July 25, 2015 13:06 PM

Overwriting the context for camera_to_view

Updated April 20, 2017 21:15 PM

Off screen window

Updated April 28, 2017 17:15 PM