pygfx.geometries.Geometry
- class pygfx.geometries.Geometry(*, positions: ArrayOrBuffer = None, indices: ArrayOrBuffer = None, normals: ArrayOrBuffer = None, texcoords: ArrayOrBuffer = None, colors: ArrayOrBuffer = None, grid: ArrayOrTexture = None, **other_attributes: ArrayOrTextureOrBuffer)
Bases:
Store
An object’s geometry is a container for data that ‘defines’ (the shape of) the object.
This class has no documented properties; attributes (usually buffers and sometimes textures) can be freely added to it. What attributes are required depends on the kind of object and the usage of the material. Some attributes are optional. However, there are several common names.
Common buffer attributes:
positions
: an Nx3 buffer representing vertex positions. Used by e.g.Mesh
,Line
,Points
,Text
.indices
: an Nx3 buffer representing the triangular faces of aMesh
.normals
: an Nx3 buffer representing the surface normals of aMesh
.texcoords
: an Nx1, Nx2, or Nx3 set of per-vertex texture coordinates. The dimensionality should match that of the dimension of the colormap’s texture (material.map
).texcoords1
,texcoords2
etc.: for additional texture coordinates. Usually Nx2. E.g. aTextureMap
withuv_channel
set to 4 will use “texcoords4”.colors
: per vertex or per-face color data for e.g.Mesh
,Line
,Points
. Can be Nx1 (grayscale), Nx2 (gray plus alpha), Nx3 (RGB), or Nx4 (RGBA).sizes
: per vertex sizes for e.g.Points
.edge_colors
per vertex edge colors for points with the marker material.rotations
: per vertex point/marker rotations.
Common texture attributes:
grid
: a 2D or 3D texture for theImage
andVolume
objects, respectively.
For mesh morphing the following attributes are used:
morph_targets_relative
: a bool indicating whether the morph positions are relative.morph_positions
: a list of arrays of per-vertex morph positions.morph_normals
: a list of arrays of per-vertex morph normals.morph_colors
: a list of arrays of per-vertex morph colors.
Instantiation
Most attributes of the geometry are buffers or textures. For convenience, these can be passed as arrays, in which case they are automatically wrapped in a buffer or texture.
Example
g = Geometry(positions=[[1, 2], [2, 4], [3, 5], [4, 1]]) g.positions # Buffer g.positions.data # numpy array