<commit_before>var createHitTest = require('./hitTest');
var createUserInputController = require('./userInput');
var renderNodes = require('./renderNodes');
var renderLinks = require('./renderLinks');

module.exports = graphView;

function graphView(graphModel) {
  var view = init3dView();
  var graph = graphModel.getGraph();

  var hitTest = createHitTest();
  hitTest.onSelected(function(idx) {
    var node = graph.getNode(idx);
    if (node) {
      console.log(node.data.label);
    }
  });

  var userInputController = createUserInputController(view.getCamera());

  view.onrender(hitTest.update);
  view.onrender(userInputController.update);

  graphModel.on('nodesReady', renderNodes(view.getScene()));
  graphModel.on('linksReady', renderLinks(view.getScene()));
}

function init3dView() {
  var scene = new THREE.Scene();
  scene.sortObjects = false;

  var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 20000);
  camera.position.x = 0;
  camera.position.y = 0;
  camera.position.z = 0;
  camera.lookAt(new THREE.Vector3(9000, 9000, 9000));
  window.camera = camera;

  var renderCallbacks = [];

  var renderer = new THREE.WebGLRenderer({
    antialias: false
  });
  renderer.setClearColor(0x000000, 1);
  renderer.setSize(window.innerWidth, window.innerHeight);
  document.body.appendChild(renderer.domElement);
  window.addEventListener('resize', onWindowResize, false);

  animate();

  return {
    onrender: onrender,
    getScene: getScene,
    getCamera: getCamera
  };

  function onrender(callback) {
    renderCallbacks.push(callback);
  }

  function getScene() {
    return scene;
  }

  function getCamera() {
    return camera;
  }

  function animate() {
    requestAnimationFrame(animate);

    renderer.render(scene, camera);
    for (var i = 0; i < renderCallbacks.length; ++i) {
      renderCallbacks[i](scene, camera);
    }
  }

  function onWindowResize() {
    windowHalfX = window.innerWidth / 2;
    windowHalfY = window.innerHeight / 2;
    camera.aspect = window.innerWidth / window.innerHeight;
    camera.updateProjectionMatrix();
    renderer.setSize(window.innerWidth, window.innerHeight);
  }
}<commit_msg>Acutally don't need two variables<commit_after>var createHitTest = require('./hitTest');
var createUserInputController = require('./userInput');
var renderNodes = require('./renderNodes');
var renderLinks = require('./renderLinks');

module.exports = graphView;

function graphView(graphModel) {
  var view = init3dView();
  var graph = graphModel.getGraph();

  var hitTest = createHitTest();
  hitTest.onSelected(function(idx) {
    var node = graph.getNode(idx);
    if (node) {
      console.log(node.data.label);
    }
  });

  var userInputController = createUserInputController(view.getCamera());

  view.onrender(hitTest.update);
  view.onrender(userInputController.update);

  graphModel.on('nodesReady', renderNodes(view.getScene()));
  graphModel.on('linksReady', renderLinks(view.getScene()));
}

function init3dView() {
  var scene = new THREE.Scene();
  scene.sortObjects = false;

  var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 20000);
  camera.position.x = 0;
  camera.position.y = 0;
  camera.position.z = 0;
  camera.lookAt(new THREE.Vector3(9000, 9000, 9000));
  window.camera = camera;

  var renderCallbacks = [];

  var renderer = new THREE.WebGLRenderer({
    antialias: false
  });
  renderer.setClearColor(0x000000, 1);
  renderer.setSize(window.innerWidth, window.innerHeight);
  document.body.appendChild(renderer.domElement);
  window.addEventListener('resize', onWindowResize, false);

  animate();

  return {
    onrender: onrender,
    getScene: getScene,
    getCamera: getCamera
  };

  function onrender(callback) {
    renderCallbacks.push(callback);
  }

  function getScene() {
    return scene;
  }

  function getCamera() {
    return camera;
  }

  function animate() {
    requestAnimationFrame(animate);

    renderer.render(scene, camera);
    for (var i = 0; i < renderCallbacks.length; ++i) {
      renderCallbacks[i](scene, camera);
    }
  }

  function onWindowResize() {
    camera.aspect = window.innerWidth / window.innerHeight;
    camera.updateProjectionMatrix();
    renderer.setSize(window.innerWidth, window.innerHeight);
  }
}
{'fraction_non_alphanumeric': 0.13353390418884517, 'fraction_numerical': 0.01712566535524184, 'mean_word_length': 4.139120095124851, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4110798', 'n_tokens_mistral': 1423, 'n_tokens_neox': 1332, 'n_words': 262}