fix: update pygfx integration for current API

- Use rendercanvas.qt.RenderCanvas instead of wgpu.gui.qt.WgpuCanvas
- Fix camera position API: use camera.local.position instead of camera.position.set()
- Fix light position API: use light.local.position
- Fix PygfxRenderObject to properly inherit from RenderObject
- Change add_mesh/add_wireframe/add_points/add_grid/add_axes to return string ID
- Update base Renderer class to return str instead of RenderObject
- Add custom compute_normals() function for mesh normals
This commit is contained in:
bklronin
2026-03-14 09:06:38 +01:00
parent d7ebbf45d5
commit d52106a48a
2 changed files with 73 additions and 49 deletions
+12 -12
View File
@@ -97,7 +97,7 @@ class Renderer(ABC):
faces: np.ndarray,
color: Tuple[float, float, float] = (0.2, 0.4, 0.8),
name: Optional[str] = None,
) -> RenderObject:
) -> str:
"""
Add a mesh to the scene.
@@ -108,7 +108,7 @@ class Renderer(ABC):
name: Optional name for the object
Returns:
RenderObject representing the mesh
String ID of the mesh
"""
pass
@@ -120,7 +120,7 @@ class Renderer(ABC):
color: Tuple[float, float, float] = (1.0, 1.0, 1.0),
line_width: float = 1.0,
name: Optional[str] = None,
) -> RenderObject:
) -> str:
"""
Add a wireframe to the scene.
@@ -132,7 +132,7 @@ class Renderer(ABC):
name: Optional name for the object
Returns:
RenderObject representing the wireframe
String ID of the wireframe
"""
pass
@@ -143,7 +143,7 @@ class Renderer(ABC):
color: Tuple[float, float, float] = (1.0, 0.0, 0.0),
size: float = 5.0,
name: Optional[str] = None,
) -> RenderObject:
) -> str:
"""
Add points to the scene.
@@ -154,7 +154,7 @@ class Renderer(ABC):
name: Optional name for the object
Returns:
RenderObject representing the points
String ID of the points
"""
pass
@@ -166,7 +166,7 @@ class Renderer(ABC):
color: Tuple[float, float, float] = (1.0, 1.0, 1.0),
line_width: float = 1.0,
name: Optional[str] = None,
) -> RenderObject:
) -> str:
"""
Add line segments to the scene.
@@ -178,7 +178,7 @@ class Renderer(ABC):
name: Optional name for the object
Returns:
RenderObject representing the lines
String ID of the lines
"""
pass
@@ -312,13 +312,13 @@ class Renderer(ABC):
size: float = 100.0,
divisions: int = 10,
color: Tuple[float, float, float] = (0.3, 0.3, 0.3),
) -> RenderObject:
"""Add a reference grid."""
) -> str:
"""Add a reference grid. Returns the grid ID."""
pass
@abstractmethod
def add_axes(self, size: float = 10.0, visible: bool = True) -> RenderObject:
"""Add coordinate axes."""
def add_axes(self, size: float = 10.0, visible: bool = True) -> str:
"""Add coordinate axes. Returns the axes ID."""
pass
@abstractmethod