Skip to content

Commit

Permalink
fix(camera): don't try to access renderer if it's undefined (#1674)
Browse files Browse the repository at this point in the history
  • Loading branch information
IbrahimCSAE authored Dec 4, 2024
1 parent 010ff3c commit 6d03b17
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/core/src/RenderingEngine/Viewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,11 @@ class Viewport {
protected getVtkActiveCamera(): vtkCamera | vtkSlabCamera {
const renderer = this.getRenderer();

if (!renderer) {
console.warn('No renderer found for the viewport');
return null;
}

return renderer.getActiveCamera();
}

Expand Down
6 changes: 6 additions & 0 deletions packages/core/src/RenderingEngine/VolumeViewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ class VolumeViewport extends BaseVolumeViewport {

protected setCameraClippingRange() {
const activeCamera = this.getVtkActiveCamera();

if (!activeCamera) {
console.warn('No active camera found');
return;
}

if (activeCamera.getParallelProjection()) {
// which makes more sense. However, in situations like MPR where the camera is
// oblique, the slab thickness might not be sufficient.
Expand Down

0 comments on commit 6d03b17

Please sign in to comment.