diff --git a/CHANGELOG.md b/CHANGELOG.md index 9614101..6989143 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +* Changed `compas_notebook.scene.ThreeBrepObject` to be compatible with `compas>=2.4`. +* Changed `compas_notebook.scene.ThreeMeshObject` to be compatible with `compas>=2.4`. + ### Removed diff --git a/requirements.txt b/requirements.txt index b6955e3..f75fa8a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -compas >= 2.1 +compas >= 2.4 jupyter pythreejs diff --git a/src/compas_notebook/scene/brepobject.py b/src/compas_notebook/scene/brepobject.py index cdd2561..8da529c 100644 --- a/src/compas_notebook/scene/brepobject.py +++ b/src/compas_notebook/scene/brepobject.py @@ -12,9 +12,7 @@ class ThreeBrepObject(ThreeSceneObject, GeometryObject): """Scene object for drawing a Brep.""" - def __init__(self, item: Brep, *args: Any, **kwargs: Any): - super().__init__(geometry=item, *args, **kwargs) - self.brep = item + geometry: Brep def draw(self): """Draw the Brep associated with the scene object. @@ -25,7 +23,7 @@ def draw(self): List of pythreejs objects created. """ - mesh, polylines = self.brep.to_viewmesh() + mesh, polylines = self.geometry.to_viewmesh() vertices, faces = mesh.to_vertices_and_faces() geometry = vertices_and_faces_to_threejs(vertices, faces) diff --git a/src/compas_notebook/scene/meshobject.py b/src/compas_notebook/scene/meshobject.py index 8160642..e84daa3 100644 --- a/src/compas_notebook/scene/meshobject.py +++ b/src/compas_notebook/scene/meshobject.py @@ -43,7 +43,7 @@ def draw(self): return self.guids def draw_vertices(self, vertices, color): - positions = [self.vertex_xyz[vertex] for vertex in vertices] + positions = [self.mesh.vertex_coordinates(vertex) for vertex in vertices] positions = numpy.array(positions, dtype=numpy.float32) colors = [color[i] for i in range(len(vertices))] colors = numpy.array(colors, dtype=numpy.float32) @@ -65,8 +65,8 @@ def draw_edges(self, edges, color): colors = [] for u, v in edges: - positions.append(self.vertex_xyz[u]) - positions.append(self.vertex_xyz[v]) + positions.append(self.mesh.vertex_coordinates(u)) + positions.append(self.mesh.vertex_coordinates(v)) colors.append(color[u, v]) colors.append(color[u, v]) @@ -91,32 +91,32 @@ def draw_faces(self, faces, color): c = color[face] if len(vertices) == 3: - positions.append(self.vertex_xyz[vertices[0]]) - positions.append(self.vertex_xyz[vertices[1]]) - positions.append(self.vertex_xyz[vertices[2]]) + positions.append(self.mesh.vertex_coordinates(vertices[0])) + positions.append(self.mesh.vertex_coordinates(vertices[1])) + positions.append(self.mesh.vertex_coordinates(vertices[2])) colors.append(c) colors.append(c) colors.append(c) elif len(vertices) == 4: - positions.append(self.vertex_xyz[vertices[0]]) - positions.append(self.vertex_xyz[vertices[1]]) - positions.append(self.vertex_xyz[vertices[2]]) + positions.append(self.mesh.vertex_coordinates(vertices[0])) + positions.append(self.mesh.vertex_coordinates(vertices[1])) + positions.append(self.mesh.vertex_coordinates(vertices[2])) colors.append(c) colors.append(c) colors.append(c) - positions.append(self.vertex_xyz[vertices[0]]) - positions.append(self.vertex_xyz[vertices[2]]) - positions.append(self.vertex_xyz[vertices[3]]) + positions.append(self.mesh.vertex_coordinates(vertices[0])) + positions.append(self.mesh.vertex_coordinates(vertices[2])) + positions.append(self.mesh.vertex_coordinates(vertices[3])) colors.append(c) colors.append(c) colors.append(c) else: - polygon = Polygon([self.vertex_xyz[v] for v in vertices]) + polygon = Polygon([self.mesh.vertex_coordinates(v) for v in vertices]) ears = earclip_polygon(polygon) for ear in ears: - positions.append(self.vertex_xyz[vertices[ear[0]]]) - positions.append(self.vertex_xyz[vertices[ear[1]]]) - positions.append(self.vertex_xyz[vertices[ear[2]]]) + positions.append(self.mesh.vertex_coordinates(vertices[ear[0]])) + positions.append(self.mesh.vertex_coordinates(vertices[ear[1]])) + positions.append(self.mesh.vertex_coordinates(vertices[ear[2]])) colors.append(c) colors.append(c) colors.append(c)