@kitware/vtk.js 26.1.1 → 26.1.3

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.
@@ -755,7 +755,16 @@ function vtkOpenGLTexture(publicAPI, model) {
755
755
 
756
756
  model.context.pixelStorei(model.context.UNPACK_FLIP_Y_WEBGL, flip);
757
757
  model.context.pixelStorei(model.context.UNPACK_ALIGNMENT, 1);
758
- model.context.texImage2D(model.target, 0, model.internalFormat, model.width, model.height, 0, model.format, model.openGLDataType, scaledData[0]);
758
+
759
+ if (model._openGLRenderWindow.getWebgl2()) {
760
+ model.context.texStorage2D(model.target, 1, model.internalFormat, model.width, model.height);
761
+
762
+ if (scaledData[0] != null) {
763
+ model.context.texSubImage2D(model.target, 0, 0, 0, model.width, model.height, model.format, model.openGLDataType, scaledData[0]);
764
+ }
765
+ } else {
766
+ model.context.texImage2D(model.target, 0, model.internalFormat, model.width, model.height, 0, model.format, model.openGLDataType, scaledData[0]);
767
+ }
759
768
 
760
769
  if (model.generateMipmap) {
761
770
  model.context.generateMipmap(model.target);
@@ -819,7 +828,12 @@ function vtkOpenGLTexture(publicAPI, model) {
819
828
  } // Source texture data from the PBO.
820
829
 
821
830
 
822
- model.context.pixelStorei(model.context.UNPACK_ALIGNMENT, 1); // We get the 6 images
831
+ model.context.pixelStorei(model.context.UNPACK_ALIGNMENT, 1);
832
+
833
+ if (model._openGLRenderWindow.getWebgl2()) {
834
+ model.context.texStorage2D(model.target, 6, model.internalFormat, model.width, model.height);
835
+ } // We get the 6 images
836
+
823
837
 
824
838
  for (var _i3 = 0; _i3 < 6; _i3++) {
825
839
  // For each mipmap level
@@ -837,7 +851,14 @@ function vtkOpenGLTexture(publicAPI, model) {
837
851
  tempData = invertedData[6 * j + _i3];
838
852
  }
839
853
 
840
- model.context.texImage2D(model.context.TEXTURE_CUBE_MAP_POSITIVE_X + _i3, j, model.internalFormat, w, h, 0, model.format, model.openGLDataType, tempData);
854
+ if (model._openGLRenderWindow.getWebgl2()) {
855
+ if (tempData != null) {
856
+ model.context.texSubImage2D(model.context.TEXTURE_CUBE_MAP_POSITIVE_X + _i3, j, 0, 0, w, h, model.format, model.openGLDataType, tempData);
857
+ }
858
+ } else {
859
+ model.context.texImage2D(model.context.TEXTURE_CUBE_MAP_POSITIVE_X + _i3, j, model.internalFormat, w, h, 0, model.format, model.openGLDataType, tempData);
860
+ }
861
+
841
862
  j++;
842
863
  w /= 2;
843
864
  h /= 2;
@@ -885,7 +906,16 @@ function vtkOpenGLTexture(publicAPI, model) {
885
906
  // model.context.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
886
907
 
887
908
  model.context.pixelStorei(model.context.UNPACK_ALIGNMENT, 1);
888
- model.context.texImage2D(model.target, 0, model.internalFormat, model.width, model.height, 0, model.format, model.openGLDataType, data);
909
+
910
+ if (model._openGLRenderWindow.getWebgl2()) {
911
+ model.context.texStorage2D(model.target, 1, model.internalFormat, model.width, model.height);
912
+
913
+ if (data != null) {
914
+ model.context.texSubImage2D(model.target, 0, 0, 0, model.width, model.height, model.format, model.openGLDataType, data);
915
+ }
916
+ } else {
917
+ model.context.texImage2D(model.target, 0, model.internalFormat, model.width, model.height, 0, model.format, model.openGLDataType, data);
918
+ }
889
919
 
890
920
  if (model.generateMipmap) {
891
921
  model.context.generateMipmap(model.target);
@@ -931,7 +961,16 @@ function vtkOpenGLTexture(publicAPI, model) {
931
961
  ctx.scale(1, -1);
932
962
  ctx.drawImage(image, 0, 0, image.width, image.height, 0, 0, canvas.width, canvas.height);
933
963
  var safeImage = canvas;
934
- model.context.texImage2D(model.target, 0, model.internalFormat, model.format, model.openGLDataType, safeImage);
964
+
965
+ if (model._openGLRenderWindow.getWebgl2()) {
966
+ model.context.texStorage2D(model.target, 1, model.internalFormat, model.width, model.height);
967
+
968
+ if (safeImage != null) {
969
+ model.context.texSubImage2D(model.target, 0, 0, 0, model.width, model.height, model.format, model.openGLDataType, safeImage);
970
+ }
971
+ } else {
972
+ model.context.texImage2D(model.target, 0, model.internalFormat, model.width, model.height, 0, model.format, model.openGLDataType, safeImage);
973
+ }
935
974
 
936
975
  if (model.generateMipmap) {
937
976
  model.context.generateMipmap(model.target);
@@ -1058,7 +1097,15 @@ function vtkOpenGLTexture(publicAPI, model) {
1058
1097
  // model.context.pixelStorei(model.context.UNPACK_ALIGNMENT, 1);
1059
1098
  // openGLDataType
1060
1099
 
1061
- model.context.texImage3D(model.target, 0, model.internalFormat, model.width, model.height, model.depth, 0, model.format, model.openGLDataType, scaledData[0]);
1100
+ if (model._openGLRenderWindow.getWebgl2()) {
1101
+ model.context.texStorage3D(model.target, 1, model.internalFormat, model.width, model.height, model.depth);
1102
+
1103
+ if (scaledData[0] != null) {
1104
+ model.context.texSubImage3D(model.target, 0, 0, 0, 0, model.width, model.height, model.depth, model.format, model.openGLDataType, scaledData[0]);
1105
+ }
1106
+ } else {
1107
+ model.context.texImage3D(model.target, 0, model.internalFormat, model.width, model.height, model.depth, 0, model.format, model.openGLDataType, scaledData[0]);
1108
+ }
1062
1109
 
1063
1110
  if (model.generateMipmap) {
1064
1111
  model.context.generateMipmap(model.target);
@@ -1293,7 +1340,17 @@ function vtkOpenGLTexture(publicAPI, model) {
1293
1340
 
1294
1341
 
1295
1342
  model.context.pixelStorei(model.context.UNPACK_ALIGNMENT, 1);
1296
- model.context.texImage2D(model.target, 0, model.internalFormat, model.width, model.height, 0, model.format, model.openGLDataType, newArray);
1343
+
1344
+ if (model._openGLRenderWindow.getWebgl2()) {
1345
+ model.context.texStorage2D(model.target, 1, model.internalFormat, model.width, model.height);
1346
+
1347
+ if (newArray != null) {
1348
+ model.context.texSubImage2D(model.target, 0, 0, 0, model.width, model.height, model.format, model.openGLDataType, newArray);
1349
+ }
1350
+ } else {
1351
+ model.context.texImage2D(model.target, 0, model.internalFormat, model.width, model.height, 0, model.format, model.openGLDataType, newArray);
1352
+ }
1353
+
1297
1354
  publicAPI.deactivate();
1298
1355
  return true;
1299
1356
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "26.1.1",
3
+ "version": "26.1.3",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",