<commit_before>var THREE = require('three'),
    OrbitControls = require('three-orbit-controls')(THREE),
    stl = require('./loaders/STLLoader.js'),
    socket = require('socket.io-client')('http://127.0.0.1:8080/');

var camera, cameraTarget, containers, scene, renderer;

init();
animate();

function init() {

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

	scene = new THREE.Scene();
	scene.fog = new THREE.Fog( 0x72645b, 2, 15 );

	camera = new THREE.PerspectiveCamera( 35, window.innerWidth / window.innerHeight, 1, 15 );

	//camera.position.set( 3, 0.15, 3 );
	camera.position.set( 3, 3, 3 );
	cameraTarget = new THREE.Vector3( 0, -0.25, 0 );


	// Ground

	var plane = new THREE.Mesh(
		new THREE.PlaneBufferGeometry( 40, 40 ),
		new THREE.MeshPhongMaterial( { color: 0x999999, specular: 0x101010 } )
	);

	plane.rotation.x = -Math.PI/2;
	plane.position.y = -0.5;
	scene.add( plane );

	// Lights

	scene.add( new THREE.HemisphereLight( 0x443333, 0x111122 ) );
	addShadowedLight( 0.5, 1, -1, 0xffff99, 1 );

	// renderer

	renderer = new THREE.WebGLRenderer( { antialias: true } );
	renderer.setClearColor( scene.fog.color );
	renderer.setPixelRatio( window.devicePixelRatio );
	renderer.setSize( window.innerWidth, window.innerHeight );

	renderer.gammaInput = true;
	renderer.gammaOutput = true;

	renderer.shadowMap.enabled = true;
	renderer.shadowMap.cullFace = THREE.CullFaceBack;

	container.appendChild( renderer.domElement );

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

  controls = new OrbitControls(camera, renderer.domElement);
  controls.enablingDamping = true;
  controls.dampingFactor = 0.25;
  controls.noPan = false;
}

function addShadowedLight( x, y, z, color, intensity ) {

	var directionalLight = new THREE.DirectionalLight( color, intensity );
	directionalLight.position.set( x, y, z );
	scene.add( directionalLight );

	directionalLight.castShadow = true;
	// directionalLight.shadowCameraVisible = true;

	var d = 1;
	directionalLight.shadowCameraLeft = -d;
	directionalLight.shadowCameraRight = d;
	directionalLight.shadowCameraTop = d;
	directionalLight.shadowCameraBottom = -d;
	directionalLight.shadowCameraNear = 1;
	directionalLight.shadowCameraFar = 4;
	directionalLight.shadowMapWidth = 1024;
	directionalLight.shadowMapHeight = 1024;
	directionalLight.shadowBias = -0.005;

}

function onWindowResize() {

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

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

}

function animate() {

	requestAnimationFrame( animate );
	render();

}

function render() {

  controls.update();
	renderer.render( scene, camera );

}

socket.on('connect', function(){
  console.log('We have made contact...');
});

socket.on('mesh1', function(data){
  console.log(data);
  var stlLoader = new stl();
  stlLoader.load('http://127.0.0.1:8080' + data, function(obj) {
    var geom = new THREE.Geometry().fromBufferGeometry(obj);
    geom.normalize();
    var mesh = new THREE.Mesh(geom, new THREE.MeshNormalMaterial());
    mesh.position.set(-3, -0.25, 0);
    scene.add(mesh);
  });
});


socket.on('mesh2', function(data){
  console.log(data);
  var stlLoader = new stl();
  stlLoader.load('http://127.0.0.1:8080' + data, function(obj) {
    var geom = new THREE.Geometry().fromBufferGeometry(obj);
    geom.normalize();
    var mesh = new THREE.Mesh(geom, new THREE.MeshNormalMaterial());
    mesh.position.set(3, -0.25, 0);
    scene.add(mesh);
  });
});
<commit_msg>added vertice merging.<commit_after>var THREE = require('three'),
    OrbitControls = require('three-orbit-controls')(THREE),
    stl = require('./loaders/STLLoader.js'),
    socket = require('socket.io-client')('http://127.0.0.1:8080/');

var camera, cameraTarget, containers, scene, renderer;

init();
animate();

function init() {

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

	scene = new THREE.Scene();
	scene.fog = new THREE.Fog( 0x72645b, 2, 15 );

	camera = new THREE.PerspectiveCamera( 35, window.innerWidth / window.innerHeight, 1, 15 );

	//camera.position.set( 3, 0.15, 3 );
	camera.position.set( 3, 3, 3 );
	cameraTarget = new THREE.Vector3( 0, -0.25, 0 );


	// Ground

	var plane = new THREE.Mesh(
		new THREE.PlaneBufferGeometry( 40, 40 ),
		new THREE.MeshPhongMaterial( { color: 0x999999, specular: 0x101010 } )
	);

	plane.rotation.x = -Math.PI/2;
	plane.position.y = -0.5;
	scene.add( plane );

	// Lights

	scene.add( new THREE.HemisphereLight( 0x443333, 0x111122 ) );
	addShadowedLight( 0.5, 1, -1, 0xffff99, 1 );

	// renderer

	renderer = new THREE.WebGLRenderer( { antialias: true } );
	renderer.setClearColor( scene.fog.color );
	renderer.setPixelRatio( window.devicePixelRatio );
	renderer.setSize( window.innerWidth, window.innerHeight );

	renderer.gammaInput = true;
	renderer.gammaOutput = true;

	renderer.shadowMap.enabled = true;
	renderer.shadowMap.cullFace = THREE.CullFaceBack;

	container.appendChild( renderer.domElement );

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

  controls = new OrbitControls(camera, renderer.domElement);
  controls.enablingDamping = true;
  controls.dampingFactor = 0.25;
  controls.noPan = false;
}

function addShadowedLight( x, y, z, color, intensity ) {

	var directionalLight = new THREE.DirectionalLight( color, intensity );
	directionalLight.position.set( x, y, z );
	scene.add( directionalLight );

	directionalLight.castShadow = true;
	// directionalLight.shadowCameraVisible = true;

	var d = 1;
	directionalLight.shadowCameraLeft = -d;
	directionalLight.shadowCameraRight = d;
	directionalLight.shadowCameraTop = d;
	directionalLight.shadowCameraBottom = -d;
	directionalLight.shadowCameraNear = 1;
	directionalLight.shadowCameraFar = 4;
	directionalLight.shadowMapWidth = 1024;
	directionalLight.shadowMapHeight = 1024;
	directionalLight.shadowBias = -0.005;

}

function onWindowResize() {

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

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

}

function animate() {

	requestAnimationFrame( animate );
	render();

}

function render() {

  controls.update();
	renderer.render( scene, camera );

}

socket.on('connect', function(){
  console.log('We have made contact...');
});

socket.on('mesh1', function(data){
  console.log(data);
  var stlLoader = new stl();
  stlLoader.load('http://127.0.0.1:8080' + data, function(obj) {
    var geom = new THREE.Geometry().fromBufferGeometry(obj);
    geom.normalize();
    geom.mergeVertices();
    var mesh = new THREE.Mesh(geom, new THREE.MeshNormalMaterial());
    mesh.position.set(-3, -0.25, 0);
    scene.add(mesh);
  });
});


socket.on('mesh2', function(data){
  console.log(data);
  var stlLoader = new stl();
  stlLoader.load('http://127.0.0.1:8080' + data, function(obj) {
    var geom = new THREE.Geometry().fromBufferGeometry(obj);
    geom.normalize();
    geom.mergeVertices();
    var mesh = new THREE.Mesh(geom, new THREE.MeshNormalMaterial());
    mesh.position.set(3, -0.25, 0);
    scene.add(mesh);
  });
});

{'fraction_non_alphanumeric': 0.1490015360983103, 'fraction_numerical': 0.03658706884513336, 'mean_word_length': 4.297337278106509, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 6, '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': '856944', 'n_tokens_mistral': 2663, 'n_tokens_neox': 2399, 'n_words': 494}