picogl.renderer.mesh_arrays

CPU-side mesh arrays used by geometry builders.

Classes

MeshArrays

Immutable NumPy arrays for positions, normals, colors, and indices.

Module Contents

class picogl.renderer.mesh_arrays.MeshArrays[source]

Immutable NumPy arrays for positions, normals, colors, and indices.

Geometry producers return this type. Color is optional: atom/bond geometry typically omits it, and AtomsMesh / BondsMesh attach it later. Primitive mode is not stored here; as_meshdata() supplies MeshDrawInfo.

positions: numpy.ndarray[source]
normals: numpy.ndarray[source]
colors: numpy.ndarray | None = None[source]
indices: numpy.ndarray | None = None[source]
__post_init__() → None[source]
property indexed: bool[source]

Whether this mesh carries an index buffer.

classmethod from_pnc(part: picogl.renderer.meshdata.PNCPart, *, indices: numpy.ndarray | None = None) → MeshArrays[source]

Build MeshArrays from a PNCPart.

Parameters:
  • part – (positions, normals, colors)

  • indices – Optional element buffer

Returns:

New MeshArrays value

as_pnc() → picogl.renderer.meshdata.PNCPart[source]

Return (positions, normals, colors).

Raises:

ValueError – When colors are missing

with_colors(colors: numpy.ndarray) → MeshArrays[source]

Return a copy with colors replacing the current color array.

Parameters:

colors – RGB triples with shape (3,) or (N, 3).

Returns:

New value with the same positions, normals, and indices.

Return type:

MeshArrays

as_meshdata(*, mode: picogl.backend.gl.enums.GLDrawMode = GLDrawMode.TRIANGLES, indexed: bool | None = None, elements_per_item: int | None = None, vertices_per_item: int | None = None) → picogl.renderer.meshdata.MeshData[source]

Convert these arrays into renderable MeshData.

Parameters:
  • mode – Primitive mode. Defaults to triangles so unindexed geometry is not inferred as points.

  • indexed – Whether drawing uses an element buffer. Defaults to indexed.

  • elements_per_item – Indices (or vertices, when unindexed) per logical item.

  • vertices_per_item – Vertices per logical item, used when expanding per-item attributes.

Returns:

CPU mesh with draw_info built from mode and the layout arguments.

Return type:

MeshData