@kitware/vtk.js 24.0.0-beta.2 → 24.0.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/Actor.js +1 -1
- package/Rendering/Core/Prop.d.ts +6 -6
- package/Rendering/OpenGL/HardwareSelector.js +11 -9
- package/Rendering/OpenGL/RenderWindow.d.ts +9 -2
- package/Rendering/OpenGL/RenderWindow.js +2 -1
- package/Rendering/OpenGL/Renderer.js +4 -3
- package/Rendering/WebGPU/RenderWindow.js +3 -1
- 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/index.d.ts +1 -1
- package/package.json +1 -1
package/Rendering/Core/Actor.js
CHANGED
package/Rendering/Core/Prop.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export interface IPropInitialValues {
|
|
|
14
14
|
estimatedRenderTime?: number;
|
|
15
15
|
savedEstimatedRenderTime?: number;
|
|
16
16
|
renderTimeMultiplier?: number;
|
|
17
|
-
textures?:
|
|
17
|
+
textures?: vtkTexture[];
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export interface vtkProp extends vtkObject {
|
|
@@ -141,20 +141,20 @@ export interface vtkProp extends vtkObject {
|
|
|
141
141
|
|
|
142
142
|
/**
|
|
143
143
|
*
|
|
144
|
-
* @param texture
|
|
144
|
+
* @param {vtkTexture} texture The vtkTexture instance.
|
|
145
145
|
*
|
|
146
146
|
*/
|
|
147
147
|
hasTexture(texture: vtkTexture): boolean;
|
|
148
148
|
|
|
149
149
|
/**
|
|
150
150
|
*
|
|
151
|
-
* @param texture
|
|
151
|
+
* @param {vtkTexture} texture The vtkTexture instance.
|
|
152
152
|
*/
|
|
153
153
|
addTexture(texture: vtkTexture): void;
|
|
154
154
|
|
|
155
155
|
/**
|
|
156
156
|
*
|
|
157
|
-
* @param texture
|
|
157
|
+
* @param {vtkTexture} texture The vtkTexture instance.
|
|
158
158
|
*/
|
|
159
159
|
removeTexture(texture: vtkTexture): void;
|
|
160
160
|
|
|
@@ -230,9 +230,9 @@ export interface vtkProp extends vtkObject {
|
|
|
230
230
|
|
|
231
231
|
/**
|
|
232
232
|
* This is used for culling and is a number between 0 and 1. It is used to create the allocated render time value.
|
|
233
|
-
* @param renderTimeMultiplier
|
|
233
|
+
* @param {Number} renderTimeMultiplier
|
|
234
234
|
*/
|
|
235
|
-
|
|
235
|
+
setRenderTimeMultiplier(renderTimeMultiplier: number): boolean;
|
|
236
236
|
|
|
237
237
|
/**
|
|
238
238
|
* Not Implemented yet
|
|
@@ -239,7 +239,7 @@ function vtkOpenGLHardwareSelector(publicAPI, model) {
|
|
|
239
239
|
|
|
240
240
|
|
|
241
241
|
publicAPI.beginSelection = function () {
|
|
242
|
-
model._openGLRenderer = model._openGLRenderWindow.getViewNodeFor(model.
|
|
242
|
+
model._openGLRenderer = model._openGLRenderWindow.getViewNodeFor(model._renderer);
|
|
243
243
|
model.maxAttributeId = 0;
|
|
244
244
|
|
|
245
245
|
var size = model._openGLRenderWindow.getSize();
|
|
@@ -307,7 +307,7 @@ function vtkOpenGLHardwareSelector(publicAPI, model) {
|
|
|
307
307
|
switch (_context.prev = _context.next) {
|
|
308
308
|
case 0:
|
|
309
309
|
// assign the renderer
|
|
310
|
-
model.
|
|
310
|
+
model._renderer = renderer; // set area to all if no arguments provided
|
|
311
311
|
|
|
312
312
|
if (fx1 === undefined) {
|
|
313
313
|
size = model._openGLRenderWindow.getSize();
|
|
@@ -361,12 +361,12 @@ function vtkOpenGLHardwareSelector(publicAPI, model) {
|
|
|
361
361
|
|
|
362
362
|
|
|
363
363
|
publicAPI.captureBuffers = function () {
|
|
364
|
-
if (!model.
|
|
364
|
+
if (!model._renderer || !model._openGLRenderWindow) {
|
|
365
365
|
vtkErrorMacro('Renderer and view must be set before calling Select.');
|
|
366
366
|
return false;
|
|
367
367
|
}
|
|
368
368
|
|
|
369
|
-
model._openGLRenderer = model._openGLRenderWindow.getViewNodeFor(model.
|
|
369
|
+
model._openGLRenderer = model._openGLRenderWindow.getViewNodeFor(model._renderer); // todo revisit making selection part of core
|
|
370
370
|
// then we can do this in core
|
|
371
371
|
|
|
372
372
|
model._openGLRenderWindow.getRenderable().preRender(); // int rgba[4];
|
|
@@ -383,8 +383,9 @@ function vtkOpenGLHardwareSelector(publicAPI, model) {
|
|
|
383
383
|
}); // Initialize renderer for selection.
|
|
384
384
|
// change the renderer's background to black, which will indicate a miss
|
|
385
385
|
|
|
386
|
-
model.originalBackground = model.
|
|
387
|
-
|
|
386
|
+
model.originalBackground = model._renderer.getBackgroundByReference();
|
|
387
|
+
|
|
388
|
+
model._renderer.setBackground(0.0, 0.0, 0.0);
|
|
388
389
|
|
|
389
390
|
var rpasses = model._openGLRenderWindow.getRenderPasses();
|
|
390
391
|
|
|
@@ -409,7 +410,8 @@ function vtkOpenGLHardwareSelector(publicAPI, model) {
|
|
|
409
410
|
|
|
410
411
|
publicAPI.endSelection(); // restore original background
|
|
411
412
|
|
|
412
|
-
model.
|
|
413
|
+
model._renderer.setBackground(model.originalBackground);
|
|
414
|
+
|
|
413
415
|
publicAPI.invokeEvent({
|
|
414
416
|
type: 'EndEvent'
|
|
415
417
|
}); // restore image, not needed?
|
|
@@ -656,13 +658,13 @@ function vtkOpenGLHardwareSelector(publicAPI, model) {
|
|
|
656
658
|
}
|
|
657
659
|
}
|
|
658
660
|
|
|
659
|
-
return convertSelection(model.fieldAssociation, dataMap, model.captureZValues, model.
|
|
661
|
+
return convertSelection(model.fieldAssociation, dataMap, model.captureZValues, model._renderer, model._openGLRenderWindow);
|
|
660
662
|
}; //----------------------------------------------------------------------------
|
|
661
663
|
|
|
662
664
|
|
|
663
665
|
publicAPI.attach = function (w, r) {
|
|
664
666
|
model._openGLRenderWindow = w;
|
|
665
|
-
model.
|
|
667
|
+
model._renderer = r;
|
|
666
668
|
}; // override
|
|
667
669
|
|
|
668
670
|
|
|
@@ -21,6 +21,13 @@ export interface IOptions {
|
|
|
21
21
|
scale: number
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
export interface I3DContextOptions {
|
|
25
|
+
preserveDrawingBuffer?: boolean;
|
|
26
|
+
depth?: boolean;
|
|
27
|
+
alpha?: boolean;
|
|
28
|
+
powerPreference?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
24
31
|
type vtkOpenGLRenderWindowBase = vtkObject & Omit<vtkAlgorithm,
|
|
25
32
|
| 'getInputData'
|
|
26
33
|
| 'setInputData'
|
|
@@ -197,9 +204,9 @@ export interface vtkOpenGLRenderWindow extends vtkOpenGLRenderWindowBase {
|
|
|
197
204
|
|
|
198
205
|
/**
|
|
199
206
|
*
|
|
200
|
-
* @param options
|
|
207
|
+
* @param {I3DContextOptions} options
|
|
201
208
|
*/
|
|
202
|
-
get3DContext(options:
|
|
209
|
+
get3DContext(options: I3DContextOptions): Nullable<WebGLRenderingContext>;
|
|
203
210
|
|
|
204
211
|
/**
|
|
205
212
|
*
|
|
@@ -223,7 +223,8 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
|
|
|
223
223
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
224
224
|
preserveDrawingBuffer: false,
|
|
225
225
|
depth: true,
|
|
226
|
-
alpha: true
|
|
226
|
+
alpha: true,
|
|
227
|
+
powerPreference: 'high-performance'
|
|
227
228
|
};
|
|
228
229
|
var result = null; // Do we have webxr support
|
|
229
230
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { newInstance as newInstance$1, get, setGet, vtkDebugMacro as vtkDebugMacro$1 } from '../../macros.js';
|
|
1
|
+
import { newInstance as newInstance$1, get, setGet, moveToProtected, vtkDebugMacro as vtkDebugMacro$1 } from '../../macros.js';
|
|
2
2
|
import vtkViewNode from '../SceneGraph/ViewNode.js';
|
|
3
3
|
import { registerOverride } from './ViewNodeFactory.js';
|
|
4
4
|
|
|
@@ -178,7 +178,7 @@ function vtkOpenGLRenderer(publicAPI, model) {
|
|
|
178
178
|
|
|
179
179
|
var DEFAULT_VALUES = {
|
|
180
180
|
context: null,
|
|
181
|
-
_openGLRenderWindow: null,
|
|
181
|
+
// _openGLRenderWindow: null,
|
|
182
182
|
selector: null
|
|
183
183
|
}; // ----------------------------------------------------------------------------
|
|
184
184
|
|
|
@@ -189,7 +189,8 @@ function extend(publicAPI, model) {
|
|
|
189
189
|
vtkViewNode.extend(publicAPI, model, initialValues); // Build VTK API
|
|
190
190
|
|
|
191
191
|
get(publicAPI, model, ['shaderCache']);
|
|
192
|
-
setGet(publicAPI, model, ['selector']);
|
|
192
|
+
setGet(publicAPI, model, ['selector']);
|
|
193
|
+
moveToProtected(publicAPI, model, ['openGLRenderWindow']); // Object methods
|
|
193
194
|
|
|
194
195
|
vtkOpenGLRenderer(publicAPI, model);
|
|
195
196
|
} // ----------------------------------------------------------------------------
|
|
@@ -199,7 +199,9 @@ function vtkWebGPURenderWindow(publicAPI, model) {
|
|
|
199
199
|
switch (_context.prev = _context.next) {
|
|
200
200
|
case 0:
|
|
201
201
|
_context.next = 2;
|
|
202
|
-
return navigator.gpu.requestAdapter(
|
|
202
|
+
return navigator.gpu.requestAdapter({
|
|
203
|
+
powerPreference: 'high-performance'
|
|
204
|
+
});
|
|
203
205
|
|
|
204
206
|
case 2:
|
|
205
207
|
model.adapter = _context.sent;
|
|
@@ -42,7 +42,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
42
42
|
newHandle.setScale1(moveHandle.getScale1());
|
|
43
43
|
} else {
|
|
44
44
|
isDragging = true;
|
|
45
|
-
|
|
45
|
+
|
|
46
|
+
model._apiSpecificRenderWindow.setCursor('grabbing');
|
|
46
47
|
|
|
47
48
|
model._interactor.requestAnimation(publicAPI);
|
|
48
49
|
}
|
|
@@ -57,8 +58,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
57
58
|
publicAPI.handleMouseMove = function (callData) {
|
|
58
59
|
if (model.pickable && model.dragable && model.manipulator && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
|
|
59
60
|
model.manipulator.setOrigin(model.activeState.getOrigin());
|
|
60
|
-
model.manipulator.setNormal(model.
|
|
61
|
-
var worldCoords = model.manipulator.handleEvent(callData, model.
|
|
61
|
+
model.manipulator.setNormal(model._camera.getDirectionOfProjection());
|
|
62
|
+
var worldCoords = model.manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
62
63
|
|
|
63
64
|
if (worldCoords.length && (model.activeState === model.widgetState.getMoveHandle() || isDragging)) {
|
|
64
65
|
model.activeState.setOrigin(worldCoords);
|
|
@@ -68,7 +69,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
if (model.hasFocus) {
|
|
71
|
-
model.
|
|
72
|
+
model._widgetManager.disablePicking();
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
return macro.VOID;
|
|
@@ -79,7 +80,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
79
80
|
|
|
80
81
|
publicAPI.handleLeftButtonRelease = function () {
|
|
81
82
|
if (isDragging && model.pickable) {
|
|
82
|
-
model.
|
|
83
|
+
model._apiSpecificRenderWindow.setCursor('pointer');
|
|
84
|
+
|
|
83
85
|
model.widgetState.deactivate();
|
|
84
86
|
|
|
85
87
|
model._interactor.cancelAnimation(publicAPI);
|
|
@@ -91,7 +93,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
91
93
|
|
|
92
94
|
if (model.hasFocus && !model.activeState || model.activeState && !model.activeState.getActive()) {
|
|
93
95
|
publicAPI.invokeEndInteractionEvent();
|
|
94
|
-
|
|
96
|
+
|
|
97
|
+
model._widgetManager.enablePicking();
|
|
95
98
|
|
|
96
99
|
model._interactor.render();
|
|
97
100
|
} // Don't make any more points
|
|
@@ -134,7 +137,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
134
137
|
model.widgetState.getMoveHandle().setVisible(false);
|
|
135
138
|
model.activeState = null;
|
|
136
139
|
model.hasFocus = false;
|
|
137
|
-
|
|
140
|
+
|
|
141
|
+
model._widgetManager.enablePicking();
|
|
138
142
|
|
|
139
143
|
model._interactor.render();
|
|
140
144
|
};
|
|
@@ -36,7 +36,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
36
36
|
newHandle.setScale1(moveHandle.getScale1());
|
|
37
37
|
} else {
|
|
38
38
|
isDragging = true;
|
|
39
|
-
|
|
39
|
+
|
|
40
|
+
model._apiSpecificRenderWindow.setCursor('grabbing');
|
|
40
41
|
|
|
41
42
|
model._interactor.requestAnimation(publicAPI);
|
|
42
43
|
}
|
|
@@ -55,7 +56,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
if (model.pickable && model.dragable && model.manipulator && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
|
|
58
|
-
var worldCoords = model.manipulator.handleEvent(callData, model.
|
|
59
|
+
var worldCoords = model.manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
59
60
|
|
|
60
61
|
if (worldCoords.length && (model.activeState === model.widgetState.getMoveHandle() || isDragging)) {
|
|
61
62
|
model.activeState.setOrigin(worldCoords);
|
|
@@ -72,7 +73,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
72
73
|
|
|
73
74
|
publicAPI.handleLeftButtonRelease = function () {
|
|
74
75
|
if (isDragging && model.pickable) {
|
|
75
|
-
model.
|
|
76
|
+
model._apiSpecificRenderWindow.setCursor('pointer');
|
|
77
|
+
|
|
76
78
|
model.widgetState.deactivate();
|
|
77
79
|
|
|
78
80
|
model._interactor.cancelAnimation(publicAPI);
|
|
@@ -84,7 +86,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
84
86
|
|
|
85
87
|
if (model.hasFocus && !model.activeState || model.activeState && !model.activeState.getActive()) {
|
|
86
88
|
publicAPI.invokeEndInteractionEvent();
|
|
87
|
-
|
|
89
|
+
|
|
90
|
+
model._widgetManager.enablePicking();
|
|
88
91
|
|
|
89
92
|
model._interactor.render();
|
|
90
93
|
}
|
|
@@ -122,7 +125,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
122
125
|
model.widgetState.getMoveHandle().setVisible(false);
|
|
123
126
|
model.activeState = null;
|
|
124
127
|
model.hasFocus = false;
|
|
125
|
-
|
|
128
|
+
|
|
129
|
+
model._widgetManager.enablePicking();
|
|
126
130
|
|
|
127
131
|
model._interactor.render();
|
|
128
132
|
};
|
|
@@ -55,8 +55,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
55
55
|
|
|
56
56
|
if (type === 'corners') {
|
|
57
57
|
// manipulator should be a plane manipulator
|
|
58
|
-
manipulator.setNormal(model.
|
|
59
|
-
worldCoords = manipulator.handleEvent(callData, model.
|
|
58
|
+
manipulator.setNormal(model._camera.getDirectionOfProjection());
|
|
59
|
+
worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
if (type === 'faces') {
|
|
@@ -69,7 +69,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
69
69
|
|
|
70
70
|
manipulator.setOrigin(transformVec3(center, indexToWorldT));
|
|
71
71
|
manipulator.setNormal(rotateVec3(constraintAxis, indexToWorldT));
|
|
72
|
-
worldCoords = manipulator.handleEvent(callData, model.
|
|
72
|
+
worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
if (type === 'edges') {
|
|
@@ -78,7 +78,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
78
78
|
return a === 1 ? a : 0;
|
|
79
79
|
});
|
|
80
80
|
manipulator.setNormal(rotateVec3(edgeAxis, indexToWorldT));
|
|
81
|
-
worldCoords = manipulator.handleEvent(callData, model.
|
|
81
|
+
worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
if (worldCoords.length) {
|
|
@@ -111,7 +111,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
111
111
|
// --------------------------------------------------------------------------
|
|
112
112
|
|
|
113
113
|
|
|
114
|
-
model.
|
|
114
|
+
model._camera = model._renderer.getActiveCamera();
|
|
115
115
|
model.classHierarchy.push('vtkImageCroppingWidgetProp');
|
|
116
116
|
}
|
|
117
117
|
|
|
@@ -21,19 +21,23 @@ function widgetBehavior(publicAPI, model) {
|
|
|
21
21
|
publicAPI.updateCursor = function () {
|
|
22
22
|
switch (model.activeState.getUpdateMethodName()) {
|
|
23
23
|
case 'updateFromOrigin':
|
|
24
|
-
model.
|
|
24
|
+
model._apiSpecificRenderWindow.setCursor('crosshair');
|
|
25
|
+
|
|
25
26
|
break;
|
|
26
27
|
|
|
27
28
|
case 'updateFromPlane':
|
|
28
|
-
model.
|
|
29
|
+
model._apiSpecificRenderWindow.setCursor('move');
|
|
30
|
+
|
|
29
31
|
break;
|
|
30
32
|
|
|
31
33
|
case 'updateFromNormal':
|
|
32
|
-
model.
|
|
34
|
+
model._apiSpecificRenderWindow.setCursor('alias');
|
|
35
|
+
|
|
33
36
|
break;
|
|
34
37
|
|
|
35
38
|
default:
|
|
36
|
-
model.
|
|
39
|
+
model._apiSpecificRenderWindow.setCursor('grabbing');
|
|
40
|
+
|
|
37
41
|
break;
|
|
38
42
|
}
|
|
39
43
|
};
|
|
@@ -88,7 +92,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
88
92
|
|
|
89
93
|
publicAPI.updateFromOrigin = function (callData) {
|
|
90
94
|
model.planeManipulator.setNormal(model.widgetState.getNormal());
|
|
91
|
-
var worldCoords = model.planeManipulator.handleEvent(callData, model.
|
|
95
|
+
var worldCoords = model.planeManipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
92
96
|
|
|
93
97
|
if (model.widgetState.containsPoint(worldCoords)) {
|
|
94
98
|
model.activeState.setOrigin(worldCoords);
|
|
@@ -101,7 +105,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
101
105
|
|
|
102
106
|
// Move origin along normal axis
|
|
103
107
|
model.lineManipulator.setNormal(model.activeState.getNormal());
|
|
104
|
-
var worldCoords = model.lineManipulator.handleEvent(callData, model.
|
|
108
|
+
var worldCoords = model.lineManipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
105
109
|
|
|
106
110
|
if ((_model$widgetState = model.widgetState).containsPoint.apply(_model$widgetState, _toConsumableArray(worldCoords))) {
|
|
107
111
|
model.activeState.setOrigin(worldCoords);
|
|
@@ -111,7 +115,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
111
115
|
|
|
112
116
|
publicAPI.updateFromNormal = function (callData) {
|
|
113
117
|
model.trackballManipulator.setNormal(model.activeState.getNormal());
|
|
114
|
-
var newNormal = model.trackballManipulator.handleEvent(callData, model.
|
|
118
|
+
var newNormal = model.trackballManipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
115
119
|
model.activeState.setNormal(newNormal);
|
|
116
120
|
}; // --------------------------------------------------------------------------
|
|
117
121
|
// initialization
|
|
@@ -15,7 +15,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
15
15
|
model.representations[1].setCircleProps(_objectSpread(_objectSpread({}, model.representations[1].getCircleProps()), {}, {
|
|
16
16
|
visible: !text
|
|
17
17
|
}));
|
|
18
|
-
|
|
18
|
+
|
|
19
|
+
model._interactor.render();
|
|
19
20
|
};
|
|
20
21
|
|
|
21
22
|
publicAPI.getText = function () {
|
|
@@ -51,8 +52,10 @@ function widgetBehavior(publicAPI, model) {
|
|
|
51
52
|
publicAPI.loseFocus();
|
|
52
53
|
} else {
|
|
53
54
|
model.isDragging = true;
|
|
54
|
-
|
|
55
|
-
model.
|
|
55
|
+
|
|
56
|
+
model._apiSpecificRenderWindow.setCursor('grabbing');
|
|
57
|
+
|
|
58
|
+
model._interactor.requestAnimation(publicAPI);
|
|
56
59
|
}
|
|
57
60
|
|
|
58
61
|
publicAPI.invokeStartInteractionEvent();
|
|
@@ -64,9 +67,12 @@ function widgetBehavior(publicAPI, model) {
|
|
|
64
67
|
|
|
65
68
|
publicAPI.handleLeftButtonRelease = function () {
|
|
66
69
|
if (model.isDragging && model.pickable) {
|
|
67
|
-
model.
|
|
70
|
+
model._apiSpecificRenderWindow.setCursor('pointer');
|
|
71
|
+
|
|
68
72
|
model.widgetState.deactivate();
|
|
69
|
-
|
|
73
|
+
|
|
74
|
+
model._interactor.cancelAnimation(publicAPI);
|
|
75
|
+
|
|
70
76
|
publicAPI.invokeEndInteractionEvent();
|
|
71
77
|
} else if (model.activeState !== model.widgetState.getMoveHandle()) {
|
|
72
78
|
model.widgetState.deactivate();
|
|
@@ -74,8 +80,10 @@ function widgetBehavior(publicAPI, model) {
|
|
|
74
80
|
|
|
75
81
|
if (model.hasFocus && !model.activeState || model.activeState && !model.activeState.getActive()) {
|
|
76
82
|
publicAPI.invokeEndInteractionEvent();
|
|
77
|
-
|
|
78
|
-
model.
|
|
83
|
+
|
|
84
|
+
model._widgetManager.enablePicking();
|
|
85
|
+
|
|
86
|
+
model._interactor.render();
|
|
79
87
|
}
|
|
80
88
|
|
|
81
89
|
model.isDragging = false;
|
|
@@ -86,7 +94,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
86
94
|
|
|
87
95
|
publicAPI.handleMouseMove = function (callData) {
|
|
88
96
|
if (model.pickable && model.dragable && model.manipulator && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
|
|
89
|
-
var worldCoords = model.manipulator.handleEvent(callData, model.
|
|
97
|
+
var worldCoords = model.manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
90
98
|
|
|
91
99
|
if (worldCoords.length && (model.activeState === model.widgetState.getMoveHandle() || model.isDragging)) {
|
|
92
100
|
model.activeState.setOrigin(worldCoords);
|
|
@@ -113,7 +121,9 @@ function widgetBehavior(publicAPI, model) {
|
|
|
113
121
|
publicAPI.reset();
|
|
114
122
|
model.activeState = model.widgetState.getMoveHandle();
|
|
115
123
|
model.widgetState.getMoveHandle().activate();
|
|
116
|
-
|
|
124
|
+
|
|
125
|
+
model._interactor.requestAnimation(publicAPI);
|
|
126
|
+
|
|
117
127
|
publicAPI.invokeStartInteractionEvent();
|
|
118
128
|
}
|
|
119
129
|
|
|
@@ -122,7 +132,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
122
132
|
|
|
123
133
|
publicAPI.loseFocus = function () {
|
|
124
134
|
if (model.hasFocus) {
|
|
125
|
-
model.
|
|
135
|
+
model._interactor.cancelAnimation(publicAPI);
|
|
136
|
+
|
|
126
137
|
publicAPI.invokeEndInteractionEvent();
|
|
127
138
|
}
|
|
128
139
|
|
|
@@ -130,8 +141,10 @@ function widgetBehavior(publicAPI, model) {
|
|
|
130
141
|
model.widgetState.getMoveHandle().deactivate();
|
|
131
142
|
model.activeState = null;
|
|
132
143
|
model.hasFocus = false;
|
|
133
|
-
|
|
134
|
-
model.
|
|
144
|
+
|
|
145
|
+
model._widgetManager.enablePicking();
|
|
146
|
+
|
|
147
|
+
model._interactor.render();
|
|
135
148
|
};
|
|
136
149
|
}
|
|
137
150
|
|
|
@@ -36,8 +36,9 @@ function widgetBehavior(publicAPI, model) {
|
|
|
36
36
|
|
|
37
37
|
function updateCursor(callData) {
|
|
38
38
|
model.isDragging = true;
|
|
39
|
-
model.previousPosition = _toConsumableArray(model.manipulator.handleEvent(callData, model.
|
|
40
|
-
|
|
39
|
+
model.previousPosition = _toConsumableArray(model.manipulator.handleEvent(callData, model._apiSpecificRenderWindow));
|
|
40
|
+
|
|
41
|
+
model._apiSpecificRenderWindow.setCursor('grabbing');
|
|
41
42
|
|
|
42
43
|
model._interactor.requestAnimation(publicAPI);
|
|
43
44
|
} // --------------------------------------------------------------------------
|
|
@@ -101,8 +102,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
101
102
|
|
|
102
103
|
|
|
103
104
|
function computeMousePosition(p1, callData) {
|
|
104
|
-
var displayMousePos = publicAPI.computeWorldToDisplay.apply(publicAPI, [model.
|
|
105
|
-
var worldMousePos = publicAPI.computeDisplayToWorld(model.
|
|
105
|
+
var displayMousePos = publicAPI.computeWorldToDisplay.apply(publicAPI, [model._renderer].concat(_toConsumableArray(p1)));
|
|
106
|
+
var worldMousePos = publicAPI.computeDisplayToWorld(model._renderer, callData.position.x, callData.position.y, displayMousePos[2]);
|
|
106
107
|
return worldMousePos;
|
|
107
108
|
}
|
|
108
109
|
/**
|
|
@@ -137,8 +138,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
137
138
|
};
|
|
138
139
|
|
|
139
140
|
publicAPI.rotateHandlesToFaceCamera = function () {
|
|
140
|
-
model.representations[0].setViewMatrix(Array.from(model.
|
|
141
|
-
model.representations[1].setViewMatrix(Array.from(model.
|
|
141
|
+
model.representations[0].setViewMatrix(Array.from(model._camera.getViewMatrix()));
|
|
142
|
+
model.representations[1].setViewMatrix(Array.from(model._camera.getViewMatrix()));
|
|
142
143
|
}; // Handles visibility ---------------------------------------------------------
|
|
143
144
|
|
|
144
145
|
|
|
@@ -227,7 +228,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
227
228
|
}
|
|
228
229
|
|
|
229
230
|
if (model.pickable && model.dragable && model.manipulator && model.activeState && model.activeState.getActive() && !ignoreKey(callData)) {
|
|
230
|
-
var worldCoords = model.manipulator.handleEvent(callData, model.
|
|
231
|
+
var worldCoords = model.manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
231
232
|
var translation = model.previousPosition ? subtract(worldCoords, model.previousPosition, []) : [0, 0, 0];
|
|
232
233
|
model.previousPosition = worldCoords;
|
|
233
234
|
|
|
@@ -269,10 +270,12 @@ function widgetBehavior(publicAPI, model) {
|
|
|
269
270
|
model._interactor.cancelAnimation(publicAPI);
|
|
270
271
|
}
|
|
271
272
|
|
|
272
|
-
model.
|
|
273
|
+
model._apiSpecificRenderWindow.setCursor('pointer');
|
|
274
|
+
|
|
273
275
|
model.hasFocus = false;
|
|
274
276
|
publicAPI.invokeEndInteractionEvent();
|
|
275
|
-
|
|
277
|
+
|
|
278
|
+
model._widgetManager.enablePicking();
|
|
276
279
|
|
|
277
280
|
model._interactor.render();
|
|
278
281
|
}
|
|
@@ -314,7 +317,8 @@ function widgetBehavior(publicAPI, model) {
|
|
|
314
317
|
model.widgetState.getMoveHandle().deactivate();
|
|
315
318
|
model.activeState = null;
|
|
316
319
|
model.hasFocus = false;
|
|
317
|
-
|
|
320
|
+
|
|
321
|
+
model._widgetManager.enablePicking();
|
|
318
322
|
|
|
319
323
|
model._interactor.render();
|
|
320
324
|
};
|
|
@@ -35,8 +35,10 @@ function widgetBehavior(publicAPI, model) {
|
|
|
35
35
|
if (model.manipulator && model.activeState && model.activeState.getActive()) {
|
|
36
36
|
var _model$activeState, _model$activeState2, _model$activeState3;
|
|
37
37
|
|
|
38
|
-
var normal = model.
|
|
39
|
-
|
|
38
|
+
var normal = model._camera.getDirectionOfProjection();
|
|
39
|
+
|
|
40
|
+
var up = model._camera.getViewUp();
|
|
41
|
+
|
|
40
42
|
var right = [];
|
|
41
43
|
vec3.cross(right, up, normal);
|
|
42
44
|
|
|
@@ -47,7 +49,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
47
49
|
(_model$activeState3 = model.activeState).setDirection.apply(_model$activeState3, _toConsumableArray(normal));
|
|
48
50
|
|
|
49
51
|
model.manipulator.setNormal(normal);
|
|
50
|
-
var worldCoords = model.manipulator.handleEvent(callData, model.
|
|
52
|
+
var worldCoords = model.manipulator.handleEvent(callData, model._apiSpecificRenderWindow);
|
|
51
53
|
|
|
52
54
|
if (worldCoords.length) {
|
|
53
55
|
var _model$widgetState, _model$activeState4;
|
|
@@ -76,7 +78,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
76
78
|
|
|
77
79
|
model._interactor.requestAnimation(publicAPI);
|
|
78
80
|
|
|
79
|
-
var canvas = model.
|
|
81
|
+
var canvas = model._apiSpecificRenderWindow.getCanvas();
|
|
80
82
|
|
|
81
83
|
canvas.onmouseenter = function () {
|
|
82
84
|
if (model.hasFocus && model.activeState === model.widgetState.getHandle()) {
|
|
@@ -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/index.d.ts
CHANGED
|
@@ -76,8 +76,8 @@
|
|
|
76
76
|
/// <reference path="./IO/Geometry/DracoReader.d.ts" />
|
|
77
77
|
/// <reference path="./IO/Geometry/PLYReader.d.ts" />
|
|
78
78
|
/// <reference path="./IO/Geometry/PLYWriter.d.ts" />
|
|
79
|
-
/// <reference path="./IO/Geometry/STLReader.d.ts" />
|
|
80
79
|
/// <reference path="./IO/Geometry/STLWriter.d.ts" />
|
|
80
|
+
/// <reference path="./IO/Geometry/STLReader.d.ts" />
|
|
81
81
|
/// <reference path="./IO/Misc/ElevationReader.d.ts" />
|
|
82
82
|
/// <reference path="./IO/Misc/ITKImageReader.d.ts" />
|
|
83
83
|
/// <reference path="./IO/Misc/ITKPolyDataReader.d.ts" />
|