code: def export_wavefront(mesh,
                       include_normals=True,
                       include_texture=True):
      
      # store the multiple options for formatting
      # a vertex index for a face
      face_formats = {('v',): '{}',
                      ('v', 'vn'): '{}//{}',
                      ('v', 'vt'): '{}/{}',
                      ('v', 'vn', 'vt'): '{}/{}/{}'}
      # we are going to reference face_formats with this
      face_type = ['v']
  
      export = 'v '
      export += util.array_to_string(mesh.vertices,
                                     col_delim=' ',
                                     row_delim='\nv ',
                                     digits=8) + '\n'
  
      if include_normals and 'vertex_normals' in mesh._cache:
          # if vertex normals are stored in cache export them
          # these will have been autogenerated if they have ever been called
          face_type.append('vn')
          export += 'vn '
          export += util.array_to_string(mesh.vertex_normals,
                                         col_delim=' ',
                                         row_delim='\nvn ',
                                         digits=8) + '\n'
  
      if (include_texture and
          'vertex_texture' in mesh.metadata and
              len(mesh.metadata['vertex_texture']) == len(mesh.vertices)):
          # if vertex texture exists and is the right shape export here
          face_type.append('vt')
          export += 'vt '
          export += util.array_to_string(mesh.metadata['vertex_texture'],
                                         col_delim=' ',
                                         row_delim='\nvt ',
                                         digits=8) + '\n'
  
      # the format for a single vertex reference of a face
      face_format = face_formats[tuple(face_type)]
      faces = 'f ' + util.array_to_string(mesh.faces + 1,
                                          col_delim=' ',
                                          row_delim='\nf ',
                                          value_format=face_format)
      # add the exported faces to the export
      export += faces
  
      return export
docs: Export a mesh as a Wavefront OBJ file
  
      Parameters
      -----------
      mesh: Trimesh object
  
      Returns
      -----------
      export: str, string of OBJ format output