@kitware/vtk.js 24.15.0 → 24.16.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.
package/Rendering/Core/Camera.js
CHANGED
|
@@ -61,7 +61,6 @@ function vtkCamera(publicAPI, model) {
|
|
|
61
61
|
model.position[2] = z; // recompute the focal distance
|
|
62
62
|
|
|
63
63
|
publicAPI.computeDistance();
|
|
64
|
-
publicAPI.computeCameraLightTransform();
|
|
65
64
|
publicAPI.modified();
|
|
66
65
|
};
|
|
67
66
|
|
|
@@ -75,7 +74,6 @@ function vtkCamera(publicAPI, model) {
|
|
|
75
74
|
model.focalPoint[2] = z; // recompute the focal distance
|
|
76
75
|
|
|
77
76
|
publicAPI.computeDistance();
|
|
78
|
-
publicAPI.computeCameraLightTransform();
|
|
79
77
|
publicAPI.modified();
|
|
80
78
|
};
|
|
81
79
|
|
|
@@ -97,7 +95,6 @@ function vtkCamera(publicAPI, model) {
|
|
|
97
95
|
model.focalPoint[0] = model.position[0] + vec[0] * model.distance;
|
|
98
96
|
model.focalPoint[1] = model.position[1] + vec[1] * model.distance;
|
|
99
97
|
model.focalPoint[2] = model.position[2] + vec[2] * model.distance;
|
|
100
|
-
publicAPI.computeCameraLightTransform();
|
|
101
98
|
publicAPI.modified();
|
|
102
99
|
}; //----------------------------------------------------------------------------
|
|
103
100
|
// This method must be called when the focal point or camera position changes
|
|
@@ -173,6 +173,16 @@ export interface vtkRenderWindowInteractor extends vtkObject {
|
|
|
173
173
|
*
|
|
174
174
|
* @param {IRenderWindowInteractorEvent} callData
|
|
175
175
|
*/
|
|
176
|
+
invokePointerEnter(callData: IRenderWindowInteractorEvent): void;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
*
|
|
180
|
+
*/
|
|
181
|
+
invokePointerLeave(callData: IRenderWindowInteractorEvent): void;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
*
|
|
185
|
+
*/
|
|
176
186
|
invokeMouseEnter(callData: IRenderWindowInteractorEvent): void;
|
|
177
187
|
|
|
178
188
|
/**
|
|
@@ -392,6 +402,18 @@ export interface vtkRenderWindowInteractor extends vtkObject {
|
|
|
392
402
|
* @param {InteractorEventCallback} cb The callback to be called.
|
|
393
403
|
* @param {Number} [priority] The priority of the event.
|
|
394
404
|
*/
|
|
405
|
+
onPointerEnter(cb: InteractorEventCallback, priority?: number): Readonly<vtkSubscription>;
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
*
|
|
409
|
+
* @param cb The callback to be called
|
|
410
|
+
*/
|
|
411
|
+
onPointerLeave(cb: InteractorEventCallback, priority?: number): Readonly<vtkSubscription>;
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
*
|
|
415
|
+
* @param cb The callback to be called
|
|
416
|
+
*/
|
|
395
417
|
onMouseEnter(cb: InteractorEventCallback, priority?: number): Readonly<vtkSubscription>;
|
|
396
418
|
|
|
397
419
|
/**
|
|
@@ -949,11 +971,35 @@ export interface vtkRenderWindowInteractor extends vtkObject {
|
|
|
949
971
|
*/
|
|
950
972
|
handleKeyUp(event: KeyboardEvent): void;
|
|
951
973
|
|
|
974
|
+
/**
|
|
975
|
+
*
|
|
976
|
+
* @param {PointerEvent} event
|
|
977
|
+
*/
|
|
978
|
+
handlePointerDown(event: PointerEvent): void;
|
|
979
|
+
|
|
980
|
+
/**
|
|
981
|
+
*
|
|
982
|
+
* @param {PointerEvent} event
|
|
983
|
+
*/
|
|
984
|
+
handlePointerUp(event: PointerEvent): void;
|
|
985
|
+
|
|
986
|
+
/**
|
|
987
|
+
*
|
|
988
|
+
* @param {PointerEvent} event
|
|
989
|
+
*/
|
|
990
|
+
handlePointerCancel(event: PointerEvent): void;
|
|
991
|
+
|
|
992
|
+
/**
|
|
993
|
+
*
|
|
994
|
+
* @param {PointerEvent} event
|
|
995
|
+
*/
|
|
996
|
+
handlePointerMove(event: PointerEvent): void;
|
|
997
|
+
|
|
952
998
|
/**
|
|
953
999
|
*
|
|
954
|
-
* @param {
|
|
1000
|
+
* @param {PointerEvent} event
|
|
955
1001
|
*/
|
|
956
|
-
handleMouseDown(event:
|
|
1002
|
+
handleMouseDown(event: PointerEvent): void;
|
|
957
1003
|
|
|
958
1004
|
/**
|
|
959
1005
|
*
|
|
@@ -1011,9 +1057,9 @@ export interface vtkRenderWindowInteractor extends vtkObject {
|
|
|
1011
1057
|
|
|
1012
1058
|
/**
|
|
1013
1059
|
*
|
|
1014
|
-
* @param {
|
|
1060
|
+
* @param {PointerEvent} event
|
|
1015
1061
|
*/
|
|
1016
|
-
handleMouseMove(event:
|
|
1062
|
+
handleMouseMove(event: PointerEvent): void;
|
|
1017
1063
|
|
|
1018
1064
|
/**
|
|
1019
1065
|
*
|
|
@@ -1028,39 +1074,39 @@ export interface vtkRenderWindowInteractor extends vtkObject {
|
|
|
1028
1074
|
|
|
1029
1075
|
/**
|
|
1030
1076
|
*
|
|
1031
|
-
* @param {
|
|
1077
|
+
* @param {PointerEvent} event
|
|
1032
1078
|
*/
|
|
1033
|
-
|
|
1079
|
+
handlePointerEnter(event: PointerEvent): void;
|
|
1034
1080
|
|
|
1035
1081
|
/**
|
|
1036
1082
|
*
|
|
1037
|
-
* @param {
|
|
1083
|
+
* @param {PointerEvent} event
|
|
1038
1084
|
*/
|
|
1039
|
-
|
|
1085
|
+
handlePointerLeave(event: PointerEvent): void;
|
|
1040
1086
|
|
|
1041
1087
|
/**
|
|
1042
1088
|
*
|
|
1043
|
-
* @param {
|
|
1089
|
+
* @param {PointerEvent} event
|
|
1044
1090
|
*/
|
|
1045
|
-
handleMouseUp(event:
|
|
1091
|
+
handleMouseUp(event: PointerEvent): void;
|
|
1046
1092
|
|
|
1047
1093
|
/**
|
|
1048
1094
|
*
|
|
1049
|
-
* @param {
|
|
1095
|
+
* @param {PointerEvent} event
|
|
1050
1096
|
*/
|
|
1051
|
-
handleTouchStart(event:
|
|
1097
|
+
handleTouchStart(event: PointerEvent): void;
|
|
1052
1098
|
|
|
1053
1099
|
/**
|
|
1054
1100
|
*
|
|
1055
|
-
* @param {
|
|
1101
|
+
* @param {PointerEvent} event
|
|
1056
1102
|
*/
|
|
1057
|
-
handleTouchMove(event:
|
|
1103
|
+
handleTouchMove(event: PointerEvent): void;
|
|
1058
1104
|
|
|
1059
1105
|
/**
|
|
1060
1106
|
*
|
|
1061
|
-
* @param {
|
|
1107
|
+
* @param {PointerEvent} event
|
|
1062
1108
|
*/
|
|
1063
|
-
handleTouchEnd(event:
|
|
1109
|
+
handleTouchEnd(event: PointerEvent): void;
|
|
1064
1110
|
|
|
1065
1111
|
/**
|
|
1066
1112
|
*
|
|
@@ -1093,7 +1139,7 @@ export interface vtkRenderWindowInteractor extends vtkObject {
|
|
|
1093
1139
|
* @param event
|
|
1094
1140
|
* @param positions
|
|
1095
1141
|
*/
|
|
1096
|
-
recognizeGesture(event: 'TouchStart' | '
|
|
1142
|
+
recognizeGesture(event: 'TouchStart' | 'TouchMove' | 'TouchEnd', positions: IPosition): void;
|
|
1097
1143
|
|
|
1098
1144
|
/**
|
|
1099
1145
|
*
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
1
2
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
3
|
import macro from '../../macros.js';
|
|
3
4
|
import { A as degreesFromRadians } from '../../Common/Core/Math/index.js';
|
|
@@ -15,10 +16,11 @@ var vtkWarningMacro = macro.vtkWarningMacro,
|
|
|
15
16
|
// Global methods
|
|
16
17
|
// ----------------------------------------------------------------------------
|
|
17
18
|
|
|
19
|
+
var EMPTY_MOUSE_EVENT = new MouseEvent('');
|
|
18
20
|
var deviceInputMap = {
|
|
19
21
|
'xr-standard': [Input.Trigger, Input.Grip, Input.TrackPad, Input.Thumbstick, Input.A, Input.B]
|
|
20
22
|
};
|
|
21
|
-
var handledEvents = ['StartAnimation', 'Animation', 'EndAnimation', 'MouseEnter', 'MouseLeave', 'StartMouseMove', 'MouseMove', 'EndMouseMove', 'LeftButtonPress', 'LeftButtonRelease', 'MiddleButtonPress', 'MiddleButtonRelease', 'RightButtonPress', 'RightButtonRelease', 'KeyPress', 'KeyDown', 'KeyUp', 'StartMouseWheel', 'MouseWheel', 'EndMouseWheel', 'StartPinch', 'Pinch', 'EndPinch', 'StartPan', 'Pan', 'EndPan', 'StartRotate', 'Rotate', 'EndRotate', 'Button3D', 'Move3D', 'StartPointerLock', 'EndPointerLock', 'StartInteraction', 'Interaction', 'EndInteraction', 'AnimationFrameRateUpdate'];
|
|
23
|
+
var handledEvents = ['StartAnimation', 'Animation', 'EndAnimation', 'PointerEnter', 'PointerLeave', 'MouseEnter', 'MouseLeave', 'StartMouseMove', 'MouseMove', 'EndMouseMove', 'LeftButtonPress', 'LeftButtonRelease', 'MiddleButtonPress', 'MiddleButtonRelease', 'RightButtonPress', 'RightButtonRelease', 'KeyPress', 'KeyDown', 'KeyUp', 'StartMouseWheel', 'MouseWheel', 'EndMouseWheel', 'StartPinch', 'Pinch', 'EndPinch', 'StartPan', 'Pan', 'EndPan', 'StartRotate', 'Rotate', 'EndRotate', 'Button3D', 'Move3D', 'StartPointerLock', 'EndPointerLock', 'StartInteraction', 'Interaction', 'EndInteraction', 'AnimationFrameRateUpdate'];
|
|
22
24
|
|
|
23
25
|
function preventDefault(event) {
|
|
24
26
|
if (event.cancelable) {
|
|
@@ -27,6 +29,16 @@ function preventDefault(event) {
|
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
return false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function pointerCacheToPositions(cache) {
|
|
35
|
+
var positions = Object.create(null);
|
|
36
|
+
cache.forEach(function (_ref) {
|
|
37
|
+
var pointerId = _ref.pointerId,
|
|
38
|
+
position = _ref.position;
|
|
39
|
+
positions[pointerId] = position;
|
|
40
|
+
});
|
|
41
|
+
return positions;
|
|
30
42
|
} // ----------------------------------------------------------------------------
|
|
31
43
|
// vtkRenderWindowInteractor methods
|
|
32
44
|
// ----------------------------------------------------------------------------
|
|
@@ -36,9 +48,9 @@ function vtkRenderWindowInteractor(publicAPI, model) {
|
|
|
36
48
|
// Set our className
|
|
37
49
|
model.classHierarchy.push('vtkRenderWindowInteractor'); // Initialize list of requesters
|
|
38
50
|
|
|
39
|
-
var animationRequesters = new Set(); //
|
|
51
|
+
var animationRequesters = new Set(); // map from pointerId to { pointerId: number, position: [x, y] }
|
|
40
52
|
|
|
41
|
-
var
|
|
53
|
+
var pointerCache = new Map(); // Public API methods
|
|
42
54
|
//----------------------------------------------------------------------
|
|
43
55
|
|
|
44
56
|
publicAPI.start = function () {
|
|
@@ -127,20 +139,13 @@ function vtkRenderWindowInteractor(publicAPI, model) {
|
|
|
127
139
|
x: scaleX * (source.clientX - bounds.left),
|
|
128
140
|
y: scaleY * (bounds.height - source.clientY + bounds.top),
|
|
129
141
|
z: 0
|
|
130
|
-
};
|
|
131
|
-
updateCurrentRenderer(position.x, position.y);
|
|
132
|
-
return position;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function getTouchEventPositionsFor(touches) {
|
|
136
|
-
var positions = {};
|
|
142
|
+
}; // if multitouch, do not update the current renderer
|
|
137
143
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
positions[touch.identifier] = getScreenEventPositionFor(touch);
|
|
144
|
+
if (pointerCache.size <= 1 || !model.currentRenderer) {
|
|
145
|
+
updateCurrentRenderer(position.x, position.y);
|
|
141
146
|
}
|
|
142
147
|
|
|
143
|
-
return
|
|
148
|
+
return position;
|
|
144
149
|
}
|
|
145
150
|
|
|
146
151
|
function getModifierKeysFor(event) {
|
|
@@ -162,40 +167,8 @@ function vtkRenderWindowInteractor(publicAPI, model) {
|
|
|
162
167
|
return keys;
|
|
163
168
|
}
|
|
164
169
|
|
|
165
|
-
function
|
|
166
|
-
|
|
167
|
-
var rootElm = document;
|
|
168
|
-
var method = addListeners ? 'addEventListener' : 'removeEventListener';
|
|
169
|
-
var invMethod = addListeners ? 'removeEventListener' : 'addEventListener';
|
|
170
|
-
|
|
171
|
-
if (!force && !addListeners && activeListenerCount > 0) {
|
|
172
|
-
--activeListenerCount;
|
|
173
|
-
} // only add/remove listeners when there are no registered listeners
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
if (!activeListenerCount || force) {
|
|
177
|
-
activeListenerCount = 0;
|
|
178
|
-
|
|
179
|
-
if (model.container) {
|
|
180
|
-
model.container[invMethod]('mousemove', publicAPI.handleMouseMove);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
rootElm[method]('mouseup', publicAPI.handleMouseUp);
|
|
184
|
-
rootElm[method]('mousemove', publicAPI.handleMouseMove);
|
|
185
|
-
rootElm[method]('touchend', publicAPI.handleTouchEnd, false);
|
|
186
|
-
rootElm[method]('touchcancel', publicAPI.handleTouchEnd, {
|
|
187
|
-
passive: false,
|
|
188
|
-
capture: false
|
|
189
|
-
});
|
|
190
|
-
rootElm[method]('touchmove', publicAPI.handleTouchMove, {
|
|
191
|
-
passive: false,
|
|
192
|
-
capture: false
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (!force && addListeners) {
|
|
197
|
-
++activeListenerCount;
|
|
198
|
-
}
|
|
170
|
+
function getDeviceTypeFor(event) {
|
|
171
|
+
return event.pointerType || '';
|
|
199
172
|
}
|
|
200
173
|
|
|
201
174
|
publicAPI.bindEvents = function (container) {
|
|
@@ -204,40 +177,50 @@ function vtkRenderWindowInteractor(publicAPI, model) {
|
|
|
204
177
|
|
|
205
178
|
container.addEventListener('wheel', publicAPI.handleWheel);
|
|
206
179
|
container.addEventListener('DOMMouseScroll', publicAPI.handleWheel);
|
|
207
|
-
container.addEventListener('
|
|
208
|
-
container.addEventListener('
|
|
209
|
-
container.addEventListener('
|
|
210
|
-
|
|
180
|
+
container.addEventListener('pointerenter', publicAPI.handlePointerEnter);
|
|
181
|
+
container.addEventListener('pointerleave', publicAPI.handlePointerLeave);
|
|
182
|
+
container.addEventListener('pointermove', publicAPI.handlePointerMove, {
|
|
183
|
+
passive: false
|
|
184
|
+
});
|
|
185
|
+
container.addEventListener('pointerdown', publicAPI.handlePointerDown, {
|
|
186
|
+
passive: false
|
|
187
|
+
});
|
|
188
|
+
container.addEventListener('pointerup', publicAPI.handlePointerUp);
|
|
189
|
+
container.addEventListener('pointercancel', publicAPI.handlePointerCancel);
|
|
211
190
|
document.addEventListener('keypress', publicAPI.handleKeyPress);
|
|
212
191
|
document.addEventListener('keydown', publicAPI.handleKeyDown);
|
|
213
192
|
document.addEventListener('keyup', publicAPI.handleKeyUp);
|
|
214
|
-
document.addEventListener('pointerlockchange', publicAPI.handlePointerLockChange);
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
193
|
+
document.addEventListener('pointerlockchange', publicAPI.handlePointerLockChange); // using touchAction is more performant than preventDefault
|
|
194
|
+
// in a touchstart handler.
|
|
195
|
+
|
|
196
|
+
container.style.touchAction = 'none';
|
|
197
|
+
container.style.userSelect = 'none'; // disables tap highlight for when cursor is pointer
|
|
198
|
+
|
|
199
|
+
container.style.webkitTapHighlightColor = 'rgba(0,0,0,0)';
|
|
219
200
|
};
|
|
220
201
|
|
|
221
202
|
publicAPI.unbindEvents = function () {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
203
|
+
var container = model.container;
|
|
204
|
+
container.removeEventListener('contextmenu', preventDefault); // model.container.removeEventListener('click', preventDefault); // Avoid stopping event propagation
|
|
205
|
+
|
|
206
|
+
container.removeEventListener('wheel', publicAPI.handleWheel);
|
|
207
|
+
container.removeEventListener('DOMMouseScroll', publicAPI.handleWheel);
|
|
208
|
+
container.removeEventListener('pointerenter', publicAPI.handlePointerEnter);
|
|
209
|
+
container.removeEventListener('pointerleave', publicAPI.handlePointerLeave);
|
|
210
|
+
container.removeEventListener('pointermove', publicAPI.handlePointerMove, {
|
|
211
|
+
passive: false
|
|
212
|
+
});
|
|
213
|
+
container.removeEventListener('pointerdown', publicAPI.handlePointerDown, {
|
|
214
|
+
passive: false
|
|
215
|
+
});
|
|
216
|
+
container.removeEventListener('pointerup', publicAPI.handlePointerUp);
|
|
217
|
+
container.removeEventListener('pointercancel', publicAPI.handlePointerCancel);
|
|
232
218
|
document.removeEventListener('keypress', publicAPI.handleKeyPress);
|
|
233
219
|
document.removeEventListener('keydown', publicAPI.handleKeyDown);
|
|
234
220
|
document.removeEventListener('keyup', publicAPI.handleKeyUp);
|
|
235
221
|
document.removeEventListener('pointerlockchange', publicAPI.handlePointerLockChange);
|
|
236
|
-
model.container.removeEventListener('touchstart', publicAPI.handleTouchStart, {
|
|
237
|
-
passive: false,
|
|
238
|
-
capture: false
|
|
239
|
-
});
|
|
240
222
|
model.container = null;
|
|
223
|
+
pointerCache.clear();
|
|
241
224
|
};
|
|
242
225
|
|
|
243
226
|
publicAPI.handleKeyPress = function (event) {
|
|
@@ -255,19 +238,131 @@ function vtkRenderWindowInteractor(publicAPI, model) {
|
|
|
255
238
|
publicAPI.keyUpEvent(data);
|
|
256
239
|
};
|
|
257
240
|
|
|
258
|
-
publicAPI.
|
|
259
|
-
|
|
241
|
+
publicAPI.handlePointerEnter = function (event) {
|
|
242
|
+
var callData = _objectSpread(_objectSpread({}, getModifierKeysFor(event)), {}, {
|
|
243
|
+
position: getScreenEventPositionFor(event),
|
|
244
|
+
deviceType: getDeviceTypeFor(event)
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
publicAPI.pointerEnterEvent(callData);
|
|
248
|
+
|
|
249
|
+
if (callData.deviceType === 'mouse') {
|
|
250
|
+
publicAPI.mouseEnterEvent(callData);
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
publicAPI.handlePointerLeave = function (event) {
|
|
255
|
+
var callData = _objectSpread(_objectSpread({}, getModifierKeysFor(event)), {}, {
|
|
256
|
+
position: getScreenEventPositionFor(event),
|
|
257
|
+
deviceType: getDeviceTypeFor(event)
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
publicAPI.pointerLeaveEvent(callData);
|
|
261
|
+
|
|
262
|
+
if (callData.deviceType === 'mouse') {
|
|
263
|
+
publicAPI.mouseLeaveEvent(callData);
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
publicAPI.handlePointerDown = function (event) {
|
|
268
|
+
if (event.button > 2 || publicAPI.isPointerLocked()) {
|
|
260
269
|
// ignore events from extra mouse buttons such as `back` and `forward`
|
|
261
270
|
return;
|
|
262
271
|
}
|
|
263
272
|
|
|
264
|
-
interactionRegistration(true);
|
|
265
273
|
preventDefault(event);
|
|
266
274
|
|
|
267
|
-
|
|
275
|
+
if (event.target.hasPointerCapture(event.pointerId)) {
|
|
276
|
+
event.target.releasePointerCapture(event.pointerId);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
model.container.setPointerCapture(event.pointerId);
|
|
280
|
+
|
|
281
|
+
if (pointerCache.has(event.pointerId)) {
|
|
282
|
+
vtkWarningMacro('[RenderWindowInteractor] duplicate pointerId detected');
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
pointerCache.set(event.pointerId, {
|
|
286
|
+
pointerId: event.pointerId,
|
|
268
287
|
position: getScreenEventPositionFor(event)
|
|
269
288
|
});
|
|
270
289
|
|
|
290
|
+
switch (event.pointerType) {
|
|
291
|
+
case 'pen':
|
|
292
|
+
case 'touch':
|
|
293
|
+
publicAPI.handleTouchStart(event);
|
|
294
|
+
break;
|
|
295
|
+
|
|
296
|
+
case 'mouse':
|
|
297
|
+
default:
|
|
298
|
+
publicAPI.handleMouseDown(event);
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
publicAPI.handlePointerUp = function (event) {
|
|
304
|
+
if (pointerCache.has(event.pointerId)) {
|
|
305
|
+
preventDefault(event);
|
|
306
|
+
pointerCache.delete(event.pointerId);
|
|
307
|
+
model.container.releasePointerCapture(event.pointerId);
|
|
308
|
+
|
|
309
|
+
switch (event.pointerType) {
|
|
310
|
+
case 'pen':
|
|
311
|
+
case 'touch':
|
|
312
|
+
publicAPI.handleTouchEnd(event);
|
|
313
|
+
break;
|
|
314
|
+
|
|
315
|
+
case 'mouse':
|
|
316
|
+
default:
|
|
317
|
+
publicAPI.handleMouseUp(event);
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
publicAPI.handlePointerCancel = function (event) {
|
|
324
|
+
if (pointerCache.has(event.pointerId)) {
|
|
325
|
+
pointerCache.delete(event.pointerId);
|
|
326
|
+
|
|
327
|
+
switch (event.pointerType) {
|
|
328
|
+
case 'pen':
|
|
329
|
+
case 'touch':
|
|
330
|
+
publicAPI.handleTouchEnd(event);
|
|
331
|
+
break;
|
|
332
|
+
|
|
333
|
+
case 'mouse':
|
|
334
|
+
default:
|
|
335
|
+
publicAPI.handleMouseUp(event);
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
publicAPI.handlePointerMove = function (event) {
|
|
342
|
+
if (pointerCache.has(event.pointerId)) {
|
|
343
|
+
var pointer = pointerCache.get(event.pointerId);
|
|
344
|
+
pointer.position = getScreenEventPositionFor(event);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
switch (event.pointerType) {
|
|
348
|
+
case 'pen':
|
|
349
|
+
case 'touch':
|
|
350
|
+
publicAPI.handleTouchMove(event);
|
|
351
|
+
break;
|
|
352
|
+
|
|
353
|
+
case 'mouse':
|
|
354
|
+
default:
|
|
355
|
+
publicAPI.handleMouseMove(event);
|
|
356
|
+
break;
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
publicAPI.handleMouseDown = function (event) {
|
|
361
|
+
var callData = _objectSpread(_objectSpread({}, getModifierKeysFor(event)), {}, {
|
|
362
|
+
position: getScreenEventPositionFor(event),
|
|
363
|
+
deviceType: getDeviceTypeFor(event)
|
|
364
|
+
});
|
|
365
|
+
|
|
271
366
|
switch (event.button) {
|
|
272
367
|
case 0:
|
|
273
368
|
publicAPI.leftButtonPressEvent(callData);
|
|
@@ -457,10 +552,9 @@ function vtkRenderWindowInteractor(publicAPI, model) {
|
|
|
457
552
|
};
|
|
458
553
|
|
|
459
554
|
publicAPI.handleMouseMove = function (event) {
|
|
460
|
-
// Do not consume event for move
|
|
461
|
-
// preventDefault(event);
|
|
462
555
|
var callData = _objectSpread(_objectSpread({}, getModifierKeysFor(event)), {}, {
|
|
463
|
-
position: getScreenEventPositionFor(event)
|
|
556
|
+
position: getScreenEventPositionFor(event),
|
|
557
|
+
deviceType: getDeviceTypeFor(event)
|
|
464
558
|
});
|
|
465
559
|
|
|
466
560
|
if (model.moveTimeoutID === 0) {
|
|
@@ -522,7 +616,8 @@ function vtkRenderWindowInteractor(publicAPI, model) {
|
|
|
522
616
|
*/
|
|
523
617
|
|
|
524
618
|
var callData = _objectSpread(_objectSpread(_objectSpread({}, normalizeWheel(event)), getModifierKeysFor(event)), {}, {
|
|
525
|
-
position: getScreenEventPositionFor(event)
|
|
619
|
+
position: getScreenEventPositionFor(event),
|
|
620
|
+
deviceType: getDeviceTypeFor(event)
|
|
526
621
|
});
|
|
527
622
|
|
|
528
623
|
if (model.wheelTimeoutID === 0) {
|
|
@@ -540,28 +635,10 @@ function vtkRenderWindowInteractor(publicAPI, model) {
|
|
|
540
635
|
}, 200);
|
|
541
636
|
};
|
|
542
637
|
|
|
543
|
-
publicAPI.handleMouseEnter = function (event) {
|
|
544
|
-
var callData = _objectSpread(_objectSpread({}, getModifierKeysFor(event)), {}, {
|
|
545
|
-
position: getScreenEventPositionFor(event)
|
|
546
|
-
});
|
|
547
|
-
|
|
548
|
-
publicAPI.mouseEnterEvent(callData);
|
|
549
|
-
};
|
|
550
|
-
|
|
551
|
-
publicAPI.handleMouseLeave = function (event) {
|
|
552
|
-
var callData = _objectSpread(_objectSpread({}, getModifierKeysFor(event)), {}, {
|
|
553
|
-
position: getScreenEventPositionFor(event)
|
|
554
|
-
});
|
|
555
|
-
|
|
556
|
-
publicAPI.mouseLeaveEvent(callData);
|
|
557
|
-
};
|
|
558
|
-
|
|
559
638
|
publicAPI.handleMouseUp = function (event) {
|
|
560
|
-
interactionRegistration(false);
|
|
561
|
-
preventDefault(event);
|
|
562
|
-
|
|
563
639
|
var callData = _objectSpread(_objectSpread({}, getModifierKeysFor(event)), {}, {
|
|
564
|
-
position: getScreenEventPositionFor(event)
|
|
640
|
+
position: getScreenEventPositionFor(event),
|
|
641
|
+
deviceType: getDeviceTypeFor(event)
|
|
565
642
|
});
|
|
566
643
|
|
|
567
644
|
switch (event.button) {
|
|
@@ -584,107 +661,85 @@ function vtkRenderWindowInteractor(publicAPI, model) {
|
|
|
584
661
|
};
|
|
585
662
|
|
|
586
663
|
publicAPI.handleTouchStart = function (event) {
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
if (model.recognizeGestures &&
|
|
591
|
-
var positions =
|
|
592
|
-
|
|
593
|
-
if (
|
|
594
|
-
var
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
controlKey: false
|
|
600
|
-
};
|
|
664
|
+
var pointers = _toConsumableArray(pointerCache.values()); // If multitouch
|
|
665
|
+
|
|
666
|
+
|
|
667
|
+
if (model.recognizeGestures && pointers.length > 1) {
|
|
668
|
+
var positions = pointerCacheToPositions(pointerCache); // did we just transition to multitouch?
|
|
669
|
+
|
|
670
|
+
if (pointers.length === 2) {
|
|
671
|
+
var callData = _objectSpread(_objectSpread({}, getModifierKeysFor(EMPTY_MOUSE_EVENT)), {}, {
|
|
672
|
+
position: pointers[0].position,
|
|
673
|
+
deviceType: getDeviceTypeFor(event)
|
|
674
|
+
});
|
|
675
|
+
|
|
601
676
|
publicAPI.leftButtonReleaseEvent(callData);
|
|
602
677
|
} // handle the gesture
|
|
603
678
|
|
|
604
679
|
|
|
605
680
|
publicAPI.recognizeGesture('TouchStart', positions);
|
|
606
|
-
} else {
|
|
607
|
-
var
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
controlKey: false
|
|
613
|
-
};
|
|
681
|
+
} else if (pointers.length === 1) {
|
|
682
|
+
var _callData = _objectSpread(_objectSpread({}, getModifierKeysFor(EMPTY_MOUSE_EVENT)), {}, {
|
|
683
|
+
position: getScreenEventPositionFor(event),
|
|
684
|
+
deviceType: getDeviceTypeFor(event)
|
|
685
|
+
});
|
|
686
|
+
|
|
614
687
|
publicAPI.leftButtonPressEvent(_callData);
|
|
615
688
|
}
|
|
616
689
|
};
|
|
617
690
|
|
|
618
691
|
publicAPI.handleTouchMove = function (event) {
|
|
619
|
-
|
|
692
|
+
var pointers = _toConsumableArray(pointerCache.values());
|
|
620
693
|
|
|
621
|
-
if (model.recognizeGestures &&
|
|
622
|
-
var positions =
|
|
694
|
+
if (model.recognizeGestures && pointers.length > 1) {
|
|
695
|
+
var positions = pointerCacheToPositions(pointerCache);
|
|
623
696
|
publicAPI.recognizeGesture('TouchMove', positions);
|
|
624
|
-
} else {
|
|
625
|
-
var
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
controlKey: false
|
|
631
|
-
};
|
|
697
|
+
} else if (pointers.length === 1) {
|
|
698
|
+
var callData = _objectSpread(_objectSpread({}, getModifierKeysFor(EMPTY_MOUSE_EVENT)), {}, {
|
|
699
|
+
position: pointers[0].position,
|
|
700
|
+
deviceType: getDeviceTypeFor(event)
|
|
701
|
+
});
|
|
702
|
+
|
|
632
703
|
publicAPI.mouseMoveEvent(callData);
|
|
633
704
|
}
|
|
634
705
|
};
|
|
635
706
|
|
|
636
707
|
publicAPI.handleTouchEnd = function (event) {
|
|
637
|
-
|
|
708
|
+
var pointers = _toConsumableArray(pointerCache.values());
|
|
638
709
|
|
|
639
710
|
if (model.recognizeGestures) {
|
|
640
711
|
// No more fingers down
|
|
641
|
-
if (
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
controlKey: false
|
|
650
|
-
};
|
|
651
|
-
publicAPI.leftButtonReleaseEvent(callData);
|
|
652
|
-
interactionRegistration(false);
|
|
653
|
-
} else {
|
|
654
|
-
// If more than one finger released, recognize touchend
|
|
655
|
-
var positions = getTouchEventPositionsFor(event.changedTouches);
|
|
656
|
-
publicAPI.recognizeGesture('TouchEnd', positions);
|
|
657
|
-
interactionRegistration(false);
|
|
658
|
-
}
|
|
659
|
-
} else if (event.touches.length === 1) {
|
|
712
|
+
if (pointers.length === 0) {
|
|
713
|
+
var callData = _objectSpread(_objectSpread({}, getModifierKeysFor(EMPTY_MOUSE_EVENT)), {}, {
|
|
714
|
+
position: pointers[0].position,
|
|
715
|
+
deviceType: getDeviceTypeFor(event)
|
|
716
|
+
});
|
|
717
|
+
|
|
718
|
+
publicAPI.leftButtonReleaseEvent(callData);
|
|
719
|
+
} else if (pointers.length === 1) {
|
|
660
720
|
// If one finger left, end touch and start button press
|
|
661
|
-
var
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
var
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
controlKey: false
|
|
670
|
-
};
|
|
721
|
+
var positions = pointerCacheToPositions(pointerCache);
|
|
722
|
+
publicAPI.recognizeGesture('TouchEnd', positions);
|
|
723
|
+
|
|
724
|
+
var _callData2 = _objectSpread(_objectSpread({}, getModifierKeysFor(EMPTY_MOUSE_EVENT)), {}, {
|
|
725
|
+
position: pointers[0].position,
|
|
726
|
+
deviceType: getDeviceTypeFor(event)
|
|
727
|
+
});
|
|
728
|
+
|
|
671
729
|
publicAPI.leftButtonPressEvent(_callData2);
|
|
672
730
|
} else {
|
|
673
731
|
// If more than one finger left, keep touch move
|
|
674
|
-
var
|
|
732
|
+
var _positions = pointerCacheToPositions(pointerCache);
|
|
675
733
|
|
|
676
|
-
publicAPI.recognizeGesture('TouchMove',
|
|
734
|
+
publicAPI.recognizeGesture('TouchMove', _positions);
|
|
677
735
|
}
|
|
678
|
-
} else {
|
|
679
|
-
var
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
controlKey: false
|
|
685
|
-
};
|
|
736
|
+
} else if (pointers.length === 1) {
|
|
737
|
+
var _callData3 = _objectSpread(_objectSpread({}, getModifierKeysFor(EMPTY_MOUSE_EVENT)), {}, {
|
|
738
|
+
position: pointers[0].position,
|
|
739
|
+
deviceType: getDeviceTypeFor(event)
|
|
740
|
+
});
|
|
741
|
+
|
|
686
742
|
publicAPI.leftButtonReleaseEvent(_callData3);
|
|
687
|
-
interactionRegistration(false);
|
|
688
743
|
}
|
|
689
744
|
};
|
|
690
745
|
|