<commit_before>import THREE from 'THREE';

var raycaster = new THREE.Raycaster();

export function raycast(camera, items, type) {

  var listener = function(event) {
    var vector = new THREE.Vector3();

    let x = ((event.clientX - 1) / window.innerWidth ) * 2 - 1;
    let y = -((event.clientY - 1) / window.innerHeight) * 2 + 1;

    vector.set(x, y, 0.5);
    vector.unproject(camera);

    raycaster.ray.set(camera.position, vector.sub(camera.position).normalize());

    var target = raycaster.intersectObjects(items);

    if (target.length) {
      target[0].type = type;
      target[0].object.dispatchEvent(target[0]);
    }

  };

  document.addEventListener(type, listener, false);
}<commit_msg>Fix raycasting for nested objects<commit_after>import THREE from 'THREE';

var raycaster = new THREE.Raycaster();

export function raycast(camera, items, type) {

  var listener = function(event) {
    var vector = new THREE.Vector3();

    let x = ((event.clientX - 1) / window.innerWidth ) * 2 - 1;
    let y = -((event.clientY - 1) / window.innerHeight) * 2 + 1;

    vector.set(x, y, 0.5);
    vector.unproject(camera);

    raycaster.ray.set(camera.position, vector.sub(camera.position).normalize());

    var target = raycaster.intersectObjects(items, true);

    if (target.length) {
      target[0].type = type;
      target[0].object.dispatchEvent(target[0]);
    }

  };

  document.addEventListener(type, listener, false);
}
{'fraction_non_alphanumeric': 0.15027700831024932, 'fraction_numerical': 0.01662049861495845, 'mean_word_length': 3.352409638554217, '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': '7287502', 'n_tokens_mistral': 505, 'n_tokens_neox': 458, 'n_words': 107}