-
Notifications
You must be signed in to change notification settings - Fork 428
Description
Describe the Bug
When Cornerstone is using CPU rendering and a StackViewport is used, calling .setDisplayArea
throws an error and the viewport is not updated.
The error thrown is:
StackViewport.js:812 Uncaught TypeError: Cannot destructure property 'focalPoint' of 'cameraInterface' as it is undefined.
at StackViewport.setCameraCPU (StackViewport.js:812:17)
at StackViewport.setDisplayArea (Viewport.js:391:14)
at initializeCornerstone (cornerstoneUtils.js:61:12)
at async cs-cpu.js:5:18
A reproduction repository is available here https://github.com/jmannau/cs-cpu-bug
In this Repo are 2 examples, c3d-gpu.html
which is the default using GPU/WebGL rendering and c3d-cpu.html
where CPU rendering is enabled.
When viewing c3d-gpu.html
the image is loaded correctly and resized/repositioned correctly.

When viewing c3d-cpu.html
the image is loaded, but not resized/repositioned as an error is thrown.\

Steps to Reproduce
- Initialise Cornerstone with CPU rendering
- Create a StackViewport
- Load a image stack
- Call
.setDisplayArea
to resize/reposition the image in the viewport.
The issue appears to be here
this.setCamera(this.fitToCanvasCamera); |
where fitToCanvasCamera
is undefined for CPU Viewports.
From the look of it. .setFitToCanvasCamera
is called in Viewport resetCamera
this.setFitToCanvasCamera(this.getCamera()); |
resetCamera
and resetCameraCPU
private resetCameraCPU({ |
fitToCanvasCamera
The current behavior
When using CPU rendering, it is not possible to resize the viewport using .setDisplayArea
The expected behavior
CPU rendering should match GPU rendering and .setDisplayArea
should not throw.
System Information
System:
OS: macOS 15.6.1
CPU: (14) arm64 Apple M4 Max
Memory: 572.66 MB / 36.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.18.0 - ~/.n/bin/node
Yarn: 1.22.22 - ~/.n/bin/yarn
npm: 10.9.3 - ~/.n/bin/npm
bun: 1.1.38 - /opt/homebrew/bin/bun
Browsers:
Brave Browser: 140.1.82.170
Chrome: 140.0.7339.185
Safari: 18.6