Skip to content

Animated Meshes

The Panopti AnimatedMesh object represents a temporally evolving triangular surface mesh. To add an animated mesh to your scene:

import panopti
import trimesh # just for io
import numpy as np

viewer = panopti.connect(server_url="http://localhost:8080", viewer_id='client')

mesh = trimesh.load('mesh.obj')
verts = mesh.vertices   # (V, 3) ndarray
faces = mesh.faces      # (F, 3) ndarray 

# Create simple animation of sliding mesh
num_frames = 60
temporal_offset = np.linspace([0, 0, 0], [1, 0, 0], num=num_frames)[:, None, :]
verts_animation = np.repeat(verts[np.newaxis], repeats=num_frames, axis=0)
verts_animation += temporal_offset

viewer.add_animated_mesh(
    vertices=verts_animation,
    faces=faces,
    name="MyAnimatedMesh",
    framerate=24
)

BaseViewer.add_animated_mesh
add_animated_mesh

Adds an AnimatedMesh object to the viewer.

Parameters:

Name Type Description Default
vertices ndarray

(T, V, 3) array of vertex coordinates for each frame.

required
faces ndarray

(F, 3) array of face indices.

required
name str

Name for the animated mesh.

required
framerate float

Framerate for the animation.

24.0
visible bool

Whether the mesh is visible.

True
position Union[Tuple[float, float, float], ndarray]

Position of the mesh (XYZ).

(0, 0, 0)
rotation Union[Tuple[float, float, float], ndarray]

Rotation of the mesh (XYZ).

(0, 0, 0)
scale Union[Tuple[float, float, float], ndarray]

Scale of the mesh in (XYZ).

(1.0, 1.0, 1.0)
color Union[Tuple[float, float, float], ndarray]

Uniform RGB color of the mesh.

(1.0, 1.0, 1.0)
vertex_colors ndarray

(V, 3) array of vertex colors.

None
face_colors ndarray

(F, 3) array of face colors.

None
material Optional[Any]

Panopti material object.

None

Returns:

Name Type Description
AnimatedMesh AnimatedMesh

The created panopti animated mesh object.

AnimatedMesh.update(**kwargs)
update

Updates this animated mesh's attributes and propagate updates to the viewer.

Example:

animated_mesh = viewer.get('MyAnimatedMesh')
animated_mesh.update(vertices=new_verts, material=new_material)

AnimatedMesh.delete()
delete

Deletes this animated mesh from the viewer.

AnimatedMesh.trans_mat property
trans_mat

Returns the 4x4 transformation matrix corresponding to the object's position, rotation, and scale in the viewer.

AnimatedMesh.viewer_verts property
viewer_verts

Returns the Mesh's vertices under the transformation given by trans_mat.