Skip to content

feat: add resetCameraScreenSpace method with offsetRatio input, so actors fully fit the screen#3371

Open
aerogt3 wants to merge 2 commits intoKitware:masterfrom
aerogt3:1285-fix-resetCameraScreenSpace
Open

feat: add resetCameraScreenSpace method with offsetRatio input, so actors fully fit the screen#3371
aerogt3 wants to merge 2 commits intoKitware:masterfrom
aerogt3:1285-fix-resetCameraScreenSpace

Conversation

@aerogt3
Copy link
Copy Markdown
Contributor

@aerogt3 aerogt3 commented Nov 30, 2025

add resetCameraScreenSpace method with offsetRatio input, essentially a resetCamera call that fills the entire screen space (where 90% offsetRatio means visible actors will fill 90% of the screen space)

#1285

Context

#1285

Results

See image here:
#1285 (comment)

Changes

Duplicated the resetCamera method, with logic to ensure visible actors fill a percentage of the screen (default: 90%)

PR and Code Checklist

  • semantic-release commit messages
  • Run npm run reformat to have correctly formatted code

Testing

  • Tested environment:
    • master
    • ubuntu 2240
    • firefox 144.0.2 & chrome 142.0

@aerogt3 aerogt3 force-pushed the 1285-fix-resetCameraScreenSpace branch from 5173f89 to 3f36750 Compare December 1, 2025 11:10
Comment thread Sources/Rendering/Core/Renderer/index.js
Copy link
Copy Markdown
Member

@finetjul finetjul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks ! That's much easier to maintain.

ymax = Math.max(dy, ymax);
}
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use vtkBoundingBox.transformBounds(boundsToUse, publicAPI.getActiveCamera().getModelTransformMatrix, boundsToUse)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done I think

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest changes (including the order of the functions) should better match VTK C++

Comment thread Sources/Rendering/Core/Renderer/index.js Outdated
@aerogt3 aerogt3 force-pushed the 1285-fix-resetCameraScreenSpace branch 2 times, most recently from 2e1ea8f to f7db178 Compare March 12, 2026 07:42
Port of VTK C++ vtkRenderer::ResetCameraScreenSpace. Uses a screen-space
bounding box to zoom closer to the data, correctly accounting for viewport
aspect ratio for both perspective and parallel projection.

Also adds zoomToBoxUsingViewAngle as a standalone public method.

Closes Kitware#1285
@aerogt3 aerogt3 force-pushed the 1285-fix-resetCameraScreenSpace branch from f7db178 to cad750c Compare March 12, 2026 07:46
@aerogt3 aerogt3 requested a review from finetjul March 12, 2026 07:54
@aerogt3 aerogt3 force-pushed the 1285-fix-resetCameraScreenSpace branch from 5830372 to c9d320b Compare May 5, 2026 16:55
Port of VTK C++ vtkRenderer::ResetCameraScreenSpace. Uses a screen-space
bounding box to zoom closer to the data, correctly accounting for viewport
aspect ratio for both perspective and parallel projection.

Also adds zoomToBoxUsingViewAngle as a standalone public method.

Closes Kitware#1285
@aerogt3 aerogt3 force-pushed the 1285-fix-resetCameraScreenSpace branch from c9d320b to 84b5d11 Compare May 5, 2026 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants