<commit_before>goog.provide('olcs.Camera');

goog.require('goog.events');
goog.require('ol.proj');
goog.require('olcs.core');



/**
 * This object takes care of additional 3d-specific properties of the view and
 * ensures proper synchronization with the underlying raw Cesium.Camera object.
 * @param {!Cesium.Scene} scene
 * @param {!ol.Map} map
 * @constructor
 * @api
 */
olcs.Camera = function(scene, map) {
  /**
   * @type {!Cesium.Scene}
   * @private
   */
  this.scene_ = scene;

  /**
   * @type {!Cesium.Camera}
   * @private
   */
  this.cam_ = scene.camera;

  /**
   * @type {!ol.Map}
   * @private
   */
  this.map_ = map;

  /**
   * @type {?ol.View}
   * @private
   */
  this.view_ = null;

  /**
   * @type {?goog.events.Key}
   * @private
   */
  this.viewListenKey_ = null;

  /**
   * @type {?ol.TransformFunction}
   * @private
   */
  this.toLonLat_ = null;

  /**
   * @type {?ol.TransformFunction}
   * @private
   */
  this.fromLonLat_ = null;

  /**
   * 0 -- topdown, PI/2 -- the horizon
   * @type {number}
   * @private
   */
  this.tilt_ = 0;

  /**
   * @type {number}
   * @private
   */
  this.distance_ = 0;

  /**
   * @type {?Cesium.Matrix4}
   * @private
   */
  this.lastCameraViewMatrix_ = null;

  /**
   * This is used to discard change events on view caused by updateView method.
   * @type {boolean}
   * @private
   */
  this.viewUpdateInProgress_ = false;

  this.map_.on('change:view', function(e) {
    this.setView_(this.map_.getView());
  }, this);
  this.setView_(this.map_.getView());
};


/**
 * @param {?ol.View} view New view to use.
 * @private
 */
olcs.Camera.prototype.setView_ = function(view) {
  if (!goog.isNull(this.view_)) {
    this.view_.unByKey(this.viewListenKey_);
    this.viewListenKey_ = null;
  }

  this.view_ = view;
  if (!goog.isNull(view)) {
    this.toLonLat_ = ol.proj.getTransform(view.getProjection(), 'EPSG:4326');
    this.fromLonLat_ = ol.proj.getTransform('EPSG:4326', view.getProjection());

    this.viewListenKey_ = view.on('propertychange',
                                  this.handleViewEvent_, this);
    this.readFromView();
  } else {
    this.toLonLat_ = null;
    this.fromLonLat_ = null;
  }
};


/**
 * @param {?} e
 * @private
 */
olcs.Camera.prototype.handleViewEvent_ = function(e) {
  if (!this.viewUpdateInProgress_) {
    this.readFromView();
  }
};


/**
 * @param {number} heading In radians.
 * @api
 */
olcs.Camera.prototype.setHeading = function(heading) {<commit_msg>Use identity transforms in Camera<commit_after>goog.provide('olcs.Camera');

goog.require('goog.events');
goog.require('ol.proj');
goog.require('olcs.core');



/**
 * This object takes care of additional 3d-specific properties of the view and
 * ensures proper synchronization with the underlying raw Cesium.Camera object.
 * @param {!Cesium.Scene} scene
 * @param {!ol.Map} map
 * @constructor
 * @api
 */
olcs.Camera = function(scene, map) {
  /**
   * @type {!Cesium.Scene}
   * @private
   */
  this.scene_ = scene;

  /**
   * @type {!Cesium.Camera}
   * @private
   */
  this.cam_ = scene.camera;

  /**
   * @type {!ol.Map}
   * @private
   */
  this.map_ = map;

  /**
   * @type {?ol.View}
   * @private
   */
  this.view_ = null;

  /**
   * @type {?goog.events.Key}
   * @private
   */
  this.viewListenKey_ = null;

  /**
   * @type {!ol.TransformFunction}
   * @private
   */
  this.toLonLat_ = olcs.Camera.identityProjection;

  /**
   * @type {!ol.TransformFunction}
   * @private
   */
  this.fromLonLat_ = olcs.Camera.identityProjection;

  /**
   * 0 -- topdown, PI/2 -- the horizon
   * @type {number}
   * @private
   */
  this.tilt_ = 0;

  /**
   * @type {number}
   * @private
   */
  this.distance_ = 0;

  /**
   * @type {?Cesium.Matrix4}
   * @private
   */
  this.lastCameraViewMatrix_ = null;

  /**
   * This is used to discard change events on view caused by updateView method.
   * @type {boolean}
   * @private
   */
  this.viewUpdateInProgress_ = false;

  this.map_.on('change:view', function(e) {
    this.setView_(this.map_.getView());
  }, this);
  this.setView_(this.map_.getView());
};


/**
 * @param {Array.<number>} input Input coordinate array.
 * @param {Array.<number>=} opt_output Output array of coordinate values.
 * @param {number=} opt_dimension Dimension.
 * @return {Array.<number>} Input coordinate array (same array as input).
 */
olcs.Camera.identityProjection = function(input, opt_output, opt_dimension) {
  var dim = opt_dimension || input.length;
  if (opt_output) {
    for (var i = 0; i < dim; ++i) {
      opt_output[i] = input[i];
    }
  }
  return input;
};


/**
 * @param {?ol.View} view New view to use.
 * @private
 */
olcs.Camera.prototype.setView_ = function(view) {
  if (!goog.isNull(this.view_)) {
    this.view_.unByKey(this.viewListenKey_);
    this.viewListenKey_ = null;
  }

  this.view_ = view;
  if (!goog.isNull(view)) {
    var toLonLat = ol.proj.getTransform(view.getProjection(), 'EPSG:4326');
    var fromLonLat = ol.proj.getTransform('EPSG:4326', view.getProjection());
    goog.asserts.assert(toLonLat && fromLonLat);

    this.toLonLat_ = toLonLat;
    this.fromLonLat_ = fromLonLat;

    this.viewListenKey_ = view.on('propertychange',
                                  this.handleViewEvent_, this);
    this.readFromView();
  } else {
    this.toLonLat_ = olcs.Camera.identityProjection;
    this.fromLonLat_ = olcs.Camera.identityProjection;
  }
};


/**
 * @param {?} e
 * @private
 */
olcs.Camera.prototype.handleViewEvent_ = function(e) {
  if (!this.viewUpdateInProgress_) {
    this.readFromView();
  }
};


/**
 * @param {number} heading In radians.
 * @api
 */
olcs.Camera.prototype.setHeading = function(heading) {
{'fraction_non_alphanumeric': 0.16695926966292135, 'fraction_numerical': 0.005091292134831461, 'mean_word_length': 2.8286290322580645, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1592946', 'n_tokens_mistral': 2143, 'n_tokens_neox': 2045, 'n_words': 390}