<commit_before>'use strict'

function FPSControls(camera, ground_normal) {
    this.__init__(camera, ground_normal)
}

FPSControls.prototype = {
    camera       : null,
    pitch        : null,
    yaw          : null,
    half_pie     : null,
    enabled      : null,

    // Movement.
    up           : null,
    down         : null,
    left         : null,
    right        : null,
    velocity     : null,
    acceleration : null,

    flying_on    : null,

    // Camera view.
    max_upward_view: null,
    max_downward_view: null,

    direction_vector: null,


    ground_normal: null,
    ground_vector: null,

    __init__: function (camera, ground_normal) {
        // Constants.
        this.half_pie = Math.PI / 2
        this.max_view_angle = this.half_pie * 0.9
        this.ground_normal = ground_normal
        console.log('GROUND NORMAL IS NOW SET TO : ' + this.ground_normal)


        var exampleA = new THREE.Vector3(1, 2, 3)
        var exampleN = new THREE.Vector3(4, 5, 6)
        exampleN.normalize()
        console.log(exampleN)
        console.log(exampleA.projectOnPlane(exampleN))

        this.camera = camera
        this.camera.rotation.set(0, 0, 0)

        this.pitch = new THREE.Object3D()
        this.pitch.add(camera)

        this.yaw = new THREE.Object3D()
        this.yaw.position.y = 10
        this.yaw.add(this.pitch)

        this.enabled = false
        this.flying_on = false

        this.velocity = new THREE.Vector3()

        document.addEventListener('onkeypress', this.on_key_press.bind(this), false)
        document.addEventListener('mousemove', this.on_mouse_move.bind(this), false)
        document.addEventListener('keydown', this.on_key_down.bind(this), false)
        document.addEventListener('keyup', this.on_key_up.bind(this), false)
    },

    physics: function(delta) {
        if (this.enabled) {

            //console.log(this.camera.getWorldDirection().x + ', ' + this.camera.getWorldDirection().y + ', ' + this.camera.getWorldDirection().z)
            //console.log(' ')


            /*
            // Walking mode.
            if (this.flying_on === false) {
                this.direction_vector = new THREE.Vector3(this.camera.getWorldDirection().x, this.camera.getWorldDirection().y, this.camera.getWorldDirection().z)

                console.log('The ground normal is : ')
                console.log(this.ground_normal)
                this.ground_vector = this.direction_vector.projectOnPlane(this.ground_normal)
                this.ground_vector.normalize()
                //var ground_vector =
                console.log('x: ' + this.ground_vector.x + ', y: ' + this.ground_vector.y + ', z: ' + this.ground_vector.z)

            } else {
                // Flying mode.
                this.direction_vector = new THREE.Vector3(this.camera.getWorldDirection().x, this.camera.getWorldDirection().y, this.camera.getWorldDirection().z)

            }*/

            // Oh just realized the vector direction system needed..., going to use old one in mean time

            if (this.flying_on) {

                if (this.space) {
                    this.velocity.y += 400.0 * delta
                }

            } else {
                if (this.up) {
                    //this.velocity.z -= this.ground_vector.x * 400.0 * delta
                    //this.velocity.x -= this.ground_vector.z * 400.0 * delta
                    this.velocity.z -= 400.0 * delta
                }
                if (this.down) {
                    //this.velocity.z += this.direction_vector.z * 400.0 * delta
                    this.velocity.z += 400.0 * delta
                }
                if (this.left) {
                    //this.velocity.x -= this.direction_vector.x * 400.0 * delta
                    this.velocity.x -= 400.0 * delta
                }
                if (this.right) {
                    //this.velocity.x += this.direction_vector.x * 400.0 * delta
                    this.velocity.x += 400.0 * delta
                }
                this.velocity.x -= this.velocity.x * 10.0 * delta
                this.velocity.z -= this.velocity.z * 10.0 * delta

                this.yaw.translateX(this.velocity.x * delta)
                this.yaw.translateY(this.velocity.y * delta)
                this.yaw.translateZ(this.velocity.z * delta)
            }
        }
    },

    get_position: function() {
        return this.yaw.position
    },

    get_velocity: function() {
        return this.velocity
    },

    enable: function() {
        this.enabled = true
    },

    disable: function() {
        this.enabled = false
    },

    on_key_press: function(event) {
        switch(event.keyCode) {
        case 70: // f
            this.flying_on = !this.flying_on
            break
        }
    },

    on_key_down: function(event) {
        switch(event.keyCode) {
        case 38: // up
        case 87: // w
            this.up = true
            break
        case 37: // left
        case 65: // a
            this.left = true
            break
        case 40: // down
        case 83: // s
            this.down = true
            break<commit_msg>Various testing 03<commit_after>'use strict'

function FPSControls(camera, ground_normal) {
    this.__init__(camera, ground_normal)
}

FPSControls.prototype = {
    camera       : null,
    pitch        : null,
    yaw          : null,
    half_pie     : null,
    enabled      : null,

    // Movement.
    up           : null,
    down         : null,
    left         : null,
    right        : null,
    velocity     : null,
    acceleration : null,

    flying_on    : null,

    // Camera view.
    max_upward_view: null,
    max_downward_view: null,

    direction_vector: null,


    ground_normal: null,
    ground_vector: null,

    __init__: function (camera, ground_normal) {
        // Constants.
        this.half_pie = Math.PI / 2
        this.max_view_angle = this.half_pie * 0.9
        this.ground_normal = ground_normal
        console.log('GROUND NORMAL IS NOW SET TO : ' + this.ground_normal)


        var exampleA = new THREE.Vector3(1, 2, 3)
        var exampleN = new THREE.Vector3(4, 5, 6)
        exampleN.normalize()
        console.log(exampleN)
        console.log(exampleA.projectOnPlane(exampleN))

        this.camera = camera
        this.camera.rotation.set(0, 0, 0)

        this.pitch = new THREE.Object3D()
        this.pitch.add(camera)

        this.yaw = new THREE.Object3D()
        this.yaw.position.y = 10
        this.yaw.add(this.pitch)

        this.enabled = false
        this.flying_on = false

        this.velocity = new THREE.Vector3()

        document.addEventListener('onkeypress', this.on_key_press.bind(this), false)
        document.addEventListener('mousemove', this.on_mouse_move.bind(this), false)
        document.addEventListener('keydown', this.on_key_down.bind(this), false)
        document.addEventListener('keyup', this.on_key_up.bind(this), false)
    },

    physics: function(delta) {
        if (this.enabled) {

            //console.log(this.camera.getWorldDirection().x + ', ' + this.camera.getWorldDirection().y + ', ' + this.camera.getWorldDirection().z)
            //console.log(' ')


            /*
            // Walking mode.
            if (this.flying_on === false) {
                this.direction_vector = new THREE.Vector3(this.camera.getWorldDirection().x, this.camera.getWorldDirection().y, this.camera.getWorldDirection().z)

                console.log('The ground normal is : ')
                console.log(this.ground_normal)
                this.ground_vector = this.direction_vector.projectOnPlane(this.ground_normal)
                this.ground_vector.normalize()
                //var ground_vector =
                console.log('x: ' + this.ground_vector.x + ', y: ' + this.ground_vector.y + ', z: ' + this.ground_vector.z)

            } else {
                // Flying mode.
                this.direction_vector = new THREE.Vector3(this.camera.getWorldDirection().x, this.camera.getWorldDirection().y, this.camera.getWorldDirection().z)

            }*/

            // Oh just realized the vector direction system needed..., going to use old one in mean time

            if (this.flying_on) {

                if (this.space) {
                    this.velocity.y += 400.0 * delta
                }

            } else {
                if (this.up) {
                    //this.velocity.z -= this.ground_vector.x * 400.0 * delta
                    //this.velocity.x -= this.ground_vector.z * 400.0 * delta
                    this.velocity.z -= 400.0 * delta
                }
                if (this.down) {
                    //this.velocity.z += this.direction_vector.z * 400.0 * delta
                    this.velocity.z += 400.0 * delta
                }
                if (this.left) {
                    //this.velocity.x -= this.direction_vector.x * 400.0 * delta
                    this.velocity.x -= 400.0 * delta
                }
                if (this.right) {
                    //this.velocity.x += this.direction_vector.x * 400.0 * delta
                    this.velocity.x += 400.0 * delta
                }
                this.velocity.x -= this.velocity.x * 10.0 * delta
                this.velocity.z -= this.velocity.z * 10.0 * delta

                this.yaw.translateX(this.velocity.x * delta)
                this.yaw.translateY(this.velocity.y * delta)
                this.yaw.translateZ(this.velocity.z * delta)
            }
        }
    },

    get_position: function() {
        return this.yaw.position
    },

    get_velocity: function() {
        return this.velocity
    },

    enable: function() {
        this.enabled = true
    },

    disable: function() {
        this.enabled = false
    },

    on_key_press: function(event) {
        switch(event.keyCode) {
        case 70: // f
            this.flying_on = !this.flying_on
            console.log('Flying toggled to : ' + this.flying_on)
            break
        }
    },

    on_key_down: function(event) {
        switch(event.keyCode) {
        case 38: // up
        case 87: // w
            this.up = true
            break
        case 37: // left
        case 65: // a
            this.left = true
            break
        case 40: // down
        case 83: // s
            this.down = true
            break
{'fraction_non_alphanumeric': 0.11598384304673975, 'fraction_numerical': 0.01577226389690325, 'mean_word_length': 1.5142649903288201, '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': '17649', 'n_tokens_mistral': 3271, 'n_tokens_neox': 2956, 'n_words': 583}