fix: Fix potential divide by 0 in Viewport.resetCamera
getExtent returns array indices, not dimensions. This fixes a division by zero when displaying 1x1 pixel images.
Context
Displaying 1x1 pixel images fails
Changes & Results
Viewport.resetCamera computes widths/heights using VTK's getExtent function, but that function return indices, not dimensions. This PR fixes the computation to correct the off-by-one error.
Testing
Checklist
PR
- [x] My Pull Request title is descriptive, accurate and follows the semantic-release format and guidelines.
Code
- [x] My code has been well-documented (function documentation, inline comments, etc.)
Public Documentation Updates
- [ ] The documentation page has been updated as necessary for any public API additions or removals.
Tested Environment
- [x] OS: macOS
- [x] Node version: 22
- [x] Browser: Firefox 146
Do you have a 1x1 pixel image that we can test this with?
Do you have a 1x1 pixel image that we can test this with?
In our case it's a placeholder image that is generated (basically we build the pixel data by hand and have a custom loader). I did generate one using The Gimp though, attaching it here.