onMouseDown method

dynamic onMouseDown(
  1. dynamic event
)

Implementation

onMouseDown(event) {
  if (_state == STATE.NONE) {
    if (event.button == scope.mouseButtons['LEFT']) {
      _state = STATE.ROTATE;
    } else if (event.button == scope.mouseButtons['MIDDLE']) {
      _state = STATE.ZOOM;
    } else if (event.button == scope.mouseButtons['RIGHT']) {
      _state = STATE.PAN;
    }
  }

  var state = (_keyState != STATE.NONE) ? _keyState : _state;

  if (state == STATE.ROTATE && !scope.noRotate) {
    _moveCurr.copy(getMouseOnCircle(event.pageX, event.pageY));
    _movePrev.copy(_moveCurr);
  } else if (state == STATE.ZOOM && !scope.noZoom) {
    _zoomStart.copy(getMouseOnScreen(event.pageX, event.pageY));
    _zoomEnd.copy(_zoomStart);
  } else if (state == STATE.PAN && !scope.noPan) {
    _panStart.copy(getMouseOnScreen(event.pageX, event.pageY));
    _panEnd.copy(_panStart);
  }

  scope.dispatchEvent(_startEvent);
}