pan method

dynamic pan(
  1. dynamic p0,
  2. dynamic p1, [
  3. dynamic adjust = false
])
  • Perform pan operation moving camera between two points
    • @param {Vector3} p0 Initial point
      • @param {Vector3} p1 Ending point
      • @param {Boolean} adjust If movement should be adjusted considering camera distance (Perspective only)

Implementation

pan(p0, p1, [adjust = false]) {
  var movement = p0.clone().sub(p1);

  if (this.camera is OrthographicCamera) {
    //adjust movement amount
    movement.multiplyScalar(1 / this.camera.zoom);
  } else if (this.camera is PerspectiveCamera && adjust) {
    //adjust movement amount
    this._v3_1.setFromMatrixPosition(
        this._cameraMatrixState0); //camera's initial position
    this._v3_2.setFromMatrixPosition(
        this._gizmoMatrixState0); //gizmo's initial position
    var distanceFactor = this._v3_1.distanceTo(this._v3_2) /
        this.camera.position.distanceTo(this._gizmos.position);
    movement.multiplyScalar(1 / distanceFactor);
  }

  this
      ._v3_1
      .set(movement.x, movement.y, 0)
      .applyQuaternion(this.camera.quaternion);

  this._m4_1.makeTranslation(this._v3_1.x, this._v3_1.y, this._v3_1.z);

  this.setTransformationMatrices(this._m4_1, this._m4_1);
  return _transformation;
}