mirror of
https://github.com/yeicor-3d/yet-another-cad-viewer.git
synced 2025-12-19 22:24:17 +01:00
Support selecting base texture
This commit is contained in:
@@ -21,9 +21,13 @@ def tessellate(
|
|||||||
edges: bool = True,
|
edges: bool = True,
|
||||||
vertices: bool = True,
|
vertices: bool = True,
|
||||||
obj_color: Optional[ColorTuple] = None,
|
obj_color: Optional[ColorTuple] = None,
|
||||||
|
base_texture: Optional[Tuple[bytes, str]] = None,
|
||||||
) -> GLTF2:
|
) -> GLTF2:
|
||||||
"""Tessellate a whole shape into a list of triangle vertices and a list of triangle indices."""
|
"""Tessellate a whole shape into a list of triangle vertices and a list of triangle indices."""
|
||||||
mgr = GLTFMgr()
|
if base_texture is None:
|
||||||
|
mgr = GLTFMgr()
|
||||||
|
else:
|
||||||
|
mgr = GLTFMgr(base_texture)
|
||||||
|
|
||||||
if isinstance(cad_like, TopLoc_Location):
|
if isinstance(cad_like, TopLoc_Location):
|
||||||
mgr.add_location(Location(cad_like))
|
mgr.add_location(Location(cad_like))
|
||||||
|
|||||||
@@ -92,6 +92,10 @@ class YACV:
|
|||||||
frontend_lock: RWLock
|
frontend_lock: RWLock
|
||||||
"""Lock to ensure that the frontend has finished working before we shut down"""
|
"""Lock to ensure that the frontend has finished working before we shut down"""
|
||||||
|
|
||||||
|
base_texture: Optional[Tuple[bytes, str]]
|
||||||
|
"""Base texture to use for model rendering, in (data, mimetype) format
|
||||||
|
If set to None, will use default checkerboard texture"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.server_thread = None
|
self.server_thread = None
|
||||||
self.server = None
|
self.server = None
|
||||||
@@ -283,7 +287,8 @@ class YACV:
|
|||||||
faces=event.kwargs.get('faces', True),
|
faces=event.kwargs.get('faces', True),
|
||||||
edges=event.kwargs.get('edges', True),
|
edges=event.kwargs.get('edges', True),
|
||||||
vertices=event.kwargs.get('vertices', True),
|
vertices=event.kwargs.get('vertices', True),
|
||||||
obj_color=event.color)
|
obj_color=event.color,
|
||||||
|
base_texture=self.base_texture)
|
||||||
glb_list_of_bytes = gltf.save_to_bytes()
|
glb_list_of_bytes = gltf.save_to_bytes()
|
||||||
glb_bytes = b''.join(glb_list_of_bytes)
|
glb_bytes = b''.join(glb_list_of_bytes)
|
||||||
publish_to.publish(glb_bytes)
|
publish_to.publish(glb_bytes)
|
||||||
|
|||||||
Reference in New Issue
Block a user