<commit_before>var container, stats, containerObj;
var camera, scene, renderer;
var mouseX = 0, mouseY = 0;

// detect if webgl is needed and available
if( !Detector.webgl ){
	Detector.addGetWebGLMessage();
}else{
	init();
	animate();
}

/**
 * Build ui with Data.GUI
*/
function buildGui(parameters, callback)
{
	urlCacheInit	= function(opts){
		if( !window.location.hash )	return
		var hashStr	= window.location.hash.substring(1);
		var urlParams	= JSON.parse(decodeURIComponent(hashStr));
console.log("urlParams", urlParams)
		Object.keys(urlParams).forEach(function(key){
			parameters[key]	= urlParams[key];
		}.bind(this));
console.log("parameters post cache init", parameters)
	}
	urlCacheUpdate	= function(opts){
		var urlParams	= {};
		if( window.location.hash ){
			urlParams	= JSON.parse(decodeURIComponent(location.hash.substring(1)));
		}

		Object.keys(opts).forEach(function(key){
			urlParams[key]	= opts[key];
		}.bind(this));

		window.location.hash	= '#'+encodeURIComponent(JSON.stringify(urlParams));
	}

	// Notice this belongs to the DAT.GUI class (uppercase)
	// and not an instance thereof.
	DAT.GUI.autoPlace = false;

	var change	= function(){
		// get parameters values from cache if needed
		urlCacheUpdate(parameters)
		callback && callback(parameters)
	};
	
	// get parameters values from cache if needed
	urlCacheInit(parameters)
	// init the cache with current parameters values
	urlCacheUpdate(parameters)
	
	var gui1 = new DAT.GUI({
		height	: 17 * 32 - 1
	});
	gui1.domElement.style.position	= 'absolute';
	gui1.domElement.style.top	= '0px';
	gui1.domElement.style.right	= '0px';
	gui1.domElement.style['z-index']= '9999';
	document.body.appendChild(gui1.domElement);	

	gui1.add(parameters, 'emitRate').min(1).max(100)		.onFinishChange(change);
	gui1.add(parameters, 'timeToLive').min(200).max(5*1000)		.onFinishChange(change);

	gui1.add(parameters, 'originZaValue').min(-Math.PI).max(Math.PI).onFinishChange(change);
	gui1.add(parameters, 'originZaRange').min(0).max(Math.PI).onFinishChange(change);

	gui1.add(parameters, 'originZhValue').min(0).max(1)		.onFinishChange(change);
	gui1.add(parameters, 'originZhRange').min(0).max(0.5)		.onFinishChange(change);

	gui1.add(parameters, 'originRadiusValue').min(0.01).max(100)	.onFinishChange(change);
	gui1.add(parameters, 'originRadiusRange').min(0).max(30)	.onFinishChange(change);

	gui1.add(parameters, 'speedValue').min(0.2).max(2)		.onFinishChange(change);
	gui1.add(parameters, 'speedRange').min(0).max(2)		.onFinishChange(change);

	gui1.add(parameters, 'gravity').min(0).max(0.2)			.onFinishChange(change);

	gui1.add(parameters, 'opacitySrc').min(0.0).max(1.0)		.onFinishChange(change);
	gui1.add(parameters, 'opacityInc').min(-0.05).max(0)		.onFinishChange(change);

	gui1.add(parameters, 'sizeSrc').min(2).max(128)			.onFinishChange(change);
	gui1.add(parameters, 'sizeInc').min(-1).max(1)			.onFinishChange(change);

	gui1.add(parameters, 'rotationSrc').min(0.0).max(2*Math.PI)	.onFinishChange(change);
	gui1.add(parameters, 'rotationInc').min(-0.05).max(0.05)	.onFinishChange(change);
		

(function(){
	var gui2	= new DAT.GUI({
		height	: 7 * 32 - 1
	});
	gui2.domElement.style.position	= 'absolute';
	gui2.domElement.style.top	= '0px';
	gui2.domElement.style.left	= '0px';
	gui1.domElement.style['z-index']= '9999';
	document.body.appendChild(gui2.domElement);	

	
	gui2.add(parameters.color, 'r').name('colorR')		.min(0.0).max(1.0).onChange(change);
	gui2.add(parameters.color, 'g').name('colorG')		.min(0.0).max(1.0).onChange(change);
	gui2.add(parameters.color, 'b').name('colorB')		.min(0.0).max(1.0).onChange(change);
	gui2.add(parameters.colorInc, 'r').name('colorIncR')	.min(-0.1).max(0.1).onChange(change);
	gui2.add(parameters.colorInc, 'g').name('colorIncG')	.min(-0.1).max(0.1).onChange(change);
	gui2.add(parameters.colorInc, 'b').name('colorIncB')	.min(-0.1).max(0.1).onChange(change);

	gui2.add(parameters, 'textureUrl').options({
		"flare"			: "images/lensFlare/Flare1.png",
		"smoke"			: "images/osg-data/smoke.png",
		"ball"			: "images/ball.png",

		"purple_particle"	: "images/tremulous/lasgun/purple_particle.jpg",
		"lcannon1"		: "images/tremulous/lcannon/primary_1.jpg",

		"shine"			: "images/lensFlare/Shine1.png",
		"continous_smoke"	: "images/osg-data/continous_smoke.png",
		"reflect"		: "images/osg-data/reflect.png"
	}).onChange(function(){
		console.log("texture change", containerObj)

		scene.removeChild(containerObj);
		containerObj	= new THREE.Object3D();
		scene.addChild(containerObj);
		
		// define the containerObj of all the particle
		Emitter	= new THREEx.Particle.Emitter(parameters);
		containerObj.addChild( Emitter.container() );
		
	});
		
}());	

}

function init()
{
	// create the container
	container = document.createElement( 'div' );
	document.body.appendChild( container );

	// init the renderer
	renderer	= new THREE.WebGLRenderer({
		antialias		: true,
		preserveDrawingBuffer	: true		
	});
	//renderer.sortObjects = true;
	renderer.setSize( window.innerWidth, window.innerHeight );
	container.appendChild( renderer.domElement );

	// create the Camera
	if( false ){<commit_msg>particle-emitter: made gravity negative possible + hide dat.gui if loaded in iframe (for embeddable)<commit_after>var container, stats, containerObj;
var camera, scene, renderer;
var mouseX = 0, mouseY = 0;

// detect if webgl is needed and available
if( !Detector.webgl ){
	Detector.addGetWebGLMessage();
}else{
	init();
	animate();
}

/**
 * Build ui with Data.GUI
*/
function buildGui(parameters, callback)
{
	urlCacheInit	= function(opts){
		if( !window.location.hash )	return
		var hashStr	= window.location.hash.substring(1);
		var urlParams	= JSON.parse(decodeURIComponent(hashStr));
console.log("urlParams", urlParams)
		Object.keys(urlParams).forEach(function(key){
			parameters[key]	= urlParams[key];
		}.bind(this));
console.log("parameters post cache init", parameters)
	}
	urlCacheUpdate	= function(opts){
		var urlParams	= {};
		if( window.location.hash ){
			urlParams	= JSON.parse(decodeURIComponent(location.hash.substring(1)));
		}

		Object.keys(opts).forEach(function(key){
			urlParams[key]	= opts[key];
		}.bind(this));

		window.location.hash	= '#'+encodeURIComponent(JSON.stringify(urlParams));
	}

	// Notice this belongs to the DAT.GUI class (uppercase)
	// and not an instance thereof.
	DAT.GUI.autoPlace = false;

	var change	= function(){
		// get parameters values from cache if needed
		urlCacheUpdate(parameters)
		callback && callback(parameters)
	};
	
	// get parameters values from cache if needed
	urlCacheInit(parameters)
	// init the cache with current parameters values
	urlCacheUpdate(parameters)
	
	var gui1 = new DAT.GUI({
		height	: 17 * 32 - 1
	});
	gui1.domElement.style.position	= 'absolute';
	gui1.domElement.style.top	= '0px';
	gui1.domElement.style.right	= '0px';
	gui1.domElement.style['z-index']= '9999';
	document.body.appendChild(gui1.domElement);
	

	gui1.add(parameters, 'emitRate').min(1).max(100)		.onFinishChange(change);
	gui1.add(parameters, 'timeToLive').min(200).max(5*1000)		.onFinishChange(change);

	gui1.add(parameters, 'originZaValue').min(-Math.PI).max(Math.PI).onFinishChange(change);
	gui1.add(parameters, 'originZaRange').min(0).max(Math.PI).onFinishChange(change);

	gui1.add(parameters, 'originZhValue').min(0).max(1)		.onFinishChange(change);
	gui1.add(parameters, 'originZhRange').min(0).max(0.5)		.onFinishChange(change);

	gui1.add(parameters, 'originRadiusValue').min(0.01).max(100)	.onFinishChange(change);
	gui1.add(parameters, 'originRadiusRange').min(0).max(30)	.onFinishChange(change);

	gui1.add(parameters, 'speedValue').min(0.2).max(2)		.onFinishChange(change);
	gui1.add(parameters, 'speedRange').min(0).max(2)		.onFinishChange(change);

	gui1.add(parameters, 'gravity').min(-0.2).max(0.2)		.onFinishChange(change);

	gui1.add(parameters, 'opacitySrc').min(0.0).max(1.0)		.onFinishChange(change);
	gui1.add(parameters, 'opacityInc').min(-0.05).max(0)		.onFinishChange(change);

	gui1.add(parameters, 'sizeSrc').min(2).max(128)			.onFinishChange(change);
	gui1.add(parameters, 'sizeInc').min(-1).max(1)			.onFinishChange(change);

	gui1.add(parameters, 'rotationSrc').min(0.0).max(2*Math.PI)	.onFinishChange(change);
	gui1.add(parameters, 'rotationInc').min(-0.05).max(0.05)	.onFinishChange(change);
		
(function(){
	var gui2	= new DAT.GUI({
		height	: 7 * 32 - 1
	});
	gui2.domElement.style.position	= 'absolute';
	gui2.domElement.style.top	= '0px';
	gui2.domElement.style.left	= '0px';
	gui1.domElement.style['z-index']= '9999';
	document.body.appendChild(gui2.domElement);	

	
	gui2.add(parameters.color, 'r').name('colorR')		.min(0.0).max(1.0).onChange(change);
	gui2.add(parameters.color, 'g').name('colorG')		.min(0.0).max(1.0).onChange(change);
	gui2.add(parameters.color, 'b').name('colorB')		.min(0.0).max(1.0).onChange(change);
	gui2.add(parameters.colorInc, 'r').name('colorIncR')	.min(-0.1).max(0.1).onChange(change);
	gui2.add(parameters.colorInc, 'g').name('colorIncG')	.min(-0.1).max(0.1).onChange(change);
	gui2.add(parameters.colorInc, 'b').name('colorIncB')	.min(-0.1).max(0.1).onChange(change);

	gui2.add(parameters, 'textureUrl').options({
		"flare"			: "images/lensFlare/Flare1.png",
		"smoke"			: "images/osg-data/smoke.png",
		"ball"			: "images/ball.png",

		"purple_particle"	: "images/tremulous/lasgun/purple_particle.jpg",
		"lcannon1"		: "images/tremulous/lcannon/primary_1.jpg",

		"shine"			: "images/lensFlare/Shine1.png",
		"continous_smoke"	: "images/osg-data/continous_smoke.png",
		"reflect"		: "images/osg-data/reflect.png"
	}).onChange(function(){
		console.log("texture change", containerObj)

		scene.removeChild(containerObj);
		containerObj	= new THREE.Object3D();
		scene.addChild(containerObj);
		
		// define the containerObj of all the particle
		Emitter	= new THREEx.Particle.Emitter(parameters);
		containerObj.addChild( Emitter.container() );
		
	});
}());	

	// hide DAT.GUI if this page is loaded in a iframe
	var inIFrame	= (window.location != window.parent.location) ? true : false;
	if( inIFrame )	DAT.GUI.toggleHide();

}

function init()
{
	// create the container
	container = document.createElement( 'div' );
	document.body.appendChild( container );

	// init the renderer
	renderer	= new THREE.WebGLRenderer({
		antialias		: true,
		preserveDrawingBuffer	: true		
	});
	//renderer.sortObjects = true;
	renderer.setSize( window.innerWidth, window.innerHeight );
	container.appendChild( renderer.domElement );

	// create the Camera
	if( false ){
{'fraction_non_alphanumeric': 0.17697349672271304, 'fraction_numerical': 0.02821316614420063, 'mean_word_length': 4.971639251276233, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3098781', 'n_tokens_mistral': 4154, 'n_tokens_neox': 3856, 'n_words': 603}