<commit_before>var THREEx		= THREEx || {};

THREEx.GeometryCenter	= {};

THREEx.GeometryCenter.center	= function(geometry, noX, noY, noZ)
{
	// make sure that geometry.boundingBox is uptodate
	geometry.computeBoundingBox();

	// compute delta
	var delta	= new THREE.Vector3()
	if( !noX )	delta.x	= -( geometry.boundingBox.x[ 1 ] + geometry.boundingBox.x[ 0 ] ) / 2;
	if( !noY )	delta.y	= -( geometry.boundingBox.y[ 1 ] + geometry.boundingBox.y[ 0 ] ) / 2;
	if( !noZ )	delta.z	= -( geometry.boundingBox.z[ 1 ] + geometry.boundingBox.z[ 0 ] ) / 2;

	// change all geometry.vertices
	for(var i = 0; i < geometry.vertices.length; i++) {
		var vertex	= geometry.vertices[i];
		vertex.position.addSelf(delta); 
	}

	// mark the vertices as dirty
	geometry.__dirtyVertices = true;
}<commit_msg>THREEx.GeometryCenter.js added scale+translate<commit_after>var THREEx		= THREEx || {};

THREEx.GeometryCenter	= {};

// TODO
// - add translate
// - add rotate
// - add scale
// - chained API
// - possibility a matrix to reduce computation ?

THREEx.GeometryCenter.center	= function(geometry, noX, noY, noZ)
{
	// make sure that geometry.boundingBox is uptodate
	geometry.computeBoundingBox();

	// compute delta
	var delta	= new THREE.Vector3()
	if( !noX )	delta.x	= -( geometry.boundingBox.x[ 1 ] + geometry.boundingBox.x[ 0 ] ) / 2;
	if( !noY )	delta.y	= -( geometry.boundingBox.y[ 1 ] + geometry.boundingBox.y[ 0 ] ) / 2;
	if( !noZ )	delta.z	= -( geometry.boundingBox.z[ 1 ] + geometry.boundingBox.z[ 0 ] ) / 2;

	return this.translate(geometry, delta)
}

THREEx.GeometryCenter.scale	= function(geometry, scale)
{
	// change all geometry.vertices
	for(var i = 0; i < geometry.vertices.length; i++) {
		var vertex	= geometry.vertices[i];
		vertex.position.multiplySelf(scale); 
	}

	// mark the vertices as dirty
	geometry.__dirtyVertices = true;

	// return this, to get chained API	
	return this;
}

THREEx.GeometryCenter.translate	= function(geometry, delta)
{
	// change all geometry.vertices
	for(var i = 0; i < geometry.vertices.length; i++) {
		var vertex	= geometry.vertices[i];
		vertex.position.addSelf(delta); 
	}

	// mark the vertices as dirty
	geometry.__dirtyVertices = true;

	// return this, to get chained API	
	return this;
}
{'fraction_non_alphanumeric': 0.14630872483221477, 'fraction_numerical': 0.01029082774049217, 'mean_word_length': 3.4809619238476954, 'pattern_counts': {'":': 0, '<': 6, '<?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': '247381', 'n_tokens_mistral': 854, 'n_tokens_neox': 802, 'n_words': 194}