def _add_colors_to_vertices(mesh, colors, attribute_name):
    """Add a color attribute to each vertex of mesh."""
    if len(mesh.vertices) != len(colors):
        raise ValueError(
            f"Got {len(mesh.vertices)} vertices and {len(colors)} color values."
        )

    color_array = np.array(colors)
    color_array[:, :3] /= 255.0
    mesh.attributes[attribute_name].data.foreach_set(
        "color", color_array.reshape(-1)
    )
Add a color attribute to each vertex of mesh.
photogrammetry_importer/importers/point_utility.py