@@ -20,6 +20,8 @@ THREE.DragControls = function ( _objects, _camera, _domElement ) {
2020 var _offset = new THREE . Vector3 ( ) ;
2121 var _intersection = new THREE . Vector3 ( ) ;
2222 var _worldPosition = new THREE . Vector3 ( ) ;
23+ var _inverseMatrix = new THREE . Matrix4 ( ) ;
24+
2325 var _selected = null , _hovered = null ;
2426
2527 //
@@ -71,7 +73,7 @@ THREE.DragControls = function ( _objects, _camera, _domElement ) {
7173
7274 if ( _raycaster . ray . intersectPlane ( _plane , _intersection ) ) {
7375
74- _selected . position . copy ( _selected . parent . worldToLocal ( _intersection . sub ( _offset ) ) ) ;
76+ _selected . position . copy ( _intersection . sub ( _offset ) . applyMatrix4 ( _inverseMatrix ) ) ;
7577
7678 }
7779
@@ -129,6 +131,7 @@ THREE.DragControls = function ( _objects, _camera, _domElement ) {
129131
130132 if ( _raycaster . ray . intersectPlane ( _plane , _intersection ) ) {
131133
134+ _inverseMatrix . getInverse ( _selected . parent . matrixWorld ) ;
132135 _offset . copy ( _intersection ) . sub ( _worldPosition . setFromMatrixPosition ( _selected . matrixWorld ) ) ;
133136
134137 }
@@ -174,7 +177,7 @@ THREE.DragControls = function ( _objects, _camera, _domElement ) {
174177
175178 if ( _raycaster . ray . intersectPlane ( _plane , _intersection ) ) {
176179
177- _selected . position . copy ( _selected . parent . worldToLocal ( _intersection . sub ( _offset ) ) ) ;
180+ _selected . position . copy ( _intersection . sub ( _offset ) . applyMatrix4 ( _inverseMatrix ) ) ;
178181
179182 }
180183
@@ -208,6 +211,7 @@ THREE.DragControls = function ( _objects, _camera, _domElement ) {
208211
209212 if ( _raycaster . ray . intersectPlane ( _plane , _intersection ) ) {
210213
214+ _inverseMatrix . getInverse ( _selected . parent . matrixWorld ) ;
211215 _offset . copy ( _intersection ) . sub ( _worldPosition . setFromMatrixPosition ( _selected . matrixWorld ) ) ;
212216
213217 }
0 commit comments