fix(viewport): restore default visual properties on reset in VolumeViewport3D and VolumeViewport#2693
Merged
jbocce merged 4 commits intocornerstonejs:mainfrom Apr 16, 2026
Conversation
…ewport3D and VolumeViewport
sedghi
reviewed
Apr 10, 2026
| // Check if there are default properties (e.g., a 3D preset or colormap) | ||
| // to restore. This ensures "Reset" goes back to the configured look | ||
| // rather than the raw initial grayscale state. | ||
| const properties = this.getDefaultProperties(volumeId); |
Member
There was a problem hiding this comment.
not sure why we are repeating the same thing twice, can you investigate, i remember 3d viewport was extending the volume viewport. worst case we need a refactor
Contributor
Author
There was a problem hiding this comment.
I'll check
Contributor
Author
There was a problem hiding this comment.
Thanks @sedghi for your feedback. Both VolumeViewport3D and VolumeViewport extend BaseVolumeViewport directly. So I added a new method on BaseVolumeViewport so that both subclasses can use it.
…o BaseVolumeViewport
jbocce
reviewed
Apr 14, 2026
| * @param volumeActor - The actor entry for the volume | ||
| * @param volumeId - The id of the volume | ||
| */ | ||
| protected _restoreDefaultVisualProperties( |
Collaborator
There was a problem hiding this comment.
How about renaming this to _restoreVolumeRenderingDefaults ?
jbocce
approved these changes
Apr 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
This is fixes an issue in ohif #5922
When a user activates the 3D tool (which applies a volume rendering preset such as CT-Bone), zooms in/out, and then clicks Reset, the image reverts to black and white instead of restoring the original 3D color rendering. The same underlying issue may exist in
VolumeViewport.Root cause
Both
VolumeViewport3D.resetPropertiesandVolumeViewport._resetPropertiesunconditionally calledsetTransferFunctionNodeswithinitialTransferFunctionNodes, which wipes the RGB color transfer function back to the default grayscale ramp captured at volume load time, before any preset or colormap was applied.setTransferFunctionNodesonly resets the RGB color function. It does not touch the opacity, gradient opacity, or lighting properties set by a preset. This left the viewport in an inconsistent state: preset opacity/lighting still active, but color rendering in grayscale.Changes & Results
Replace the unconditional
setTransferFunctionNodescall with a check against the configured default properties (getDefaultProperties):presetorcolormap, apply them viasetProperties(properties, volumeId, true). This routes throughapplyPreset, which fully restores the color transfer function, scalar opacity, gradient opacity, interpolation, and lighting — the complete visual state — in a single call.suppressEventsis set totrueto avoid duplicate or redundant events sinceresetPropertiesfires its ownVOI_MODIFIEDat the end.setTransferFunctionNodesbehaviour (no regression).The fix is applied to both
VolumeViewport3D.resetPropertiesandVolumeViewport._resetPropertiesfor consistency. ForVolumeViewport(MPR), the fallback path means plain CT viewports with no configured defaults behave exactly as before.Before
3d-reset-Before.mov
After
3d-reset-After.mov
Testing
Verify that not only the color has been reset to default but also the opacity, shading, and lighting all set to default.
Checklist
PR
semantic-release format and guidelines.
Code
etc.)
Public Documentation Updates
additions or removals.
Tested Environment