picogl.renderer.molecular.pnc_buffer ==================================== .. py:module:: picogl.renderer.molecular.pnc_buffer .. autoapi-nested-parse:: Accumulate position, normal, color, and index mesh arrays. Classes ------- .. autoapisummary:: picogl.renderer.molecular.pnc_buffer.PNCBuffer Module Contents --------------- .. py:class:: PNCBuffer Accumulate indexed position / normal / color geometry. This class does not construct primitives. Geometry producers append via :meth:`extend` (world-space :class:`~picogl.renderer.mesh_arrays.MeshArrays`) or :meth:`add_instance` / :meth:`add_instances` (translated templates). :meth:`to_mesh_arrays` materializes combined geometry; :meth:`to_mesh_data` is the render boundary. .. py:attribute:: _positions :type: list[numpy.ndarray] :value: [] .. py:attribute:: _normals :type: list[numpy.ndarray] :value: [] .. py:attribute:: _colors :type: list[numpy.ndarray] :value: [] .. py:attribute:: _indices :type: list[numpy.ndarray] :value: [] .. py:attribute:: vertex_offset :type: int :value: 0 .. py:method:: add_instance(mesh: picogl.renderer.mesh_arrays.MeshArrays, translation: collections.abc.Iterable[float], color: tuple[float, float, float], *, scale: float = 1.0) -> None Translate a geometry template and append it with a uniform color. Template colors are ignored; *color* is tiled onto every new vertex. :param mesh: Origin-centered positions, normals, and local indices :param translation: World-space offset applied to every template vertex :param color: RGB triple copied onto every new vertex :param scale: Uniform scale applied to template positions before translation .. py:method:: add_instances(mesh: picogl.renderer.mesh_arrays.MeshArrays, translations: numpy.ndarray, colors: numpy.ndarray, *, scales: numpy.ndarray | None = None) -> None 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. :param mesh: Origin-centered positions, normals, and local indices :param translations: World-space offsets with shape ``(N, 3)`` :param colors: Per-instance RGB triples with shape ``(N, 3)`` :param scales: Optional per-instance uniform scales with shape ``(N,)`` .. py:method:: extend(mesh: picogl.renderer.mesh_arrays.MeshArrays, *, color: tuple[float, float, float] | None = None) -> None Append world-space geometry and offset local indices. :param mesh: Positions, normals, and indices already in world space :param 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 .. py:method:: _resolve_colors(mesh: picogl.renderer.mesh_arrays.MeshArrays, n_verts: int, color: tuple[float, float, float] | None) -> numpy.ndarray .. py:method:: _offset_indices(indices: numpy.ndarray | None) -> numpy.ndarray .. py:method:: _append_chunk(positions: numpy.ndarray, normals: numpy.ndarray, colors: numpy.ndarray, indices: numpy.ndarray, n_verts: int) -> None .. py:method:: to_mesh_arrays() -> picogl.renderer.mesh_arrays.MeshArrays Materialize accumulated chunks as combined geometry. :return: Positions, normals, colors, and offset triangle indices .. py:method:: to_mesh_data() -> picogl.renderer.meshdata.MeshData Build renderable :class:`~picogl.renderer.meshdata.MeshData`. :return: Mesh with positions, normals, colors, and triangle indices .. py:method:: to_arrays(dtype: numpy.dtype | type = np.float32) -> tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray] Return concatenated NumPy arrays for :meth:`to_mesh_arrays`. :param dtype: Floating-point dtype for positions, normals, and colors :return: ``(vertices, normals, colors, indices)``