onTriplePanMove method

dynamic onTriplePanMove(
  1. dynamic event
)

Implementation

onTriplePanMove(event) {
  if (this.enabled && this.enableZoom) {
    //	  fov / 2
    //		|\
    //		| \
    //		|  \
    //	x	|	\
    //		| 	 \
    //		| 	  \
    //		| _ _ _\
    //			y

    //var center = event.center;
    num clientX = 0;
    num clientY = 0;
    var nFingers = this._touchCurrent.length;

    for (var i = 0; i < nFingers; i++) {
      clientX += this._touchCurrent[i].clientX;
      clientY += this._touchCurrent[i].clientY;
    }

    this.setCenter(clientX / nFingers, clientY / nFingers);

    var screenNotches =
        8; //how many wheel notches corresponds to a full screen pan
    this._currentCursorPosition.setY(
        this.getCursorNDC(_center.x, _center.y, this.domElement).y * 0.5);

    var movement =
        this._currentCursorPosition.y - this._startCursorPosition.y;

    num size = 1;

    if (movement < 0) {
      size = 1 / (Math.pow(this.scaleFactor, -movement * screenNotches));
    } else if (movement > 0) {
      size = Math.pow(this.scaleFactor, movement * screenNotches);
    }

    this._v3_1.setFromMatrixPosition(this._cameraMatrixState);
    var x = this._v3_1.distanceTo(this._gizmos.position);
    var xNew = x /
        size; //distance between camera and gizmos if scale(size, scalepoint) would be performed

    //check min and max distance
    xNew = MathUtils.clamp(xNew, this.minDistance, this.maxDistance);

    var y = x * Math.tan(MathUtils.DEG2RAD * this._fovState * 0.5);

    //calculate new fov
    var newFov = MathUtils.RAD2DEG * (Math.atan(y / xNew) * 2);

    //check min and max fov
    newFov = MathUtils.clamp(newFov, this.minFov, this.maxFov);

    var newDistance = y / Math.tan(MathUtils.DEG2RAD * (newFov / 2));
    size = x / newDistance;
    this._v3_2.setFromMatrixPosition(this._gizmoMatrixState);

    this.setFov(newFov);
    this.applyTransformMatrix(this.scale(size, this._v3_2, false));

    //adjusting distance
    _offset
        .copy(this._gizmos.position)
        .sub(this.camera.position)
        .normalize()
        .multiplyScalar(newDistance / x);
    this._m4_1.makeTranslation(_offset.x, _offset.y, _offset.z);

    this.dispatchEvent(_changeEvent);
  }
}