<commit_before>/**
 * @author mrdoob / http://mrdoob.com/
 * @author alteredq / http://alteredqualia.com/
 * @author paulirish / http://paulirish.com/
 */

THREE.FirstPersonControls = function (object, domElement) {
    this.object = object;
    this.target = new THREE.Vector3(0, 0, 0);

    this.domElement = (domElement !== undefined) ? domElement : document;

    this.movementSpeed = 1.0;
    this.lookSpeed = 0.005;

    this.heightCoef = 1.0;
    this.heightMin = 0.0;
    this.heightMax = 1.0;

    this.verticalMin = -Math.PI * 0.9;
    this.verticalMax = Math.PI * 0.9;

    this.movementX = 0;
    this.movementY = 0;

    this.lat = -45;
    this.lon = 0;
    this.phi = 0;
    this.theta = 0;

    this.moveForward = false;
    this.moveBackward = false;
    this.moveLeft = false;
    this.moveRight = false;
    
    var jumping = { pressed : false, released : true };

    this.viewHalfX = 0;
    this.viewHalfY = 0;

    if (this.domElement !== document) {
        this.domElement.setAttribute('tabindex', -1);
    }
    
    this.isJumping = function () {
        return jumping.pressed;
    };
    
    this.jumped = function () {
        jumping.pressed = false;
    };

    this.handleResize = function () {
        if (this.domElement === document) {
            this.viewHalfX = window.innerWidth / 2;
            this.viewHalfY = window.innerHeight / 2;
        } else {
            this.viewHalfX = this.domElement.offsetWidth / 2;
            this.viewHalfY = this.domElement.offsetHeight / 2;
        }
    };
    
    var havePointerLock = 'pointerLockElement' in document ||
            'mozPointerLockElement' in document ||
            'webkitPointerLockElement' in document;
    
    if (havePointerLock) {
        this.domElement.requestPointerLock = this.domElement.requestPointerLock ||
                this.domElement.mozRequestPointerLock ||
                this.domElement.webkitRequestPointerLock;
    } else {
        alert("You should probably use the latest Chrome or Firefox. Pointer lock is required");
    }

    this.onMouseDown = function (event) {
        if (this.domElement !== document) {
            this.domElement.focus();
        }

        event.preventDefault();
        event.stopPropagation();
        
        this.domElement.requestPointerLock();
    };

    this.onMouseUp = function (event) {
        event.preventDefault();
        event.stopPropagation();
        // TODO: Add use for this?
    };

    this.onMouseMove = function (event) {
        this.movementX += event.movementX ||
                event.mozMovementX        ||
                event.webkitMovementX     ||
                0;
        this.movementY += event.movementY ||
                event.mozMovementY        ||
                event.webkitMovementY     ||
                0;
    };
    
    this.mouseMoveFunction = bind(this, this.onMouseMove);
    
    this.onPointerLockChange = function () {
        if (document.pointerLockElement === this.domElement ||
                document.mozPointerLockElement === this.domElement ||
                document.webkitPointerLockElement === this.domElement) {
            // Pointer was just locked, enable the mousemove listener
            this.domElement.addEventListener('mousemove', this.mouseMoveFunction, false);
        } else {
            // Pointer was just unlocked, disable the mousemove listener
            this.domElement.removeEventListener('mousemove', this.mouseMoveFunction, false);
        }
    };

    this.onKeyDown = function (event) {
        switch (event.keyCode) {
            case 188: /*comma*/
            case 38: /*up*/
            case 87: /*W*/ this.moveForward = true; break;

            case 37: /*left*/
            case 65: /*A*/ this.moveLeft = true; break;

            case 79: /*O*/
            case 40: /*down*/
            case 83: /*S*/ this.moveBackward = true; break;

            case 69: /*E*/
            case 39: /*right*/
            case 68: /*D*/ this.moveRight = true; break;
            
            case 32: /*space*/
                if (jumping.released) {
                    jumping.pressed = true;
                    jumping.released = false;
                }
                break;
        }
    };

    this.onKeyUp = function (event) {<commit_msg>Added console log when unrecognized key is pressed for easier debugging.<commit_after>/**
 * @author mrdoob / http://mrdoob.com/
 * @author alteredq / http://alteredqualia.com/
 * @author paulirish / http://paulirish.com/
 */

THREE.FirstPersonControls = function (object, domElement) {
    this.object = object;
    this.target = new THREE.Vector3(0, 0, 0);

    this.domElement = (domElement !== undefined) ? domElement : document;

    this.movementSpeed = 1.0;
    this.lookSpeed = 0.005;

    this.heightCoef = 1.0;
    this.heightMin = 0.0;
    this.heightMax = 1.0;

    this.verticalMin = -Math.PI * 0.9;
    this.verticalMax = Math.PI * 0.9;

    this.movementX = 0;
    this.movementY = 0;

    this.lat = -45;
    this.lon = 0;
    this.phi = 0;
    this.theta = 0;

    this.moveForward = false;
    this.moveBackward = false;
    this.moveLeft = false;
    this.moveRight = false;
    
    var jumping = { pressed : false, released : true };

    this.viewHalfX = 0;
    this.viewHalfY = 0;

    if (this.domElement !== document) {
        this.domElement.setAttribute('tabindex', -1);
    }
    
    this.isJumping = function () {
        return jumping.pressed;
    };
    
    this.jumped = function () {
        jumping.pressed = false;
    };

    this.handleResize = function () {
        if (this.domElement === document) {
            this.viewHalfX = window.innerWidth / 2;
            this.viewHalfY = window.innerHeight / 2;
        } else {
            this.viewHalfX = this.domElement.offsetWidth / 2;
            this.viewHalfY = this.domElement.offsetHeight / 2;
        }
    };
    
    var havePointerLock = 'pointerLockElement' in document ||
            'mozPointerLockElement' in document ||
            'webkitPointerLockElement' in document;
    
    if (havePointerLock) {
        this.domElement.requestPointerLock = this.domElement.requestPointerLock ||
                this.domElement.mozRequestPointerLock ||
                this.domElement.webkitRequestPointerLock;
    } else {
        alert("You should probably use the latest Chrome or Firefox. Pointer lock is required");
    }

    this.onMouseDown = function (event) {
        if (this.domElement !== document) {
            this.domElement.focus();
        }

        event.preventDefault();
        event.stopPropagation();
        
        this.domElement.requestPointerLock();
    };

    this.onMouseUp = function (event) {
        event.preventDefault();
        event.stopPropagation();
        // TODO: Add use for this?
    };

    this.onMouseMove = function (event) {
        this.movementX += event.movementX ||
                event.mozMovementX        ||
                event.webkitMovementX     ||
                0;
        this.movementY += event.movementY ||
                event.mozMovementY        ||
                event.webkitMovementY     ||
                0;
    };
    
    this.mouseMoveFunction = bind(this, this.onMouseMove);
    
    this.onPointerLockChange = function () {
        if (document.pointerLockElement === this.domElement ||
                document.mozPointerLockElement === this.domElement ||
                document.webkitPointerLockElement === this.domElement) {
            // Pointer was just locked, enable the mousemove listener
            this.domElement.addEventListener('mousemove', this.mouseMoveFunction, false);
        } else {
            // Pointer was just unlocked, disable the mousemove listener
            this.domElement.removeEventListener('mousemove', this.mouseMoveFunction, false);
        }
    };

    this.onKeyDown = function (event) {
        switch (event.keyCode) {
            case 188: /*comma*/
            case 38: /*up*/
            case 87: /*W*/ this.moveForward = true; break;

            case 37: /*left*/
            case 65: /*A*/ this.moveLeft = true; break;

            case 79: /*O*/
            case 40: /*down*/
            case 83: /*S*/ this.moveBackward = true; break;

            case 69: /*E*/
            case 39: /*right*/
            case 68: /*D*/ this.moveRight = true; break;
            
            case 32: /*space*/
                if (jumping.released) {
                    jumping.pressed = true;
                    jumping.released = false;
                }
                break;
            default:
                console.log("Warning: Unrecognized keyCode: " + event.keyCode);
        }
    };

    this.onKeyUp = function (event) {
{'fraction_non_alphanumeric': 0.11651816312542837, 'fraction_numerical': 0.013936486177747315, 'mean_word_length': 1.7714466603355492, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7041959', 'n_tokens_mistral': 2636, 'n_tokens_neox': 2453, 'n_words': 545}