5
5
transformVec3 ,
6
6
handleTypeFromName ,
7
7
calculateDirection ,
8
+ calculateCropperCenter ,
8
9
} from 'vtk.js/Sources/Widgets/Widgets3D/ImageCroppingWidget/helpers' ;
9
10
10
11
export default function widgetBehavior ( publicAPI , model ) {
@@ -76,14 +77,8 @@ export default function widgetBehavior(publicAPI, model) {
76
77
77
78
if ( type === 'faces' ) {
78
79
// get center of current crop box
79
- const center = [
80
- ( planes [ 0 ] + planes [ 1 ] ) / 2 ,
81
- ( planes [ 2 ] + planes [ 3 ] ) / 2 ,
82
- ( planes [ 4 ] + planes [ 5 ] ) / 2 ,
83
- ] ;
84
-
85
- // manipulator should be a line manipulator
86
- const worldCenter = transformVec3 ( center , indexToWorldT ) ;
80
+ const worldCenter = calculateCropperCenter ( planes , indexToWorldT ) ;
81
+
87
82
manipulator . setHandleOrigin ( worldCenter ) ;
88
83
manipulator . setHandleNormal (
89
84
calculateDirection ( model . activeState . getOrigin ( ) , worldCenter )
@@ -100,14 +95,7 @@ export default function widgetBehavior(publicAPI, model) {
100
95
const faceName = edgeAxis . map ( ( i ) => AXES [ i + 1 ] ) . join ( '' ) ;
101
96
const handle = model . widgetState . getStatesWithLabel ( faceName ) [ 0 ] ;
102
97
// get center of current crop box
103
- const center = [
104
- ( planes [ 0 ] + planes [ 1 ] ) / 2 ,
105
- ( planes [ 2 ] + planes [ 3 ] ) / 2 ,
106
- ( planes [ 4 ] + planes [ 5 ] ) / 2 ,
107
- ] ;
108
-
109
- // manipulator should be a line manipulator
110
- const worldCenter = transformVec3 ( center , indexToWorldT ) ;
98
+ const worldCenter = calculateCropperCenter ( planes , indexToWorldT ) ;
111
99
112
100
manipulator . setHandleNormal (
113
101
calculateDirection ( handle . getOrigin ( ) , worldCenter )
0 commit comments