mmatl / pyrender

Easy-to-use glTF 2.0-compliant OpenGL renderer for visualization of 3D scenes.
http://pyrender.readthedocs.io/
MIT License
1.31k stars 225 forks source link

[Feature request] Get Viewer's camera pose matrix natively #234

Open hhakk opened 2 years ago

hhakk commented 2 years ago

A feature I would find useful is to interactively move and zoom the camera in the Viewer and then use this position later in the code. As an example, if you have multiple 3D objects that you want to render with the same settings, you might want to interactively rotate the object to a desired position and then render all of the objects with this position. This also eliminates iterative test rendering and changing the pose of the objects.

Currently, I managed to do this utilizing the Trackball instance:

pyrender.Viewer(
    scene, 
    registered_keys={
        "k": lambda viewer: print(viewer._trackball.pose)
    }
)

Here, pressing K on the keyboard while in the Viewer prints the Viewer's camera pose matrix to console. This is obviously a hacky solution - this functionality could be exposed in cleaner way.

Even if this feature is not to be implemented, I wanted to share this solution as it might be of help to others searching for this functionality.

elenacliu commented 2 years ago

@hhakk just what I need