From 06b8c3c984301c8ddd3590e68c67028f56a7f86b Mon Sep 17 00:00:00 2001 From: Zac Zhang Date: Fri, 15 Dec 2023 18:09:31 +0100 Subject: [PATCH 1/3] add code --- src/compas_view2/objects/textobject.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/compas_view2/objects/textobject.py b/src/compas_view2/objects/textobject.py index c263d678e..e487cc79f 100644 --- a/src/compas_view2/objects/textobject.py +++ b/src/compas_view2/objects/textobject.py @@ -87,9 +87,7 @@ def calculate_text_height(self, camera_position): if self._data.absolute_height: return int( (10 * self._data.height) - / np.linalg.norm( - np.array(self._data.position) - np.array([camera_position.x, camera_position.y, camera_position.z]) - ) + / np.linalg.norm(np.array(self._data.position) - np.array([camera_position.x, camera_position.y, camera_position.z])) ) else: @@ -109,3 +107,7 @@ def draw(self, shader, camera_position): shader.uniform1i("is_text", 0) shader.uniform1f("object_opacity", 1) shader.disable_attribute("position") + + def update(self): + super()._update_matrix() + self.init() From b121f4499ccd9bd170a6d55874cf386c567dc518 Mon Sep 17 00:00:00 2001 From: Zac Zhang Date: Fri, 15 Dec 2023 18:14:29 +0100 Subject: [PATCH 2/3] lint --- src/compas_view2/objects/textobject.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/compas_view2/objects/textobject.py b/src/compas_view2/objects/textobject.py index e487cc79f..4e50ebc44 100644 --- a/src/compas_view2/objects/textobject.py +++ b/src/compas_view2/objects/textobject.py @@ -1,13 +1,14 @@ import os -import numpy as np + import freetype as ft +import numpy as np +from matplotlib import font_manager from OpenGL import GL from compas_view2.gl import make_index_buffer from compas_view2.gl import make_vertex_buffer from .object import Object -from matplotlib import font_manager here = os.path.dirname(__file__) fonts = os.path.join(here, "..", "fonts") @@ -87,7 +88,9 @@ def calculate_text_height(self, camera_position): if self._data.absolute_height: return int( (10 * self._data.height) - / np.linalg.norm(np.array(self._data.position) - np.array([camera_position.x, camera_position.y, camera_position.z])) + / np.linalg.norm( + np.array(self._data.position) - np.array([camera_position.x, camera_position.y, camera_position.z]) + ) ) else: From 7df0e692a5b36a3caaceed1a872cb9f90cba6310 Mon Sep 17 00:00:00 2001 From: Zac Zhang Date: Fri, 15 Dec 2023 18:15:33 +0100 Subject: [PATCH 3/3] changelog --- CHANGELOG.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6d747c1e..d03cd931d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,26 +9,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +* Added the update method for the `textobject`. + ### Changed * Fix a bug when camera is looking straight up or down. ### Removed - ## [0.10.1] 2023-12-12 ### Added - ### Changed - ### Removed * Removed dependency on `cython`. - ## [0.10.0] 2023-11-27 ### Added