<commit_before>/**
 * @author mrdoob / http://mrdoob.com/
 */

THREE.OBJExporter = function () {};

THREE.OBJExporter.prototype = {

	constructor: THREE.OBJExporter,

	indexVertex: 0,
	indexVertexUvs: 0,
	indexNormals: 0,

	parse: function ( object ) {
		var output = '';

		var nbVertex, nbVertexUvs, nbNormals;
		nbVertex = nbVertexUvs = nbNormals = 0;

		var geometry = object.geometry;

		output += 'o ' + object.id + '\n';

		if (object.geometry) {
			for ( var i = 0, l = geometry.vertices.length; i < l; i ++ ) {

				var vertex = geometry.vertices[ i ].clone();
				vertex.applyMatrix4( object.matrixWorld );

				output += 'v ' + vertex.x + ' ' + vertex.y + ' ' + vertex.z + '\n';

				nbVertex++;
			}

			// uvs

			for ( var i = 0, l = geometry.faceVertexUvs[ 0 ].length; i < l; i ++ ) {

				var vertexUvs = geometry.faceVertexUvs[ 0 ][ i ];

				for ( var j = 0; j < vertexUvs.length; j ++ ) {

					var uv = vertexUvs[ j ];
					vertex.applyMatrix4( object.matrixWorld );

					output += 'vt ' + uv.x + ' ' + uv.y + '\n';

					nbVertexUvs++;
				}

			}

			// normals

			for ( var i = 0, l = geometry.faces.length; i < l; i ++ ) {

				var normals = geometry.faces[ i ].vertexNormals;

				for ( var j = 0; j < normals.length; j ++ ) {

					var normal = normals[ j ];
					output += 'vn ' + normal.x + ' ' + normal.y + ' ' + normal.z + '\n';

					nbNormals++;
				}

			}

			// faces

			for ( var i = 0, j = 1, l = geometry.faces.length; i < l; i ++, j += 3 ) {

				var face = geometry.faces[ i ];

				output += 'f ';
				output += ( this.indexVertex + face.a + 1 ) + '/' + ( this.indexVertexUvs + j ) + '/' + ( this.indexNormals + j ) + ' ';
				output += ( this.indexVertex + face.b + 1 ) + '/' + ( this.indexVertexUvs + j + 1 ) + '/' + ( this.indexNormals + j + 1 ) + ' ';
				output += ( this.indexVertex + face.c + 1 ) + '/' + ( this.indexVertexUvs + j + 2 ) + '/' + ( this.indexNormals + j + 2 ) + '\n';

			}
		}

		// update index
		this.indexVertex += nbVertex;
		this.indexVertexUvs += nbVertexUvs
		this.indexNormals += nbNormals

		// Create children objects
		for ( var i in object.children ) {
			output += '# new children object: ' + object.children[i].id + '\n';
			output += this.parse( object.children[i] );
		}

		return output;

	}

}<commit_msg>OBJExporter: move index vars in parse function + use object#traverse to parse each children<commit_after>/**
 * @author mrdoob / http://mrdoob.com/
 */

THREE.OBJExporter = function () {};

THREE.OBJExporter.prototype = {

	constructor: THREE.OBJExporter,

	parse: function ( object ) {
		var output = '';

		var indexVertex = 0;
		var indexVertexUvs = 0
		var indexNormals = 0;

		var parseObject = function ( child ) {

			var nbVertex, nbVertexUvs, nbNormals;
			nbVertex = nbVertexUvs = nbNormals = 0;

			var geometry = object.geometry;

			output += 'o ' + object.id + '\n';

			if (object.geometry) {
				for ( var i = 0, l = geometry.vertices.length; i < l; i ++ ) {

					var vertex = geometry.vertices[ i ].clone();
					vertex.applyMatrix4( object.matrixWorld );

					output += 'v ' + vertex.x + ' ' + vertex.y + ' ' + vertex.z + '\n';

					nbVertex++;
				}

				// uvs

				for ( var i = 0, l = geometry.faceVertexUvs[ 0 ].length; i < l; i ++ ) {

					var vertexUvs = geometry.faceVertexUvs[ 0 ][ i ];

					for ( var j = 0; j < vertexUvs.length; j ++ ) {

						var uv = vertexUvs[ j ];
						vertex.applyMatrix4( object.matrixWorld );

						output += 'vt ' + uv.x + ' ' + uv.y + '\n';

						nbVertexUvs++;
					}

				}

				// normals

				for ( var i = 0, l = geometry.faces.length; i < l; i ++ ) {

					var normals = geometry.faces[ i ].vertexNormals;

					for ( var j = 0; j < normals.length; j ++ ) {

						var normal = normals[ j ];
						output += 'vn ' + normal.x + ' ' + normal.y + ' ' + normal.z + '\n';

						nbNormals++;
					}

				}

				// faces

				for ( var i = 0, j = 1, l = geometry.faces.length; i < l; i ++, j += 3 ) {

					var face = geometry.faces[ i ];

					output += 'f ';
					output += ( indexVertex + face.a + 1 ) + '/' + ( indexVertexUvs + j ) + '/' + ( indexNormals + j ) + ' ';
					output += ( indexVertex + face.b + 1 ) + '/' + ( indexVertexUvs + j + 1 ) + '/' + ( indexNormals + j + 1 ) + ' ';
					output += ( indexVertex + face.c + 1 ) + '/' + ( indexVertexUvs + j + 2 ) + '/' + ( indexNormals + j + 2 ) + '\n';

				}
			}

			// update index
			indexVertex += nbVertex;
			indexVertexUvs += nbVertexUvs
			indexNormals += nbNormals
		};

		object.traverse( parseObject );

		return output;

	}

}
{'fraction_non_alphanumeric': 0.17710393320149417, 'fraction_numerical': 0.01010766864425401, 'mean_word_length': 2.203377902885292, 'pattern_counts': {'":': 0, '<': 15, '<?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': '4921520', 'n_tokens_mistral': 2034, 'n_tokens_neox': 1639, 'n_words': 414}