@kitware/vtk.js 28.13.1 → 29.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/BREAKING_CHANGES.md +7 -0
- package/Common/Core/Math/index.js +1 -1
- package/Common/Core/Math.js +1 -1
- package/Proxy/Core/ViewProxy.d.ts +2 -1
- package/Rendering/Core/CellPicker.d.ts +11 -0
- package/Rendering/Core/CellPicker.js +112 -4
- package/Rendering/Core/ColorTransferFunction.js +1 -1
- package/Rendering/Core/Coordinate.js +1 -1
- package/Rendering/Core/CubeAxesActor.js +1 -1
- package/Rendering/Core/ImageMapper.js +1 -1
- package/Rendering/Core/Picker.js +26 -2
- package/Rendering/Core/PointPicker.js +1 -1
- package/Rendering/Core/RenderWindow.d.ts +1 -0
- package/Rendering/Core/Renderer.js +1 -1
- package/Rendering/Core/ScalarBarActor.js +1 -1
- package/Rendering/Core/VolumeMapper.js +1 -1
- package/Rendering/Misc/FullScreenRenderWindow.d.ts +4 -1
- package/Rendering/Misc/FullScreenRenderWindow.js +2 -1
- package/Rendering/Misc/GenericRenderWindow.d.ts +3 -2
- package/Rendering/Misc/GenericRenderWindow.js +11 -9
- package/Rendering/OpenGL/PolyDataMapper2D.js +1 -1
- package/Rendering/OpenGL/RenderWindow.d.ts +0 -34
- package/Rendering/OpenGL/RenderWindow.js +2 -177
- package/Rendering/OpenGL/Texture.js +1 -1
- package/Rendering/OpenGL/VolumeMapper.js +4 -4
- package/Rendering/WebGPU/RenderWindow.js +12 -0
- package/Rendering/{OpenGL/RenderWindow → WebXR/RenderWindowHelper}/Constants.d.ts +2 -1
- package/Rendering/WebXR/RenderWindowHelper.d.ts +90 -0
- package/Rendering/WebXR/RenderWindowHelper.js +242 -0
- package/Widgets/Core/WidgetManager.d.ts +0 -24
- package/Widgets/Core/WidgetManager.js +5 -29
- package/Widgets/Widgets3D/AngleWidget.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +1 -1
- package/Widgets/Widgets3D.js +0 -2
- package/index.d.ts +2 -1
- package/package.json +2 -1
- package/Widgets/Widgets3D/DistanceWidget/behavior.js +0 -133
- package/Widgets/Widgets3D/DistanceWidget/state.js +0 -22
- package/Widgets/Widgets3D/DistanceWidget.js +0 -109
- /package/Rendering/{OpenGL/RenderWindow → WebXR/RenderWindowHelper}/Constants.js +0 -0
|
@@ -10,8 +10,7 @@ const {
|
|
|
10
10
|
CaptureOn
|
|
11
11
|
} = WidgetManagerConst;
|
|
12
12
|
const {
|
|
13
|
-
vtkErrorMacro
|
|
14
|
-
vtkWarningMacro
|
|
13
|
+
vtkErrorMacro
|
|
15
14
|
} = macro;
|
|
16
15
|
let viewIdCount = 1;
|
|
17
16
|
|
|
@@ -203,15 +202,16 @@ function vtkWidgetManager(publicAPI, model) {
|
|
|
203
202
|
}
|
|
204
203
|
async function captureBuffers(x1, y1, x2, y2) {
|
|
205
204
|
if (model._captureInProgress) {
|
|
205
|
+
await model._captureInProgress;
|
|
206
206
|
return;
|
|
207
207
|
}
|
|
208
|
-
model._captureInProgress = true;
|
|
209
208
|
renderPickingBuffer();
|
|
210
209
|
model._capturedBuffers = null;
|
|
211
|
-
model.
|
|
210
|
+
model._captureInProgress = model._selector.getSourceDataAsync(model._renderer, x1, y1, x2, y2);
|
|
211
|
+
model._capturedBuffers = await model._captureInProgress;
|
|
212
|
+
model._captureInProgress = null;
|
|
212
213
|
model.previousSelectedData = null;
|
|
213
214
|
renderFrontBuffer();
|
|
214
|
-
model._captureInProgress = false;
|
|
215
215
|
}
|
|
216
216
|
publicAPI.enablePicking = () => {
|
|
217
217
|
model.pickingEnabled = true;
|
|
@@ -343,30 +343,6 @@ function vtkWidgetManager(publicAPI, model) {
|
|
|
343
343
|
}
|
|
344
344
|
return publicAPI.getSelectedData();
|
|
345
345
|
};
|
|
346
|
-
publicAPI.updateSelectionFromXY = (x, y) => {
|
|
347
|
-
vtkWarningMacro('updateSelectionFromXY is deprecated, please use getSelectedDataForXY');
|
|
348
|
-
if (model.pickingEnabled) {
|
|
349
|
-
// Then pick regular representations.
|
|
350
|
-
if (model.captureOn === CaptureOn.MOUSE_MOVE) {
|
|
351
|
-
captureBuffers(x, y, x, y);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
};
|
|
355
|
-
publicAPI.updateSelectionFromMouseEvent = event => {
|
|
356
|
-
vtkWarningMacro('updateSelectionFromMouseEvent is deprecated, please use getSelectedDataForXY');
|
|
357
|
-
const {
|
|
358
|
-
pageX,
|
|
359
|
-
pageY
|
|
360
|
-
} = event;
|
|
361
|
-
const {
|
|
362
|
-
top,
|
|
363
|
-
left,
|
|
364
|
-
height
|
|
365
|
-
} = model._apiSpecificRenderWindow.getCanvas().getBoundingClientRect();
|
|
366
|
-
const x = pageX - left;
|
|
367
|
-
const y = height - (pageY - top);
|
|
368
|
-
publicAPI.updateSelectionFromXY(x, y);
|
|
369
|
-
};
|
|
370
346
|
publicAPI.getSelectedData = () => {
|
|
371
347
|
if (!model.selections || !model.selections.length) {
|
|
372
348
|
model.previousSelectedData = null;
|
|
@@ -3,7 +3,7 @@ import vtkAbstractWidgetFactory from '../Core/AbstractWidgetFactory.js';
|
|
|
3
3
|
import vtkPlanePointManipulator from '../Manipulators/PlaneManipulator.js';
|
|
4
4
|
import vtkPolyLineRepresentation from '../Representations/PolyLineRepresentation.js';
|
|
5
5
|
import vtkSphereHandleRepresentation from '../Representations/SphereHandleRepresentation.js';
|
|
6
|
-
import { s as subtract,
|
|
6
|
+
import { s as subtract, T as angleBetweenVectors } from '../../Common/Core/Math/index.js';
|
|
7
7
|
import widgetBehavior from './AngleWidget/behavior.js';
|
|
8
8
|
import generateState from './AngleWidget/state.js';
|
|
9
9
|
import { ViewTypes } from '../Core/WidgetManager/Constants.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { m as macro } from '../../../macros2.js';
|
|
2
2
|
import vtkBoundingBox from '../../../Common/DataModel/BoundingBox.js';
|
|
3
3
|
import vtkLine from '../../../Common/DataModel/Line.js';
|
|
4
|
-
import { k as add, l as normalize, s as subtract, d as dot, j as cross, m as multiplyAccumulate, w as multiplyScalar,
|
|
4
|
+
import { k as add, l as normalize, s as subtract, d as dot, j as cross, m as multiplyAccumulate, w as multiplyScalar, U as signedAngleBetweenVectors } from '../../../Common/Core/Math/index.js';
|
|
5
5
|
import { getLineNames, getOtherLineName, updateState, boundPointOnPlane, getLinePlaneName, getLineInPlaneName, rotateVector } from './helpers.js';
|
|
6
6
|
import { InteractionMethodsName, ScrollingMethods, planeNameToViewType } from './Constants.js';
|
|
7
7
|
|
|
@@ -2,7 +2,7 @@ import vtkBoundingBox, { STATIC } from '../../../Common/DataModel/BoundingBox.js
|
|
|
2
2
|
import vtkCubeSource from '../../../Filters/Sources/CubeSource.js';
|
|
3
3
|
import vtkCutter from '../../../Filters/Core/Cutter.js';
|
|
4
4
|
import vtkPlane from '../../../Common/DataModel/Plane.js';
|
|
5
|
-
import { s as subtract, l as normalize, j as cross, w as multiplyScalar, m as multiplyAccumulate,
|
|
5
|
+
import { s as subtract, l as normalize, j as cross, w as multiplyScalar, m as multiplyAccumulate, U as signedAngleBetweenVectors } from '../../../Common/Core/Math/index.js';
|
|
6
6
|
import vtkMatrixBuilder from '../../../Common/Core/MatrixBuilder.js';
|
|
7
7
|
import { viewTypeToPlaneName, planeNameToViewType, planeNames } from './Constants.js';
|
|
8
8
|
|
package/Widgets/Widgets3D.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import vtkAngleWidget from './Widgets3D/AngleWidget.js';
|
|
2
|
-
import vtkDistanceWidget from './Widgets3D/DistanceWidget.js';
|
|
3
2
|
import vtkEllipseWidget from './Widgets3D/EllipseWidget.js';
|
|
4
3
|
import vtkImageCroppingWidget from './Widgets3D/ImageCroppingWidget.js';
|
|
5
4
|
import vtkImplicitPlaneWidget from './Widgets3D/ImplicitPlaneWidget.js';
|
|
@@ -16,7 +15,6 @@ import vtkSplineWidget from './Widgets3D/SplineWidget.js';
|
|
|
16
15
|
|
|
17
16
|
var Widgets3D = {
|
|
18
17
|
vtkAngleWidget,
|
|
19
|
-
vtkDistanceWidget,
|
|
20
18
|
vtkEllipseWidget,
|
|
21
19
|
vtkImageCroppingWidget,
|
|
22
20
|
vtkImplicitPlaneWidget,
|
package/index.d.ts
CHANGED
|
@@ -205,11 +205,12 @@
|
|
|
205
205
|
/// <reference path="./Rendering/Misc/TextureLODsDownloader.d.ts" />
|
|
206
206
|
/// <reference path="./Rendering/OpenGL/HardwareSelector/Constants.d.ts" />
|
|
207
207
|
/// <reference path="./Rendering/OpenGL/HardwareSelector.d.ts" />
|
|
208
|
-
/// <reference path="./Rendering/OpenGL/RenderWindow/Constants.d.ts" />
|
|
209
208
|
/// <reference path="./Rendering/OpenGL/RenderWindow.d.ts" />
|
|
210
209
|
/// <reference path="./Rendering/SceneGraph/RenderPass.d.ts" />
|
|
211
210
|
/// <reference path="./Rendering/SceneGraph/ViewNode.d.ts" />
|
|
212
211
|
/// <reference path="./Rendering/SceneGraph/ViewNodeFactory.d.ts" />
|
|
212
|
+
/// <reference path="./Rendering/WebXR/RenderWindowHelper/Constants.d.ts" />
|
|
213
|
+
/// <reference path="./Rendering/WebXR/RenderWindowHelper.d.ts" />
|
|
213
214
|
/// <reference path="./Widgets/Core/AbstractWidget.d.ts" />
|
|
214
215
|
/// <reference path="./Widgets/Core/AbstractWidgetFactory.d.ts" />
|
|
215
216
|
/// <reference path="./Widgets/Core/StateBuilder.d.ts" />
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitware/vtk.js",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "29.1.0",
|
|
4
4
|
"description": "Visualization Toolkit for the Web",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"3d",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"module": "./index.js",
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/runtime": "7.22.11",
|
|
34
|
+
"@types/webxr": "^0.5.5",
|
|
34
35
|
"commander": "9.2.0",
|
|
35
36
|
"d3-scale": "4.0.2",
|
|
36
37
|
"fast-deep-equal": "^3.1.3",
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { m as macro } from '../../../macros2.js';
|
|
2
|
-
|
|
3
|
-
const MAX_POINTS = 2;
|
|
4
|
-
function widgetBehavior(publicAPI, model) {
|
|
5
|
-
model.classHierarchy.push('vtkDistanceWidgetProp');
|
|
6
|
-
model._isDragging = false;
|
|
7
|
-
|
|
8
|
-
// --------------------------------------------------------------------------
|
|
9
|
-
// Display 2D
|
|
10
|
-
// --------------------------------------------------------------------------
|
|
11
|
-
|
|
12
|
-
publicAPI.setDisplayCallback = callback => model.representations[0].setDisplayCallback(callback);
|
|
13
|
-
|
|
14
|
-
// --------------------------------------------------------------------------
|
|
15
|
-
// Interactor events
|
|
16
|
-
// --------------------------------------------------------------------------
|
|
17
|
-
|
|
18
|
-
function ignoreKey(e) {
|
|
19
|
-
return e.altKey || e.controlKey || e.shiftKey;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// --------------------------------------------------------------------------
|
|
23
|
-
// Left press: Select handle to drag
|
|
24
|
-
// --------------------------------------------------------------------------
|
|
25
|
-
|
|
26
|
-
publicAPI.handleLeftButtonPress = e => {
|
|
27
|
-
if (!model.activeState || !model.activeState.getActive() || !model.pickable || ignoreKey(e)) {
|
|
28
|
-
return macro.VOID;
|
|
29
|
-
}
|
|
30
|
-
const manipulator = model.activeState?.getManipulator?.() ?? model.manipulator;
|
|
31
|
-
if (model.activeState === model.widgetState.getMoveHandle() && model.widgetState.getHandleList().length < MAX_POINTS && manipulator) {
|
|
32
|
-
const {
|
|
33
|
-
worldCoords
|
|
34
|
-
} = manipulator.handleEvent(e, model._apiSpecificRenderWindow);
|
|
35
|
-
// Commit handle to location
|
|
36
|
-
const moveHandle = model.widgetState.getMoveHandle();
|
|
37
|
-
moveHandle.setOrigin(...worldCoords);
|
|
38
|
-
const newHandle = model.widgetState.addHandle();
|
|
39
|
-
newHandle.setOrigin(...moveHandle.getOrigin());
|
|
40
|
-
newHandle.setColor(moveHandle.getColor());
|
|
41
|
-
newHandle.setScale1(moveHandle.getScale1());
|
|
42
|
-
newHandle.setManipulator(manipulator);
|
|
43
|
-
} else if (model.dragable) {
|
|
44
|
-
model._isDragging = true;
|
|
45
|
-
model._apiSpecificRenderWindow.setCursor('grabbing');
|
|
46
|
-
model._interactor.requestAnimation(publicAPI);
|
|
47
|
-
}
|
|
48
|
-
publicAPI.invokeStartInteractionEvent();
|
|
49
|
-
return macro.EVENT_ABORT;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
// --------------------------------------------------------------------------
|
|
53
|
-
// Mouse move: Drag selected handle / Handle follow the mouse
|
|
54
|
-
// --------------------------------------------------------------------------
|
|
55
|
-
|
|
56
|
-
publicAPI.handleMouseMove = callData => {
|
|
57
|
-
const manipulator = model.activeState?.getManipulator?.() ?? model.manipulator;
|
|
58
|
-
if (manipulator && model.pickable && model.dragable && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
|
|
59
|
-
const {
|
|
60
|
-
worldCoords
|
|
61
|
-
} = manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
62
|
-
if (worldCoords.length && (model.activeState === model.widgetState.getMoveHandle() || model._isDragging) && model.activeState.setOrigin // e.g. the line is pickable but not draggable
|
|
63
|
-
) {
|
|
64
|
-
model.activeState.setOrigin(worldCoords);
|
|
65
|
-
publicAPI.invokeInteractionEvent();
|
|
66
|
-
return macro.EVENT_ABORT;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return macro.VOID;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
// --------------------------------------------------------------------------
|
|
73
|
-
// Left release: Finish drag / Create new handle
|
|
74
|
-
// --------------------------------------------------------------------------
|
|
75
|
-
|
|
76
|
-
publicAPI.handleLeftButtonRelease = () => {
|
|
77
|
-
if (!model.activeState || !model.activeState.getActive() || !model.pickable) {
|
|
78
|
-
return macro.VOID;
|
|
79
|
-
}
|
|
80
|
-
if (model.hasFocus && model.widgetState.getHandleList().length === MAX_POINTS) {
|
|
81
|
-
publicAPI.loseFocus();
|
|
82
|
-
return macro.VOID;
|
|
83
|
-
}
|
|
84
|
-
if (model._isDragging) {
|
|
85
|
-
model._apiSpecificRenderWindow.setCursor('pointer');
|
|
86
|
-
model.widgetState.deactivate();
|
|
87
|
-
model._interactor.cancelAnimation(publicAPI);
|
|
88
|
-
model._isDragging = false;
|
|
89
|
-
} else if (model.activeState !== model.widgetState.getMoveHandle()) {
|
|
90
|
-
model.widgetState.deactivate();
|
|
91
|
-
}
|
|
92
|
-
if (model.hasFocus && !model.activeState || model.activeState && !model.activeState.getActive()) {
|
|
93
|
-
model._widgetManager.enablePicking();
|
|
94
|
-
model._interactor.render();
|
|
95
|
-
}
|
|
96
|
-
publicAPI.invokeEndInteractionEvent();
|
|
97
|
-
return macro.EVENT_ABORT;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
// --------------------------------------------------------------------------
|
|
101
|
-
// Focus API - modeHandle follow mouse when widget has focus
|
|
102
|
-
// --------------------------------------------------------------------------
|
|
103
|
-
|
|
104
|
-
publicAPI.grabFocus = () => {
|
|
105
|
-
if (!model.hasFocus && model.widgetState.getHandleList().length < MAX_POINTS) {
|
|
106
|
-
model.activeState = model.widgetState.getMoveHandle();
|
|
107
|
-
model.activeState.activate();
|
|
108
|
-
model.activeState.setVisible(true);
|
|
109
|
-
model._interactor.requestAnimation(publicAPI);
|
|
110
|
-
publicAPI.invokeStartInteractionEvent();
|
|
111
|
-
}
|
|
112
|
-
model.hasFocus = true;
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
// --------------------------------------------------------------------------
|
|
116
|
-
|
|
117
|
-
publicAPI.loseFocus = () => {
|
|
118
|
-
if (model.hasFocus) {
|
|
119
|
-
model._interactor.cancelAnimation(publicAPI);
|
|
120
|
-
publicAPI.invokeEndInteractionEvent();
|
|
121
|
-
}
|
|
122
|
-
model.widgetState.deactivate();
|
|
123
|
-
model.widgetState.getMoveHandle().deactivate();
|
|
124
|
-
model.widgetState.getMoveHandle().setVisible(false);
|
|
125
|
-
model.widgetState.getMoveHandle().setOrigin(null);
|
|
126
|
-
model.activeState = null;
|
|
127
|
-
model.hasFocus = false;
|
|
128
|
-
model._widgetManager.enablePicking();
|
|
129
|
-
model._interactor.render();
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export { widgetBehavior as default };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import vtkStateBuilder from '../../Core/StateBuilder.js';
|
|
2
|
-
|
|
3
|
-
function generateState() {
|
|
4
|
-
return vtkStateBuilder.createBuilder().addStateFromMixin({
|
|
5
|
-
labels: ['moveHandle'],
|
|
6
|
-
mixins: ['origin', 'color', 'scale1', 'visible', 'manipulator'],
|
|
7
|
-
name: 'moveHandle',
|
|
8
|
-
initialValues: {
|
|
9
|
-
scale1: 30,
|
|
10
|
-
visible: false
|
|
11
|
-
}
|
|
12
|
-
}).addDynamicMixinState({
|
|
13
|
-
labels: ['handles'],
|
|
14
|
-
mixins: ['origin', 'color', 'scale1', 'visible', 'manipulator'],
|
|
15
|
-
name: 'handle',
|
|
16
|
-
initialValues: {
|
|
17
|
-
scale1: 30
|
|
18
|
-
}
|
|
19
|
-
}).build();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export { generateState as default };
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { m as macro } from '../../macros2.js';
|
|
2
|
-
import vtkAbstractWidgetFactory from '../Core/AbstractWidgetFactory.js';
|
|
3
|
-
import vtkPlanePointManipulator from '../Manipulators/PlaneManipulator.js';
|
|
4
|
-
import vtkPolyLineRepresentation from '../Representations/PolyLineRepresentation.js';
|
|
5
|
-
import vtkSphereHandleRepresentation from '../Representations/SphereHandleRepresentation.js';
|
|
6
|
-
import { e as distance2BetweenPoints } from '../../Common/Core/Math/index.js';
|
|
7
|
-
import widgetBehavior from './DistanceWidget/behavior.js';
|
|
8
|
-
import generateState from './DistanceWidget/state.js';
|
|
9
|
-
import { ViewTypes } from '../Core/WidgetManager/Constants.js';
|
|
10
|
-
|
|
11
|
-
// ----------------------------------------------------------------------------
|
|
12
|
-
// Factory
|
|
13
|
-
// ----------------------------------------------------------------------------
|
|
14
|
-
|
|
15
|
-
function vtkDistanceWidget(publicAPI, model) {
|
|
16
|
-
model.classHierarchy.push('vtkDistanceWidget');
|
|
17
|
-
const superClass = {
|
|
18
|
-
...publicAPI
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// --- Widget Requirement ---------------------------------------------------
|
|
22
|
-
|
|
23
|
-
model.methodsToLink = ['activeScaleFactor', 'activeColor', 'useActiveColor', 'glyphResolution', 'defaultScale', 'scaleInPixels'];
|
|
24
|
-
publicAPI.getRepresentationsForViewType = viewType => {
|
|
25
|
-
switch (viewType) {
|
|
26
|
-
case ViewTypes.DEFAULT:
|
|
27
|
-
case ViewTypes.GEOMETRY:
|
|
28
|
-
case ViewTypes.SLICE:
|
|
29
|
-
case ViewTypes.VOLUME:
|
|
30
|
-
default:
|
|
31
|
-
return [{
|
|
32
|
-
builder: vtkSphereHandleRepresentation,
|
|
33
|
-
labels: ['handles']
|
|
34
|
-
}, {
|
|
35
|
-
builder: vtkSphereHandleRepresentation,
|
|
36
|
-
labels: ['moveHandle']
|
|
37
|
-
}, {
|
|
38
|
-
builder: vtkPolyLineRepresentation,
|
|
39
|
-
labels: ['handles', 'moveHandle']
|
|
40
|
-
}];
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
// --- Public methods -------------------------------------------------------
|
|
45
|
-
|
|
46
|
-
publicAPI.getDistance = () => {
|
|
47
|
-
const handles = model.widgetState.getHandleList();
|
|
48
|
-
if (handles.length !== 2) {
|
|
49
|
-
return 0;
|
|
50
|
-
}
|
|
51
|
-
if (!handles[0].getOrigin() || !handles[1].getOrigin()) {
|
|
52
|
-
return 0;
|
|
53
|
-
}
|
|
54
|
-
return Math.sqrt(distance2BetweenPoints(handles[0].getOrigin(), handles[1].getOrigin()));
|
|
55
|
-
};
|
|
56
|
-
publicAPI.setManipulator = manipulator => {
|
|
57
|
-
superClass.setManipulator(manipulator);
|
|
58
|
-
model.widgetState.getMoveHandle().setManipulator(manipulator);
|
|
59
|
-
model.widgetState.getHandleList().forEach(handle => {
|
|
60
|
-
handle.setManipulator(manipulator);
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
// --------------------------------------------------------------------------
|
|
65
|
-
// initialization
|
|
66
|
-
// --------------------------------------------------------------------------
|
|
67
|
-
|
|
68
|
-
model.widgetState.onBoundsChange(bounds => {
|
|
69
|
-
const center = [(bounds[0] + bounds[1]) * 0.5, (bounds[2] + bounds[3]) * 0.5, (bounds[4] + bounds[5]) * 0.5];
|
|
70
|
-
model.widgetState.getMoveHandle().setOrigin(center);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
// Default manipulator
|
|
74
|
-
publicAPI.setManipulator(model.manipulator || vtkPlanePointManipulator.newInstance({
|
|
75
|
-
useCameraNormal: true
|
|
76
|
-
}));
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// ----------------------------------------------------------------------------
|
|
80
|
-
|
|
81
|
-
const defaultValues = initialValues => ({
|
|
82
|
-
// manipulator: null,
|
|
83
|
-
behavior: widgetBehavior,
|
|
84
|
-
widgetState: generateState(),
|
|
85
|
-
...initialValues
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
// ----------------------------------------------------------------------------
|
|
89
|
-
|
|
90
|
-
function extend(publicAPI, model) {
|
|
91
|
-
let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
92
|
-
Object.assign(model, defaultValues(initialValues));
|
|
93
|
-
vtkAbstractWidgetFactory.extend(publicAPI, model, initialValues);
|
|
94
|
-
macro.setGet(publicAPI, model, ['manipulator']);
|
|
95
|
-
vtkDistanceWidget(publicAPI, model);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// ----------------------------------------------------------------------------
|
|
99
|
-
|
|
100
|
-
const newInstance = macro.newInstance(extend, 'vtkDistanceWidget');
|
|
101
|
-
|
|
102
|
-
// ----------------------------------------------------------------------------
|
|
103
|
-
|
|
104
|
-
var vtkDistanceWidget$1 = {
|
|
105
|
-
newInstance,
|
|
106
|
-
extend
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
export { vtkDistanceWidget$1 as default, extend, newInstance };
|
|
File without changes
|