<commit_before>//Based on "A User Interface for Specifying Three-Dimensional Orientation Using a Mouse" by <NAME>
//http://www.talisman.org/~erlkonig/misc/shoemake92-arcball.pdf

//## Example Use
//     var camera = new PerspecitveCamera();
//     var arball = new Arcball(this, camera, 5.0);

//## Reference
define(["pex/core/Vec2", "pex/core/Vec3", "pex/core/Vec4", "pex/core/Quat", "pex/core/Mat4"], function(Vec2, Vec3, Vec4, Quat, Mat4) {
  function Arcball(window, camera, distance) {
    this.distance = distance || 2;
    this.minDistance = distance/2 || 0.3;
    this.maxDistance = distance*2 || 5;
    this.camera = camera;
    this.window = window;
    this.radius = Math.min(window.width/2, window.height/2) * 2;
    this.center = new Vec2(window.width/2, window.height/2);
    this.orientation = Quat.identity();
    this.currRot = Quat.identity();
    this.clickRot = Quat.identity();
    this.dragRot = Quat.identity();
    this.clickPos = new Vec3();
    this.dragPos = new Vec3();
    this.rotAxis = new Vec3();

    this.updateCamera();

    var self = this;
    window.on('leftMouseDown', function(e) {
      if (e.handled) return;
      self.down(e.x, self.window.height - e.y); //we flip the y coord to make rotating camera work
    });

    window.on('mouseDragged', function(e) {
      if (e.handled) return;
      self.drag(e.x, self.window.height - e.y); //we flip the y coord to make rotating camera work
    });

    window.on('scrollWheel', function(e) {
      if (e.handled) return;
      self.distance = Math.min(self.maxDistance, Math.max(self.distance + e.dy/100*(self.maxDistance-self.minDistance), self.minDistance));<commit_msg>Fixed they way we use quaternions<commit_after>//Based on "A User Interface for Specifying Three-Dimensional Orientation Using a Mouse" by <NAME>
//http://www.talisman.org/~erlkonig/misc/shoemake92-arcball.pdf

//## Example Use
//     var camera = new PerspecitveCamera();
//     var arball = new Arcball(this, camera, 5.0);

//## Reference
define(["pex/core/Vec2", "pex/core/Vec3", "pex/core/Vec4", "pex/core/Quat", "pex/core/Mat4"], function(Vec2, Vec3, Vec4, Quat, Mat4) {
  function Arcball(window, camera, distance) {
    this.distance = distance || 2;
    this.minDistance = distance/2 || 0.3;
    this.maxDistance = distance*2 || 5;
    this.camera = camera;
    this.window = window;
    this.radius = Math.min(window.width/2, window.height/2) * 2;
    this.center = new Vec2(window.width/2, window.height/2);
    this.currRot = Quat.identity();
    this.currRot.rotate(Math.PI, 0, 1, 0);
    this.clickRot = Quat.identity();
    this.dragRot = Quat.identity();
    this.clickPos = new Vec3();
    this.dragPos = new Vec3();
    this.rotAxis = new Vec3();

    this.updateCamera();

    var self = this;
    window.on('leftMouseDown', function(e) {
      if (e.handled) return;
      self.down(e.x, self.window.height - e.y); //we flip the y coord to make rotating camera work
    });

    window.on('mouseDragged', function(e) {
      if (e.handled) return;
      self.drag(e.x, self.window.height - e.y); //we flip the y coord to make rotating camera work
    });

    window.on('scrollWheel', function(e) {
      if (e.handled) return;
      self.distance = Math.min(self.maxDistance, Math.max(self.distance + e.dy/100*(self.maxDistance-self.minDistance), self.minDistance));
{'fraction_non_alphanumeric': 0.159749178859361, 'fraction_numerical': 0.018811585547924753, 'mean_word_length': 3.1770573566084788, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7361084', 'n_tokens_mistral': 1192, 'n_tokens_neox': 1136, 'n_words': 266}