@kitware/vtk.js 27.2.1 → 27.3.1
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/IO/Misc/OBJReader.js +3 -1
- package/Interaction/Manipulators/MouseCameraAxisRotateManipulator.js +33 -64
- package/Rendering/Core/Actor2D.d.ts +11 -0
- package/Rendering/OpenGL/ImageResliceMapper.js +3 -3
- package/Rendering/OpenGL/Texture.js +4 -2
- package/Widgets/Core/WidgetManager.d.ts +7 -0
- package/Widgets/Core/WidgetManager.js +5 -2
- package/package.json +1 -1
package/IO/Misc/OBJReader.js
CHANGED
|
@@ -349,7 +349,9 @@ function vtkOBJReader(publicAPI, model) {
|
|
|
349
349
|
|
|
350
350
|
publicAPI.loadData = function () {
|
|
351
351
|
var option = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
352
|
-
return fetchData(model.url, option).then(
|
|
352
|
+
return fetchData(model.url, option).then(function (content) {
|
|
353
|
+
return publicAPI.isDeleted() ? false : publicAPI.parseAsText(content);
|
|
354
|
+
});
|
|
353
355
|
};
|
|
354
356
|
|
|
355
357
|
publicAPI.parseAsText = function (content) {
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { mat4, vec3 } from 'gl-matrix';
|
|
1
|
+
import { vec3, mat4 } from 'gl-matrix';
|
|
3
2
|
import macro from '../../macros.js';
|
|
4
3
|
import vtkCompositeCameraManipulator from './CompositeCameraManipulator.js';
|
|
5
4
|
import vtkCompositeMouseManipulator from './CompositeMouseManipulator.js';
|
|
6
5
|
import { r as radiansFromDegrees, j as cross } from '../../Common/Core/Math/index.js';
|
|
7
|
-
import vtkMatrixBuilder from '../../Common/Core/MatrixBuilder.js';
|
|
8
6
|
|
|
9
7
|
// vtkMouseCameraAxisRotateManipulator methods
|
|
10
8
|
// ----------------------------------------------------------------------------
|
|
@@ -12,14 +10,15 @@ import vtkMatrixBuilder from '../../Common/Core/MatrixBuilder.js';
|
|
|
12
10
|
function vtkMouseCameraAxisRotateManipulator(publicAPI, model) {
|
|
13
11
|
// Set our className
|
|
14
12
|
model.classHierarchy.push('vtkMouseCameraAxisRotateManipulator');
|
|
13
|
+
var negCameraDir = new Float64Array(3);
|
|
15
14
|
var newCamPos = new Float64Array(3);
|
|
16
|
-
var newFp = new Float64Array(3);
|
|
17
|
-
|
|
15
|
+
var newFp = new Float64Array(3);
|
|
16
|
+
var newViewUp = new Float64Array(3);
|
|
18
17
|
var trans = new Float64Array(16);
|
|
18
|
+
var rotation = new Float64Array(16);
|
|
19
19
|
var v2 = new Float64Array(3);
|
|
20
20
|
var centerNeg = new Float64Array(3);
|
|
21
|
-
var
|
|
22
|
-
var fpDirection = new Float64Array(3);
|
|
21
|
+
var negRotationAxis = new Float64Array(3);
|
|
23
22
|
|
|
24
23
|
publicAPI.onButtonDown = function (interactor, renderer, position) {
|
|
25
24
|
model.previousPosition = position;
|
|
@@ -35,83 +34,53 @@ function vtkMouseCameraAxisRotateManipulator(publicAPI, model) {
|
|
|
35
34
|
var cameraFp = camera.getFocalPoint();
|
|
36
35
|
var cameraViewUp = camera.getViewUp();
|
|
37
36
|
var cameraDirection = camera.getDirectionOfProjection();
|
|
37
|
+
vec3.negate(negCameraDir, cameraDirection);
|
|
38
38
|
mat4.identity(trans);
|
|
39
|
+
mat4.identity(rotation);
|
|
39
40
|
var center = model.center,
|
|
40
41
|
rotationFactor = model.rotationFactor,
|
|
41
|
-
rotationAxis = model.rotationAxis;
|
|
42
|
-
|
|
43
|
-
mat4.translate(trans, trans, center);
|
|
42
|
+
rotationAxis = model.rotationAxis;
|
|
43
|
+
vec3.negate(negRotationAxis, rotationAxis);
|
|
44
44
|
var dx = model.previousPosition.x - position.x;
|
|
45
45
|
var dy = model.previousPosition.y - position.y;
|
|
46
46
|
var size = interactor.getView().getViewportSize(renderer); // Azimuth
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
var azimuthDelta = radiansFromDegrees(360.0 * dx / size[0] * rotationFactor);
|
|
49
|
+
mat4.rotate(rotation, rotation, azimuthDelta, rotationAxis); // Elevation
|
|
49
50
|
|
|
50
51
|
cross(cameraDirection, cameraViewUp, v2);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
centerNeg[0] = -center[0];
|
|
54
|
-
centerNeg[1] = -center[1];
|
|
55
|
-
centerNeg[2] = -center[2];
|
|
56
|
-
mat4.translate(trans, trans, centerNeg); // Apply transformation to camera position, focal point, and view up
|
|
52
|
+
var elevationDelta = radiansFromDegrees(-360.0 * dy / size[1] * rotationFactor); // angle of camera to rotation axis on the positive or negative half,
|
|
53
|
+
// relative to the origin.
|
|
57
54
|
|
|
58
|
-
vec3.
|
|
59
|
-
vec3.
|
|
60
|
-
// to the camera
|
|
55
|
+
var angleToPosHalf = Math.acos(vec3.dot(negCameraDir, rotationAxis));
|
|
56
|
+
var angleToNegHalf = Math.acos(vec3.dot(negCameraDir, negRotationAxis)); // whether camera is in positive half of the rotation axis or neg half
|
|
61
57
|
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
var inPosHalf = angleToPosHalf <= angleToNegHalf;
|
|
59
|
+
var elevationToAxis = Math.min(angleToPosHalf, angleToNegHalf);
|
|
64
60
|
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
61
|
+
if (model.useHalfAxis && !inPosHalf) {
|
|
62
|
+
elevationDelta = Math.PI / 2 - angleToPosHalf;
|
|
63
|
+
} else if (inPosHalf && elevationToAxis + elevationDelta < 0) {
|
|
64
|
+
elevationDelta = -elevationToAxis; // } else if (!inPosHalf && elevationToAxis - elevationDelta < 0) {
|
|
65
|
+
} else if (!inPosHalf && angleToPosHalf + elevationDelta > Math.PI) {
|
|
66
|
+
elevationDelta = elevationToAxis;
|
|
70
67
|
}
|
|
71
68
|
|
|
72
|
-
|
|
73
|
-
// what is the current distance from pos to center of rotation
|
|
74
|
-
var distance = vec3.distance(newCamPos, center); // what is the current direction from the center of rotation
|
|
75
|
-
// to the camera
|
|
76
|
-
|
|
77
|
-
vec3.subtract(direction, newCamPos, center);
|
|
78
|
-
vec3.normalize(direction, direction); // project the rotation axis onto the direction
|
|
79
|
-
// so we know how much below the half plane we are
|
|
80
|
-
|
|
81
|
-
var dotP = vec3.dot(rotationAxis, direction);
|
|
69
|
+
mat4.rotate(rotation, rotation, elevationDelta, v2); // Translate from origin
|
|
82
70
|
|
|
83
|
-
|
|
84
|
-
// adjust the new camera position to bring it up to the half plane
|
|
85
|
-
vec3.scaleAndAdd(newCamPos, newCamPos, rotationAxis, -dotP * distance); // the above step will change the distance which might feel odd
|
|
86
|
-
// so the next couple lines restore the distance to the center
|
|
87
|
-
// what is the new direction from the center of rotation
|
|
88
|
-
// to the camera
|
|
71
|
+
mat4.translate(trans, trans, center); // apply rotation
|
|
89
72
|
|
|
90
|
-
|
|
91
|
-
vec3.normalize(direction, direction);
|
|
92
|
-
vec3.scaleAndAdd(newCamPos, center, direction, distance); // compute original cam direction to center
|
|
73
|
+
mat4.multiply(trans, trans, rotation); // Translate to origin
|
|
93
74
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
var acosR = Math.min(1.0, Math.max(-1.0, vec3.dot(direction, v2)));
|
|
98
|
-
var rAngle = Math.acos(acosR); // 0 to pi
|
|
99
|
-
|
|
100
|
-
vec3.cross(v2, v2, direction);
|
|
101
|
-
vec3.normalize(v2, v2);
|
|
102
|
-
vec3.subtract(newFp, cameraFp, center);
|
|
103
|
-
var fpDist = vec3.length(newFp); // Note it normalizes the vector to be rotated
|
|
104
|
-
|
|
105
|
-
var result = _toConsumableArray(newFp);
|
|
106
|
-
|
|
107
|
-
vtkMatrixBuilder.buildFromRadian().rotate(rAngle, v2).apply(result);
|
|
108
|
-
vec3.scaleAndAdd(newFp, center, result, fpDist);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
75
|
+
vec3.negate(centerNeg, center);
|
|
76
|
+
mat4.translate(trans, trans, centerNeg); // Apply transformation to camera position, focal point, and view up
|
|
111
77
|
|
|
78
|
+
vec3.transformMat4(newCamPos, cameraPos, trans);
|
|
79
|
+
vec3.transformMat4(newFp, cameraFp, trans);
|
|
80
|
+
vec3.transformMat4(newViewUp, cameraViewUp, rotation);
|
|
112
81
|
camera.setPosition(newCamPos[0], newCamPos[1], newCamPos[2]);
|
|
113
82
|
camera.setFocalPoint(newFp[0], newFp[1], newFp[2]);
|
|
114
|
-
camera.setViewUp(
|
|
83
|
+
camera.setViewUp(newViewUp);
|
|
115
84
|
renderer.resetCameraClippingRange();
|
|
116
85
|
|
|
117
86
|
if (interactor.getLightFollowCamera()) {
|
|
@@ -2,6 +2,7 @@ import vtkProp, { IPropInitialValues } from './Prop';
|
|
|
2
2
|
import vtkCoordinate from './Coordinate';
|
|
3
3
|
import vtkMapper from './Mapper';
|
|
4
4
|
import vtkProperty2D, { IProperty2DInitialValues } from './Property2D';
|
|
5
|
+
import vtkMapper2D from './Mapper2D';
|
|
5
6
|
import { Bounds } from './../../types';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -44,6 +45,16 @@ export interface vtkActor2D extends vtkProp {
|
|
|
44
45
|
*/
|
|
45
46
|
makeProperty(initialValues?: IProperty2DInitialValues): vtkProperty2D;
|
|
46
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Sets the 2D mapper.
|
|
50
|
+
*/
|
|
51
|
+
setMapper(mapper: vtkMapper2D): boolean;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Gets the 2D mapper.
|
|
55
|
+
*/
|
|
56
|
+
getMapper(): vtkMapper2D;
|
|
57
|
+
|
|
47
58
|
/**
|
|
48
59
|
*
|
|
49
60
|
*/
|
|
@@ -126,9 +126,6 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
|
|
|
126
126
|
});
|
|
127
127
|
model.renderable.update();
|
|
128
128
|
model.currentInput = model.renderable.getInputData();
|
|
129
|
-
publicAPI.invokeEvent({
|
|
130
|
-
type: 'EndEvent'
|
|
131
|
-
});
|
|
132
129
|
|
|
133
130
|
if (!model.currentInput) {
|
|
134
131
|
vtkErrorMacro('No input!');
|
|
@@ -139,6 +136,9 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
|
|
|
139
136
|
publicAPI.renderPieceStart(ren, actor);
|
|
140
137
|
publicAPI.renderPieceDraw(ren, actor);
|
|
141
138
|
publicAPI.renderPieceFinish(ren, actor);
|
|
139
|
+
publicAPI.invokeEvent({
|
|
140
|
+
type: 'EndEvent'
|
|
141
|
+
});
|
|
142
142
|
};
|
|
143
143
|
|
|
144
144
|
publicAPI.renderPieceStart = function (ren, actor) {
|
|
@@ -16,7 +16,8 @@ var Wrap = Constants.Wrap,
|
|
|
16
16
|
var VtkDataTypes = vtkDataArray.VtkDataTypes;
|
|
17
17
|
var vtkDebugMacro = vtkDebugMacro$1,
|
|
18
18
|
vtkErrorMacro = vtkErrorMacro$1,
|
|
19
|
-
vtkWarningMacro = vtkWarningMacro$1;
|
|
19
|
+
vtkWarningMacro = vtkWarningMacro$1;
|
|
20
|
+
var toHalf = HalfFloat.toHalf; // ----------------------------------------------------------------------------
|
|
20
21
|
// vtkOpenGLTexture methods
|
|
21
22
|
// ----------------------------------------------------------------------------
|
|
22
23
|
|
|
@@ -610,9 +611,10 @@ function vtkOpenGLTexture(publicAPI, model) {
|
|
|
610
611
|
for (var _idx2 = 0; _idx2 < data.length; _idx2++) {
|
|
611
612
|
if (data[_idx2]) {
|
|
612
613
|
var newArray = new Uint16Array(pixCount);
|
|
614
|
+
var src = data[_idx2];
|
|
613
615
|
|
|
614
616
|
for (var i = 0; i < pixCount; i++) {
|
|
615
|
-
newArray[i] =
|
|
617
|
+
newArray[i] = toHalf(src[i]);
|
|
616
618
|
}
|
|
617
619
|
|
|
618
620
|
pixData.push(newArray);
|
|
@@ -82,6 +82,13 @@ export interface vtkWidgetManager extends vtkObject {
|
|
|
82
82
|
*/
|
|
83
83
|
getWidgets(): vtkAbstractWidget[];
|
|
84
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Get the active widget.
|
|
87
|
+
*
|
|
88
|
+
* If no widget is active, returns null.
|
|
89
|
+
*/
|
|
90
|
+
getActiveWidget(): Nullable<vtkAbstractWidget>;
|
|
91
|
+
|
|
85
92
|
/**
|
|
86
93
|
* Get the view id.
|
|
87
94
|
*/
|
|
@@ -190,10 +190,12 @@ function vtkWidgetManager(publicAPI, model) {
|
|
|
190
190
|
// Default cursor behavior
|
|
191
191
|
model._apiSpecificRenderWindow.setCursor(widget ? 'pointer' : 'default');
|
|
192
192
|
|
|
193
|
+
model.activeWidget = null;
|
|
193
194
|
wantRender = false;
|
|
194
195
|
|
|
195
196
|
if (model.widgetInFocus === widget && widget.hasFocus()) {
|
|
196
197
|
activateHandle(widget);
|
|
198
|
+
model.activeWidget = widget;
|
|
197
199
|
wantRender = true;
|
|
198
200
|
} else {
|
|
199
201
|
for (i = 0; i < model.widgets.length; i++) {
|
|
@@ -214,7 +216,7 @@ function vtkWidgetManager(publicAPI, model) {
|
|
|
214
216
|
model._interactor.render();
|
|
215
217
|
}
|
|
216
218
|
|
|
217
|
-
case
|
|
219
|
+
case 16:
|
|
218
220
|
case "end":
|
|
219
221
|
return _context3.stop();
|
|
220
222
|
}
|
|
@@ -614,6 +616,7 @@ var DEFAULT_VALUES = {
|
|
|
614
616
|
// _currentUpdateSelectionCallID: null,
|
|
615
617
|
viewId: null,
|
|
616
618
|
widgets: [],
|
|
619
|
+
activeWidget: null,
|
|
617
620
|
renderer: null,
|
|
618
621
|
viewType: ViewTypes.DEFAULT,
|
|
619
622
|
isAnimating: false,
|
|
@@ -633,7 +636,7 @@ function extend(publicAPI, model) {
|
|
|
633
636
|
name: 'viewType',
|
|
634
637
|
enum: ViewTypes
|
|
635
638
|
}]);
|
|
636
|
-
macro.get(publicAPI, model, ['selections', 'widgets', 'viewId', 'pickingEnabled']); // Object specific methods
|
|
639
|
+
macro.get(publicAPI, model, ['selections', 'widgets', 'viewId', 'pickingEnabled', 'activeWidget']); // Object specific methods
|
|
637
640
|
|
|
638
641
|
vtkWidgetManager(publicAPI, model);
|
|
639
642
|
} // ----------------------------------------------------------------------------
|