onPointerMove method

dynamic onPointerMove(
  1. dynamic event
)

Implementation

onPointerMove(event) {
  if (scope.enabled == false) return;

  updatePointer(event);

  _raycaster.setFromCamera(_pointer, _camera);

  if (_selected != null) {
    if (_raycaster.ray.intersectPlane(_plane, _intersection)) {
      _selected!.position.copy(_intersection.sub(_offset).applyMatrix4(_inverseMatrix));
    }

    scope.dispatchEvent(Event({'type': 'drag', 'object': _selected}));

    return;
  }

  // hover support

  if (event.pointerType == 'mouse' || event.pointerType == 'pen') {
    _intersections.length = 0;

    _raycaster.setFromCamera(_pointer, _camera);
    _raycaster.intersectObjects(_objects, true, _intersections);

    if (_intersections.isNotEmpty) {
      var object = _intersections[0].object;

      _plane.setFromNormalAndCoplanarPoint(
          _camera.getWorldDirection(_plane.normal), _worldPosition.setFromMatrixPosition(object.matrixWorld));

      if (_hovered != object && _hovered != null) {
        scope.dispatchEvent(Event({'type': 'hoveroff', 'object': _hovered}));

        // _domElement.style.cursor = 'auto';
        _hovered = null;
      }

      if (_hovered != object) {
        scope.dispatchEvent(Event({'type': 'hoveron', 'object': object}));

        // _domElement.style.cursor = 'pointer';
        _hovered = object;
      }
    } else {
      if (_hovered != null) {
        scope.dispatchEvent(Event({'type': 'hoveroff', 'object': _hovered}));

        // _domElement.style.cursor = 'auto';
        _hovered = null;
      }
    }
  }
}