From 08d1f2855bd8b755d42876487288adf9aec61b92 Mon Sep 17 00:00:00 2001 From: rodrigobasilio2022 Date: Wed, 20 Mar 2024 10:22:26 -0300 Subject: [PATCH] fix(Colors): fix UInt8Clamped array color definition --- Sources/Common/Core/DataArray/Constants.js | 1 + Sources/Common/Core/ScalarsToColors/index.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/Common/Core/DataArray/Constants.js b/Sources/Common/Core/DataArray/Constants.js index c65f58b9bd5..98f4d462d2f 100644 --- a/Sources/Common/Core/DataArray/Constants.js +++ b/Sources/Common/Core/DataArray/Constants.js @@ -15,6 +15,7 @@ export const VtkDataTypes = { CHAR: 'Int8Array', SIGNED_CHAR: 'Int8Array', UNSIGNED_CHAR: 'Uint8Array', + UNSIGNED_CHAR_CLAMPED: 'Uint8ClampedArray', // should be used for VTK.js internal purpose only SHORT: 'Int16Array', UNSIGNED_SHORT: 'Uint16Array', INT: 'Int32Array', diff --git a/Sources/Common/Core/ScalarsToColors/index.js b/Sources/Common/Core/ScalarsToColors/index.js index b83fd881295..f98e68167cd 100644 --- a/Sources/Common/Core/ScalarsToColors/index.js +++ b/Sources/Common/Core/ScalarsToColors/index.js @@ -206,7 +206,8 @@ function vtkScalarsToColors(publicAPI, model) { // map scalars through lookup table only if needed if ( (colorMode === ColorMode.DEFAULT && - scalars.getDataType() === VtkDataTypes.UNSIGNED_CHAR) || + (scalars.getDataType() === VtkDataTypes.UNSIGNED_CHAR || + scalars.getDataType() === VtkDataTypes.UNSIGNED_CHAR_CLAMPED)) || (colorMode === ColorMode.DIRECT_SCALARS && scalars) ) { newColors = publicAPI.convertToRGBA(