<commit_before>/**
 * @author <NAME> / http://www.baicoianu.com/
 */

THREE.FreeFlyControls = function ( object, inputMgr ) {

  this.object = object;

  this.inputMgr = ( inputMgr !== undefined ) ? inputMgr : InputManager;

  // API

  this.movementSpeed = 1.0;

  // internals

  this.mouseStatus = 0;
  this.mousePos = new THREE.Vector2( 0, 0 );

  this.moveState = { up: 0, down: 0, left: 0, right: 0, forward: 0, back: 0 };
  this.moveVector = new THREE.Vector3( 0, 0, 0 );
  this.rotationEuler = new THREE.Euler( );
  this.movementSpeedMultiplier = 1;

  this.setRotationFromQuaternion = function(quat) {

    this.rotationEuler = new THREE.Euler();
    this.rotationEuler.setFromQuaternion(quat, 'ZYX');

  };
  this.setRotationFromQuaternion(this.object.quaternion);

  this.keydown = function( event ) {

    if ( event.altKey ) {

      return;

    }

    //event.preventDefault();

    switch ( event.keyCode ) {

      case 16: /* shift */ this.movementSpeedMultiplier = 5; break;

      case 87: /*W*/ this.moveState.forward = 1; break;
      case 83: /*S*/ this.moveState.back = 1; break;

      case 65: /*A*/ this.moveState.left = 1; break;
      case 68: /*D*/ this.moveState.right = 1; break;

      case 82: /*R*/ this.moveState.up = 1; break;
      case 70: /*F*/ this.moveState.down = 1; break;

    }

    if (event.keyCode === 82) {
      this.setRotationFromQuaternion(this.object.quaternion);
      this.updateRotation();
    }

    this.updateMovementVector();

  };

  this.keyup = function( event ) {

    switch( event.keyCode ) {

      case 16: /* shift */ this.movementSpeedMultiplier = 1; break;

      case 87: /*W*/ this.moveState.forward = 0; break;
      case 83: /*S*/ this.moveState.back = 0; break;

      case 65: /*A*/ this.moveState.left = 0; break;
      case 68: /*D*/ this.moveState.right = 0; break;

      case 82: /*R*/ this.moveState.up = 0; break;
      case 70: /*F*/ this.moveState.down = 0; break;

    }

    this.updateMovementVector();

  };

  this.mousedown = function( event ) {

    event.preventDefault();
    event.stopPropagation();

    this.mouseStatus ++;

    this.mousePos.x = event.pageX;
    this.mousePos.y = event.pageY;

  };
<commit_msg>Added Q & E buttons to freefly to speed up or slow down movement.<commit_after>/**
 * @author <NAME> / http://www.baicoianu.com/
 */

THREE.FreeFlyControls = function ( object, inputMgr ) {

  this.object = object;

  this.inputMgr = ( inputMgr !== undefined ) ? inputMgr : InputManager;

  // API

  this.movementSpeed = 1.0;

  // internals

  this.mouseStatus = 0;
  this.mousePos = new THREE.Vector2( 0, 0 );

  this.moveState = { up: 0, down: 0, left: 0, right: 0, forward: 0, back: 0 };
  this.moveVector = new THREE.Vector3( 0, 0, 0 );
  this.rotationEuler = new THREE.Euler( );
  this.movementSpeedMultiplier = 1;

  this.setRotationFromQuaternion = function(quat) {

    this.rotationEuler = new THREE.Euler();
    this.rotationEuler.setFromQuaternion(quat, 'ZYX');

  };
  this.setRotationFromQuaternion(this.object.quaternion);

  this.keydown = function( event ) {

    if ( event.altKey ) {

      return;

    }

    //event.preventDefault();

    switch ( event.keyCode ) {

      case 16: /* shift */ this.movementSpeedMultiplier = 5; break;
      case 81: /* Q */ this.movementSpeedMultiplier = 1/4; break;
      case 69: /* E */ this.movementSpeedMultiplier = 4; break;

      case 87: /*W*/ this.moveState.forward = 1; break;
      case 83: /*S*/ this.moveState.back = 1; break;

      case 65: /*A*/ this.moveState.left = 1; break;
      case 68: /*D*/ this.moveState.right = 1; break;

      case 82: /*R*/ this.moveState.up = 1; break;
      case 70: /*F*/ this.moveState.down = 1; break;

    }

    if (event.keyCode === 82) {
      this.setRotationFromQuaternion(this.object.quaternion);
      this.updateRotation();
    }

    this.updateMovementVector();

  };

  this.keyup = function( event ) {

    switch( event.keyCode ) {

      case 16: /* shift */ this.movementSpeedMultiplier = 1; break;
      case 81: /* Q */ this.movementSpeedMultiplier = 1; break;
      case 69: /* E */ this.movementSpeedMultiplier = 1; break;

      case 87: /*W*/ this.moveState.forward = 0; break;
      case 83: /*S*/ this.moveState.back = 0; break;

      case 65: /*A*/ this.moveState.left = 0; break;
      case 68: /*D*/ this.moveState.right = 0; break;

      case 82: /*R*/ this.moveState.up = 0; break;
      case 70: /*F*/ this.moveState.down = 0; break;

    }

    this.updateMovementVector();

  };

  this.mousedown = function( event ) {

    event.preventDefault();
    event.stopPropagation();

    this.mouseStatus ++;

    this.mousePos.x = event.pageX;
    this.mousePos.y = event.pageY;

  };

{'fraction_non_alphanumeric': 0.15392736486486486, 'fraction_numerical': 0.028505067567567568, 'mean_word_length': 2.5670180722891565, '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': '7434342', 'n_tokens_mistral': 1811, 'n_tokens_neox': 1618, 'n_words': 382}