onSinglePanStart method

dynamic onSinglePanStart(
  1. dynamic event,
  2. dynamic operation
)

Implementation

onSinglePanStart(event, operation) {
  if (enabled) {
    dispatchEvent(_startEvent);

    setCenter(event.clientX, event.clientY);

    switch (operation) {
      case 'PAN':
        if (!enablePan) {
          return;
        }

        if (_animationId != -1) {
          cancelAnimationFrame(_animationId);
          _animationId = -1;
          _timeStart = -1;

          activateGizmos(false);
          dispatchEvent(_changeEvent);
        }

        updateTbState(State2.pan, true);
        _startCursorPosition.copy(unprojectOnTbPlane(camera, _center.x, _center.y, domElement));
        if (enableGrid) {
          drawGrid();
          dispatchEvent(_changeEvent);
        }

        break;

      case 'ROTATE':
        if (!enableRotate) {
          return;
        }

        if (_animationId != -1) {
          cancelAnimationFrame(_animationId);
          _animationId = -1;
          _timeStart = -1;
        }

        updateTbState(State2.rotate, true);
        _startCursorPosition.copy(unprojectOnTbSurface(camera, _center.x, _center.y, listenableKey, _tbRadius));
        activateGizmos(true);
        if (enableAnimations) {
          _timePrev = _timeCurrent = DateTime.now().millisecondsSinceEpoch;
          _angleCurrent = _anglePrev = 0;
          _cursorPosPrev.copy(_startCursorPosition);
          _cursorPosCurr.copy(_cursorPosPrev);
          _wCurr = 0;
          _wPrev = _wCurr;
        }

        dispatchEvent(_changeEvent);
        break;

      case 'FOV':
        if (camera is! PerspectiveCamera || !enableZoom) {
          return;
        }

        if (_animationId != -1) {
          cancelAnimationFrame(_animationId);
          _animationId = -1;
          _timeStart = -1;

          activateGizmos(false);
          dispatchEvent(_changeEvent);
        }

        updateTbState(State2.fov, true);
        _startCursorPosition.setY(getCursorNDC(_center.x, _center.y, domElement).y * 0.5);
        _currentCursorPosition.copy(_startCursorPosition);
        break;

      case 'ZOOM':
        if (!enableZoom) {
          return;
        }

        if (_animationId != -1) {
          cancelAnimationFrame(_animationId);
          _animationId = -1;
          _timeStart = -1;

          activateGizmos(false);
          dispatchEvent(_changeEvent);
        }

        updateTbState(State2.scale, true);
        _startCursorPosition.setY(getCursorNDC(_center.x, _center.y, domElement).y * 0.5);
        _currentCursorPosition.copy(_startCursorPosition);
        break;
    }
  }
}