@kitware/vtk.js 30.4.3 → 30.5.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/Proxy/Core/ViewProxy.js
CHANGED
|
@@ -540,7 +540,7 @@ function extend(publicAPI, model) {
|
|
|
540
540
|
let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
541
541
|
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
542
542
|
obj(publicAPI, model);
|
|
543
|
-
setGet(publicAPI, model, ['name', 'disableAnimation']);
|
|
543
|
+
setGet(publicAPI, model, ['name', 'disableAnimation', 'resetCameraOnFirstRender']);
|
|
544
544
|
get(publicAPI, model, ['annotationOpacity', 'camera', 'container', 'cornerAnnotation', 'interactor', 'interactorStyle2D', 'interactorStyle3D', '_openGLRenderWindow',
|
|
545
545
|
// todo breaking? convert to apiSpecificWindow
|
|
546
546
|
'orientationAxesType', 'presetToOrientationAxes', 'renderer', 'renderWindow', 'representations', 'useParallelRendering']);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { m as macro } from '../../../macros2.js';
|
|
2
|
-
import { handleTypeFromName, AXES,
|
|
2
|
+
import { handleTypeFromName, AXES, calculateCropperCenter, calculateDirection, transformVec3 } from './helpers.js';
|
|
3
3
|
|
|
4
4
|
function widgetBehavior(publicAPI, model) {
|
|
5
5
|
model._isDragging = false;
|
|
@@ -47,23 +47,20 @@ function widgetBehavior(publicAPI, model) {
|
|
|
47
47
|
worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow).worldCoords;
|
|
48
48
|
}
|
|
49
49
|
if (type === 'faces') {
|
|
50
|
-
// constraint axis is line defined by the index and center point.
|
|
51
|
-
// Since our index point is defined inside a box [0, 2, 0, 2, 0, 2],
|
|
52
|
-
// center point is [1, 1, 1].
|
|
53
|
-
const constraintAxis = [1 - index[0], 1 - index[1], 1 - index[2]];
|
|
54
|
-
|
|
55
50
|
// get center of current crop box
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
manipulator.setHandleOrigin(transformVec3(center, indexToWorldT));
|
|
60
|
-
manipulator.setHandleNormal(rotateVec3(constraintAxis, indexToWorldT));
|
|
51
|
+
const worldCenter = calculateCropperCenter(planes, indexToWorldT);
|
|
52
|
+
manipulator.setHandleOrigin(worldCenter);
|
|
53
|
+
manipulator.setHandleNormal(calculateDirection(model.activeState.getOrigin(), worldCenter));
|
|
61
54
|
worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow).worldCoords;
|
|
62
55
|
}
|
|
63
56
|
if (type === 'edges') {
|
|
64
57
|
// constrain to a plane with a normal parallel to the edge
|
|
65
58
|
const edgeAxis = index.map(a => a === 1 ? a : 0);
|
|
66
|
-
|
|
59
|
+
const faceName = edgeAxis.map(i => AXES[i + 1]).join('');
|
|
60
|
+
const handle = model.widgetState.getStatesWithLabel(faceName)[0];
|
|
61
|
+
// get center of current crop box
|
|
62
|
+
const worldCenter = calculateCropperCenter(planes, indexToWorldT);
|
|
63
|
+
manipulator.setHandleNormal(calculateDirection(handle.getOrigin(), worldCenter));
|
|
67
64
|
worldCoords = manipulator.handleEvent(callData, model._apiSpecificRenderWindow).worldCoords;
|
|
68
65
|
}
|
|
69
66
|
if (worldCoords.length) {
|
|
@@ -34,5 +34,16 @@ function handleTypeFromName(name) {
|
|
|
34
34
|
}
|
|
35
35
|
return 'faces';
|
|
36
36
|
}
|
|
37
|
+
function calculateCropperCenter(planes, transform) {
|
|
38
|
+
// get center of current crop box
|
|
39
|
+
const center = [(planes[0] + planes[1]) / 2, (planes[2] + planes[3]) / 2, (planes[4] + planes[5]) / 2];
|
|
40
|
+
return transformVec3(center, transform);
|
|
41
|
+
}
|
|
42
|
+
function calculateDirection(v1, v2) {
|
|
43
|
+
const direction = vec3.create();
|
|
44
|
+
vec3.subtract(direction, v1, v2);
|
|
45
|
+
vec3.normalize(direction, direction);
|
|
46
|
+
return direction;
|
|
47
|
+
}
|
|
37
48
|
|
|
38
|
-
export { AXES, handleTypeFromName, rotateVec3, transformVec3 };
|
|
49
|
+
export { AXES, calculateCropperCenter, calculateDirection, handleTypeFromName, rotateVec3, transformVec3 };
|