@kitware/vtk.js 32.1.0 → 32.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -43,7 +43,7 @@ function vtkCalculator(publicAPI, model) {
43
43
  return {
44
44
  getArrays: inData => ({
45
45
  // don't augment input data array in case of structured input dataset
46
- input: inData[0].isA('vtkImageData') ? arrNames.map(x => ({
46
+ input: inData[0]?.isA('vtkImageData') ? arrNames.map(x => ({
47
47
  location: locn,
48
48
  name: x
49
49
  })) : publicAPI.augmentInputArrays(locn, arrNames.map(x => ({
@@ -133,7 +133,7 @@ function vtkLineIntegralConvolution2D(publicAPI, model) {
133
133
  }
134
134
  const gl = model.context;
135
135
  let fb = model.framebuffer;
136
- const fbSize = fb.getSize();
136
+ const fbSize = fb?.getSize();
137
137
  if (!fb || !fbSize || size[0] !== fbSize || size[1] !== fbSize) {
138
138
  fb = vtkOpenGLFramebuffer.newInstance();
139
139
  fb.setOpenGLRenderWindow(model._openGLRenderWindow);
@@ -295,7 +295,7 @@ function vtkOpenGLTexture(publicAPI, model) {
295
295
  }
296
296
  return result;
297
297
  };
298
- publicAPI.useHalfFloat = () => model.enableHalfFloat && model.canUseHalfFloat;
298
+ publicAPI.useHalfFloat = () => model.enableUseHalfFloat && model.canUseHalfFloat;
299
299
 
300
300
  //----------------------------------------------------------------------------
301
301
  publicAPI.setInternalFormat = iFormat => {
@@ -929,18 +929,21 @@ function vtkOpenGLTexture(publicAPI, model) {
929
929
  }
930
930
  function setCanUseHalfFloat(dataType, offset, scale, preferSizeOverAccuracy) {
931
931
  publicAPI.getOpenGLDataType(dataType);
932
+
933
+ // Don't consider halfFloat and convert back to Float when the range of data does not generate an accurate halfFloat
934
+ // AND it is not preferable to have a smaller texture than an exact texture.
935
+ const isExactHalfFloat = hasExactHalfFloat(offset, scale) || preferSizeOverAccuracy;
932
936
  let useHalfFloat = false;
933
937
  if (model._openGLRenderWindow.getWebgl2()) {
934
- useHalfFloat = model.openGLDataType === model.context.HALF_FLOAT;
938
+ // If OES_texture_float_linear is not available, and using a half float would still be exact, force half floats
939
+ // This is because half floats are always texture filterable in webgl2, while full *32F floats are not (unless the extension is present)
940
+ const forceHalfFloat = model.openGLDataType === model.context.FLOAT && model.context.getExtension('OES_texture_float_linear') === null && isExactHalfFloat;
941
+ useHalfFloat = forceHalfFloat || model.openGLDataType === model.context.HALF_FLOAT;
935
942
  } else {
936
943
  const halfFloatExt = model.context.getExtension('OES_texture_half_float');
937
944
  useHalfFloat = halfFloatExt && model.openGLDataType === halfFloatExt.HALF_FLOAT_OES;
938
945
  }
939
-
940
- // Don't consider halfFloat and convert back to Float when the range of data does not generate an accurate halfFloat
941
- // AND it is not preferable to have a smaller texture than an exact texture.
942
- const isHalfFloat = useHalfFloat && (hasExactHalfFloat(offset, scale) || preferSizeOverAccuracy);
943
- model.canUseHalfFloat = isHalfFloat;
946
+ model.canUseHalfFloat = useHalfFloat && isExactHalfFloat;
944
947
  }
945
948
  function processDataArray(dataArray, preferSizeOverAccuracy) {
946
949
  const numComps = dataArray.getNumberOfComponents();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "32.1.0",
3
+ "version": "32.1.2",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",