focus method

dynamic focus(
  1. dynamic point,
  2. dynamic size, [
  3. dynamic amount = 1
])
  • Focus operation consist of positioning the point of interest in front of the camera and a slightly zoom in
    • @param {Vector3} point The point of interest
      • @param {Number} size Scale factor
      • @param {Number} amount Amount of operation to be completed (used for focus animations, default is complete full operation)

Implementation

focus(point, size, [amount = 1]) {
  //move center of camera (along with gizmos) towards point of interest
  _offset.copy(point).sub(this._gizmos.position).multiplyScalar(amount);
  this._translationMatrix.makeTranslation(_offset.x, _offset.y, _offset.z);

  _gizmoMatrixStateTemp.copy(this._gizmoMatrixState);
  this._gizmoMatrixState.premultiply(this._translationMatrix);
  this._gizmoMatrixState.decompose(
      this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale);

  _cameraMatrixStateTemp.copy(this._cameraMatrixState);
  this._cameraMatrixState.premultiply(this._translationMatrix);
  this._cameraMatrixState.decompose(
      this.camera.position, this.camera.quaternion, this.camera.scale);

  //apply zoom
  if (this.enableZoom) {
    this.applyTransformMatrix(this.scale(size, this._gizmos.position));
  }

  this._gizmoMatrixState.copy(_gizmoMatrixStateTemp);
  this._cameraMatrixState.copy(_cameraMatrixStateTemp);
}