diff --git a/Sources/Rendering/Core/Mapper/index.d.ts b/Sources/Rendering/Core/Mapper/index.d.ts index ecba627740b..f4e22a5292c 100755 --- a/Sources/Rendering/Core/Mapper/index.d.ts +++ b/Sources/Rendering/Core/Mapper/index.d.ts @@ -35,6 +35,7 @@ export interface IMapperInitialValues extends IAbstractMapper3DInitialValues { interpolateScalarsBeforeMapping?: boolean; forceCompileOnly?: number; useInvertibleColors?: boolean; + coordShiftScaleEnabled?: boolean; customShaderAttributes?: any; } @@ -467,6 +468,15 @@ export interface vtkMapper setInterpolateScalarsBeforeMapping( interpolateScalarsBeforeMapping: boolean ): boolean; + + /** + * Control whether the mapper should automatically shift and scale + * the coordinates to improve precision. This is enabled by default. + * + * @param {Boolean} coordShiftScaleEnabled + * @default true + */ + setCoordShiftScaleEnabled(coordShiftScaleEnabled: boolean): boolean; } /** diff --git a/Sources/Rendering/Core/Mapper/index.js b/Sources/Rendering/Core/Mapper/index.js index 5b2eb4a5f76..e3142cb8a88 100644 --- a/Sources/Rendering/Core/Mapper/index.js +++ b/Sources/Rendering/Core/Mapper/index.js @@ -794,6 +794,8 @@ const DEFAULT_VALUES = { invertibleScalars: null, customShaderAttributes: [], + + coordShiftScaleEnabled: true, }; // ---------------------------------------------------------------------------- @@ -825,6 +827,7 @@ export function extend(publicAPI, model, initialValues = {}) { 'scalarVisibility', 'static', 'useLookupTableScalarRange', + 'coordShiftScaleEnabled', 'customShaderAttributes', // point data array names that will be transferred to the VBO ]); macro.setGetArray(publicAPI, model, ['scalarRange'], 2); diff --git a/Sources/Rendering/OpenGL/Glyph3DMapper/index.js b/Sources/Rendering/OpenGL/Glyph3DMapper/index.js index ade5c31ce95..58b91ea8777 100644 --- a/Sources/Rendering/OpenGL/Glyph3DMapper/index.js +++ b/Sources/Rendering/OpenGL/Glyph3DMapper/index.js @@ -694,8 +694,14 @@ function vtkOpenGLGlyph3DMapper(publicAPI, model) { const garray = model.renderable.getMatrixArray(); const pts = model.renderable.getInputData(0).getPoints(); - const { useShiftAndScale, coordShift, coordScale } = - computeCoordShiftAndScale(pts); + let useShiftAndScale = false; + let coordShift = 0.0; + let coordScale = 1.0; + + if (model.renderable.getCoordShiftScaleEnabled() && pts) { + ({ useShiftAndScale, coordShift, coordScale } = + computeCoordShiftAndScale(pts)); + } if (model.hardwareSupport) { // update the buffer objects if needed diff --git a/Sources/Rendering/OpenGL/PolyDataMapper/index.js b/Sources/Rendering/OpenGL/PolyDataMapper/index.js index a59f7786e63..becfdf9b659 100755 --- a/Sources/Rendering/OpenGL/PolyDataMapper/index.js +++ b/Sources/Rendering/OpenGL/PolyDataMapper/index.js @@ -1258,7 +1258,9 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { const numClipPlanes = model.renderable.getNumberOfClippingPlanes(); const planeEquations = []; - const shiftScaleEnabled = cellBO.getCABO().getCoordShiftAndScaleEnabled(); + const shiftScaleEnabled = + model.renderable.coordShiftScaleEnabled && + cellBO.getCABO().getCoordShiftAndScaleEnabled(); const inverseShiftScaleMatrix = shiftScaleEnabled ? cellBO.getCABO().getInverseShiftAndScaleMatrix() : null; @@ -1460,7 +1462,9 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) { const camm = model.openGLCamera.getKeyMatrixTime().getMTime(); const progm = program.getLastCameraMTime(); - const shiftScaleEnabled = cellBO.getCABO().getCoordShiftAndScaleEnabled(); + const shiftScaleEnabled = + model.renderable.coordShiftScaleEnabled && + cellBO.getCABO().getCoordShiftAndScaleEnabled(); const inverseShiftScaleMatrix = shiftScaleEnabled ? cellBO.getCABO().getInverseShiftAndScaleMatrix() : null; diff --git a/Sources/Widgets/Representations/GlyphRepresentation/index.js b/Sources/Widgets/Representations/GlyphRepresentation/index.js index 803b400bc09..d9e4dd0a724 100644 --- a/Sources/Widgets/Representations/GlyphRepresentation/index.js +++ b/Sources/Widgets/Representations/GlyphRepresentation/index.js @@ -261,6 +261,7 @@ function defaultValues(publicAPI, model, initialValues) { initialValues._pipeline?.mapper ?? // in case mapper was provided vtkGlyph3DMapper.newInstance({ scalarMode: ScalarMode.USE_POINT_FIELD_DATA, + coordShiftScaleEnabled: false, // disable shift scale by default for widgets using glyphs }), actor: initialValues._pipeline?.actor ?? // in case actor was provided