@kitware/vtk.js 24.0.1 → 24.1.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.
- package/Rendering/OpenGL/Glyph3DMapper.js +11 -2
- package/Rendering/OpenGL/HardwareSelector.js +11 -9
- package/Rendering/OpenGL/Helper.js +145 -3
- package/Rendering/OpenGL/OrderIndependentTranslucentPass.js +10 -14
- package/Rendering/OpenGL/PolyDataMapper.js +16 -77
- package/Rendering/OpenGL/PolyDataMapper2D.js +14 -98
- package/Rendering/OpenGL/RenderWindow.js +6 -0
- package/Rendering/OpenGL/Renderer.js +4 -3
- package/Widgets/SVG/SVGLandmarkRepresentation.js +9 -2
- package/Widgets/Widgets3D/AngleWidget/behavior.js +11 -7
- package/Widgets/Widgets3D/DistanceWidget/behavior.js +9 -5
- package/Widgets/Widgets3D/ImageCroppingWidget/behavior.js +5 -5
- package/Widgets/Widgets3D/ImplicitPlaneWidget.js +11 -7
- package/Widgets/Widgets3D/LabelWidget/behavior.js +25 -12
- package/Widgets/Widgets3D/LineWidget/behavior.js +14 -10
- package/Widgets/Widgets3D/PaintWidget/behavior.js +6 -4
- package/Widgets/Widgets3D/PolyLineWidget/behavior.js +11 -7
- package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +11 -7
- package/Widgets/Widgets3D/ShapeWidget/behavior.js +23 -15
- package/Widgets/Widgets3D/SphereWidget/behavior.js +15 -7
- package/Widgets/Widgets3D/SplineWidget/behavior.js +11 -8
- package/package.json +2 -2
|
@@ -59,7 +59,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
59
59
|
newHandle.setScale1(moveHandle.getScale1());
|
|
60
60
|
} else {
|
|
61
61
|
isDragging = true;
|
|
62
|
-
|
|
62
|
+
|
|
63
|
+
model._apiSpecificRenderWindow.setCursor('grabbing');
|
|
63
64
|
|
|
64
65
|
model._interactor.requestAnimation(publicAPI);
|
|
65
66
|
}
|
|
@@ -74,8 +75,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
74
75
|
publicAPI.handleMouseMove = function (callData) {
|
|
75
76
|
if (model.pickable && model.dragable && model.manipulator && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
|
|
76
77
|
model.manipulator.setOrigin(model.activeState.getOrigin());
|
|
77
|
-
model.manipulator.setNormal(model.
|
|
78
|
-
var worldCoords = model.manipulator.handleEvent(callData, model.
|
|
78
|
+
model.manipulator.setNormal(model._camera.getDirectionOfProjection());
|
|
79
|
+
var worldCoords = model.manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
79
80
|
|
|
80
81
|
if (worldCoords.length && (model.activeState === model.widgetState.getMoveHandle() || isDragging)) {
|
|
81
82
|
model.activeState.setOrigin(worldCoords);
|
|
@@ -85,7 +86,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
if (model.hasFocus) {
|
|
88
|
-
model.
|
|
89
|
+
model._widgetManager.disablePicking();
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
return macro.VOID;
|
|
@@ -96,7 +97,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
96
97
|
|
|
97
98
|
publicAPI.handleLeftButtonRelease = function () {
|
|
98
99
|
if (isDragging && model.pickable) {
|
|
99
|
-
model.
|
|
100
|
+
model._apiSpecificRenderWindow.setCursor('pointer');
|
|
101
|
+
|
|
100
102
|
model.widgetState.deactivate();
|
|
101
103
|
|
|
102
104
|
model._interactor.cancelAnimation(publicAPI);
|
|
@@ -108,7 +110,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
108
110
|
|
|
109
111
|
if (model.hasFocus && !model.activeState || model.activeState && !model.activeState.getActive()) {
|
|
110
112
|
publicAPI.invokeEndInteractionEvent();
|
|
111
|
-
|
|
113
|
+
|
|
114
|
+
model._widgetManager.enablePicking();
|
|
112
115
|
|
|
113
116
|
model._interactor.render();
|
|
114
117
|
}
|
|
@@ -157,7 +160,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
157
160
|
model.widgetState.getMoveHandle().setVisible(false);
|
|
158
161
|
model.activeState = null;
|
|
159
162
|
model.hasFocus = false;
|
|
160
|
-
|
|
163
|
+
|
|
164
|
+
model._widgetManager.enablePicking();
|
|
161
165
|
|
|
162
166
|
model._interactor.render();
|
|
163
167
|
};
|
|
@@ -37,19 +37,23 @@ function widgetBehavior(publicAPI, model) {
|
|
|
37
37
|
publicAPI.updateCursor = function () {
|
|
38
38
|
switch (model.activeState.getUpdateMethodName()) {
|
|
39
39
|
case InteractionMethodsName.TranslateCenter:
|
|
40
|
-
model.
|
|
40
|
+
model._apiSpecificRenderWindow.setCursor('move');
|
|
41
|
+
|
|
41
42
|
break;
|
|
42
43
|
|
|
43
44
|
case InteractionMethodsName.RotateLine:
|
|
44
|
-
model.
|
|
45
|
+
model._apiSpecificRenderWindow.setCursor('alias');
|
|
46
|
+
|
|
45
47
|
break;
|
|
46
48
|
|
|
47
49
|
case InteractionMethodsName.TranslateAxis:
|
|
48
|
-
model.
|
|
50
|
+
model._apiSpecificRenderWindow.setCursor('pointer');
|
|
51
|
+
|
|
49
52
|
break;
|
|
50
53
|
|
|
51
54
|
default:
|
|
52
|
-
model.
|
|
55
|
+
model._apiSpecificRenderWindow.setCursor('default');
|
|
56
|
+
|
|
53
57
|
break;
|
|
54
58
|
}
|
|
55
59
|
};
|
|
@@ -197,7 +201,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
197
201
|
|
|
198
202
|
publicAPI[InteractionMethodsName.TranslateAxis] = function (calldata) {
|
|
199
203
|
var stateLine = model.widgetState.getActiveLineState();
|
|
200
|
-
var worldCoords = model.planeManipulator.handleEvent(calldata, model.
|
|
204
|
+
var worldCoords = model.planeManipulator.handleEvent(calldata, model._apiSpecificRenderWindow);
|
|
201
205
|
var point1 = stateLine.getPoint1();
|
|
202
206
|
var point2 = stateLine.getPoint2(); // Translate the current line along the other line
|
|
203
207
|
|
|
@@ -237,7 +241,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
237
241
|
};
|
|
238
242
|
|
|
239
243
|
publicAPI[InteractionMethodsName.TranslateCenter] = function (calldata) {
|
|
240
|
-
var worldCoords = model.planeManipulator.handleEvent(calldata, model.
|
|
244
|
+
var worldCoords = model.planeManipulator.handleEvent(calldata, model._apiSpecificRenderWindow);
|
|
241
245
|
worldCoords = publicAPI.getBoundedCenter(worldCoords);
|
|
242
246
|
model.activeState.setCenter(worldCoords);
|
|
243
247
|
updateState(model.widgetState);
|
|
@@ -246,7 +250,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
246
250
|
publicAPI[InteractionMethodsName.RotateLine] = function (calldata) {
|
|
247
251
|
var activeLine = model.widgetState.getActiveLineState();
|
|
248
252
|
var planeNormal = model.planeManipulator.getNormal();
|
|
249
|
-
var worldCoords = model.planeManipulator.handleEvent(calldata, model.
|
|
253
|
+
var worldCoords = model.planeManipulator.handleEvent(calldata, model._apiSpecificRenderWindow);
|
|
250
254
|
var center = model.widgetState.getCenter();
|
|
251
255
|
var previousLineDirection = subtract(activeLine.getPoint1(), activeLine.getPoint2(), []);
|
|
252
256
|
normalize(previousLineDirection);
|
|
@@ -238,17 +238,19 @@ function widgetBehavior(publicAPI, model) {
|
|
|
238
238
|
};
|
|
239
239
|
|
|
240
240
|
var computeTextPosition = function computeTextPosition(worldBounds, textPosition) {
|
|
241
|
-
var _model$
|
|
241
|
+
var _model$_apiSpecificRe, _model$_apiSpecificRe2, _model$_apiSpecificRe5;
|
|
242
242
|
|
|
243
243
|
var worldMargin = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
244
244
|
var viewPlaneOrigin = model.manipulator.getOrigin();
|
|
245
245
|
var viewPlaneNormal = model.manipulator.getNormal();
|
|
246
|
-
|
|
246
|
+
|
|
247
|
+
var viewUp = model._renderer.getActiveCamera().getViewUp();
|
|
248
|
+
|
|
247
249
|
var positionMargin = Array.isArray(worldMargin) ? _toConsumableArray(worldMargin) : [worldMargin, worldMargin, viewPlaneOrigin ? worldMargin : 0]; // Map bounds from world positions to display positions
|
|
248
250
|
|
|
249
|
-
var minPoint = (_model$
|
|
251
|
+
var minPoint = (_model$_apiSpecificRe = model._apiSpecificRenderWindow).worldToDisplay.apply(_model$_apiSpecificRe, _toConsumableArray(vtkBoundingBox.getMinPoint(worldBounds)).concat([model._renderer]));
|
|
250
252
|
|
|
251
|
-
var maxPoint = (_model$
|
|
253
|
+
var maxPoint = (_model$_apiSpecificRe2 = model._apiSpecificRenderWindow).worldToDisplay.apply(_model$_apiSpecificRe2, _toConsumableArray(vtkBoundingBox.getMaxPoint(worldBounds)).concat([model._renderer]));
|
|
252
254
|
|
|
253
255
|
var displayBounds = vtkMath.computeBoundsFromPoints(minPoint, maxPoint, []);
|
|
254
256
|
var planeOrigin = [];
|
|
@@ -257,15 +259,15 @@ function widgetBehavior(publicAPI, model) {
|
|
|
257
259
|
var p3 = []; // If we are in a 2D projection
|
|
258
260
|
|
|
259
261
|
if (viewPlaneOrigin && viewPlaneNormal && viewUp && vtkBoundingBox.intersectPlane(displayBounds, viewPlaneOrigin, viewPlaneNormal)) {
|
|
260
|
-
var _model$
|
|
262
|
+
var _model$_apiSpecificRe3, _model$_apiSpecificRe4;
|
|
261
263
|
|
|
262
264
|
// Map plane origin from world positions to display positions
|
|
263
|
-
var displayPlaneOrigin = (_model$
|
|
265
|
+
var displayPlaneOrigin = (_model$_apiSpecificRe3 = model._apiSpecificRenderWindow).worldToDisplay.apply(_model$_apiSpecificRe3, _toConsumableArray(viewPlaneOrigin).concat([model._renderer])); // Map plane normal from world positions to display positions
|
|
264
266
|
|
|
265
267
|
|
|
266
268
|
var planeNormalPoint = vtkMath.add(viewPlaneOrigin, viewPlaneNormal, []);
|
|
267
269
|
|
|
268
|
-
var displayPlaneNormalPoint = (_model$
|
|
270
|
+
var displayPlaneNormalPoint = (_model$_apiSpecificRe4 = model._apiSpecificRenderWindow).worldToDisplay.apply(_model$_apiSpecificRe4, _toConsumableArray(planeNormalPoint).concat([model._renderer]));
|
|
269
271
|
|
|
270
272
|
var displayPlaneNormal = vtkMath.subtract(displayPlaneNormalPoint, displayPlaneOrigin); // Project view plane into bounding box
|
|
271
273
|
|
|
@@ -300,7 +302,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
300
302
|
vtkMath.add(finalPosition, v, finalPosition);
|
|
301
303
|
vtkMath.add(finalPosition, w, finalPosition);
|
|
302
304
|
vtkMath.add(finalPosition, positionMargin, finalPosition);
|
|
303
|
-
return (_model$
|
|
305
|
+
return (_model$_apiSpecificRe5 = model._apiSpecificRenderWindow).displayToWorld.apply(_model$_apiSpecificRe5, finalPosition.concat([model._renderer]));
|
|
304
306
|
};
|
|
305
307
|
|
|
306
308
|
publicAPI.updateTextPosition = function (point1, point2) {
|
|
@@ -350,8 +352,10 @@ function widgetBehavior(publicAPI, model) {
|
|
|
350
352
|
if (!model.point2) {
|
|
351
353
|
// Update orientation to match the camera's plane
|
|
352
354
|
// if the corners are not yet placed
|
|
353
|
-
var normal = model.
|
|
354
|
-
|
|
355
|
+
var normal = model._camera.getDirectionOfProjection();
|
|
356
|
+
|
|
357
|
+
var up = model._camera.getViewUp();
|
|
358
|
+
|
|
355
359
|
var right = [];
|
|
356
360
|
vec3.cross(right, up, normal);
|
|
357
361
|
model.shapeHandle.setUp(up);
|
|
@@ -360,7 +364,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
360
364
|
model.manipulator.setNormal(normal);
|
|
361
365
|
}
|
|
362
366
|
|
|
363
|
-
var worldCoords = model.manipulator.handleEvent(callData, model.
|
|
367
|
+
var worldCoords = model.manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
364
368
|
|
|
365
369
|
if (!worldCoords.length) {
|
|
366
370
|
return macro.VOID;
|
|
@@ -420,7 +424,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
420
424
|
|
|
421
425
|
if (model.point1 && (model.activeState === model.point1Handle || model.activeState === model.point2Handle)) {
|
|
422
426
|
model.isDragging = true;
|
|
423
|
-
|
|
427
|
+
|
|
428
|
+
model._apiSpecificRenderWindow.setCursor('grabbing');
|
|
424
429
|
|
|
425
430
|
model._interactor.requestAnimation(publicAPI);
|
|
426
431
|
|
|
@@ -437,7 +442,9 @@ function widgetBehavior(publicAPI, model) {
|
|
|
437
442
|
publicAPI.handleLeftButtonRelease = function (e) {
|
|
438
443
|
if (model.isDragging) {
|
|
439
444
|
model.isDragging = false;
|
|
440
|
-
|
|
445
|
+
|
|
446
|
+
model._apiSpecificRenderWindow.setCursor('pointer');
|
|
447
|
+
|
|
441
448
|
model.widgetState.deactivate();
|
|
442
449
|
|
|
443
450
|
model._interactor.cancelAnimation(publicAPI);
|
|
@@ -450,7 +457,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
450
457
|
return macro.VOID;
|
|
451
458
|
}
|
|
452
459
|
|
|
453
|
-
var viewSize = model.
|
|
460
|
+
var viewSize = model._apiSpecificRenderWindow.getSize();
|
|
454
461
|
|
|
455
462
|
if (e.position.x < 0 || e.position.x > viewSize[0] - 1 || e.position.y < 0 || e.position.y > viewSize[1] - 1) {
|
|
456
463
|
return macro.VOID;
|
|
@@ -550,7 +557,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
550
557
|
|
|
551
558
|
model._interactor.render();
|
|
552
559
|
|
|
553
|
-
model.
|
|
560
|
+
model._widgetManager.enablePicking();
|
|
561
|
+
|
|
554
562
|
superClass.loseFocus();
|
|
555
563
|
};
|
|
556
564
|
}
|
|
@@ -50,11 +50,12 @@ function widgetBehavior(publicAPI, model) {
|
|
|
50
50
|
shapeHandle.setVisible(true);
|
|
51
51
|
shapeHandle.setOrigin(center);
|
|
52
52
|
shapeHandle.setScale1(radius * 2);
|
|
53
|
-
|
|
53
|
+
|
|
54
|
+
model._interactor.render();
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
function currentWorldCoords(e) {
|
|
57
|
-
return model.manipulator.handleEvent(e, model.
|
|
58
|
+
return model.manipulator.handleEvent(e, model._apiSpecificRenderWindow);
|
|
58
59
|
} // Update the sphere's center and radius. Example:
|
|
59
60
|
// handle.setCenterAndRadius([1,2,3], 10);
|
|
60
61
|
|
|
@@ -78,7 +79,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
78
79
|
centerHandle.setOrigin(newCenter);
|
|
79
80
|
borderHandle.setOrigin(newBorder);
|
|
80
81
|
updateSphere();
|
|
81
|
-
|
|
82
|
+
|
|
83
|
+
model._widgetManager.enablePicking();
|
|
82
84
|
};
|
|
83
85
|
|
|
84
86
|
publicAPI.handleLeftButtonPress = function (e) {
|
|
@@ -101,7 +103,9 @@ function widgetBehavior(publicAPI, model) {
|
|
|
101
103
|
}
|
|
102
104
|
|
|
103
105
|
model.isDragging = true;
|
|
104
|
-
|
|
106
|
+
|
|
107
|
+
model._apiSpecificRenderWindow.setCursor('grabbing');
|
|
108
|
+
|
|
105
109
|
model.previousPosition = _toConsumableArray(currentWorldCoords(e));
|
|
106
110
|
publicAPI.invokeStartInteractionEvent();
|
|
107
111
|
return macro.EVENT_ABORT;
|
|
@@ -115,8 +119,11 @@ function widgetBehavior(publicAPI, model) {
|
|
|
115
119
|
|
|
116
120
|
if (isPlaced()) {
|
|
117
121
|
model.previousPosition = null;
|
|
118
|
-
|
|
119
|
-
model.
|
|
122
|
+
|
|
123
|
+
model._widgetManager.enablePicking();
|
|
124
|
+
|
|
125
|
+
model._apiSpecificRenderWindow.setCursor('pointer');
|
|
126
|
+
|
|
120
127
|
model.isDragging = false;
|
|
121
128
|
model.activeState = null;
|
|
122
129
|
state.deactivate();
|
|
@@ -165,7 +172,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
165
172
|
borderHandle.setOrigin(null);
|
|
166
173
|
model.isDragging = true;
|
|
167
174
|
model.activeState = moveHandle;
|
|
168
|
-
|
|
175
|
+
|
|
176
|
+
model._interactor.render();
|
|
169
177
|
};
|
|
170
178
|
|
|
171
179
|
publicAPI.loseFocus = function () {
|
|
@@ -37,14 +37,14 @@ function widgetBehavior(publicAPI, model) {
|
|
|
37
37
|
model.firstHandle = model.lastHandle;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
model.
|
|
40
|
+
model._apiSpecificRenderWindow.setCursor('grabbing');
|
|
41
41
|
}
|
|
42
42
|
}; // --------------------------------------------------------------------------
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
var getHoveredHandle = function getHoveredHandle() {
|
|
46
46
|
var handles = model.widgetState.getHandleList();
|
|
47
|
-
var scale = model.moveHandle.getScale1() * vec3.distance(model.
|
|
47
|
+
var scale = model.moveHandle.getScale1() * vec3.distance(model._apiSpecificRenderWindow.displayToWorld(0, 0, 0, model._renderer), model._apiSpecificRenderWindow.displayToWorld(1, 0, 0, model._renderer));
|
|
48
48
|
return handles.reduce(function (_ref, handle) {
|
|
49
49
|
var closestHandle = _ref.closestHandle,
|
|
50
50
|
closestDistance = _ref.closestDistance;
|
|
@@ -185,7 +185,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
185
185
|
model.freeHand = publicAPI.getAllowFreehand() && !model.isDragging;
|
|
186
186
|
} else {
|
|
187
187
|
model.isDragging = true;
|
|
188
|
-
|
|
188
|
+
|
|
189
|
+
model._apiSpecificRenderWindow.setCursor('grabbing');
|
|
189
190
|
|
|
190
191
|
model._interactor.requestAnimation(publicAPI);
|
|
191
192
|
|
|
@@ -201,7 +202,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
201
202
|
publicAPI.handleLeftButtonRelease = function (e) {
|
|
202
203
|
if (model.isDragging) {
|
|
203
204
|
if (!model.hasFocus) {
|
|
204
|
-
model.
|
|
205
|
+
model._apiSpecificRenderWindow.setCursor(model.defaultCursor);
|
|
206
|
+
|
|
205
207
|
model.widgetState.deactivate();
|
|
206
208
|
|
|
207
209
|
model._interactor.cancelAnimation(publicAPI);
|
|
@@ -249,19 +251,20 @@ function widgetBehavior(publicAPI, model) {
|
|
|
249
251
|
return macro.VOID;
|
|
250
252
|
}
|
|
251
253
|
|
|
252
|
-
model.manipulator.setNormal(model.
|
|
253
|
-
var worldCoords = model.manipulator.handleEvent(callData, model.
|
|
254
|
+
model.manipulator.setNormal(model._camera.getDirectionOfProjection());
|
|
255
|
+
var worldCoords = model.manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
254
256
|
var hoveredHandle = getHoveredHandle();
|
|
255
257
|
|
|
256
258
|
if (hoveredHandle) {
|
|
257
259
|
model.moveHandle.setVisible(false);
|
|
258
260
|
|
|
259
261
|
if (hoveredHandle !== model.firstHandle) {
|
|
260
|
-
model.
|
|
262
|
+
model._apiSpecificRenderWindow.setCursor('grabbing');
|
|
261
263
|
}
|
|
262
264
|
} else if (!model.isDragging && model.hasFocus) {
|
|
263
265
|
model.moveHandle.setVisible(true);
|
|
264
|
-
|
|
266
|
+
|
|
267
|
+
model._apiSpecificRenderWindow.setCursor(model.defaultCursor);
|
|
265
268
|
}
|
|
266
269
|
|
|
267
270
|
if (model.lastHandle) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitware/vtk.js",
|
|
3
|
-
"version": "24.0
|
|
3
|
+
"version": "24.1.0",
|
|
4
4
|
"description": "Visualization Toolkit for the Web",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"3d",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"html-webpack-plugin": "5.5.0",
|
|
88
88
|
"husky": "7.0.4",
|
|
89
89
|
"ignore-loader": "0.1.2",
|
|
90
|
-
"karma": "6.3.
|
|
90
|
+
"karma": "6.3.17",
|
|
91
91
|
"karma-chrome-launcher": "3.1.0",
|
|
92
92
|
"karma-coverage": "2.1.0",
|
|
93
93
|
"karma-firefox-launcher": "2.1.2",
|