Skip to content

Commit 85fc190

Browse files
committed
fix list bugs
1 parent e666240 commit 85fc190

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/compas_viewer/scene/buffermanager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def _add_buffer_data(self, obj: Any, buffer_type: str) -> None:
115115

116116
# Convert to numpy arrays
117117
pos_array = np.array(positions, dtype=np.float32).flatten()
118-
col_array = np.array([c.rgba for c in colors] if isinstance(colors[0], Color) else colors, dtype=np.float32).flatten()
118+
col_array = np.array([c.rgba for c in colors] if len(colors) > 0 and isinstance(colors[0], Color) else colors, dtype=np.float32).flatten()
119119
elem_array = np.array(elements, dtype=np.int32).flatten()
120120

121121
if buffer_type == "_frontfaces_data" or buffer_type == "_backfaces_data":

src/compas_viewer/scene/sceneobject.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,11 @@ def _update_bounding_box(self, positions: Optional[list[Point]] = None):
183183
"""Update the bounding box of the object"""
184184
if positions is None:
185185
positions = np.array([]).reshape(0, 3)
186-
if self._points_data is not None:
186+
if self._points_data is not None and len(self._points_data[0]) > 0:
187187
positions = np.vstack([positions, self._points_data[0]])
188-
if self._lines_data is not None:
188+
if self._lines_data is not None and len(self._lines_data[0]) > 0:
189189
positions = np.vstack([positions, self._lines_data[0]])
190-
if self._frontfaces_data is not None:
190+
if self._frontfaces_data is not None and len(self._frontfaces_data[0]) > 0:
191191
positions = np.vstack([positions, self._frontfaces_data[0]])
192192
if len(positions) == 0:
193193
return

0 commit comments

Comments
 (0)