Allow browsing group_hdri nodes.
Nodes of type 'hdri' don't work well yet.
This commit is contained in:
parent
f6d05c4c84
commit
70a0aba10a
@ -17,6 +17,7 @@ from pillarsdk.utils import sanitize_filename
|
|||||||
from . import cache
|
from . import cache
|
||||||
|
|
||||||
SUBCLIENT_ID = 'PILLAR'
|
SUBCLIENT_ID = 'PILLAR'
|
||||||
|
TEXTURE_NODE_TYPES = {'texture', 'hdri'}
|
||||||
|
|
||||||
_pillar_api = {} # will become a mapping from bool (cached/non-cached) to pillarsdk.Api objects.
|
_pillar_api = {} # will become a mapping from bool (cached/non-cached) to pillarsdk.Api objects.
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -294,7 +295,8 @@ async def get_nodes(project_uuid: str = None, parent_node_uuid: str = None,
|
|||||||
if isinstance(node_type, str):
|
if isinstance(node_type, str):
|
||||||
where['node_type'] = node_type
|
where['node_type'] = node_type
|
||||||
else:
|
else:
|
||||||
where['node_type'] = {'$in': node_type}
|
# Convert set & tuple to list
|
||||||
|
where['node_type'] = {'$in': list(node_type)}
|
||||||
|
|
||||||
params = {'projection': {'name': 1, 'parent': 1, 'node_type': 1, 'properties.order': 1,
|
params = {'projection': {'name': 1, 'parent': 1, 'node_type': 1, 'properties.order': 1,
|
||||||
'properties.status': 1, 'properties.files': 1,
|
'properties.status': 1, 'properties.files': 1,
|
||||||
@ -478,7 +480,7 @@ async def fetch_texture_thumbs(parent_node_uuid: str, desired_size: str,
|
|||||||
# Download all texture nodes in parallel.
|
# Download all texture nodes in parallel.
|
||||||
log.debug('Getting child nodes of node %r', parent_node_uuid)
|
log.debug('Getting child nodes of node %r', parent_node_uuid)
|
||||||
texture_nodes = await get_nodes(parent_node_uuid=parent_node_uuid,
|
texture_nodes = await get_nodes(parent_node_uuid=parent_node_uuid,
|
||||||
node_type='texture')
|
node_type=TEXTURE_NODE_TYPES)
|
||||||
|
|
||||||
if is_cancelled(future):
|
if is_cancelled(future):
|
||||||
log.warning('fetch_texture_thumbs: Texture downloading cancelled')
|
log.warning('fetch_texture_thumbs: Texture downloading cancelled')
|
||||||
@ -504,7 +506,7 @@ async def download_texture_thumbnail(texture_node, desired_size: str,
|
|||||||
thumbnail_loaded: callable,
|
thumbnail_loaded: callable,
|
||||||
future: asyncio.Future = None):
|
future: asyncio.Future = None):
|
||||||
# Skip non-texture nodes, as we can't thumbnail them anyway.
|
# Skip non-texture nodes, as we can't thumbnail them anyway.
|
||||||
if texture_node['node_type'] != 'texture':
|
if texture_node['node_type'] not in TEXTURE_NODE_TYPES:
|
||||||
return
|
return
|
||||||
|
|
||||||
if is_cancelled(future):
|
if is_cancelled(future):
|
||||||
@ -616,8 +618,9 @@ async def download_texture(texture_node,
|
|||||||
texture_loading: callable,
|
texture_loading: callable,
|
||||||
texture_loaded: callable,
|
texture_loaded: callable,
|
||||||
future: asyncio.Future):
|
future: asyncio.Future):
|
||||||
if texture_node['node_type'] != 'texture':
|
if texture_node['node_type'] not in TEXTURE_NODE_TYPES:
|
||||||
raise TypeError("Node type should be 'texture', not %r" % texture_node['node_type'])
|
raise TypeError("Node type should be in %r, not %r" %
|
||||||
|
(TEXTURE_NODE_TYPES, texture_node['node_type']))
|
||||||
|
|
||||||
# Download every file. Eve doesn't support embedding from a list-of-dicts.
|
# Download every file. Eve doesn't support embedding from a list-of-dicts.
|
||||||
downloaders = (download_file_by_uuid(file_info['file'],
|
downloaders = (download_file_by_uuid(file_info['file'],
|
||||||
|
@ -81,7 +81,8 @@ class MenuItem:
|
|||||||
'SPINNER': os.path.join(library_icons_path, 'spinner.png'),
|
'SPINNER': os.path.join(library_icons_path, 'spinner.png'),
|
||||||
}
|
}
|
||||||
|
|
||||||
SUPPORTED_NODE_TYPES = {'UP', 'PROJECT', 'group_texture', 'texture'}
|
FOLDER_NODE_TYPES = {'group_texture', 'group_hdri'}
|
||||||
|
SUPPORTED_NODE_TYPES = {'UP', 'PROJECT', 'texture', 'hdri'}.union(FOLDER_NODE_TYPES)
|
||||||
|
|
||||||
def __init__(self, node, file_desc, thumb_path: str, label_text):
|
def __init__(self, node, file_desc, thumb_path: str, label_text):
|
||||||
self.log = logging.getLogger('%s.MenuItem' % __name__)
|
self.log = logging.getLogger('%s.MenuItem' % __name__)
|
||||||
@ -97,7 +98,7 @@ class MenuItem:
|
|||||||
self.label_text = label_text
|
self.label_text = label_text
|
||||||
self._thumb_path = ''
|
self._thumb_path = ''
|
||||||
self.icon = None
|
self.icon = None
|
||||||
self._is_folder = (node['node_type'] == 'group_texture' or
|
self._is_folder = (node['node_type'] in self.FOLDER_NODE_TYPES or
|
||||||
isinstance(node, SpecialFolderNode))
|
isinstance(node, SpecialFolderNode))
|
||||||
|
|
||||||
# Determine sorting order.
|
# Determine sorting order.
|
||||||
@ -479,13 +480,13 @@ class BlenderCloudBrowser(pillar.PillarOperatorMixin,
|
|||||||
# Query for sub-nodes of this node.
|
# Query for sub-nodes of this node.
|
||||||
self.log.debug('Getting subnodes for parent node %r', node_uuid)
|
self.log.debug('Getting subnodes for parent node %r', node_uuid)
|
||||||
children = await pillar.get_nodes(parent_node_uuid=node_uuid,
|
children = await pillar.get_nodes(parent_node_uuid=node_uuid,
|
||||||
node_type='group_texture')
|
node_type={'group_texture', 'group_hdri'})
|
||||||
elif project_uuid:
|
elif project_uuid:
|
||||||
# Query for top-level nodes.
|
# Query for top-level nodes.
|
||||||
self.log.debug('Getting subnodes for project node %r', project_uuid)
|
self.log.debug('Getting subnodes for project node %r', project_uuid)
|
||||||
children = await pillar.get_nodes(project_uuid=project_uuid,
|
children = await pillar.get_nodes(project_uuid=project_uuid,
|
||||||
parent_node_uuid='',
|
parent_node_uuid='',
|
||||||
node_type='group_texture')
|
node_type={'group_texture', 'group_hdri'})
|
||||||
else:
|
else:
|
||||||
# Query for projects
|
# Query for projects
|
||||||
self.log.debug('No node UUID and no project UUID, listing available projects')
|
self.log.debug('No node UUID and no project UUID, listing available projects')
|
||||||
|
Reference in New Issue
Block a user