|
|
|
@ -30,7 +30,7 @@ class DragControls extends EventDispatcher { |
|
|
|
//
|
|
|
|
|
|
|
|
let isMove = false |
|
|
|
|
|
|
|
let isMouseDownClicked = false |
|
|
|
const scope = this |
|
|
|
|
|
|
|
function activate() { |
|
|
|
@ -66,33 +66,27 @@ class DragControls extends EventDispatcher { |
|
|
|
} |
|
|
|
|
|
|
|
function onPointerMove(event) { |
|
|
|
|
|
|
|
if (!scope.enabled || !scope.enabledMove) return |
|
|
|
|
|
|
|
isMove = true |
|
|
|
if (isMouseDownClicked) { |
|
|
|
_domElement.style.cursor = 'move' |
|
|
|
} |
|
|
|
|
|
|
|
isMove = true |
|
|
|
updatePointer(event) |
|
|
|
|
|
|
|
_raycaster.setFromCamera(_pointer, _camera) |
|
|
|
|
|
|
|
if (_selected) { |
|
|
|
|
|
|
|
if (_raycaster.ray.intersectPlane(_plane, _intersection)) { |
|
|
|
|
|
|
|
const pos = _intersection.sub(_offset).applyMatrix4(_inverseMatrix) |
|
|
|
const newIntersection = calcPositionUseSnap(event, pos) |
|
|
|
_selected.position.copy(newIntersection) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
scope.dispatchEvent({ type: 'drag', object: _selected }) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// hover support
|
|
|
|
|
|
|
|
if (event.pointerType === 'mouse' || event.pointerType === 'pen') { |
|
|
|
|
|
|
|
_intersections.length = 0 |
|
|
|
@ -127,12 +121,9 @@ class DragControls extends EventDispatcher { |
|
|
|
} else { |
|
|
|
|
|
|
|
if (_hovered !== null) { |
|
|
|
|
|
|
|
scope.dispatchEvent({ type: 'hoveroff', object: _hovered }) |
|
|
|
|
|
|
|
_domElement.style.cursor = 'auto' |
|
|
|
_hovered = null |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
@ -163,7 +154,10 @@ class DragControls extends EventDispatcher { |
|
|
|
_offset.copy(_intersection).sub(_worldPosition.setFromMatrixPosition(_selected.matrixWorld)) |
|
|
|
} |
|
|
|
|
|
|
|
_domElement.style.cursor = 'move' |
|
|
|
// setTimeout(() => {
|
|
|
|
// _domElement.style.cursor = 'move'
|
|
|
|
// }, 20)
|
|
|
|
isMouseDownClicked = true |
|
|
|
} |
|
|
|
scope.dispatchEvent({ type: 'dragstart', object: _selected, e: event }) |
|
|
|
} |
|
|
|
@ -183,6 +177,7 @@ class DragControls extends EventDispatcher { |
|
|
|
} |
|
|
|
|
|
|
|
_domElement.style.cursor = _hovered ? 'pointer' : 'auto' |
|
|
|
isMouseDownClicked = false |
|
|
|
} |
|
|
|
|
|
|
|
function updatePointer(event) { |
|
|
|
|