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);
  }
}