@@ -1237,13 +1237,6 @@ function vtkOpenGLImageMapper(publicAPI, model) {
1237
1237
const spatialExt = image . getSpatialExtent ( ) ;
1238
1238
const basicScalars = imgScalars . getData ( ) ;
1239
1239
let scalars = null ;
1240
- /**
1241
- * Used to store the range of the scalars array, if available. Pre-setting
1242
- * the scalars range can prevent it being calculated again.
1243
- *
1244
- * @type { import("../../../interfaces").vtkRange[]|undefined }
1245
- */
1246
- let ranges ;
1247
1240
// Get right scalars according to slicing mode
1248
1241
if ( ijkMode === SlicingMode . I ) {
1249
1242
scalars = new basicScalars . constructor ( dims [ 2 ] * dims [ 1 ] * numComp ) ;
@@ -1317,18 +1310,25 @@ function vtkOpenGLImageMapper(publicAPI, model) {
1317
1310
ptsArray [ 9 ] = spatialExt [ 1 ] ;
1318
1311
ptsArray [ 10 ] = spatialExt [ 3 ] ;
1319
1312
ptsArray [ 11 ] = sliceDepth ;
1320
- if ( sliceOffset === 0 ) {
1321
- // If the sliceOffset is 0, the scalars array is a view of the
1322
- // original scalars array. As a micro-optimization, we can get the
1323
- // range from the original scalars array and set the range to the
1324
- // scalars array. This means there is no need to re-calculate the
1325
- // ranges for the scalars array.
1326
- ranges = imgScalars . getRanges ( ) ;
1327
- }
1328
1313
} else {
1329
1314
vtkErrorMacro ( 'Reformat slicing not yet supported.' ) ;
1330
1315
}
1331
1316
1317
+ /**
1318
+ *
1319
+ * Fetch the ranges of the source volume, `imgScalars`, and use them when
1320
+ * creating the texture. Whilst the pre-calculated ranges may not be
1321
+ * strictly correct for the slice, it is guarateed to be within the
1322
+ * source volume's range.
1323
+ *
1324
+ * There is a significant performance improvement by pre-setting the range
1325
+ * of the scalars array particaulrly when scrolling through the source
1326
+ * volume as there is no need to calculate the range of the slice scalar.
1327
+ *
1328
+ * @type { import("../../../interfaces").vtkRange[] }
1329
+ */
1330
+ const ranges = imgScalars . getRanges ( ) ;
1331
+
1332
1332
// Don't share this resource as `scalars` is created in this function
1333
1333
// so it is impossible to share
1334
1334
model . openGLTexture . resetFormatAndType ( ) ;
0 commit comments