setCamera method

dynamic setCamera(
  1. dynamic camera
)

Set the camera to be controlled @param {Camera} camera The virtual camera to be controlled

Implementation

setCamera(camera) {
  camera.lookAt(target);
  camera.updateMatrix();

  //setting state
  if (camera.type == 'PerspectiveCamera') {
    _fov0 = camera.fov;
    _fovState = camera.fov;
  }

  _cameraMatrixState0.copy(camera.matrix);
  _cameraMatrixState.copy(_cameraMatrixState0);
  _cameraProjectionState.copy(camera.projectionMatrix);
  _zoom0 = camera.zoom;
  _zoomState = _zoom0;

  _initialNear = camera.near;
  _nearPos0 = camera.position.distanceTo(target) - camera.near;
  _nearPos = _initialNear;

  _initialFar = camera.far;
  _farPos0 = camera.position.distanceTo(target) - camera.far;
  _farPos = _initialFar;

  _up0.copy(camera.up);
  _upState.copy(camera.up);

  camera = camera;
  camera.updateProjectionMatrix();

  //making gizmos
  _tbRadius = calculateTbRadius(camera);
  makeGizmos(target, _tbRadius);
}