picogl.renderer.molecular.pnc_buffer

Accumulate position, normal, color, and index mesh arrays.

Classes

PNCBuffer

Accumulate indexed position / normal / color geometry.

Module Contents

class picogl.renderer.molecular.pnc_buffer.PNCBuffer[source]

Accumulate indexed position / normal / color geometry.

This class does not construct primitives. Geometry producers append via extend() (world-space MeshArrays) or add_instance() / add_instances() (translated templates). to_mesh_arrays() materializes combined geometry; to_mesh_data() is the render boundary.

_positions: list[numpy.ndarray] = [][source]
_normals: list[numpy.ndarray] = [][source]
_colors: list[numpy.ndarray] = [][source]
_indices: list[numpy.ndarray] = [][source]
vertex_offset: int = 0[source]
add_instance(mesh: picogl.renderer.mesh_arrays.MeshArrays, translation: collections.abc.Iterable[float], color: tuple[float, float, float], *, scale: float = 1.0) → None[source]

Translate a geometry template and append it with a uniform color.

Template colors are ignored; color is tiled onto every new vertex.

Parameters:
  • mesh – Origin-centered positions, normals, and local indices

  • translation – World-space offset applied to every template vertex

  • color – RGB triple copied onto every new vertex

  • scale – Uniform scale applied to template positions before translation

add_instances(mesh: picogl.renderer.mesh_arrays.MeshArrays, translations: numpy.ndarray, colors: numpy.ndarray, *, scales: numpy.ndarray | None = None) → None[source]

Translate one template to many instances in a single NumPy expand.

Template colors are ignored; each row of colors is tiled onto that instance’s vertices.

Parameters:
  • mesh – Origin-centered positions, normals, and local indices

  • translations – World-space offsets with shape (N, 3)

  • colors – Per-instance RGB triples with shape (N, 3)

  • scales – Optional per-instance uniform scales with shape (N,)

extend(mesh: picogl.renderer.mesh_arrays.MeshArrays, *, color: tuple[float, float, float] | None = None) → None[source]

Append world-space geometry and offset local indices.

Parameters:
  • mesh – Positions, normals, and indices already in world space

  • color – Optional RGB triple tiled onto every vertex. Used when given; otherwise mesh.colors is required.

Raises:

ValueError – If neither color nor mesh.colors is present

_resolve_colors(mesh: picogl.renderer.mesh_arrays.MeshArrays, n_verts: int, color: tuple[float, float, float] | None) → numpy.ndarray[source]
_offset_indices(indices: numpy.ndarray | None) → numpy.ndarray[source]
_append_chunk(positions: numpy.ndarray, normals: numpy.ndarray, colors: numpy.ndarray, indices: numpy.ndarray, n_verts: int) → None[source]
to_mesh_arrays() → picogl.renderer.mesh_arrays.MeshArrays[source]

Materialize accumulated chunks as combined geometry.

Returns:

Positions, normals, colors, and offset triangle indices

to_mesh_data() → picogl.renderer.meshdata.MeshData[source]

Build renderable MeshData.

Returns:

Mesh with positions, normals, colors, and triangle indices

to_arrays(dtype: numpy.dtype | type = np.float32) → tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray][source]

Return concatenated NumPy arrays for to_mesh_arrays().

Parameters:

dtype – Floating-point dtype for positions, normals, and colors

Returns:

(vertices, normals, colors, indices)