|
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, download_type=None) | |
| Fetch MaterialX assets from PolyHaven API and filter them by resolution. | |
| download_gltf_asset (self, asset_list) | |
| Download glTF asset from PolyHaven. | |
| download_blender_asset (self, asset_list) | |
| Download Blender asset from PolyHaven. | |
| download_mtlx_asset (self, asset_list, convert_exr_to_png=True) | |
| Download MaterialX asset and its textures from PolyHaven. | |
| save_blender_with_textures (self, id, blend_binary, texture_binaries, data_folder, extract_zip=False) | |
| Save Blender file and texture binaries to a zip file. | |
| save_gltf_with_textures (self, id, gltf_ascii, texture_binaries, data_folder, extract_zip=False) | |
| Save glTF file and texture binaries to a zip file. | |
| 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 |
| str | MTLX_KEY = 'mtlx' |
| str | GLTF_KEY = 'gltf' |
| str | BLEND_KEY = 'blend' |
| 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_blender_asset | ( | self, | |
| asset_list ) |
Download Blender asset from PolyHaven.
| asset_list | Dictionary of Blender assets with URLs and texture files. |
Definition at line 259 of file polyHavenLoader.py.
| materialxMaterials.polyHavenLoader.PolyHavenLoader.download_gltf_asset | ( | self, | |
| asset_list ) |
Download glTF asset from PolyHaven.
| asset_list | Dictionary of glTF assets with URLs and texture files. |
Definition at line 209 of file polyHavenLoader.py.
| materialxMaterials.polyHavenLoader.PolyHavenLoader.download_mtlx_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 302 of file polyHavenLoader.py.
| materialxMaterials.polyHavenLoader.PolyHavenLoader.fetch_materialx_assets | ( | self, | |
| max_items = 1, | |||
| download_id = None, | |||
| download_type = 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. |
| download_type | Type of asset to download (e.g. 'mtlx', 'blend', 'gltf'). Default is None which means to fetch MaterialX |
Definition at line 48 of file polyHavenLoader.py.
| materialxMaterials.polyHavenLoader.PolyHavenLoader.save_blender_with_textures | ( | self, | |
| id, | |||
| blend_binary, | |||
| texture_binaries, | |||
| data_folder, | |||
| extract_zip = False ) |
Save Blender file and texture binaries to a zip file.
| id | The ID of the Blender asset. |
| blend_binary | The Blender file as binary 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 426 of file polyHavenLoader.py.
| materialxMaterials.polyHavenLoader.PolyHavenLoader.save_gltf_with_textures | ( | self, | |
| id, | |||
| gltf_ascii, | |||
| texture_binaries, | |||
| data_folder, | |||
| extract_zip = False ) |
Save glTF file and texture binaries to a zip file.
| id | The ID of the glTF asset. |
| gltf_ascii | The glTF file as ASCII string. |
| 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 455 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 484 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.BLEND_KEY = 'blend' |
Definition at line 43 of file polyHavenLoader.py.
| str materialxMaterials.polyHavenLoader.PolyHavenLoader.FILES_API = "https://api.polyhaven.com/files" |
Definition at line 35 of file polyHavenLoader.py.
| str materialxMaterials.polyHavenLoader.PolyHavenLoader.GLTF_KEY = 'gltf' |
Definition at line 42 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 45 of file polyHavenLoader.py.
| str materialxMaterials.polyHavenLoader.PolyHavenLoader.MTLX_KEY = 'mtlx' |
Definition at line 41 of file polyHavenLoader.py.