trimesh.resolvers

resolvers.py

Provides a common interface to load assets referenced by name like MTL files, texture images, etc. Assets can be from ZIP archives, web assets, or a local file path.

class trimesh.resolvers.FilePathResolver(source)

Bases: trimesh.resolvers.Resolver

Resolve files from a source path on the file system.

__init__(source)

Resolve files based on a source path.

Parameters

source (str) – File path where mesh was loaded from

get(name)

Get an asset.

Parameters

name (str) – Name of the asset

Returns

data – Loaded data from asset

Return type

bytes

write(name, data)

Write an asset to a file path.

Parameters
  • name (str) – Name of the file to write

  • data (str or bytes) – Data to write to the file

class trimesh.resolvers.Resolver(*args, **kwargs)

Bases: object

The base class for resolvers.

__init__(*args, **kwargs)
write(name, data)
class trimesh.resolvers.WebResolver(url)

Bases: trimesh.resolvers.Resolver

Resolve assets from a remote URL.

__init__(url)

Resolve assets from a base URL.

Parameters

url (str) – Location where a mesh was stored or directory where mesh was stored

get(name)

Get a resource from the remote site.

Parameters

name (str) – Asset name, i.e. ‘quadknot.obj.mtl’

class trimesh.resolvers.ZipResolver(archive)

Bases: trimesh.resolvers.Resolver

Resolve files inside a ZIP archive.

__init__(archive)

Resolve files inside a ZIP archive as loaded by trimesh.util.decompress

Parameters

archive (dict) – Contains resources as file object

get(name)

Get an asset from the ZIP archive.

Parameters

name (str) – Name of the asset

Returns

data – Loaded data from asset

Return type

bytes

trimesh.resolvers.nearby_names(name)

Try to find nearby variants of a specified name.

Parameters

name (str) – Initial name.

Yields

nearby (str) – Name that is a lightly permutated version of initial name.