MaterialXMaterials 0.0.3
Utilities for retrieving materials from remote servers
|
A class to 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) | |
Download MaterialX asset and its textures from PolyHaven. | |
save_materialx_with_textures (self, id, mtlx_string, texture_binaries, data_folder) | |
' 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') | |
A class to fetch MaterialX assets from PolyHaven API and download them.
Definition at line 12 of file polyHavenLoader.py.
materialxMaterials.polyHavenLoader.PolyHavenLoader.__init__ | ( | self | ) |
Initialize the PolyHavenLoader with API endpoints and headers.
Definition at line 16 of file polyHavenLoader.py.
materialxMaterials.polyHavenLoader.PolyHavenLoader.download_asset | ( | self, | |
asset_list ) |
Download MaterialX asset and its textures from PolyHaven.
e.g. asset_list = {'polystyrene': {'url': 'https://.../polystyrene.mtlx', 'texture_files': {...}}}
asset_list | A dictionary of MaterialX assets with their URLs and texture files. |
Definition at line 128 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.
resolution | The resolution of the MaterialX assets to fetch (e.g. "1k", "2k", "4k", "8k"). |
Definition at line 31 of file polyHavenLoader.py.
materialxMaterials.polyHavenLoader.PolyHavenLoader.save_materialx_with_textures | ( | self, | |
id, | |||
mtlx_string, | |||
texture_binaries, | |||
data_folder ) |
' 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 | A list of tuples containing texture file paths and their binary content. |
data_folder | The folder to save the zip file. |
Definition at line 176 of file polyHavenLoader.py.
str materialxMaterials.polyHavenLoader.PolyHavenLoader.ASSET_API = "https://api.polyhaven.com/assets" |
Definition at line 21 of file polyHavenLoader.py.
str materialxMaterials.polyHavenLoader.PolyHavenLoader.BASE_API = "https://api.polyhaven.com" |
Definition at line 20 of file polyHavenLoader.py.
str materialxMaterials.polyHavenLoader.PolyHavenLoader.FILES_API = "https://api.polyhaven.com/files" |
Definition at line 23 of file polyHavenLoader.py.
dict materialxMaterials.polyHavenLoader.PolyHavenLoader.HEADERS |
Definition at line 24 of file polyHavenLoader.py.
str materialxMaterials.polyHavenLoader.PolyHavenLoader.INFO_API = "https://api.polyhaven.com/info" |
Definition at line 22 of file polyHavenLoader.py.
materialxMaterials.polyHavenLoader.PolyHavenLoader.logger = logging.getLogger('PolyH') |
Definition at line 28 of file polyHavenLoader.py.