<commit_before>/**
 * Loader for UTF8 version2 (after r51) encoded models generated by:
 *	http://code.google.com/p/webgl-loader/
 *
 * Code to load/decompress mesh is taken from r100 of this webgl-loader
 */

THREE.UTF8Loader = function () {};

/**
 * Load UTF8 encoded model
 * @param jsonUrl - URL from which to load json containing information about model
 * @param callback - Callback(THREE.Object3D) on successful loading of model
 * @param options - options on how to load model (see THREE.MTLLoader.MaterialCreator for basic options)
 *                  Additional options include
 *                   geometryBase: Base url from which to load referenced geometries
 *                   materialBase: Base url from which to load referenced textures
 */

THREE.UTF8Loader.prototype.load = function ( jsonUrl, callback, options ) {

    this.downloadModelJson( jsonUrl, options, callback );

};

// BufferGeometryCreator

THREE.UTF8Loader.BufferGeometryCreator = function () {
};

THREE.UTF8Loader.BufferGeometryCreator.prototype.create = function ( attribArray, indexArray ) {

	var ntris = indexArray.length / 3;

	var geometry = new THREE.BufferGeometry();

	var positionArray = new Float32Array( 3 * 3 * ntris );
	var normalArray = new Float32Array( 3 * 3 * ntris );
	var uvArray = new Float32Array( 2 * 3 * ntris );

	var i, j, offset;
	var x, y, z;
	var u, v;

	var end = attribArray.length;
	var stride = 8;

	// extract positions

	j = 0;
	offset = 0;

	for( i = offset; i < end; i += stride ) {

		x = attribArray[ i ];
		y = attribArray[ i + 1 ];
		z = attribArray[ i + 2 ];

		positionArray[ j++ ] = x;
		positionArray[ j++ ] = y;
		positionArray[ j++ ] = z;

	}

	// extract uvs

	j = 0;
	offset = 3;

	for( i = offset; i < end; i += stride ) {

		u = attribArray[ i ];
		v = attribArray[ i + 1 ];

		uvArray[ j++ ] = u;
		uvArray[ j++ ] = v;

	}

	// extract normals

	j = 0;
	offset = 5;

	for( i = offset; i < end; i += stride ) {

		x = attribArray[ i ];
		y = attribArray[ i + 1 ];
		z = attribArray[ i + 2 ];

		normalArray[ j++ ] = x;
		normalArray[ j++ ] = y;
		normalArray[ j++ ] = z;

	}

    geometry.addAttribute( 'index', indexArray, 1 );
    geometry.addAttribute( 'position', positionArray, 3 );
    geometry.addAttribute( 'normal', normalArray, 3 );
    geometry.addAttribute( 'uv', uvArray, 2 );

    geometry.offsets.push( { start: 0, count: indexArray.length, index: 0 } );

	geometry.computeBoundingSphere();

	return geometry;

};


// UTF-8 decoder from webgl-loader (r100)
// http://code.google.com/p/webgl-loader/

// Model manifest description. Contains objects like:
// name: {
//   materials: { 'material_name': { ... } ... },
//   decodeParams: {
//     decodeOffsets: [ ... ],
//     decodeScales: [ ... ],
//   },<commit_msg>UTF8Loader: Updated some of the addAttribute calls. Need to think what to do when the array is already created, like index in this case...<commit_after>/**
 * Loader for UTF8 version2 (after r51) encoded models generated by:
 *	http://code.google.com/p/webgl-loader/
 *
 * Code to load/decompress mesh is taken from r100 of this webgl-loader
 */

THREE.UTF8Loader = function () {};

/**
 * Load UTF8 encoded model
 * @param jsonUrl - URL from which to load json containing information about model
 * @param callback - Callback(THREE.Object3D) on successful loading of model
 * @param options - options on how to load model (see THREE.MTLLoader.MaterialCreator for basic options)
 *                  Additional options include
 *                   geometryBase: Base url from which to load referenced geometries
 *                   materialBase: Base url from which to load referenced textures
 */

THREE.UTF8Loader.prototype.load = function ( jsonUrl, callback, options ) {

    this.downloadModelJson( jsonUrl, options, callback );

};

// BufferGeometryCreator

THREE.UTF8Loader.BufferGeometryCreator = function () {
};

THREE.UTF8Loader.BufferGeometryCreator.prototype.create = function ( attribArray, indexArray ) {

	var ntris = indexArray.length / 3;

	var geometry = new THREE.BufferGeometry();

    var positions = new THREE.Float32Attribute( ntris * 3, 3 );
    var normals = new THREE.Float32Attribute( ntris * 3, 3 );
    var uvs = new THREE.Float32Attribute( ntris * 3, 2 );

	var positionsArray = positions.array;
	var normalsArray = normals.array;
	var uvsArray = uvs.array;

	var i, j, offset;
	var x, y, z;
	var u, v;

	var end = attribArray.length;
	var stride = 8;

	// extract positions

	j = 0;
	offset = 0;

	for( i = offset; i < end; i += stride ) {

		x = attribArray[ i ];
		y = attribArray[ i + 1 ];
		z = attribArray[ i + 2 ];

		positionsArray[ j++ ] = x;
		positionsArray[ j++ ] = y;
		positionsArray[ j++ ] = z;

	}

	// extract uvs

	j = 0;
	offset = 3;

	for( i = offset; i < end; i += stride ) {

		u = attribArray[ i ];
		v = attribArray[ i + 1 ];

		uvsArray[ j++ ] = u;
		uvsArray[ j++ ] = v;

	}

	// extract normals

	j = 0;
	offset = 5;

	for( i = offset; i < end; i += stride ) {

		x = attribArray[ i ];
		y = attribArray[ i + 1 ];
		z = attribArray[ i + 2 ];

		normalsArray[ j++ ] = x;
		normalsArray[ j++ ] = y;
		normalsArray[ j++ ] = z;

	}

    geometry.addAttribute( 'index', indexArray, 1 );
    geometry.addAttribute( 'position', positions );
    geometry.addAttribute( 'normal', normals );
    geometry.addAttribute( 'uv', uvs );

    geometry.offsets.push( { start: 0, count: indexArray.length, index: 0 } );

	geometry.computeBoundingSphere();

	return geometry;

};


// UTF-8 decoder from webgl-loader (r100)
// http://code.google.com/p/webgl-loader/

// Model manifest description. Contains objects like:
// name: {
//   materials: { 'material_name': { ... } ... },
//   decodeParams: {
//     decodeOffsets: [ ... ],
//     decodeScales: [ ... ],
//   },
{'fraction_non_alphanumeric': 0.13710235131396958, 'fraction_numerical': 0.01625172890733057, 'mean_word_length': 2.8643954575818302, 'pattern_counts': {'":': 0, '<': 9, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6592226', 'n_tokens_mistral': 2068, 'n_tokens_neox': 1879, 'n_words': 591}