onSinglePanStart method

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

Implementation

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

    this.setCenter(event.clientX, event.clientY);

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

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

          this.activateGizmos(false);
          this.dispatchEvent(_changeEvent);
        }

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

        break;

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

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

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

        this.dispatchEvent(_changeEvent);
        break;

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

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

          this.activateGizmos(false);
          this.dispatchEvent(_changeEvent);
        }

        this.updateTbState(STATE2.FOV, true);
        this._startCursorPosition.setY(
            this.getCursorNDC(_center.x, _center.y, this.domElement).y * 0.5);
        this._currentCursorPosition.copy(this._startCursorPosition);
        break;

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

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

          this.activateGizmos(false);
          this.dispatchEvent(_changeEvent);
        }

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