|
MaterialXMaterials 1.39.5
Utilities for retrieving materials from remote servers
|
Fetch MaterialX assets from PolyHaven API and download them. More...
Public Member Functions | |
| __init__ (self) | |
| Initialize the PolyHavenLoader with API endpoints and headers. | |
| fetch_materialx_assets (self, max_items=1, download_id=None) | |
| Fetch MaterialX assets from PolyHaven API and filter them by resolution. | |
| download_asset (self, asset_list, convert_exr_to_png=True) | |
| Download MaterialX asset and its textures from PolyHaven. | |
| save_materialx_with_textures (self, id, mtlx_string, texture_binaries, data_folder, extract_zip=False) | |
| Save MaterialX string and texture binaries to a zip file. | |
Public Attributes | |
| str | BASE_API = "https://api.polyhaven.com" |
| str | ASSET_API = "https://api.polyhaven.com/assets" |
| str | INFO_API = "https://api.polyhaven.com/info" |
| str | FILES_API = "https://api.polyhaven.com/files" |
| dict | HEADERS |
| logger = logging.getLogger('PolyH') | |
Fetch MaterialX assets from PolyHaven API and download them.
This class provides methods to fetch and download MaterialX assets and textures from PolyHaven.
Definition at line 22 of file polyHavenLoader.py.
| materialxMaterials.polyHavenLoader.PolyHavenLoader.__init__ | ( | self | ) |
Initialize the PolyHavenLoader with API endpoints and headers.
Definition at line 28 of file polyHavenLoader.py.
| materialxMaterials.polyHavenLoader.PolyHavenLoader.download_asset | ( | self, | |
| asset_list, | |||
| convert_exr_to_png = True ) |
Download MaterialX asset and its textures from PolyHaven.
| asset_list | Dictionary of MaterialX assets with URLs and texture files. |
| convert_exr_to_png | If True, attempt to use PNG images instead of EXR if available other attempt to convert using OpenImageIO if installed. Default is to use PNG if possible, and convert EXR to PNG if OpenImageIO is available. |
Definition at line 145 of file polyHavenLoader.py.
| materialxMaterials.polyHavenLoader.PolyHavenLoader.fetch_materialx_assets | ( | self, | |
| max_items = 1, | |||
| download_id = None ) |
Fetch MaterialX assets from PolyHaven API and filter them by resolution.
| max_items | Maximum number of assets to fetch. If None, fetch all. |
| download_id | If set, only fetch asset with this ID. |
Definition at line 43 of file polyHavenLoader.py.
| materialxMaterials.polyHavenLoader.PolyHavenLoader.save_materialx_with_textures | ( | self, | |
| id, | |||
| mtlx_string, | |||
| texture_binaries, | |||
| data_folder, | |||
| extract_zip = False ) |
Save MaterialX string and texture binaries to a zip file.
| id | The ID of the MaterialX asset. |
| mtlx_string | The MaterialX string content. |
| texture_binaries | List of tuples (path, binary content) for textures and thumbnails. |
| data_folder | Folder to save the zip file. |
| extract_zip | If True, extract the zip file after saving zip. |
Definition at line 269 of file polyHavenLoader.py.
| str materialxMaterials.polyHavenLoader.PolyHavenLoader.ASSET_API = "https://api.polyhaven.com/assets" |
Definition at line 33 of file polyHavenLoader.py.
| str materialxMaterials.polyHavenLoader.PolyHavenLoader.BASE_API = "https://api.polyhaven.com" |
Definition at line 32 of file polyHavenLoader.py.
| str materialxMaterials.polyHavenLoader.PolyHavenLoader.FILES_API = "https://api.polyhaven.com/files" |
Definition at line 35 of file polyHavenLoader.py.
| dict materialxMaterials.polyHavenLoader.PolyHavenLoader.HEADERS |
Definition at line 36 of file polyHavenLoader.py.
| str materialxMaterials.polyHavenLoader.PolyHavenLoader.INFO_API = "https://api.polyhaven.com/info" |
Definition at line 34 of file polyHavenLoader.py.
| materialxMaterials.polyHavenLoader.PolyHavenLoader.logger = logging.getLogger('PolyH') |
Definition at line 40 of file polyHavenLoader.py.