code: def material_to_texture(material):
      
  
      # try to extract a PIL image from material
      if hasattr(material, 'image'):
          img = material.image
      else:
          img = material.baseColorTexture
  
      if img is None:
          return None
  
      # use a PNG export to exchange into pyglet
      # probably a way to do this with a PIL converter
      with util.BytesIO() as f:
          # export PIL image as PNG
          img.save(f, format='png')
          f.seek(0)
          # filename used for format guess
          gl_image = pyglet.image.load(filename='.png', file=f)
  
      # turn image into pyglet texture
      texture = gl_image.get_texture()
  
      return texture
docs: Convert a trimesh.visual.texture.Material object into
      a pyglet- compatible texture object.
  
      Parameters
      --------------
      material : trimesh.visual.texture.Material
        Material to be converted
  
      Returns
      ---------------
      texture : pyglet.image.Texture
        Texture loaded into pyglet form