<commit_before>function FlyCam() {
    this.target = pc.math.vec3.create(0.0, 0.0, 0.0);

    this.x = 0;
    this.y = 0;

    this.distance = 3.25;
}

FlyCam = pc.inherits(FlyCam, pc.scene.CameraNode);

FlyCam.prototype.pan = function(movement) {
    var tx = pc.math.clamp(movement[0], -100.0, 100.0) * -0.025;
    var ty = pc.math.clamp(movement[1], -100.0, 100.0) * 0.025;

    this.translateLocal(tx, ty, 0);
}

FlyCam.prototype.dolly = function (distance) {
    // Dolly along the Z axis of the camera's local transform
    var tz = pc.math.clamp(distance, -100.0, 100.0) * -0.025;

    this.distance += tz;
    this.translateLocal(0, 0, tz);
}

FlyCam.prototype.orbit = function (movement) {
    this.x += movement[0] * 0.2;
    this.y += movement[1] * 0.2;

    var qx = pc.math.quat.create();
    var qy = pc.math.quat.create();
    var qxy = pc.math.quat.create();
    pc.math.quat.setFromAxisAngle(qx, [1, 0, 0], this.y);
    pc.math.quat.setFromAxisAngle(qy, [0, 1, 0], this.x);
    pc.math.quat.multiply(qx, qy, qxy);

    this.setLocalPosition(0, 0, 0);
    this.setLocalRotation(qxy);
    this.translateLocal(0, 0, this.distance);
}

FlyCam.prototype.onMouseWheel = function (event) {
    var distance = event.wheel * 10;
    this.dolly(distance);
}

FlyCam.prototype.onMouseMove = function (event) {
    // We can't rely on a right click because that has a 'special function'
    // in most (all?) browsers
    if (event.buttons[pc.input.MOUSE_BUTTON_LEFT] && event.buttons[pc.input.MOUSE_BUTTON_MIDDLE]) {
        this.dolly(event.movementY);
    } else if (event.altKey && event.buttons[pc.input.MOUSE_BUTTON_LEFT]) {
        this.orbit([event.movementX, event.movementY]);
    } else if (event.altKey && event.buttons[pc.input.MOUSE_BUTTON_MIDDLE]) {
        this.pan([event.movementX, event.movementY]);
    }
}<commit_msg>Tweaks to flycam code.<commit_after>function FlyCam() {
    this.target = pc.math.vec3.create(0.0, 0.0, 0.0);

    this.x = 0;
    this.y = 0;

    this.distance = 3.25;
}

FlyCam = pc.inherits(FlyCam, pc.scene.CameraNode);

FlyCam.prototype.pan = function(movex, movey) {
    // Pan around in the camera's local XY plane
    this.translateLocal(movex, movey, 0);
}

FlyCam.prototype.dolly = function (movez) {
    // Dolly along the Z axis of the camera's local transform
    this.distance += movez;
    this.translateLocal(0, 0, movez);
}

FlyCam.prototype.orbit = function (movex, movey) {
    this.x += movex;
    this.y += movey;

    var qx = pc.math.quat.create();
    var qy = pc.math.quat.create();
    var qxy = pc.math.quat.create();
    pc.math.quat.setFromAxisAngle(qx, [1, 0, 0], this.y);
    pc.math.quat.setFromAxisAngle(qy, [0, 1, 0], this.x);
    pc.math.quat.multiply(qx, qy, qxy);

    this.setLocalRotation(qxy);
    this.setLocalPosition(0, 0, 0);
    this.translateLocal(0, 0, this.distance);
}

FlyCam.prototype.onMouseWheel = function (event) {
    this.dolly(event.wheel * -0.25);
}

FlyCam.prototype.onMouseMove = function (event) {
    // We can't rely on a right click because that has a 'special function'
    // in most (all?) browsers
    if (event.buttons[pc.input.MOUSE_BUTTON_LEFT] && event.buttons[pc.input.MOUSE_BUTTON_MIDDLE]) {
        this.dolly(event.movementY * -0.025);
    } else if (event.altKey && event.buttons[pc.input.MOUSE_BUTTON_LEFT]) {
        this.orbit(event.movementX * 0.2, event.movementY * 0.2);
    } else if (event.altKey && event.buttons[pc.input.MOUSE_BUTTON_MIDDLE]) {
        this.pan(event.movementX * -0.025, event.movementY * 0.025);
    }
}
{'fraction_non_alphanumeric': 0.16131756756756757, 'fraction_numerical': 0.032939189189189186, 'mean_word_length': 3.107514450867052, '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': '7563243', 'n_tokens_mistral': 1459, 'n_tokens_neox': 1368, 'n_words': 271}