onMouseDown method

dynamic onMouseDown(
  1. dynamic event
)

Implementation

onMouseDown(event) {
  var mouseAction;

  switch (event.button) {
    case 0:
      mouseAction = scope.mouseButtons['LEFT'];
      break;

    case 1:
      mouseAction = scope.mouseButtons['MIDDLE'];
      break;

    case 2:
      mouseAction = scope.mouseButtons['RIGHT'];
      break;

    default:
      mouseAction = -1;
  }

  switch (mouseAction) {
    case MOUSE.DOLLY:
      if (scope.enableZoom == false) return;

      handleMouseDownDolly(event);

      state = STATE.DOLLY;

      break;

    case MOUSE.ROTATE:
      if (event.ctrlKey || event.metaKey || event.shiftKey) {
        if (scope.enablePan == false) return;

        handleMouseDownPan(event);

        state = STATE.PAN;
      } else {
        if (scope.enableRotate == false) return;

        handleMouseDownRotate(event);

        state = STATE.ROTATE;
      }

      break;

    case MOUSE.PAN:
      if (event.ctrlKey || event.metaKey || event.shiftKey) {
        if (scope.enableRotate == false) return;

        handleMouseDownRotate(event);

        state = STATE.ROTATE;
      } else {
        if (scope.enablePan == false) return;

        handleMouseDownPan(event);

        state = STATE.PAN;
      }

      break;

    default:
      state = STATE.NONE;
  }

  if (state != STATE.NONE) {
    scope.dispatchEvent(_startEvent);
  }
}