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.

Classes:

FilePathResolver(source)

Resolve files from a source path on the file system.

Resolver(*args, **kwargs)

The base class for resolvers.

WebResolver(url)

Resolve assets from a remote URL.

ZipResolver(archive)

Resolve files inside a ZIP archive.

Functions:

nearby_names(name)

Try to find nearby variants of a specified name.

urljoin(base, url[, allow_fragments])

Join a base URL and a possibly relative URL to form an absolute interpretation of the latter.

urlparse(url[, scheme, allow_fragments])

Parse a URL into 6 components: <scheme>://<netloc>/<path>;<params>?<query>#<fragment> Return a 6-tuple: (scheme, netloc, path, params, query, fragment).

class trimesh.resolvers.FilePathResolver(source)

Bases: trimesh.resolvers.Resolver

Resolve files from a source path on the file system.

Methods:

get(name)

Get an asset.

write(name, data)

Write an asset to a file path.

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.

Methods:

write(name, data)

write(name, data)
class trimesh.resolvers.WebResolver(url)

Bases: trimesh.resolvers.Resolver

Resolve assets from a remote URL.

Methods:

get(name)

Get a resource from the remote site.

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.

Methods:

get(name)

Get an asset from the ZIP archive.

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.