diff --git a/src/compas_viewer/renderer/renderer.py b/src/compas_viewer/renderer/renderer.py index 5dcc4a56b8..31fd32b386 100644 --- a/src/compas_viewer/renderer/renderer.py +++ b/src/compas_viewer/renderer/renderer.py @@ -574,7 +574,7 @@ def paint(self): viewworld = self.camera.viewworld() self.update_projection() # Object categorization - tag_objs, vector_objs, mesh_objs = self.sort_objects_from_category((obj for obj in self.viewer.scene.objects if obj.show)) + tag_objs, vector_objs, mesh_objs = self.sort_objects_from_category(self.viewer.scene.visiable_objects) # Draw model objects in the scene self.shader_model.bind() diff --git a/src/compas_viewer/scene/scene.py b/src/compas_viewer/scene/scene.py index 1d40140356..aef03192cf 100644 --- a/src/compas_viewer/scene/scene.py +++ b/src/compas_viewer/scene/scene.py @@ -67,13 +67,19 @@ class ViewerScene(Scene): def __init__(self, name: str = "ViewerScene", context: str = "Viewer"): super().__init__(name=name, context=context) - - # Primitive - self.objects: list[ViewerSceneObject] - # Selection self.instance_colors: dict[tuple[int, int, int], ViewerSceneObject] = {} self._instance_colors_generator = instance_colors_generator() + @property + def visiable_objects(self) -> list[ViewerSceneObject]: + def traverse(obj): + for child in obj.children: + if child.show: + yield child + yield from traverse(child) + + return traverse(self.root) + @property def viewer(self): from compas_viewer import Viewer