Skip to content

Commit 0cfa55c

Browse files
committed
show buffer geo points if there are any
1 parent 6a7a3f5 commit 0cfa55c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/compas_viewer/scene/bufferobject.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,33 +112,47 @@ class BufferObject(ViewerSceneObject):
112112
113113
"""
114114

115+
def __init__(self, *args, show_points: bool = True, show_lines: bool = True, show_faces: bool = True, **kwargs):
116+
super().__init__(*args, **kwargs)
117+
self.show_points = show_points if show_points is not None else self.buffergeometry.points is not None
118+
self.show_lines = show_lines if show_lines is not None else self.buffergeometry.lines is not None
119+
self.show_faces = show_faces if show_faces is not None else self.buffergeometry.faces is not None
120+
115121
@property
116122
def buffergeometry(self) -> BufferGeometry:
117123
return self.item
118124

119125
def _read_points_data(self):
120126
"""Read points data from the object."""
127+
if self.buffergeometry.points is None:
128+
return None
121129
positions = self.buffergeometry.points
122130
colors = self.buffergeometry.pointcolor
123131
elements = np.arange(positions.shape[0] // 3, dtype=int)
124132
return positions, colors, elements
125133

126134
def _read_lines_data(self):
127135
"""Read lines data from the object."""
136+
if self.buffergeometry.lines is None:
137+
return None
128138
positions = self.buffergeometry.lines
129139
colors = self.buffergeometry.linecolor
130140
elements = np.arange(positions.shape[0] // 3, dtype=int)
131141
return positions, colors, elements
132142

133143
def _read_frontfaces_data(self):
134144
"""Read frontfaces data from the object."""
145+
if self.buffergeometry.faces is None:
146+
return None
135147
positions = self.buffergeometry.faces
136148
colors = self.buffergeometry.facecolor
137149
elements = np.arange(positions.shape[0] // 3, dtype=int)
138150
return positions, colors, elements
139151

140152
def _read_backfaces_data(self):
141153
"""Read backfaces data from the object."""
154+
if self.buffergeometry.faces is None:
155+
return None
142156
positions = self.buffergeometry.faces
143157
colors = self.buffergeometry.facecolor
144158
elements = np.flip(np.arange(positions.shape[0] // 3, dtype=int))

0 commit comments

Comments
 (0)