Skip to content

Transformations & Gizmo

Panopti offers interactive mechanisms for translating, rotating, and scaling geometries through the transformation panel and through gizmos. To open the transformation panel, simply select a scene object. For the gizmo tool, see the toolbar. The transformated state of scene objects can be accessed by your code through property fields of scene geometries.

Example:

import panopti
import numpy as np
viewer = panopti.connect(server_url="http://localhost:8080", viewer_id="client")

# ... load triangle mesh vertices / faces ...

viewer.add_mesh(vertices=vertices, faces=faces, name="MyMesh")

# Add a button that reads off the mesh's current transformation:
def my_button_callback(viewer):
    mesh = viewer.get('MyMesh')

    # request MyMesh's 4x4 transformation matrix:
    trans_mat = mesh.trans_mat

    # or directly access the transformed vertex tensor:
    transformed_verts = mesh.viewer_verts

    # ... do something here ...

viewer.button(callback=my_button_callback, name='MyButton')

viewer.hold() # prevent script from terminating

Each geometry type exposes helper attributes for retrieving the object's current 4x4 transformation matrix and associated quantities. For example, for Meshes and AnimatedMeshes objects, we offer:

SceneObject.trans_mat
trans_mat

Fetches the objects current 4x4 transformation matrix.

viewer.get('MyObject').trans_mat

SceneObject.viewer_verts
viewer_verts

Fetches the objects current vertices with trans_mat pre-applied

viewer.get('MyObject').viewer_verts

See other geometry types for related functions, e.g. Points.

Gizmo

The transformation gizmo can be enabled from the top left toolbar. It offers familiar controls to what you'd find in common 3D packages, select an object (either by clicking on it directly or in the layers panel), then the gizmo will appear.

Controls:

Key Action
T Switch to translate mode
R Switch to rotate mode
E Switch to scale mode
Q Toggle between world and local transformations
CTRL (hold) Snapping mode
ESC Hide gizmo

Event Callbacks

Both the transformation panel and gizmo offer event callbacks through @viewer.events.update_object() and @viewer.events.gizmo() respectively. See Viewer Events for details.