Skip to content

Conversation

@sankhesh
Copy link
Collaborator

Context

See #3330

Results

Screenshot 2025-10-30 235713

Changes

  • Documentation and TypeScript definitions were updated to match those changes

PR and Code Checklist

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

Testing

  • This change adds or fixes unit tests
  • Tested environment:
    • vtk.js:
    • OS:
    • Browser:

…aling

Introduces the `(set|get)CoordinateShiftScaleEnabled` property to
`vtkMapper` and its subclasses. This new property provides an API to
explicitly enable/disable the automatic coordinate shifting and scaling
mechanism within polydata mappers, which is typically used to improve
rendering precision for geometry with large coordinate values.

fix Kitware#3330
The glyph representation is primarily used for widget assembly where
there the infinite lines or smaller diagonal length would trigger an
unexpected coordinate shift scale. This change disables this by default.

fix Kitware#3330
@sankhesh sankhesh force-pushed the fix_widgets_shiftscale branch from d087ea6 to 488f970 Compare October 31, 2025 04:22

// Build VTK API
macro.setGet(publicAPI, model, ['context']);
macro.setGet(publicAPI, model, ['context', 'coordShiftScaleEnabled']);
Copy link
Member

Choose a reason for hiding this comment

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

model.coordShiftScaleEnabled is not initialized on purpose ?
Therefore false by default ?
Why would coordShiftScaleEnabled have a different value between the API specific mapper (vtkOpenGLPolyDataMapper) and the original mapper (vtkPolyDataMapper)

Copy link
Member

Choose a reason for hiding this comment

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

This should be added in the documentation.


/**
* Control whether the mapper should automatically shift and scale
* the coordinates to improve precision. This is enabled by default.
Copy link
Member

Choose a reason for hiding this comment

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

please add comment to explain when/why you would want to turn it off.

let coordShift = 0.0;
let coordScale = 1.0;

if (model.coordShiftAndScaleEnabled && pts) {
Copy link
Member

Choose a reason for hiding this comment

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

why don't you check the value of the original mapper (vtkPolyDataMapper.coordShiftAndScaleEnabled), but just the value of the API specific value (vtkOpenGLPolyDataMapper.coordShiftAndScaleEnabled)

if (model.coordShiftAndScaleEnabled && pts) {
({ useShiftAndScale, coordShift, coordScale } =
computeCoordShiftAndScale(pts));
}
Copy link
Member

Choose a reason for hiding this comment

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

instead of having a flag, could you detect when shift/scale have "bad" values ?

Copy link
Member

Choose a reason for hiding this comment

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

maybe a metric could be computed with regard to the current camera settings.
An error in the "display world" could be considered to too large and coord shift/scale be therefore discarded ?

This `coordShiftScaleEnabled` property is now accessed via `model.renderable.getCoordShiftScaleEnabled()` in `Glyph3DMapper`.
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.

2 participants