@@ -136,6 +136,7 @@ const colorTextureCoordinatesCache = new WeakMap();
136
136
* @param {vtkDataArray } input The input data array used for coloring
137
137
* @param {Number } component The component of the input data array that is used for coloring (-1 for magnitude of the vectors)
138
138
* @param {Range } range The range of the scalars
139
+ * @param {boolean } useLogScale Should the values be transformed to logarithmic scale. When true, the range must already be in logarithmic scale.
139
140
* @param {Number } numberOfColorsInRange The number of colors that are used in the range
140
141
* @param {vec3 } dimensions The dimensions of the texture
141
142
* @param {boolean } useZigzagPattern If a zigzag pattern should be used. Otherwise 1 row for colors (including min and max) and 1 row for NaN are used.
@@ -145,6 +146,7 @@ function getOrCreateColorTextureCoordinates(
145
146
input ,
146
147
component ,
147
148
range ,
149
+ useLogScale ,
148
150
numberOfColorsInRange ,
149
151
dimensions ,
150
152
useZigzagPattern
@@ -219,6 +221,10 @@ function getOrCreateColorTextureCoordinates(
219
221
} else {
220
222
scalarValue = inputV [ inputIdx + component ] ;
221
223
}
224
+ if ( useLogScale ) {
225
+ scalarValue = Math . log10 ( scalarValue ) ;
226
+ }
227
+
222
228
inputIdx += numComps ;
223
229
224
230
// Convert to texture coordinates and update output
@@ -446,6 +452,9 @@ function vtkMapper(publicAPI, model) {
446
452
const range = model . lookupTable . getRange ( ) ;
447
453
const useLogScale = model . lookupTable . usingLogScale ( ) ;
448
454
const origAlpha = model . lookupTable . getAlpha ( ) ;
455
+ const scaledRange = useLogScale
456
+ ? [ Math . log10 ( range [ 0 ] ) , Math . log10 ( range [ 1 ] ) ]
457
+ : range ;
449
458
450
459
// Get rid of vertex color array. Only texture or vertex coloring
451
460
// can be active at one time. The existence of the array is the
@@ -518,9 +527,6 @@ function vtkMapper(publicAPI, model) {
518
527
const numberOfNonNaNColors = numberOfNonSpecialColors + 2 ;
519
528
const textureCoordinates = [ 0 , 0 , 0 ] ;
520
529
521
- const scaledRange = useLogScale
522
- ? [ Math . log10 ( range [ 0 ] ) , Math . log10 ( range [ 1 ] ) ]
523
- : range ;
524
530
const rangeMin = scaledRange [ 0 ] ;
525
531
const rangeDifference = scaledRange [ 1 ] - scaledRange [ 0 ] ;
526
532
for ( let i = 0 ; i < numberOfNonNaNColors ; ++ i ) {
@@ -576,7 +582,8 @@ function vtkMapper(publicAPI, model) {
576
582
model . colorCoordinates = getOrCreateColorTextureCoordinates (
577
583
scalars ,
578
584
scalarComponent ,
579
- range ,
585
+ scaledRange ,
586
+ useLogScale ,
580
587
model . numberOfColorsInRange ,
581
588
model . colorTextureMap . getDimensions ( ) ,
582
589
cellFlag
0 commit comments