docstr: Get the texture object representing the given mesh primitive.
  
  Args:
      primitive: the mesh primitive being loaded.
      indices: the face indices of the mesh
docstr_tok: ["Get","the","texture","object","representing","the","given","mesh","primitive",".","Args",":","primitive",":","the","mesh","primitive","being","loaded",".","indices",":","the","face","indices","of","the","mesh"]
code: def get_texture_for_mesh(
      self, primitive: Dict[str, Any], indices: torch.Tensor
  ) -> Optional[TexturesBase]:
      """
      Get the texture object representing the given mesh primitive.
  
      Args:
          primitive: the mesh primitive being loaded.
          indices: the face indices of the mesh
      """
      attributes = primitive["attributes"]
      vertex_colors = self._get_primitive_attribute(
          attributes, "COLOR_0", np.float32
      )
      if vertex_colors is not None:
          return TexturesVertex([torch.from_numpy(vertex_colors)])
  
      vertex_texcoords_0 = self._get_primitive_attribute(
          attributes, "TEXCOORD_0", np.float32
      )
      if vertex_texcoords_0 is not None:
          verts_uvs = torch.from_numpy(vertex_texcoords_0)
          verts_uvs[:, 1] = 1 - verts_uvs[:, -1]
          faces_uvs = indices
          material_index = primitive.get("material", 0)
          material = self._json_data["materials"][material_index]
          material_roughness = material["pbrMetallicRoughness"]
          if "baseColorTexture" in material_roughness:
              texture_index = material_roughness["baseColorTexture"][
                  "index"
              ]
              texture_json = self._json_data["textures"][texture_index]
              # Todo - include baseColorFactor when also given
              # Todo - look at the sampler
              image_index = texture_json["source"]
              map = self._get_texture_map_image(image_index)
          elif "baseColorFactor" in material_roughness:
              # Constant color?
              map = torch.FloatTensor(
                  material_roughness["baseColorFactor"]
              )[None, None, :3]
          texture = TexturesUV(
              # pyre-fixme[61]: `map` may not be initialized here.
              maps=[map],  # alpha channel ignored
              faces_uvs=[faces_uvs],
              verts_uvs=[verts_uvs],
          )
          return texture
  
      return None
  
imports: import json
  import struct
  import warnings
  from base64 import b64decode
  from collections import defaultdict, deque
  from enum import IntEnum
  from io import BytesIO
  from typing import Any, BinaryIO, cast, Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from iopath.common.file_io import PathManager
  from PIL import Image
  from pytorch3d.io.utils import _open_file, PathOrStr
  from pytorch3d.renderer.mesh import TexturesBase, TexturesUV, TexturesVertex
  from pytorch3d.structures import join_meshes_as_scene, Meshes
  from pytorch3d.transforms import quaternion_to_matrix, Transform3d
  from .pluggable_formats import endswith, MeshFormatInterpreter
label_desc: Use image node_id 7 for calling the _GLTFLoader obj's underlying member method code with example usage: obj.get_texture_for_mesh(primitive, indices) and returns: None, TexturesVertex, texture