<commit_before>var container;
var camera, scene, renderer;
var controls;
var cube;
var cubeGeo, cubeMat;
var rollOverGeo, rollOverMesh, rollOverMaterial;
var framerate = 1000/30;
var voxelSideLength = 50;
var robotVoxel = new THREE.MeshLambertMaterial({color:0xff9999});
var raycaster;
var voxels = [];
var voxelMap = new VoxelMap();

main();

function main() {
  init();
  render();
  initPointerLock();
  initMoveOnClick()
  render();
  setInterval(function() {controls.enabled ? render() : false}, framerate);
}

function init() {

  container = document.createElement( 'div' );
  document.body.appendChild( container );

  camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 10000 );

  scene = new THREE.Scene();

  // controls
  controls = new PointerLockControls(camera);
  var controlsObject = controls.getObject();

  // change the starting position of the camera/controls
  // settings for 0, 0
  controlsObject.translateZ(200);
  controlsObject.translateY(800);
  controlsObject.children[0].rotation.x = -1.5;

  // settings for 235, 63, 366
  // controlsObject.position.x = 9137.7;
  // controlsObject.position.y = 4234.5;
  // controlsObject.position.z = 18416.7;
  // controlsObject.rotation.y = -13.886;
  // controlsObject.children[0].rotation.x = -.8112;

  scene.add(controlsObject);

  // raycaster
  raycaster = new THREE.Raycaster();

  // cubes

  cubeGeo = new THREE.BoxGeometry( 50, 50, 50 );
  cubeMat = new THREE.MeshLambertMaterial({color: 0xfeb74c});

  rollOverGeo = new THREE.BoxGeometry( 50, 50, 50 );
  rollOverMaterial = new THREE.MeshBasicMaterial({ color: 0x0000ff, opacity: 0.5, transparent: true });
	rollOverMesh = new THREE.Mesh(rollOverGeo, rollOverMaterial);
	scene.add(rollOverMesh);

  // Lights

  var ambientLight = new THREE.AmbientLight( 0x606060 );
  scene.add( ambientLight );

  var directionalLight = new THREE.DirectionalLight( 0xffffff );
  directionalLight.position.set( 1, 0.75, 0.5 ).normalize();
  scene.add( directionalLight );

  renderer = new THREE.WebGLRenderer( { antialias: true } );
  renderer.setClearColor( 0xf0f0f0 );
  renderer.setPixelRatio( window.devicePixelRatio );
  renderer.setSize( window.innerWidth, window.innerHeight );
  container.appendChild( renderer.domElement );

  window.addEventListener( 'resize', onWindowResize, false );

}

function onWindowResize() {

  camera.aspect = window.innerWidth / window.innerHeight;
  camera.updateProjectionMatrix();

  renderer.setSize( window.innerWidth, window.innerHeight );
  render();

}

// determine where the hover guide should be
function placeSelector() {

  var fromScreenCenter = new THREE.Vector2(
    ((renderer.domElement.clientWidth / 2) / renderer.domElement.width) * 2 - 1,
    -(((renderer.domElement.clientHeight / 2) / renderer.domElement.height) * 2 - 1)
  );

  raycaster.setFromCamera(fromScreenCenter, camera);

  var intersects = raycaster.intersectObjects(voxels);
  if (intersects.length > 0) {

    var intersect = intersects[0];
    var normal = intersect.face.normal.clone();
    normal.multiplyScalar(50);
    rollOverMesh.position.copy(intersect.object.position).add(normal);

  }

  var worldCoords = getWorldCoord(rollOverMesh);
  var hoverCoordDiv = document.getElementById('hoverGuideCoordinates');
  hoverCoordDiv.innerHTML = String([worldCoords.x, worldCoords.y, worldCoords.z]);

}

function render() {
  // use # of ms since last update as delta
  placeSelector();
  controls.update(framerate);
  renderer.render(scene, camera);
}

// code for drawing minecraft maps

// robotVoxel is global
function moveRobotVoxel(pos) {

  var priorVoxel = voxelMap.get(pos.x, pos.y, pos.z);
  if (priorVoxel) {removeVoxel(pos.x, pos.y, pos.z, priorVoxel);}

  addVoxel(
    pos.x * voxelSideLength,
    pos.y * voxelSideLength,
    pos.z * voxelSideLength,
    robotVoxel
  );
  
  render();
}

function addVoxel(x, y, z, material) {
  var voxel = new THREE.Mesh(cubeGeo, material || cubeMat);
  voxel.position.set(x, y, z);

  var coord = getWorldCoord(voxel);
  var priorVoxel = voxelMap.get(coord.x, coord.y, coord.z);
  if (priorVoxel) {removeVoxel(coord.x, coord.y, coord.z, priorVoxel);}

  voxels.push(voxel);
  voxelMap.set(coord.x, coord.y, coord.z, voxel);
  scene.add(voxel);

  return voxel;
}

function removeVoxel(x, y, z, voxel) {<commit_msg>fixing robot movement display glitch<commit_after>var container;
var camera, scene, renderer;
var controls;
var cube;
var cubeGeo, cubeMat;
var rollOverGeo, rollOverMesh, rollOverMaterial;
var framerate = 1000/30;
var voxelSideLength = 50;
var raycaster;
var voxels = [];
var voxelMap = new VoxelMap();

main();

function main() {
  init();
  render();
  initPointerLock();
  initMoveOnClick()
  render();
  setInterval(function() {controls.enabled ? render() : false}, framerate);
}

function init() {

  container = document.createElement( 'div' );
  document.body.appendChild( container );

  camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 10000 );

  scene = new THREE.Scene();

  // controls
  controls = new PointerLockControls(camera);
  var controlsObject = controls.getObject();

  // change the starting position of the camera/controls
  // settings for 0, 0
  controlsObject.translateZ(200);
  controlsObject.translateY(800);
  controlsObject.children[0].rotation.x = -1.5;

  // settings for 235, 63, 366
  // controlsObject.position.x = 9137.7;
  // controlsObject.position.y = 4234.5;
  // controlsObject.position.z = 18416.7;
  // controlsObject.rotation.y = -13.886;
  // controlsObject.children[0].rotation.x = -.8112;

  scene.add(controlsObject);

  // raycaster
  raycaster = new THREE.Raycaster();

  // cubes

  cubeGeo = new THREE.BoxGeometry( 50, 50, 50 );
  cubeMat = new THREE.MeshLambertMaterial({color: 0xfeb74c});

  rollOverGeo = new THREE.BoxGeometry( 50, 50, 50 );
  rollOverMaterial = new THREE.MeshBasicMaterial({ color: 0x0000ff, opacity: 0.5, transparent: true });
	rollOverMesh = new THREE.Mesh(rollOverGeo, rollOverMaterial);
	scene.add(rollOverMesh);

  // Lights

  var ambientLight = new THREE.AmbientLight( 0x606060 );
  scene.add( ambientLight );

  var directionalLight = new THREE.DirectionalLight( 0xffffff );
  directionalLight.position.set( 1, 0.75, 0.5 ).normalize();
  scene.add( directionalLight );

  renderer = new THREE.WebGLRenderer( { antialias: true } );
  renderer.setClearColor( 0xf0f0f0 );
  renderer.setPixelRatio( window.devicePixelRatio );
  renderer.setSize( window.innerWidth, window.innerHeight );
  container.appendChild( renderer.domElement );

  window.addEventListener( 'resize', onWindowResize, false );

}

function onWindowResize() {

  camera.aspect = window.innerWidth / window.innerHeight;
  camera.updateProjectionMatrix();

  renderer.setSize( window.innerWidth, window.innerHeight );
  render();

}

// determine where the hover guide should be
function placeSelector() {

  var fromScreenCenter = new THREE.Vector2(
    ((renderer.domElement.clientWidth / 2) / renderer.domElement.width) * 2 - 1,
    -(((renderer.domElement.clientHeight / 2) / renderer.domElement.height) * 2 - 1)
  );

  raycaster.setFromCamera(fromScreenCenter, camera);

  var intersects = raycaster.intersectObjects(voxels);
  if (intersects.length > 0) {

    var intersect = intersects[0];
    var normal = intersect.face.normal.clone();
    normal.multiplyScalar(50);
    rollOverMesh.position.copy(intersect.object.position).add(normal);

  }

  var worldCoords = getWorldCoord(rollOverMesh);
  var hoverCoordDiv = document.getElementById('hoverGuideCoordinates');
  hoverCoordDiv.innerHTML = String([worldCoords.x, worldCoords.y, worldCoords.z]);

}

function render() {
  // use # of ms since last update as delta
  placeSelector();
  controls.update(framerate);
  renderer.render(scene, camera);
}

// code for drawing minecraft maps

// robotVoxel is global
function moveRobotVoxel(pos) {

  var priorVoxel = voxelMap.get(pos.x, pos.y, pos.z);
  if (priorVoxel) {removeVoxel(pos.x, pos.y, pos.z, priorVoxel);}

  addVoxel(
    pos.x * voxelSideLength,
    pos.y * voxelSideLength,
    pos.z * voxelSideLength,
    new THREE.MeshLambertMaterial({color:0xff9999})
  );

  render();
}

function addVoxel(x, y, z, material) {
  var voxel = new THREE.Mesh(cubeGeo, material || cubeMat);
  voxel.position.set(x, y, z);

  var coord = getWorldCoord(voxel);
  var priorVoxel = voxelMap.get(coord.x, coord.y, coord.z);
  if (priorVoxel) {removeVoxel(coord.x, coord.y, coord.z, priorVoxel);}

  voxels.push(voxel);
  voxelMap.set(coord.x, coord.y, coord.z, voxel);
  scene.add(voxel);

  return voxel;
}

function removeVoxel(x, y, z, voxel) {
{'fraction_non_alphanumeric': 0.13194925028835064, 'fraction_numerical': 0.02698961937716263, 'mean_word_length': 4.201559688062387, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7102221', 'n_tokens_mistral': 3205, 'n_tokens_neox': 2852, 'n_words': 643}