@kitware/vtk.js 26.5.5 → 26.6.0
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.
|
@@ -60,6 +60,7 @@ export interface IRenderWindowInteractorInitialValues {
|
|
|
60
60
|
moveTimeoutID?: number;
|
|
61
61
|
preventDefaultOnPointerDown?: boolean;
|
|
62
62
|
preventDefaultOnPointerUp?: boolean;
|
|
63
|
+
mouseScrollDebounceByPass?: boolean;
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
interface IPosition {
|
|
@@ -164,6 +165,11 @@ export interface vtkRenderWindowInteractor extends vtkObject {
|
|
|
164
165
|
*/
|
|
165
166
|
getPreventDefaultOnPointerUp(): boolean;
|
|
166
167
|
|
|
168
|
+
/**
|
|
169
|
+
* @default false
|
|
170
|
+
*/
|
|
171
|
+
getMouseScrollDebounceByPass(): boolean;
|
|
172
|
+
|
|
167
173
|
/**
|
|
168
174
|
*
|
|
169
175
|
* @param {IRenderWindowInteractorEvent} callData
|
|
@@ -849,6 +855,13 @@ export interface vtkRenderWindowInteractor extends vtkObject {
|
|
|
849
855
|
*/
|
|
850
856
|
setPreventDefaultOnPointerUp(preventDefault: boolean): boolean;
|
|
851
857
|
|
|
858
|
+
/**
|
|
859
|
+
* Allow system to bypass scrolling debounce. This function must be called to allow the debounce to be bypassed
|
|
860
|
+
* @param mouseScrollDebounceByPass
|
|
861
|
+
*/
|
|
862
|
+
|
|
863
|
+
setMouseScrollDebounceByPass(mouseScrollDebounceByPass:boolean): boolean;
|
|
864
|
+
|
|
852
865
|
/**
|
|
853
866
|
*
|
|
854
867
|
* @param recognizeGestures
|
|
@@ -630,14 +630,20 @@ function vtkRenderWindowInteractor(publicAPI, model) {
|
|
|
630
630
|
} else {
|
|
631
631
|
publicAPI.mouseWheelEvent(callData);
|
|
632
632
|
clearTimeout(model.wheelTimeoutID);
|
|
633
|
-
}
|
|
634
|
-
|
|
633
|
+
}
|
|
635
634
|
|
|
636
|
-
model.
|
|
635
|
+
if (model.mouseScrollDebounceByPass) {
|
|
637
636
|
publicAPI.extendAnimation(600);
|
|
638
637
|
publicAPI.endMouseWheelEvent();
|
|
639
638
|
model.wheelTimeoutID = 0;
|
|
640
|
-
}
|
|
639
|
+
} else {
|
|
640
|
+
// start a timer to keep us animating while we get wheel events
|
|
641
|
+
model.wheelTimeoutID = setTimeout(function () {
|
|
642
|
+
publicAPI.extendAnimation(600);
|
|
643
|
+
publicAPI.endMouseWheelEvent();
|
|
644
|
+
model.wheelTimeoutID = 0;
|
|
645
|
+
}, 200);
|
|
646
|
+
}
|
|
641
647
|
};
|
|
642
648
|
|
|
643
649
|
publicAPI.handleMouseUp = function (event) {
|
|
@@ -1086,7 +1092,8 @@ var DEFAULT_VALUES = {
|
|
|
1086
1092
|
moveTimeoutID: 0,
|
|
1087
1093
|
lastGamepadValues: {},
|
|
1088
1094
|
preventDefaultOnPointerDown: false,
|
|
1089
|
-
preventDefaultOnPointerUp: false
|
|
1095
|
+
preventDefaultOnPointerUp: false,
|
|
1096
|
+
mouseScrollDebounceByPass: false
|
|
1090
1097
|
}; // ----------------------------------------------------------------------------
|
|
1091
1098
|
|
|
1092
1099
|
function extend(publicAPI, model) {
|
|
@@ -1103,7 +1110,7 @@ function extend(publicAPI, model) {
|
|
|
1103
1110
|
|
|
1104
1111
|
macro.get(publicAPI, model, ['initialized', 'container', 'interactorStyle', 'lastFrameTime', 'recentAnimationFrameRate', '_view']); // Create get-set macros
|
|
1105
1112
|
|
|
1106
|
-
macro.setGet(publicAPI, model, ['lightFollowCamera', 'enabled', 'enableRender', 'recognizeGestures', 'desiredUpdateRate', 'stillUpdateRate', 'picker', 'preventDefaultOnPointerDown', 'preventDefaultOnPointerUp']);
|
|
1113
|
+
macro.setGet(publicAPI, model, ['lightFollowCamera', 'enabled', 'enableRender', 'recognizeGestures', 'desiredUpdateRate', 'stillUpdateRate', 'picker', 'preventDefaultOnPointerDown', 'preventDefaultOnPointerUp', 'mouseScrollDebounceByPass']);
|
|
1107
1114
|
macro.moveToProtected(publicAPI, model, ['view']); // For more macro methods, see "Sources/macros.js"
|
|
1108
1115
|
// Object specific methods
|
|
1109
1116
|
|
|
@@ -725,6 +725,33 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
725
725
|
} //----------------------------------------------------------------------------
|
|
726
726
|
|
|
727
727
|
|
|
728
|
+
function useTexStorage(dataType) {
|
|
729
|
+
if (model._openGLRenderWindow) {
|
|
730
|
+
if (model.resizable) {
|
|
731
|
+
// Cannot use texStorage if the texture is supposed to be resizable.
|
|
732
|
+
return false;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
if (model._openGLRenderWindow.getWebgl2()) {
|
|
736
|
+
var webGLInfo = model._openGLRenderWindow.getGLInformations();
|
|
737
|
+
|
|
738
|
+
if (webGLInfo.RENDERER.value.match(/WebKit/gi) && navigator.platform.match(/Mac/gi) && model.oglNorm16Ext && (dataType === VtkDataTypes.UNSIGNED_SHORT || dataType === VtkDataTypes.SHORT)) {
|
|
739
|
+
// Cannot use texStorage with EXT_texture_norm16 textures on Mac M1 GPU.
|
|
740
|
+
// No errors reported but the texture is unusable.
|
|
741
|
+
return false;
|
|
742
|
+
} // Use texStorage for WebGL2
|
|
743
|
+
|
|
744
|
+
|
|
745
|
+
return true;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
return false;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
return false;
|
|
752
|
+
} //----------------------------------------------------------------------------
|
|
753
|
+
|
|
754
|
+
|
|
728
755
|
publicAPI.create2DFromRaw = function (width, height, numComps, dataType, data) {
|
|
729
756
|
var flip = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
730
757
|
// Now determine the texture parameters using the arguments.
|
|
@@ -756,7 +783,7 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
756
783
|
model.context.pixelStorei(model.context.UNPACK_FLIP_Y_WEBGL, flip);
|
|
757
784
|
model.context.pixelStorei(model.context.UNPACK_ALIGNMENT, 1);
|
|
758
785
|
|
|
759
|
-
if (
|
|
786
|
+
if (useTexStorage(dataType)) {
|
|
760
787
|
model.context.texStorage2D(model.target, 1, model.internalFormat, model.width, model.height);
|
|
761
788
|
|
|
762
789
|
if (scaledData[0] != null) {
|
|
@@ -830,7 +857,7 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
830
857
|
|
|
831
858
|
model.context.pixelStorei(model.context.UNPACK_ALIGNMENT, 1);
|
|
832
859
|
|
|
833
|
-
if (
|
|
860
|
+
if (useTexStorage(dataType)) {
|
|
834
861
|
model.context.texStorage2D(model.target, 6, model.internalFormat, model.width, model.height);
|
|
835
862
|
} // We get the 6 images
|
|
836
863
|
|
|
@@ -907,7 +934,7 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
907
934
|
|
|
908
935
|
model.context.pixelStorei(model.context.UNPACK_ALIGNMENT, 1);
|
|
909
936
|
|
|
910
|
-
if (
|
|
937
|
+
if (useTexStorage(dataType)) {
|
|
911
938
|
model.context.texStorage2D(model.target, 1, model.internalFormat, model.width, model.height);
|
|
912
939
|
|
|
913
940
|
if (data != null) {
|
|
@@ -939,8 +966,6 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
939
966
|
|
|
940
967
|
model.target = model.context.TEXTURE_2D;
|
|
941
968
|
model.components = 4;
|
|
942
|
-
model.width = image.width;
|
|
943
|
-
model.height = image.height;
|
|
944
969
|
model.depth = 1;
|
|
945
970
|
model.numberOfDimensions = 2;
|
|
946
971
|
|
|
@@ -952,17 +977,19 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
952
977
|
|
|
953
978
|
model.context.pixelStorei(model.context.UNPACK_ALIGNMENT, 1); // Scale up the texture to the next highest power of two dimensions (if needed) and flip y.
|
|
954
979
|
|
|
955
|
-
var needNearestPowerOfTwo = !isPowerOfTwo(image.width) || !isPowerOfTwo(image.height);
|
|
980
|
+
var needNearestPowerOfTwo = !model._openGLRenderWindow.getWebgl2() && (!isPowerOfTwo(image.width) || !isPowerOfTwo(image.height));
|
|
956
981
|
var canvas = document.createElement('canvas');
|
|
957
982
|
canvas.width = needNearestPowerOfTwo ? nearestPowerOfTwo(image.width) : image.width;
|
|
958
983
|
canvas.height = needNearestPowerOfTwo ? nearestPowerOfTwo(image.height) : image.height;
|
|
984
|
+
model.width = canvas.width;
|
|
985
|
+
model.height = canvas.height;
|
|
959
986
|
var ctx = canvas.getContext('2d');
|
|
960
987
|
ctx.translate(0, canvas.height);
|
|
961
988
|
ctx.scale(1, -1);
|
|
962
989
|
ctx.drawImage(image, 0, 0, image.width, image.height, 0, 0, canvas.width, canvas.height);
|
|
963
990
|
var safeImage = canvas;
|
|
964
991
|
|
|
965
|
-
if (
|
|
992
|
+
if (useTexStorage(VtkDataTypes.UNSIGNED_CHAR)) {
|
|
966
993
|
model.context.texStorage2D(model.target, 1, model.internalFormat, model.width, model.height);
|
|
967
994
|
|
|
968
995
|
if (safeImage != null) {
|
|
@@ -1097,7 +1124,7 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
1097
1124
|
// model.context.pixelStorei(model.context.UNPACK_ALIGNMENT, 1);
|
|
1098
1125
|
// openGLDataType
|
|
1099
1126
|
|
|
1100
|
-
if (
|
|
1127
|
+
if (useTexStorage(dataType)) {
|
|
1101
1128
|
model.context.texStorage3D(model.target, 1, model.internalFormat, model.width, model.height, model.depth);
|
|
1102
1129
|
|
|
1103
1130
|
if (scaledData[0] != null) {
|
|
@@ -1342,7 +1369,7 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
1342
1369
|
|
|
1343
1370
|
model.context.pixelStorei(model.context.UNPACK_ALIGNMENT, 1);
|
|
1344
1371
|
|
|
1345
|
-
if (
|
|
1372
|
+
if (useTexStorage(dataTypeToUse)) {
|
|
1346
1373
|
model.context.texStorage2D(model.target, 1, model.internalFormat, model.width, model.height);
|
|
1347
1374
|
|
|
1348
1375
|
if (newArray != null) {
|