ObjectControls.prototype.mousedown = function()

in packages/miew/src/ui/ObjectControls.js [608:654]


ObjectControls.prototype.mousedown = function (event) {
  if (this.enabled === false || this._state !== STATE.NONE) {
    return;
  }

  event.preventDefault();
  event.stopPropagation();

  if (this._state === STATE.NONE) {
    if (event.button === 0) {
      this._affectedObj.stop(); // can edit only one object at a time

      let workWithAltObj = false;

      if (event.altKey) {
        const altObj = this.getAltObj();
        workWithAltObj = (altObj.objects.length > 0);
        if (workWithAltObj) {
          this._altObj.setObjects(altObj.objects);
          this._altObj.pivot = altObj.pivot;

          if ('axis' in altObj) {
            this._altObj.axis = altObj.axis.clone();
          } else {
            this._altObj.axis.set(0, 0, 1);
          }
        }
      }

      this._affectedObj = workWithAltObj ? this._altObj : this._mainObj;

      this._state = (workWithAltObj && event.ctrlKey && this._isTranslationAllowed) ? STATE.TRANSLATE : STATE.ROTATE;
    } else if (event.button === 2) {
      this._state = STATE.TRANSLATE_PIVOT;
    }
  }

  if (this._state === STATE.ROTATE) {
    this.convertMouseToOnCircle(this._mouseCurPos, event.pageX, event.pageY);
    this._mousePrevPos.copy(this._mouseCurPos);
  }

  if (this._state === STATE.TRANSLATE || this._state === STATE.TRANSLATE_PIVOT) {
    this.convertMouseToViewport(this._mouseCurPos, event.pageX, event.pageY);
    this._mousePrevPos.copy(this._mouseCurPos);
  }
};