<commit_before>'use strict';

define(['Three', 'Camera', 'PointerLock', 'Tween', 'ItemSelector', 'World'], function(THREE, camera, pointerLock, tween, itemSelector, world) {
    var currentTween;
    var mesh;
    var currentRadius;
    
    var init = function() {
        createReticle();
        
        var reticleContainer = new THREE.Object3D();
        reticleContainer.add(mesh);
        camera.add(reticleContainer);
        
        world.onLoop(animate);
    };
    
    var animate = function(time) {
        if (!pointerLock.enabled()) {
			hideReticle();
            return;
        }
		
		showReticle();
        
        if(currentTween) {
            currentTween.update(time.time);    
        }
        
        updateTween(itemSelector.isIntersecting());
    };

    var updateTween = function(isIntersecting) {
        if(currentTween && currentTween.isIntersecting != isIntersecting) {
            currentTween.stop();
        }
        
        if(!currentTween || currentTween.isIntersecting != isIntersecting) {
            currentTween = new tween.Tween({radius: currentRadius})
            .to({radius: isIntersecting ? 0.15 : 0.05}, 750 )
            .easing(TWEEN.Easing.Sinusoidal.InOut )
            .onUpdate(function () {
                var geometry = new THREE.CircleGeometry(this.radius, 32);
                geometry.vertices.shift();
                mesh.geometry = geometry;
                currentRadius = this.radius;
            }).start();
            
            currentTween.isIntersecting = isIntersecting;
        }
    };

    var createReticle = function() {
        var defaultRadius = 0.05;
        
        var geometry = new THREE.CircleGeometry(defaultRadius, 32);
        geometry.vertices.shift();
        
        var material = new THREE.LineBasicMaterial();
        material.color.set(0x000000);

        mesh = new THREE.Line(geometry, material);
        mesh.position.x = 0;
        mesh.position.y = 0;
        mesh.position.z = -10;
        
        currentRadius = defaultRadius;
    };<commit_msg>Reticle ux improvements<commit_after>'use strict';

define(['Three', 'Camera', 'PointerLock', 'Tween', 'ItemSelector', 'World'], function(THREE, camera, pointerLock, tween, itemSelector, world) {
    var currentTween;
    var mesh;
    var currentRadius;
    
    var init = function() {
        createReticle();
        
        var reticleContainer = new THREE.Object3D();
        reticleContainer.add(mesh);
        camera.add(reticleContainer);
        
        world.onLoop(animate);
    };
    
    var animate = function(time) {
        if (!pointerLock.enabled()) {
			hideReticle();
            return;
        }
		
		showReticle();
        
        if(currentTween) {
            currentTween.update(time.time);    
        }
        
        updateTween(itemSelector.isIntersecting());
    };

    var updateTween = function(isIntersecting) {
        if(currentTween && currentTween.isIntersecting != isIntersecting) {
            currentTween.stop();
        }
        
        if(!currentTween || currentTween.isIntersecting != isIntersecting) {
            currentTween = new tween.Tween({radius: currentRadius})
            .to({radius: isIntersecting ? 0.12 : 0.03}, 250 )
            .easing(TWEEN.Easing.Cubic.InOut)
            .onUpdate(function () {
                var geometry = new THREE.CircleGeometry(this.radius, 32);
                geometry.vertices.shift();
                mesh.geometry = geometry;
                currentRadius = this.radius;
            }).start();
            
            currentTween.isIntersecting = isIntersecting;
        }
    };

    var createReticle = function() {
        var defaultRadius = 0.05;
        
        var geometry = new THREE.CircleGeometry(defaultRadius, 32);
        geometry.vertices.shift();
        
        var material = new THREE.LineBasicMaterial({
			'color': 0x333333
		});

        mesh = new THREE.Line(geometry, material);
        mesh.position.x = 0;
        mesh.position.y = 0;
        mesh.position.z = -10;
        
        currentRadius = defaultRadius;
    };
{'fraction_non_alphanumeric': 0.1146187469645459, 'fraction_numerical': 0.013598834385624089, 'mean_word_length': 1.8986629134412385, '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': '4784135', 'n_tokens_mistral': 1235, 'n_tokens_neox': 1157, 'n_words': 213}