Skip to content

Commit 3595b5b

Browse files
committed
update to compas 2.4
1 parent 91a1856 commit 3595b5b

File tree

4 files changed

+22
-21
lines changed

4 files changed

+22
-21
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
### Changed
1313

14+
* Changed `compas_notebook.scene.ThreeBrepObject` to be compatible with `compas>=2.4`.
15+
* Changed `compas_notebook.scene.ThreeMeshObject` to be compatible with `compas>=2.4`.
16+
1417
### Removed
1518

1619

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
compas >= 2.1
1+
compas >= 2.4
22
jupyter
33
pythreejs

src/compas_notebook/scene/brepobject.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
class ThreeBrepObject(ThreeSceneObject, GeometryObject):
1313
"""Scene object for drawing a Brep."""
1414

15-
def __init__(self, item: Brep, *args: Any, **kwargs: Any):
16-
super().__init__(geometry=item, *args, **kwargs)
17-
self.brep = item
15+
geometry: Brep
1816

1917
def draw(self):
2018
"""Draw the Brep associated with the scene object.
@@ -25,7 +23,7 @@ def draw(self):
2523
List of pythreejs objects created.
2624
2725
"""
28-
mesh, polylines = self.brep.to_viewmesh()
26+
mesh, polylines = self.geometry.to_viewmesh()
2927
vertices, faces = mesh.to_vertices_and_faces()
3028

3129
geometry = vertices_and_faces_to_threejs(vertices, faces)

src/compas_notebook/scene/meshobject.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def draw(self):
4343
return self.guids
4444

4545
def draw_vertices(self, vertices, color):
46-
positions = [self.vertex_xyz[vertex] for vertex in vertices]
46+
positions = [self.mesh.vertex_coordinates(vertex) for vertex in vertices]
4747
positions = numpy.array(positions, dtype=numpy.float32)
4848
colors = [color[i] for i in range(len(vertices))]
4949
colors = numpy.array(colors, dtype=numpy.float32)
@@ -65,8 +65,8 @@ def draw_edges(self, edges, color):
6565
colors = []
6666

6767
for u, v in edges:
68-
positions.append(self.vertex_xyz[u])
69-
positions.append(self.vertex_xyz[v])
68+
positions.append(self.mesh.vertex_coordinates(u))
69+
positions.append(self.mesh.vertex_coordinates(v))
7070
colors.append(color[u, v])
7171
colors.append(color[u, v])
7272

@@ -91,32 +91,32 @@ def draw_faces(self, faces, color):
9191
c = color[face]
9292

9393
if len(vertices) == 3:
94-
positions.append(self.vertex_xyz[vertices[0]])
95-
positions.append(self.vertex_xyz[vertices[1]])
96-
positions.append(self.vertex_xyz[vertices[2]])
94+
positions.append(self.mesh.vertex_coordinates(vertices[0]))
95+
positions.append(self.mesh.vertex_coordinates(vertices[1]))
96+
positions.append(self.mesh.vertex_coordinates(vertices[2]))
9797
colors.append(c)
9898
colors.append(c)
9999
colors.append(c)
100100
elif len(vertices) == 4:
101-
positions.append(self.vertex_xyz[vertices[0]])
102-
positions.append(self.vertex_xyz[vertices[1]])
103-
positions.append(self.vertex_xyz[vertices[2]])
101+
positions.append(self.mesh.vertex_coordinates(vertices[0]))
102+
positions.append(self.mesh.vertex_coordinates(vertices[1]))
103+
positions.append(self.mesh.vertex_coordinates(vertices[2]))
104104
colors.append(c)
105105
colors.append(c)
106106
colors.append(c)
107-
positions.append(self.vertex_xyz[vertices[0]])
108-
positions.append(self.vertex_xyz[vertices[2]])
109-
positions.append(self.vertex_xyz[vertices[3]])
107+
positions.append(self.mesh.vertex_coordinates(vertices[0]))
108+
positions.append(self.mesh.vertex_coordinates(vertices[2]))
109+
positions.append(self.mesh.vertex_coordinates(vertices[3]))
110110
colors.append(c)
111111
colors.append(c)
112112
colors.append(c)
113113
else:
114-
polygon = Polygon([self.vertex_xyz[v] for v in vertices])
114+
polygon = Polygon([self.mesh.vertex_coordinates(v) for v in vertices])
115115
ears = earclip_polygon(polygon)
116116
for ear in ears:
117-
positions.append(self.vertex_xyz[vertices[ear[0]]])
118-
positions.append(self.vertex_xyz[vertices[ear[1]]])
119-
positions.append(self.vertex_xyz[vertices[ear[2]]])
117+
positions.append(self.mesh.vertex_coordinates(vertices[ear[0]]))
118+
positions.append(self.mesh.vertex_coordinates(vertices[ear[1]]))
119+
positions.append(self.mesh.vertex_coordinates(vertices[ear[2]]))
120120
colors.append(c)
121121
colors.append(c)
122122
colors.append(c)

0 commit comments

Comments
 (0)