Setting the 3d cursor in perspective mode would keep the cursor behind the viewport, now check if the cursor is begind the viewport and use the orbit location to set the cursor depth rather then the existing plane.
Setting the 3d cursor in perspective mode would keep the cursor behind the viewport, now check if the cursor is begind the viewport and use the orbit location to set the cursor depth rather then the existing plane.