How to get Viewport Position, Direction, UpVector? For Perspective and Ortho views.
Here is explanation Screenshot:
Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. It only takes a minute to sign up.Sign up to join this community
There are utility functions available in the bpy_extras.view3d_utils module.
You may get the view direction like this
r3d.view_rotation * Vector((0.0, 0.0, -1.0))
the up direction should be
r3d.view_rotation * Vector((0.0, 1.0, 0.0))
and the view location:
Or another way
region = context.region rv3d = context.region_data view3d_utils.region_2d_to_origin_3d(region, rv3d, (region.width/2.0, region.height/2.0))
Despite its name,
RegionView3D.view_location specifies the view target.