Skip to main content
`Ctrl`+`K`

# vispy.visuals.instanced_mesh module

An instanced version of MeshVisual with arbitrary shifts, transforms, and colors.

class vispy.visuals.instanced_mesh.InstancedMeshVisual(*args, instance_positions, instance_transforms, instance_colors=None, **kwargs)

  Bases: `MeshVisual`

  Instanced Mesh visual.

  Mostly identical to MeshVisual, but additionally takes arrays of of positions and transforms (optionally colors) to create multiple instances of the mesh.

  Instancing is a rendering technique that re-uses the same mesh data by applying transformations to vertices and vertex data or textures, wich can drastically improve performance compared to having many simple MeshVisuals.

  Parameters:
    instance_positions(I, 3) array

      Coordinates for each instance of the mesh.

    instance_transforms(I, 3, 3) array

      Matrices for the transforms to apply to each instance.

    instance_colors ColorArray

      Matrices of colors for each instance. Colors

    *args list

      Positional arguments to pass to `MeshVisual`.

    **kwargs dict

      Keyword arguments to pass to `MeshVisual`.

  Examples

  See example scene/instanced_mesh_visual.py in the gallery.

  property instance_colors
  property instance_positions
  property instance_transforms