
var Demo = function() {
}
	var sippeKerroin=0;
	var prevTime=0;
	var prevRandTime=0;
	var xRange = 2;
		var zRange = 360;	
	var yRange = 1080;

	var bpm = 115;
	var beat = 60/bpm;
	var pattern = beat*8;
	var tick = beat/4;
	var hittingOrder = 0;
	var cubeNumber;
	var syncOrder = 0;
	var lastTime;
	var deltaTime;
	var slowRandomValue = [];
	var slowRandomTarget = [];
	slowRandomTarget.length=20;
	slowRandomValue.length=20;
	var normalSyncValue=1.4;
	var syncValue = normalSyncValue;
	var syncTime = [
		,13*pattern+beat
		];
	


Demo.prototype.init = function()
{
	Sync.addSync(
	[
		 { "name":"tunneldistort", "type":"rocket" }
		 ,{ "name":"distortionamount", "type":"rocket"}
		  ,{ "name":"brightnessamount", "type":"rocket"}
		  ,{ "name":"allseeingcamerax", "type":"rocket"}
		  ,{ "name":"allseeingcameray", "type":"rocket"}
		  ,{ "name":"allseeingcameraz", "type":"rocket"}
		  
	]);
	
	this.loader.addAnimation([
	{
		 "start": 0, "duration": 300, "layer": 1,"runFunction":"{perFrameCalculations(animation);}"
	}]);

this.hellscene(1*pattern,8*pattern);
this.wirecube(9*pattern,2*pattern);
this.teleportStart(11*pattern,4*pattern);
this.teleport(15*pattern,8*pattern);
this.planetscene(23*pattern,8*pattern);
this.allseeing(31*pattern,8*pattern);
this.endbuddha(39*pattern,4*pattern);
this.enddestruction(43*pattern,8*pattern);
this.fullScreenNoise(0,64*pattern,50000,.1);

this.brightnessContrast(0,pattern*64.5,50001,50004,50007,0.065,0.75);
this.distortion(0,pattern*64.5,0,50000,50002);

this.hackGlow(0,pattern*64,50006,50008,50012);

}

Demo.prototype.hellscene = function (startTime, duration)
{

	//fades
	this.loader.addAnimation([
    {
         "start": startTime+4*beat, "duration":2*pattern
        ,"layer": 52331, "image": ["data/jumalauta_presents.png"]
		,"scale":[{"x":.5,"y":.5}]
		,"position":[{"x":270,"y":635}]
		,"color":[{"a":0}
			,{"duration":2*beat,"a":255}
			,{"duration":.5*pattern,"a":255}
			,{"duration":2*beat,"a":0}
			]
    }]);
	
	this.loader.addAnimation([
    {
         "start": startTime+1*pattern, "duration":2*pattern
        ,"layer": 52331, "image": ["data/universe666.png"]
		,"scale":[{"x":.60,"y":.60}]
		,"position":[{"x":700,"y":45}]
		,"color":[{"a":0}
			,{"duration":2*beat,"a":255}
			,{"duration":.5*pattern,"a":255}
			,{"duration":2*beat,"a":0}
			]
    }]);	
		
	this.loader.addAnimation([
    {
         "start": startTime+2*pattern+4*beat, "duration":2*pattern
        ,"layer": 52331, "image": ["data/the_most_advanced.png"]
		,"scale":[{"x":.65,"y":.65}]
		,"position":[{"x":378,"y":615}]
		,"color":[{"a":0}
			,{"duration":2*beat,"a":255}
			,{"duration":.75*pattern,"a":255}
			,{"duration":2*beat,"a":0}
			]	
    }]);
		
	this.loader.addAnimation([
    {
         "start": startTime+4*pattern, "duration":2*pattern
        ,"layer": 52331, "image": ["data/666_terawatt.png"]
		,"scale":[{"x":.65,"y":.65}]
		,"position":[{"x":280,"y":615}]
		,"color":[{"a":0}
			,{"duration":2*beat,"a":255}
			,{"duration":.5*pattern,"a":255}
			,{"duration":2*beat,"a":0}
			]
    }]);
	this.loader.addAnimation([
    {
         "start": startTime+5*pattern, "duration":2.5*pattern
        ,"layer": 52331, "image": ["data/nine_layers_of.png"]
		,"scale":[{"x":.65,"y":.65}]
		,"position":[{"x":990,"y":615}]
		,"color":[{"a":0}
			,{"duration":2*beat,"a":255}
			,{"duration":1*pattern,"a":255}
			,{"duration":2*beat,"a":0}
			]
    }]);	

	this.loader.addAnimation([
    {
         "start": startTime+6.5*pattern, "duration":1.25*pattern
        ,"layer": 52331, "image": ["data/brimstone_cannons.png"]
		,"scale":[{"x":.65,"y":.65}]
		,"position":[{"x":400,"y":635}]
		,"color":[{"a":0}
			,{"duration":2*beat,"a":255}
			,{"duration":.75*pattern,"a":255}
			,{"duration":2*beat,"a":0}
			]	
    }]);
		
	this.loader.addAnimation([
    {
         "start": startTime, "duration":2*beat
        ,"layer": 53331, "image": ["data/empty.png"]
		,"scale":[{"x":2,"y":3.55}]
		,"color":[{"a":255}
			,{"duration":2*beat,"a":0}
			]	
    }]);

	this.loader.addAnimation([
    {
         "start": startTime+pattern+6*beat, "duration":2*beat
        ,"layer": 53331, "image": ["data/empty.png"]
		,"scale":[{"x":2,"y":3.55}]
		,"color":[{"a":0}
			,{"duration":2*beat,"a":255}
			]
    }]);

	this.loader.addAnimation([
    {
         "start": startTime+2*pattern, "duration":2*beat
        ,"layer": 53331, "image": ["data/empty.png"]
		,"scale":[{"x":2,"y":3.55}]

		,"color":[{"a":255}
			,{"duration":2*beat,"a":0}
			]
    }]);

	this.loader.addAnimation([
    {
         "start": startTime+3*pattern+6*beat, "duration":2*beat
        ,"layer": 53331, "image": ["data/empty.png"]
		,"scale":[{"x":2,"y":3.55}]

		,"color":[{"a":0}
			,{"duration":2*beat,"a":255}
		]	
    }]);
	
	this.loader.addAnimation([
    {
         "start": startTime+4*pattern, "duration":2*beat
        ,"layer": 53331, "image": ["data/empty.png"]
		,"scale":[{"x":2,"y":3.55}]

		,"color":[{"a":255}
			,{"duration":2*beat,"a":0}
		]	
    }]);

	this.loader.addAnimation([
    {
         "start": startTime+7*pattern+6*beat, "duration":2*beat
        ,"layer": 53331, "image": ["data/empty.png"]
		,"scale":[{"x":2,"y":3.55}]

		,"color":[{"a":0}
			,{"duration":2*beat,"a":255}
		]
    }]);

	//light
		
	this.loader.addAnimation([
	{
		 "start": startTime, "duration": duration, "light":{"index":0, "action":"begin"}
		,"layer": 20000
		,"diffuseColor":[
			 {"r":455, "g":255, "b":455, "a":255}
		]
		,"ambientColor":[
				 {"r":0, "g":0, "b":0, "a":0}
		]
		,"specularColor":[
			 {"r":155, "g":55, "b":55, "a":55}
		]
		,"position":[
			 {"x":-44.0, "y":163.5, "z":-120.1}]
	}]);
	

			this.loader.addAnimation([
	{
		 "start": startTime, "duration": duration, "light":{"index":1, "action":"begin"}
		,"layer": 20000
		,"diffuseColor":[
			 {"r":555, "g":2355, "b":2555, "a":255}
		]
		,"ambientColor":[
				 {"r":0, "g":0, "b":0, "a":0}
		]
		,"specularColor":[
			 {"r":255, "g":255, "b":255, "a":55}
		]
		,"position":[
			 {"x":0.0, "y":-0.5, "z":0.1}]
	}]);
	
	
	// kamerat
	this.loader.addAnimation([
	{
		 "start": startTime, "duration": 2*pattern, "camera": "Cam01"
		,"layer": 20000
		
		,"target":[
			 {"x":0.0, "y":5.0, "z":0.0}

		]
		,"up":[
			 {"x":0.0, "y":1.0, "z":0.0}
		]
		,"position":[
		{"x":"{return Math.sin(.2*getSceneTimeFromStart()-pattern);}"
		,"y":0
		,"z":"{return Math.cos(.2*getSceneTimeFromStart()-pattern);}"
		}]
	}]);
	
	
	
	this.loader.addAnimation([
	{
		 "start": startTime+2*pattern, "duration": 2*pattern, "camera": "Cam01"
		,"layer": 20000
		
		,"target":[
			 {"x":0.0, "y":5.7, "z":0.0}
	
		]
		,"up":[
			 {"x":0.0, "y":1.0, "z":0.0}
		]
		,"position":[
		{"x":0.0
		,"y":"{return 3-4*Math.cos(-.17*getSceneTimeFromStart()+.6);}"
		,"z":3.0
		}]
	}]);
	
		
		
	this.loader.addAnimation([
	{
		 "start": startTime+4*pattern, "duration": 4*pattern, "camera": "Cam01"
		,"layer": 20000
		
		,"target":[
			 {"x":0.0, "y":5.7, "z":0.0}

		]
		,"up":[
			 {"x":0.0, "y":1.0, "z":0.0}
		]
		,"position":[
		{"x":"{return 2*Math.sin(.245*(getSceneTimeFromStart()-pattern-5.5));}"
		,"y":5.8
		,"z":"{return 2*Math.cos(.245*(getSceneTimeFromStart()-pattern-5.5));}"
		}]
	}]);
	
	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/hellscene.obj"
		,"layer": 20000
		,"position": [{"x":0,"y":0,"z":0}]
		,"scale": [{"x":0.5,"y":0.5,"z":0.5}]
		,"angle": [{"degreesZ":0,"degreesX":0,"degreesY":45}]
		}]);

	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/lussu.obj"
		,"layer": 20000
		,"position": [{"x":0,"y":5.5,"z":0}]
		,"scale": [{"x":0.35,"y":0.35,"z":0.35}]
		,"angle": [{"degreesX":0,"degreesY":0,"degreesZ":0}]
		}]);

// valot pois
	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "light":{"index":0, "action":"end"}
		,"layer": 20000
		}]);

	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "light":{"index":1, "action":"end"}
		,"layer": 20000
		}]);
					
	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/spacesphere.obj"
		,"layer": 20000
		,"position": [{"z":0,"y":0.0,"x":0.0}]
		,"scale": [{"x":1.2,"y":1.7,"z":1.7}]
		}]);

	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/spacesphere.obj"
		,"layer": 20000
		,"position": [{"z":0,"y":0.0,"x":0.0}]
		,"angle": [{"degreesX":250,"degreesY":0,"degreesZ":180}]
		,"scale": [{"x":-0.6,"y":-0.6,"z":-0.6}]
		}]);	
					
}

				
Demo.prototype.endbuddha = function (startTime, duration)
{		
//light2

		this.loader.addAnimation([
    {
         "start": startTime, "duration":pattern
        ,"layer": 53331, "image": ["data/text7.png"]
		,"scale":[{"x":1,"y":1}]
		,"color":[{"a":255}
			,{"duration":pattern,"a":0}
			]	
    }]);
	
			this.loader.addAnimation([
    {
         "start": startTime+pattern, "duration":pattern
        ,"layer": 53331, "image": ["data/text8.png"]
		,"scale":[{"x":1,"y":1}]
		,"color":[{"a":255}
			,{"duration":pattern,"a":0}
			]	
    }]);

			this.loader.addAnimation([
    {
         "start": startTime+pattern*2, "duration":pattern
        ,"layer": 53331, "image": ["data/text9.png"]
		,"scale":[{"x":1,"y":1}]
		,"color":[{"a":255}
			,{"duration":pattern,"a":0}
			]	
    }]);
				this.loader.addAnimation([
    {
         "start": startTime+pattern*3, "duration":pattern
        ,"layer": 53331, "image": ["data/text10.png"]
		,"scale":[{"x":1,"y":1}]
		,"color":[{"a":255}
			,{"duration":pattern,"a":0}
			]	
    }]);
	
	
	this.loader.addAnimation([
	{
		 "start": startTime, "duration": duration, "light":{"index":3, "action":"begin"}
		,"layer": 20000
		,"diffuseColor":[
			 {"r":355, "g":255, "b":355, "a":255}
		]
		,"ambientColor":[
				 {"r":0, "g":0, "b":0, "a":0}
		]
		,"specularColor":[
			 {"r":255, "g":255, "b":255, "a":255}
		]
		,"position":[
			 {"x":0.0, "y":5.0, "z":-50}]
	}]);
	

			this.loader.addAnimation([
	{
		 "start": startTime, "duration": duration, "light":{"index":4, "action":"begin"}
		,"layer": 20000
		,"diffuseColor":[
			 {"r":355, "g":255, "b":355, "a":255}
		]
		,"ambientColor":[
				 {"r":0, "g":0, "b":0, "a":0}
		]
		,"specularColor":[
			 {"r":255, "g":255, "b":255, "a":255}
		]
		,"position":[
			 {"x":0.0, "y":0.0, "z":20.0}]
	}]);
	
//kamerat
	this.loader.addAnimation([
	{
		 "start": startTime, "duration": 4*pattern, "camera": "Cam01"
		,"layer": 20000
		
		,"target":[
			 {"x":0.0, "y":0.0, "z":0.0}

		]
		,"up":[
			 {"x":Math.random()-Math.random(), "y":1.0, "z":0}
		,{"duration":.99*pattern,"x":0}
		,{"duration":.01*pattern,"x":Math.random()-Math.random()}
		,{"duration":.99*pattern,"x":0}
		,{"duration":.01*pattern,"x":Math.random()-Math.random()}
		,{"duration":.99*pattern,"x":0}
		,{"duration":.01*pattern,"x":Math.random()-Math.random()}
		,{"duration":.99*pattern,"x":0}
				,{"duration":.01*pattern,"x":Math.random()-Math.random()}
		,{"duration":.99*pattern,"x":0}		 
				,{"duration":.01*pattern,"x":Math.random()-Math.random()}
		,{"duration":.99*pattern,"x":0}		 
				,{"duration":.01*pattern,"x":Math.random()-Math.random()}
		,{"duration":.99*pattern,"x":0}		 
		]
		,"position":[
		{"x":0
		,"y":0
		,"z":2}
		,
		]
		
	}]);
	
		this.loader.addAnimation([
		{
		"start": startTime, "duration": duration-pattern, "object":"data/3d_tunnel_1.obj"
		,"layer": 20000
		
		     ,"shader":{
            "name":"data/shader/tunnel.fs",
            "variable":[
                  {"name":"time","value":["{return getSceneTimeFromStart()-pattern;}"]}
				  ,{"name":"distort","value":["{return Sync.getSyncValue('tunneldistort');}"]}
				  
            ]
        }
		,"position": [{"x":0,"y":0.0,"z":20}]
		,"scale": [{"x":1.85,"y":1.85,"z":-3.55}]
		,"angle": [{"degreesZ":0,"degreesX":90,"degreesY":0}]
		}]);
		
		
		this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "image": ["data/empty.png"]
		,"layer": 10000
		     ,"shader":{
            "name":"data/shader/starfield2.fs",
            "variable":[
                  {"name":"time","value":["{return getSceneTimeFromStart()-pattern;}"]}
            ]
        }
		,"position": [{"x":640,"y":360,"z":0}]
		,"scale": [{"x":1.0,"y":1.0,"z":1.0}]
		,"angle": [{"degreesZ":0,"degreesX":0,"degreesY":0}]
		}]);
	this.loader.addAnimation([
		{
		"start": startTime+3*pattern, "duration": pattern, "object":"data/wirecube.obj"
		,"layer": 20000
		,"position": [{"x":0,"y":0.0,"z":0}]
		,"scale": [{"x":0.15,"y":0.15,"z":0.15}]
		,"angle": [{"degreesX":"{return 10*getSceneTimeFromStart()-pattern;}","degreesY":"{return 6.6*getSceneTimeFromStart()-pattern;}","degreesZ":"{return 3.3*getSceneTimeFromStart()-pattern;}"}]
		}]);
		
	this.loader.addAnimation([
    {
         "start": startTime, "duration":4*pattern
        ,"layer": 20000, "image": ["data/gradient.png"]
		,"perspective":"3d"
		,"scale":[{"x":33.75,"y":.15}]
		,"position":[{"x":0,"y":0,"z":-.1}]

    }]);
	this.loader.addAnimation([
    {
         "start": startTime, "duration":4*pattern
        ,"layer": 20000, "image": ["data/gradient.png"]
		,"perspective":"3d"
				,"scale":[{"x":.15,"y":33.75}]
				,"angle": [{"degreesZ":270,"degreesX":0,"degreesY":180}]


		,"position":[{"x":0,"y":0,"z":-.1}]

    }]);	
		this.loader.addAnimation([
    {
         "start": startTime, "duration":4*pattern
        ,"layer": 20000, "image": ["data/buddha.png"]
		,"perspective":"3d"
		,"scale":[{"x":0.75,"y":.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		
		]
		,"position":[{"x":0,"y":0,"z":0}]

    }]);
		this.loader.addAnimation([
    {
         "start": startTime+1*pattern+6*beat, "duration":2*beat
        ,"layer": 53331, "image": ["data/empty.png"]
		,"scale":[{"x":2,"y":3.55}]
		,"color":[{"a":0}
			,{"duration":2*beat,"a":255}
			]	
    }]);
	
	//valot pois		
	
	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "light":{"index":3, "action":"end"}
		,"layer": 20000
		}]);

	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "light":{"index":4, "action":"end"}
		,"layer": 20000
		}]);	
		


			
}


				
Demo.prototype.enddestruction = function (startTime, duration)
{		
				this.loader.addAnimation([
    {
         "start": startTime+pattern*3, "duration":pattern
        ,"layer": 53331, "image": ["data/producer1.png"]
		,"scale":[{"x":.5,"y":.5 }]
		,"color":[{"a":255}
			,{"duration":pattern,"a":0}
			]	
    }]);
					this.loader.addAnimation([
    {
         "start": startTime+pattern*4, "duration":pattern
        ,"layer": 53331, "image": ["data/producer2.png"]
		,"scale":[{"x":.5,"y":.5 }]
		,"color":[{"a":255}
			,{"duration":pattern,"a":0}
			]	
    }]);
	
					this.loader.addAnimation([
    {
         "start": startTime+pattern*5, "duration":pattern
        ,"layer": 53331, "image": ["data/producer3.png"]
		,"scale":[{"x":.5,"y":.5 }]
		,"color":[{"a":255}
			,{"duration":pattern,"a":0}
			]	
    }]);

						this.loader.addAnimation([
    {
         "start": startTime+pattern*6, "duration":pattern
        ,"layer": 53331, "image": ["data/jumalauta2017.png"]
		,"scale":[{"x":.5,"y":.5 }]
		,"color":[{"a":255}
			,{"duration":pattern,"a":0}
			]	
    }]);

	
	
//light2
	this.loader.addAnimation([
	{
		 "start": startTime, "duration": duration, "light":{"index":3, "action":"begin"}
		,"layer": 20000
		,"diffuseColor":[
			 {"r":355, "g":255, "b":355, "a":255}
		]
		,"ambientColor":[
				 {"r":0, "g":0, "b":0, "a":0}
		]
		,"specularColor":[
			 {"r":255, "g":255, "b":255, "a":255}
		]
		,"position":[
			 {"x":0.0, "y":5.0, "z":-50}]
	}]);
	

			this.loader.addAnimation([
	{
		 "start": startTime, "duration": duration, "light":{"index":4, "action":"begin"}
		,"layer": 20000
		,"diffuseColor":[
			 {"r":355, "g":255, "b":355, "a":255}
		]
		,"ambientColor":[
				 {"r":0, "g":0, "b":0, "a":0}
		]
		,"specularColor":[
			 {"r":255, "g":255, "b":255, "a":255}
		]
		,"position":[
			 {"x":0.0, "y":0.0, "z":20.0}]
	}]);
	
//kamerat
	this.loader.addAnimation([
	{
		 "start": startTime, "duration": 2*pattern, "camera": "Cam01"
		,"layer": 20000
		
		,"target":[
			 {"x":0.0, "y":0.0, "z":0.0}

		]
		,"up":[
			 {"x":Math.random()-Math.random(), "y":1.0, "z":0} 
		]
		,"position":[
		{"x":0
		,"y":0
		,"z":12}
		,
		]
		
	}]);
	
	
		
		
		this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "image": ["data/empty.png"]
		,"layer": 10000
		     ,"shader":{
            "name":"data/shader/starfield2.fs",
            "variable":[
                  {"name":"time","value":["{return getSceneTimeFromStart()-pattern;}"]}
            ]
        }
		,"position": [{"x":640,"y":360,"z":0}]
		,"scale": [{"x":1.0,"y":1.0,"z":1.0}]
		,"angle": [{"degreesZ":0,"degreesX":0,"degreesY":0}]
		}]);
		
	this.explosion(startTime+.5*pattern,.5*pattern-beat*.5,0,0,0,.5,15,255,255,255,2,1);	
	this.explosion(startTime+pattern,.5*pattern-beat*.5,0,0,0,.5,15,255,255,255,2,1);	
		
	this.loader.addAnimation([
		{
		"start": startTime, "duration": pattern*.5, "object":"data/wirecube.obj"
		,"layer": 20000
		,"position": [{"x":0,"y":0.0,"z":0}]
		,"scale": [{"x":0.15,"y":0.15,"z":0.15}]
		,"angle": [{"degreesX":"{return 10*getSceneTimeFromStart()-pattern;}","degreesY":"{return 6.6*getSceneTimeFromStart()-pattern;}","degreesZ":"{return 3.3*getSceneTimeFromStart()-pattern;}"}]
		}]);
		
	this.loader.addAnimation([
    {
         "start": startTime, "duration":1*pattern
        ,"layer": 20000, "image": ["data/gradient.png"]
		,"perspective":"3d"
		,"scale":[{"x":33.75,"y":.15}]
		,"position":[{"x":0,"y":0,"z":-.1}]

    }]);
	this.loader.addAnimation([
    {
         "start": startTime, "duration":1*pattern
        ,"layer": 20000, "image": ["data/gradient.png"]
		,"perspective":"3d"
				,"scale":[{"x":.15,"y":33.75}]
				,"angle": [{"degreesZ":270,"degreesX":0,"degreesY":180}]


		,"position":[{"x":0,"y":0,"z":-.1}]

    }]);	
		this.loader.addAnimation([
    {
         "start": startTime, "duration":1*pattern
        ,"layer": 20000, "image": ["data/buddha.png"]
		,"perspective":"3d"
		,"scale":[{"x":0.75,"y":.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		
		]
		,"position":[{"x":0,"y":0,"z":0}]

    }]);

	
	//valot pois		
	
	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "light":{"index":3, "action":"end"}
		,"layer": 20000
		}]);

	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "light":{"index":4, "action":"end"}
		,"layer": 20000
		}]);	
		


			
}

Demo.prototype.wirecube = function (startTime, duration)
{		
//light2
	this.loader.addAnimation([
	{
		 "start": startTime, "duration": duration, "light":{"index":3, "action":"begin"}
		,"layer": 20000
		,"diffuseColor":[
			 {"r":355, "g":255, "b":355, "a":255}
		]
		,"ambientColor":[
				 {"r":0, "g":0, "b":0, "a":0}
		]
		,"specularColor":[
			 {"r":255, "g":255, "b":255, "a":255}
		]
		,"position":[
			 {"x":0.0, "y":5.0, "z":-50}]
	}]);
	

			this.loader.addAnimation([
	{
		 "start": startTime, "duration": duration, "light":{"index":4, "action":"begin"}
		,"layer": 20000
		,"diffuseColor":[
			 {"r":355, "g":255, "b":355, "a":255}
		]
		,"ambientColor":[
				 {"r":0, "g":0, "b":0, "a":0}
		]
		,"specularColor":[
			 {"r":255, "g":255, "b":255, "a":255}
		]
		,"position":[
			 {"x":0.0, "y":0.0, "z":20.0}]
	}]);
	
//kamerat
	this.loader.addAnimation([
	{
		 "start": startTime, "duration": 2*pattern, "camera": "Cam01"
		,"layer": 20000
		
		,"target":[
			 {"x":0.0, "y":0.0, "z":0.0}

		]
		,"up":[
			 {"x":Math.random()-Math.random(), "y":1.0, "z":0}
		,{"duration":.5*pattern,"x":0}
		,{"duration":.01*pattern,"x":Math.random()-Math.random()}
		,{"duration":.49*pattern,"x":0}
		,{"duration":.01*pattern,"x":Math.random()-Math.random()}
		,{"duration":.49*pattern,"x":0}
		,{"duration":.01*pattern,"x":Math.random()-Math.random()}
		,{"duration":.49*pattern,"x":0}		 
		]
		,"position":[
		{"x":0
		,"y":0
		,"z":16}
		,{"duration":.5*pattern,"z":16}
		,{"duration":.01*pattern,"z":6}
		,{"duration":.49*pattern,"z":6}
		,{"duration":.01*pattern,"z":2.25}
		,{"duration":.49*pattern,"z":2.25}
		,{"duration":.01*pattern,"z":1.0}
		,{"duration":.49*pattern,"z":1.0}
		
		]
		
	}]);
		this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "image": ["data/empty.png"]
		,"layer": 10000
		     ,"shader":{
            "name":"data/shader/starfield2.fs",
            "variable":[
                  {"name":"time","value":["{return getSceneTimeFromStart()-pattern;}"]}
            ]
        }
		,"position": [{"x":640,"y":360,"z":0}]
		,"scale": [{"x":1.0,"y":1.0,"z":1.0}]
		,"angle": [{"degreesZ":0,"degreesX":0,"degreesY":0}]
		}]);
	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/wirecube.obj"
		,"layer": 20000
		,"position": [{"x":0,"y":0.0,"z":0}]
		,"scale": [{"x":0.15,"y":0.15,"z":0.15}]
		,"angle": [{"degreesX":"{return 10*getSceneTimeFromStart()-pattern;}","degreesY":"{return 6.6*getSceneTimeFromStart()-pattern;}","degreesZ":"{return 3.3*getSceneTimeFromStart()-pattern;}"}]
		}]);
		
	this.loader.addAnimation([
    {
         "start": startTime, "duration":2*pattern
        ,"layer": 20000, "image": ["data/gradient.png"]
		,"perspective":"3d"
		,"scale":[{"x":33.75,"y":.15}]
		,"position":[{"x":0,"y":0,"z":-.1}]

    }]);
	this.loader.addAnimation([
    {
         "start": startTime, "duration":2*pattern
        ,"layer": 20000, "image": ["data/gradient.png"]
		,"perspective":"3d"
				,"scale":[{"x":.15,"y":33.75}]
				,"angle": [{"degreesZ":270,"degreesX":0,"degreesY":180}]


		,"position":[{"x":0,"y":0,"z":-.1}]

    }]);	
		this.loader.addAnimation([
    {
         "start": startTime, "duration":2*pattern
        ,"layer": 20000, "image": ["data/buddha.png"]
		,"perspective":"3d"
		,"scale":[{"x":0.75,"y":.75}
		,{"duration":1*pattern,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		,{"duration":.05*beat,"x":.65,"y":0.65}
		,{"duration":.95*beat,"x":.75,"y":0.75}
		
		]
		,"position":[{"x":0,"y":0,"z":0}]

    }]);
		this.loader.addAnimation([
    {
         "start": startTime+1*pattern+6*beat, "duration":2*beat
        ,"layer": 53331, "image": ["data/empty.png"]
		,"scale":[{"x":2,"y":3.55}]
		,"color":[{"a":0}
			,{"duration":2*beat,"a":255}
			]	
    }]);
	
	//valot pois		
	
	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "light":{"index":3, "action":"end"}
		,"layer": 20000
		}]);

	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "light":{"index":4, "action":"end"}
		,"layer": 20000
		}]);	
		


			
}


Demo.prototype.teleportStart = function (startTime, duration)
{		
	this.loader.addAnimation([
    {
         "start": startTime, "duration":8*beat
        ,"layer": 53331, "image": ["data/empty.png"]
		,"scale":[{"x":2,"y":3.55}]
		,"color":[{"a":255}
		,{"duration":4*beat,"a":255}
			,{"duration":8*beat,"a":0}
			]	
    }]);
		this.loader.addAnimation([
    {
         "start": startTime, "duration":7.5*beat
        ,"layer": 53332, "image": ["data/punished_by_anger.png"]
		,"scale":[{"x":1.0,"y":1.0}]
		,"color":[{"a":"{return 255-255*(getSceneTimeFromStart()%.2);}"}]
    }]);
	this.loader.addAnimation([
	{
		 "start": startTime, "duration": duration, "light":{"index":5, "action":"begin"}
		,"layer": 20000
		,"diffuseColor":[
			 {"r":355, "g":255, "b":355, "a":255}
		]
		,"ambientColor":[
				 {"r":0, "g":0, "b":0, "a":0}
		]
		,"specularColor":[
			 {"r":255, "g":255, "b":255, "a":255}
		]
		,"position":[
			 {"x":0.0, "y":0.0, "z":50}]
	}]);
	

			this.loader.addAnimation([
	{
		 "start": startTime, "duration": duration, "light":{"index":6, "action":"begin"}
		,"layer": 20000
		,"diffuseColor":[
			 {"r":355, "g":255, "b":355, "a":255}
		]
		,"ambientColor":[
				 {"r":0, "g":0, "b":0, "a":0}
		]
		,"specularColor":[
			 {"r":255, "g":255, "b":255, "a":255}
		]
		,"position":[
			 {"x":0.0, "y":-0.5, "z":0.1}]
	}]);
	
//kamerat
	this.loader.addAnimation([
	{
		 "start": startTime, "duration": 3*pattern, "camera": "Cam01"
		,"layer": 20000
		
		,"target":[
			 {"x":0, "y":0.0, "z":-2.0}
			,{"duration":4.0*pattern,"z":10}
		]
		,"up":[
			 {"x":0.0, "y":1.0, "z":0.0}
		]
		,"position":[
		{"x":-6
		,"y":2
		,"z":0
		}]
	}]);

	
	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/lussu.obj"
		,"layer": 20000
		,"position": [{"x":0,"y":0.0,"z":-8}
		,{"duration":3.3*pattern,"z":8}
		,{"duration":0.2*pattern,"z":28}
		,{"duration":0.1*pattern,"z":98}
		]
		,"scale": [{"x":0.35,"y":0.35,"z":0.35}
		,{"duration":3.2*pattern,"z":.35}
		,{"duration":0.31*pattern,"z":.45}
		
		,{"duration":.05*pattern,"z":18.75,"x":0,"y":0}
		,{"duration":.05*pattern,"z":0.0,"x":0,"y":0}
		]
		,"angle": [{"degreesX":0,"degreesY":0,"degreesZ":0}]
		}]);
	//valot pois		
			this.loader.addAnimation([
    {
         "start": startTime, "duration":4*pattern
        ,"layer": 20000, "image": ["data/baphomet.png"]
		,"perspective":"3d"
		,"scale":[{"x":370*1.1,"y":1.1*420,"z":51}]
		,"position":[{"x":75,"y":-130,"z":555}]
,"angle": [{"degreesZ":10,"degreesX":20,"degreesY":-10}]
    }]);
	
	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "light":{"index":5, "action":"end"}
		,"layer": 20000
		}]);

	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "light":{"index":6, "action":"end"}
		,"layer": 20000
		}]);	
		
	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/spacesphere.obj"
		,"layer": 20001
		,"position": [{"z":0,"y":0.0,"x":0.0}]
		,"scale": [{"x":1.2,"y":1.7,"z":1.7}]
		}]);

	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/spacesphere.obj"
		,"layer": 20001
		,"position": [{"z":0,"y":0.0,"x":0.0}]
		,"angle": [{"degreesX":250,"degreesY":0,"degreesZ":180}]
		,"scale": [{"x":-0.6,"y":-0.6,"z":-0.6}]
		}]);		
		
}

Demo.prototype.teleport = function (startTime, duration)
{		

	this.loader.addAnimation([
    {
         "start": startTime+2*pattern+4*beat, "duration":pattern
        ,"layer": 53331, "image": ["data/text2.png"]
		,"scale":[{"x":1,"y":1}]
		,"color":[{"a":255}
			,{"duration":2*beat,"a":0}
			]	
    }]);

	this.loader.addAnimation([
    {
         "start": startTime+3*pattern+4*beat, "duration":pattern
        ,"layer": 53331, "image": ["data/text3.png"]
		,"scale":[{"x":1,"y":1}]
		,"color":[{"a":255}
			,{"duration":2*beat,"a":0}
			]	
    }]);	
//light2
	this.loader.addAnimation([
	{
		 "start": startTime, "duration": duration, "light":{"index":3, "action":"begin"}
		,"layer": 20000
		,"diffuseColor":[
			 {"r":355, "g":255, "b":355, "a":255}
		]
		,"ambientColor":[
				 {"r":0, "g":0, "b":0, "a":0}
		]
		,"specularColor":[
			 {"r":255, "g":255, "b":255, "a":255}
		]
		,"position":[
			 {"x":20.0, "y":-20.0, "z":25.0}]
	}]);
	

			this.loader.addAnimation([
	{
		 "start": startTime, "duration": duration, "light":{"index":4, "action":"begin"}
		,"layer": 20000
		,"diffuseColor":[
			 {"r":355, "g":255, "b":355, "a":255}
		]
		,"ambientColor":[
				 {"r":0, "g":0, "b":0, "a":0}
		]
		,"specularColor":[
			 {"r":255, "g":255, "b":255, "a":255}
		]
		,"position":[
			 {"x":-20.0, "y":20.0, "z":25.0}]
	}]);
	
//kamerat
	this.loader.addAnimation([
	{
		 "start": startTime, "duration": 2*pattern, "camera": "Cam06"
		,"layer": 20000
		
		,"target":[
			 {"x":0.0, "y":0.0, "z":0.0}

		]
		,"up":[
			 {"x":0.0, "y":1.0, "z":0.0}
		]
		,"position":[
		{"x":"{return 4.25*Math.sin(6.4+.5*(getSceneTimeFromStart()-pattern-pattern));}"
		,"y":"{return .55*Math.cos(.5*(getSceneTimeFromStart()-pattern-pattern));}"
		,"z":"{return 10.5+(13*pattern-(getSceneTimeFromStart()-pattern-pattern));}"
		}]
	}]);

	this.loader.addAnimation([
	{
		 "start": startTime+2*pattern, "duration": 2*pattern, "camera": "Cam07"
		,"layer": 20000
		
		,"target":[
			 {"x":0.0, "y":0.0, "z":-1.0}

		]
		,"up":[
			 {"x":0.0, "y":1.0, "z":0.0}
		]
		,"position":[
		{"x":0
		,"y":0
		,"z":-.1
		}]
	}]);
	
		this.loader.addAnimation([
	{
		 "start": startTime+4*pattern, "duration": 2*pattern, "camera": "Cam08"
		,"layer": 20000
		
		,"target":[
			 {"x":0.0, "y":-1.0, "z":0}
			 	,{"duration":2*pattern,"z":-1}]
		,"up":[
			 {"x":0.0, "y":0.0, "z":-1.0}
		]
		,"position":[
		{"x":"{return .25*Math.sin(.5*getSceneTimeFromStart()-pattern);}"
		,"y":3.5
		,"z":0
		}
			,{"duration":2*pattern,"y":8.5,"z":-1}]
	}]);
	
	this.loader.addAnimation([
	{
		 "start": startTime+6*pattern, "duration": 2*pattern, "camera": "Cam07"
		,"layer": 20000
		
		,"target":[
			 {"x":0.0, "y":0.0, "z":1.0}

		]
		,"up":[
			 {"x":0.0, "y":1.0, "z":0.0}
		]
		,"position":[
		{"x":0
		,"y":1
		,"z":-5
		}]
	}]);
	
	
	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration-2*pattern, "object":"data/3d_tunnel_1.obj"
		,"layer": 20000
		
		     ,"shader":{
            "name":"data/shader/tunnel.fs",
            "variable":[
                  {"name":"time","value":["{return getSceneTimeFromStart()-pattern;}"]}
				  ,{"name":"distort","value":["{return Sync.getSyncValue('tunneldistort');}"]}
				  
            ]
        }
		,"position": [{"x":0,"y":0.0,"z":20}]
		,"scale": [{"x":1.85,"y":1.85,"z":-3.55}]
		,"angle": [{"degreesZ":0,"degreesX":90,"degreesY":0}]
		}]);
		
	this.loader.addAnimation([
		{
		"start": startTime+6*pattern, "duration": 2*pattern, "object":"data/3d_tunnel_1.obj"

		,"layer": 20000
		     ,"shader":{
            "name":"data/shader/tunnel.fs",
            "variable":[
                  {"name":"time","value":["{return -getSceneTimeFromStart()-pattern;}"]}
				  	  ,{"name":"distort","value":["{return Sync.getSyncValue('tunneldistort');}"]}
            ]
        }
		,"position": [{"x":0,"y":0.0,"z":-20}]
		,"scale": [{"x":1.85,"y":1.85,"z":3.55}]
		,"angle": [{"degreesZ":0,"degreesX":90,"degreesY":"{return -40*getSceneTimeFromStart()-pattern;}"}]
		}]);
		
	//valot pois		
	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/lussu.obj"
		,"layer": 20000
		,"position": [{"x":0,"y":0.0,"z":0}]
		,"scale": [{"x":0.35,"y":0.35,"z":-0.35}]
		,"angle": [{"degreesX":0,"degreesY":0,"degreesZ":0}]
		}]);
		
	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "light":{"index":3, "action":"end"}
		,"layer": 20000
		}]);

	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "light":{"index":4, "action":"end"}
		,"layer": 20000
		}]);	
		

		this.loader.addAnimation([
    {
         "start": startTime, "duration":2*beat
        ,"layer": 53331, "image": ["data/empty.png"]
		,"scale":[{"x":2,"y":3.55}]
		,"color":[{"a":255}
			,{"duration":2*beat,"a":0}
			]	
    }]);

		this.loader.addAnimation([
    {
         "start": startTime+1*pattern+6*beat, "duration":2*beat
        ,"layer": 53331, "image": ["data/empty.png"]
		,"scale":[{"x":2,"y":3.55}]
		,"color":[{"a":0}
			,{"duration":2*beat,"a":255}
			]	
    }]);
		this.loader.addAnimation([
    {
         "start": startTime+2*pattern, "duration":2*beat
        ,"layer": 53331, "image": ["data/empty.png"]
		,"scale":[{"x":2,"y":3.55}]
		,"color":[{"a":255}
			,{"duration":2*beat,"a":0}
			]	
    }]);

		this.loader.addAnimation([
    {
         "start": startTime+3*pattern+6*beat, "duration":2*beat
        ,"layer": 53331, "image": ["data/empty.png"]
		,"scale":[{"x":2,"y":3.55}]
		,"color":[{"a":0}
			,{"duration":2*beat,"a":255}
			]	
    }]);
		this.loader.addAnimation([
    {
         "start": startTime+4*pattern, "duration":2*beat
        ,"layer": 53331, "image": ["data/empty.png"]
		,"scale":[{"x":2,"y":3.55}]
		,"color":[{"a":255}
			,{"duration":2*beat,"a":0}
			]	
    }]);

		this.loader.addAnimation([
    {
         "start": startTime+5*pattern+6*beat, "duration":2*beat
        ,"layer": 53331, "image": ["data/empty.png"]
		,"scale":[{"x":2,"y":3.55}]
		,"color":[{"a":0}
			,{"duration":2*beat,"a":255}
			]	
    }]);
		this.loader.addAnimation([
    {
         "start": startTime+6*pattern, "duration":2*beat
        ,"layer": 53331, "image": ["data/empty.png"]
		,"scale":[{"x":2,"y":3.55}]
		,"color":[{"a":255}
			,{"duration":2*beat,"a":0}
			]	
    }]);
			this.loader.addAnimation([
    {
         "start": startTime+7*pattern+6*beat, "duration":2*beat
        ,"layer": 53331, "image": ["data/empty.png"]
		,"scale":[{"x":2,"y":3.55}]
		,"color":[{"a":0}
			,{"duration":2*beat,"a":255}
			]	
    }]);

}


Demo.prototype.planetscene = function (startTime, duration)
{		
		this.loader.addAnimation([
    {
         "start": startTime, "duration":2*beat
        ,"layer": 53331, "image": ["data/empty.png"]
		,"scale":[{"x":2,"y":3.55}]
		,"color":[{"a":255}
			,{"duration":2*beat,"a":0}
			]	
    }]);
		this.loader.addAnimation([
    {
         "start": startTime+5*pattern+6*beat, "duration":2*beat
        ,"layer": 53331, "image": ["data/empty.png"]
		,"scale":[{"x":2,"y":3.55}]
		,"color":[{"a":0}
			,{"duration":2*beat,"a":255}
			]	
    }]);
			this.loader.addAnimation([
    {
         "start": startTime+6*pattern, "duration":4*beat
        ,"layer": 53331, "image": ["data/empty.png"]
		,"scale":[{"x":2,"y":3.55}]
		,"color":[{"a":255}
			,{"duration":4*beat,"a":0}
			]	
    }]);
	
				this.loader.addAnimation([
    {
         "start": startTime+7*pattern+4*beat, "duration":4*beat
        ,"layer": 53331, "image": ["data/empty.png"]
		,"scale":[{"x":2,"y":3.55}]
		,"color":[{"a":0}
			,{"duration":4*beat,"a":255}
			]	
    }]);
	
//light2
	this.loader.addAnimation([
	{
		 "start": startTime, "duration": duration, "light":{"index":3, "action":"begin"}
		,"layer": 20000
		,"diffuseColor":[
			 {"r":355, "g":255, "b":355, "a":255}
		]
		,"ambientColor":[
				 {"r":255, "g":255, "b":255, "a":255}
		]
		,"specularColor":[
			 {"r":255, "g":255, "b":255, "a":255}
		]
		,"position":[
			 {"x":-50.0, "y":5.0, "z":-50}]
	}]);
	

			this.loader.addAnimation([
	{
		 "start": startTime, "duration": duration, "light":{"index":4, "action":"begin"}
		,"layer": 20000
		,"diffuseColor":[
			 {"r":355, "g":255, "b":355, "a":255}
		]
		,"ambientColor":[
				 {"r":255, "g":255, "b":255, "a":255}
		]
		,"specularColor":[
			 {"r":255, "g":255, "b":255, "a":255}
		]

		,"position":[
		{"x":"{return 30*Math.sin(-50+.1*getSceneTimeFromStart()-pattern);}"
		,"y":0
		,"z":"{return 30*Math.cos(-50+.1*getSceneTimeFromStart()-pattern);}"
		}]
	}]);
	
//kamerat
	this.loader.addAnimation([
	{
		 "start": startTime, "duration": 2*pattern, "camera": "Cam01"
		,"layer": 20000
		
		,"target":[
			 {"x":0.0, "y":0.0, "z":0.0}

		]
		,"up":[
			 {"x":0, "y":1.0, "z":0}
		]
		,"position":[
		{"x":"{return (getSceneTimeFromStart()-pattern-89)*Math.sin(.2*getSceneTimeFromStart()-pattern-16);}"
		,"y":0
		,"z":"{return (getSceneTimeFromStart()-pattern-89)*Math.cos(.2*getSceneTimeFromStart()-pattern-16);}"
		}]
	}]);
	//kamera 2
	this.loader.addAnimation([
	{
		 "start": startTime+2*pattern, "duration": duration, "camera": "Cam01"
		,"layer": 20000
		,"target":[
			 {"x":0.0, "y":0.0, "z":0.0}
		]
		,"up":[
			 {"x":0, "y":1.0, "z":0}
		]
		,"position":[
		{"x":"{return -10*Math.sin(18-.1*getSceneTimeFromStart()-pattern);}"
		,"y":0
		,"z":"{return -10*Math.cos(18-.1*getSceneTimeFromStart()-pattern);}"
		}]
		
	}]);
//kamera 3
	this.loader.addAnimation([
	{
		 "start": startTime+4*pattern, "duration": .5*pattern, "camera": "Cam01"
		,"layer": 20000
		
		,"target":[
			 {"x":0.0, "y":0.0, "z":0.0}

		]
		,"up":[
			 {"x":Math.random(), "y":Math.random(), "z":Math.random()}
		]
		,"position":[
		{"x":"{return -10*Math.sin(.2*getSceneTimeFromStart()-pattern);}"
		,"y":0
		,"z":"{return -10*Math.cos(.2*getSceneTimeFromStart()-pattern);}"
		}]
	}]);

//kamera 4
	this.loader.addAnimation([
	{
		 "start": startTime+4.5*pattern, "duration": .5*pattern, "camera": "Cam01"
		,"layer": 20000
		
		,"target":[
			 {"x":0.0, "y":0.0, "z":0.0}

		]
		,"up":[
			 {"x":Math.random(), "y":Math.random(), "z":Math.random()}
		]
		,"position":[
		{"x":"{return -10*Math.sin(.2*getSceneTimeFromStart()-pattern);}"
		,"y":0
		,"z":"{return -10*Math.cos(.2*getSceneTimeFromStart()-pattern);}"
		}]
	}]);

	//kamera 5
	this.loader.addAnimation([
	{
		 "start": startTime+5*pattern, "duration": .5*pattern, "camera": "Cam01"
		,"layer": 20000
		
		,"target":[
			 {"x":0.0, "y":0.0, "z":0.0}

		]
		,"up":[
			 {"x":Math.random(), "y":Math.random(), "z":Math.random()}
		]
		,"position":[
		{"x":"{return -10*Math.sin(10+.2*getSceneTimeFromStart()-pattern);}"
		,"y":0
		,"z":"{return -10*Math.cos(10+.2*getSceneTimeFromStart()-pattern);}"
		}]
	}]);

//kamera 6
	this.loader.addAnimation([
	{
		 "start": startTime+5.5*pattern, "duration": .5*pattern, "camera": "Cam01"
		,"layer": 20000
		
		,"target":[
			 {"x":0.0, "y":0.0, "z":0.0}

		]
		,"up":[
			 {"x":Math.random(), "y":Math.random(), "z":Math.random()}
		]
		,"position":[
		{"x":"{return -10*Math.sin(.2*getSceneTimeFromStart()-pattern);}"
		,"y":0
		,"z":"{return -10*Math.cos(.2*getSceneTimeFromStart()-pattern);}"
		}]
	}]);

//kamera 7
	this.loader.addAnimation([
	{
		 "start": startTime+6*pattern, "duration": 2*pattern, "camera": "Cam01"
		,"layer": 20000
		
		,"target":[
			 {"x":0.0, "y":0.0, "z":0.0}

		]
		,"up":[
			 {"x":0, "y":0, "z":1.0}
		]
		,"position":[
		{"x":0
		,"y":1
		,"z":0
		}
		,{"duration":2*pattern,"y":23}]
	}]);
	
	
		//planet 1	
	this.loader.addAnimation([
		{
		"start": startTime, "duration": pattern*2, "object":"data/planet1.obj"
		,"layer": 20000
		
		,"position": [{"x":0,"y":0.0,"z":0}]
		,"scale": [{"x":1.01,"y":1.01,"z":1.01}]
		}]);
		
	this.loader.addAnimation([
		{
		"start": startTime+2*pattern, "duration": .5*pattern, "object":"data/lussu.obj"
		,"layer": 20000
		,"position": [{"x":0,"y":0.0,"z":0}]
		,"scale": [{"x":1.35,"y":1.35,"z":1.35}]
		,"angle": [{"degreesX":0,"degreesY":20,"degreesZ":20}]
		}]);		

			this.loader.addAnimation([
		{
		"start": startTime+2*pattern+beat*2, "duration": .25*pattern, "object":"data/lussulaser.obj"
		,"layer": 20000
		,"position": [{"x":0,"y":0.0,"z":0}]
		,"scale": [{"x":1.35,"y":1.35,"z":1.35}]
		,"angle": [{"degreesX":0,"degreesY":20,"degreesZ":20}]
		}]);		

		
		this.loader.addAnimation([
		{
		"start": startTime+2.5*pattern, "duration": beat*.5, "object":"data/planet1.obj"
		,"layer": 20000
		,"position": [{"x":0,"y":0.0,"z":0}]
		,"scale": [{"x":1.01,"y":1.01,"z":1.01}]
		}]);
		
// 1
		this.explosion(startTime+2.5*pattern+beat*.5,4.5*pattern-beat*.5,0,0,0,.5,15,255,255,255,2,1);	

				this.loader.addAnimation([
				{
				"start": startTime+4*pattern, "duration": beat*.5, "object":"data/planet1.obj"
				,"layer": 20000
				,"position": [{"x":0,"y":0.0,"z":0}]
				,"scale": [{"x":1.01,"y":1.01,"z":1.01}]
				}]);
				
		this.explosion(startTime+4*pattern+beat*.5,.5*pattern-beat*.5,0,0,0,.5,15,255,255,255,2,1);	
		// 2

				this.loader.addAnimation([
				{
				"start": startTime+4.5*pattern, "duration": beat*.5, "object":"data/planet1.obj"
				,"layer": 20000
				,"position": [{"x":0,"y":0.0,"z":0}]
				,"scale": [{"x":1.01,"y":1.01,"z":1.01}]
				}]);
				
		this.explosion(startTime+4.5*pattern+beat*.5,.5*pattern-beat*.5,0,0,0,.5,15,255,255,255,2,1);	

// 1

				this.loader.addAnimation([
				{
				"start": startTime+5*pattern, "duration": beat*.5, "object":"data/planet1.obj"
				,"layer": 20000
				,"position": [{"x":0,"y":0.0,"z":0}]
				,"scale": [{"x":1.01,"y":1.01,"z":1.01}]
				}]);
				
		this.explosion(startTime+5*pattern+beat*.5,.5*pattern-beat*.5,0,0,0,.5,15,255,255,255,2,1);	
		// 2

				this.loader.addAnimation([
				{
				"start": startTime+5.5*pattern, "duration": beat*.5, "object":"data/planet1.obj"
				,"layer": 20000
				,"position": [{"x":0,"y":0.0,"z":0}]
				,"scale": [{"x":1.01,"y":1.01,"z":1.01}]
				}]);
				
		this.explosion(startTime+5.5*pattern+beat*.5,.5*pattern-beat*.5,0,0,0,.5,15,255,255,255,2,1);	

		

	
		
			this.loader.addAnimation([
    {
         "start": startTime+6*pattern, "duration":2*pattern
        ,"layer": 22331, "image": ["data/pentagram.png"]
		,"scale":[{"x":.5,"y":.5}
		,{"duration":16*beat,"x":1.2,"y":1.2}]
		,"position":[{"x":640,"y":360}]
		,"color":[{"a":0}
			,{"duration":8*beat,"a":155}
			,{"duration":pattern,"a":0}
			
			]
    }]);	
// asdfasdf
	/*
	//planet 1	
	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/planet_1.obj"
		,"layer": 20000
		,"position": [{"x":0,"y":0.0,"z":0}]
		,"scale": [{"x":0.01,"y":0.01,"z":0.01}]
		}]);
		
	//planet 2	
	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/planet_1.obj"
		,"layer": 20000
		,"scale": [{"x":0.01,"y":0.01,"z":0.01}]
		,"position":[
			{"x":"{return 10*Math.sin(5+getSceneTimeFromStart()-pattern);}"
			,"y":0
			,"z":"{return 10*Math.cos(5+getSceneTimeFromStart()-pattern);}"
			}]
		}]);

	//planet 3
	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/planet_1.obj"
		,"layer": 20000
		,"scale": [{"x":0.01,"y":0.01,"z":0.01}]
		,"position":[
			{"x":"{return 20*Math.sin(12+getSceneTimeFromStart()-pattern);}"
			,"y":0
			,"z":"{return 20*Math.cos(12+getSceneTimeFromStart()-pattern);}"
			}]
		}]);
		
	//planet 3
	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/planet_1.obj"
		,"layer": 20000
		,"scale": [{"x":0.01,"y":0.01,"z":0.01}]
		,"position":[
			{"x":"{return 30*Math.sin(9+getSceneTimeFromStart()-pattern);}"
			,"y":0
			,"z":"{return 30*Math.cos(9+getSceneTimeFromStart()-pattern);}"
			}]
		}]);

	//planet 3
	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/planet_1.obj"
		,"layer": 20000
		,"scale": [{"x":0.01,"y":0.01,"z":0.01}]
		,"position":[
			{"x":"{return 40*Math.sin(getSceneTimeFromStart()-pattern);}"
			,"y":0
			,"z":"{return 40*Math.cos(getSceneTimeFromStart()-pattern);}"
			}]
		}]);

	//planet 3
	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/planet_1.obj"
		,"layer": 20000
		,"scale": [{"x":0.01,"y":0.01,"z":0.01}]
		,"position":[
			{"x":"{return 50*Math.sin(getSceneTimeFromStart()-pattern);}"
			,"y":0
			,"z":"{return 50*Math.cos(getSceneTimeFromStart()-pattern);}"
			}]
		}]);
		
		
*/
	
	//valot pois		
	
	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "light":{"index":3, "action":"end"}
		,"layer": 20000
		}]);

	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "light":{"index":4, "action":"end"}
		,"layer": 20000
		}]);	
		

		
		this.explosion2(startTime+6.0*pattern,2*pattern,1.8,0,-2.8,.1,2,255,255,255,.4,10);	

		this.explosion2(startTime+6.0*pattern,2*pattern,-1.8,0,-2.8,.1,2,255,255,255,.4,10);	
	
		this.explosion2(startTime+6.0*pattern,2*pattern,-2.9,0,.65,.1,2,255,255,255,.4,10);	

		this.explosion2(startTime+6.0*pattern,2*pattern,2.9,0,.65,.1,2,255,255,255,.4,10);	

		this.explosion2(startTime+6.0*pattern,2*pattern,0,0,2.8,.1,2,255,255,255,.4,10);	
		
		this.loader.addAnimation([
		{
		"start": startTime+6*pattern, "duration": 2*pattern, "object":"data/planet1.obj"
				     ,"shader":{
            "name":"data/shader/tunnel.fs",
            "variable":[
                  {"name":"time","value":["{return getSceneTimeFromStart()-pattern;}"]}
            ]
        }
		,"layer": 20000
		,"position": [{"x":0,"y":0.0,"z":-.2}]
		,"scale": [{"x":0.5,"y":0.5,"z":0.5}]
			,"angle": [{"degreesZ":0,"degreesX":0,"degreesY":0}]
		}]);
		

			this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/galaxy.obj"
		,"layer": 20001
		,"position": [{"z":0,"y":0.0,"x":0.0}]
		,"angle": [{"degreesX":0,"degreesY":0,"degreesZ":0}]
		,"scale": [{"x":21.6,"y":21.6,"z":21.6}]
		}]);		
	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/spacesphere.obj"
		,"layer": 20001
		,"position": [{"z":0,"y":0.0,"x":0.0}]
		,"scale": [{"x":1.2,"y":1.7,"z":1.7}]
		}]);

	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/spacesphere.obj"
		,"layer": 20001
		,"position": [{"z":0,"y":0.0,"x":0.0}]
		,"angle": [{"degreesX":250,"degreesY":0,"degreesZ":180}]
		,"scale": [{"x":-0.6,"y":-0.6,"z":-0.6}]
		}]);		


		
}

Demo.prototype.allseeing = function (startTime, duration)
{		

//light2
					this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/galaxy.obj"
		,"layer": 40000
		,"position": [{"z":0,"y":0.0,"x":0.0}]
		,"angle": [{"degreesX":0,"degreesY":0,"degreesZ":0}]
		,"scale": [{"x":21.6,"y":25.6,"z":21.6}]
		}]);		
		
	
//kamerat
	this.loader.addAnimation([
	{
		 "start": startTime, "duration": 2*pattern, "camera": "Cam01"
		,"layer": 20000
		
		,"target":[
			 {"x":0.0, "y":-17.0, "z":0.0}
	,{"duration":1*pattern,"y":-20}		 
	,{"duration":1*pattern,"y":-55}
		]
		,"up":[
			 {"x":0, "y":-1.0, "z":0}
	,{"duration":1*pattern,"z":.4}		 
 
		]
				,"position":[
		{"x":"{return 46*Math.sin(.2*getSceneTimeFromStart()-pattern);}"
		,"y":-12
		,"z":"{return 46*Math.cos(.2*getSceneTimeFromStart()-pattern);}"
		}
		,{"duration":2*pattern,"y":-40}
		]
	
		
	}]);
//text

	this.loader.addAnimation([
    {
         "start": startTime+2*pattern, "duration":pattern
        ,"layer": 53331, "image": ["data/text1.png"]
		,"scale":[{"x":1,"y":1}]
		,"color":[{"a":255}
			,{"duration":pattern,"a":0}
			]	
    }]);


	this.loader.addAnimation([
    {
         "start": startTime+3*pattern, "duration":pattern
        ,"layer": 53331, "image": ["data/text4.png"]
		,"scale":[{"x":1,"y":1}]
		,"color":[{"a":255}
			,{"duration":pattern,"a":0}
			]	
    }]);
	this.loader.addAnimation([
    {
         "start": startTime+4*pattern, "duration":pattern
        ,"layer": 53331, "image": ["data/text5.png"]
		,"scale":[{"x":1,"y":1}]
		,"color":[{"a":255}
			,{"duration":pattern,"a":0}
			]	
    }]);

		this.loader.addAnimation([
    {
         "start": startTime+5*pattern, "duration":pattern
        ,"layer": 53331, "image": ["data/text6.png"]
		,"scale":[{"x":1,"y":1}]
		,"color":[{"a":255}
			,{"duration":pattern,"a":0}
			]	
    }]);
	
	
	this.loader.addAnimation([
	{
		 "start": startTime+2*pattern, "duration": 8*pattern, "camera": "Cam01"
		,"layer": 20000
		
		,"target":[
			 {"x":0.0, "y":-55.0, "z":0.0}
		]
		,"up":[
			 {"x":0, "y":-1.0, "z":.4}
	 
		]
				,"position":[
		{"x":"{return Sync.getSyncValue('allseeingcamerax');}"
		,"y":"{return Sync.getSyncValue('allseeingcameray');}"
		,"z":"{return Sync.getSyncValue('allseeingcameraz');}"
		}]
	
		
	}]);

			
	this.loader.addAnimation([
		{
		"start": startTime+4*pattern, "duration": duration-2*pattern, "object":"data/eyelaser.obj"
		,"layer": 20000
		,"position": [{"x":0,"y":-50.4,"z":0}]
		,"scale": [{"x":.5,"y":.5,"z":.5}]
	,"angle": [{"degreesZ":0,"degreesX":0,"degreesY":"{return 125*getSceneTimeFromStart()-pattern;}"}]
		}]);
	this.loader.addAnimation([
		{
		"start": startTime+4*pattern, "duration": duration-2*pattern, "object":"data/eyelaser.obj"
		,"layer": 20000
		,"position": [{"x":0,"y":-50.4,"z":0}]
		,"scale": [{"x":.5,"y":.5,"z":.5}]
	,"angle": [{"degreesZ":0,"degreesX":0,"degreesY":"{return 90+125*getSceneTimeFromStart()-pattern;}"}]
		}]);	
	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/all_seeing_head.obj"
		,"layer": 20000
		,"position": [{"x":0,"y":0.0,"z":0}
		,{"duration":2*pattern,"y":-50}]
		,"scale": [{"x":0.5,"y":0.5,"z":0.5}]
			,"angle": [{"degreesZ":0,"degreesX":0,"degreesY":"{return 125*getSceneTimeFromStart()-pattern;}"}]
		}]);

	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/all_seeing_tentacle_1.obj"
		,"layer": 20000
		,"position": [{"x":0,"y":0.0,"z":0}
			,{"duration":2*pattern,"y":-50}]
		,"scale": [{"x":-0.5,"y":0.5,"z":0.5}]
		,"angle": [{"degreesZ":"{return zRange*.5-getSlowRandom(3,zRange);}","degreesX":"{return xRange*.5-getSlowRandom(4,xRange);}","degreesY":"{return -170*getSceneTimeFromStart()-pattern;}"}]
		}]);
	
	
	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/all_seeing_tentacle_2.obj"
		,"layer": 20000
		,"position": [{"x":0,"y":0.0,"z":0}
			,{"duration":2*pattern,"y":-50}]
		,"scale": [{"x":-0.5,"y":0.5,"z":0.5}]
		,"angle": [{"degreesZ":"{return zRange*.5-getSlowRandom(6,zRange);}","degreesX":"{return xRange*.5-getSlowRandom(7,xRange);}","degreesY":"{return 177*getSceneTimeFromStart()-pattern;}"}]
		}]);
	
	
	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/all_seeing_tentacle_3.obj"
		,"layer": 20000
		,"position": [{"x":0,"y":0.0,"z":0}
			,{"duration":2*pattern,"y":-50}]
		,"scale": [{"x":-0.5,"y":0.5,"z":0.5}]
		,"angle": [{"degreesZ":"{return zRange*.5-getSlowRandom(9,zRange);}","degreesX":"{return xRange*.5-getSlowRandom(10,xRange);}","degreesY":"{return -144*getSceneTimeFromStart()-pattern;}"}]
		}]);
	
	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/all_seeing_tentacle_0.obj"
		,"layer": 20000
		,"position": [{"x":0,"y":0.0,"z":0}
			,{"duration":2*pattern,"y":-50}]
		,"scale": [{"x":0.5,"y":0.5,"z":0.5}]
		,"angle": [{"degreesZ":"{return zRange*.5-getSlowRandom(11,zRange);}","degreesX":"{return xRange*.5-getSlowRandom(12,xRange);}","degreesY":"{return -184*getSceneTimeFromStart()-pattern;}"}]
		}]);	
		
			this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/all_seeing_tentacle_1.obj"
		,"layer": 20000
		,"position": [{"x":0,"y":0.0,"z":0}
			,{"duration":2*pattern,"y":-50}]
		,"scale": [{"x":0.5,"y":0.5,"z":0.5}]
		,"angle": [{"degreesZ":"{return zRange*.5-getSlowRandom(13,zRange);}","degreesX":"{return xRange*.5-getSlowRandom(14,xRange);}","degreesY":"{return 184*getSceneTimeFromStart()-pattern;}"}]
		}]);
		
			this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/all_seeing_tentacle_2.obj"
		,"layer": 20000
		,"position": [{"x":0,"y":0.0,"z":0}
			,{"duration":2*pattern,"y":-50}]
		,"scale": [{"x":0.5,"y":0.5,"z":0.5}]
		,"angle": [{"degreesZ":"{return zRange*.5-getSlowRandom(15,zRange);}","degreesX":"{return xRange*.5-getSlowRandom(16,xRange);}","degreesY":"{return -244*getSceneTimeFromStart()-pattern;}"}]
		}]);
		
			this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/all_seeing_tentacle_3.obj"
		,"layer": 20000
		,"position": [{"x":0,"y":0.0,"z":0}
			,{"duration":2*pattern,"y":-50}]
		,"scale": [{"x":0.5,"y":0.5,"z":0.5}]
		,"angle": [{"degreesZ":"{return zRange*.5-getSlowRandom(17,zRange);}","degreesX":"{return xRange*.5-getSlowRandom(18,xRange);}","degreesY":"{return 214*getSceneTimeFromStart()-pattern;}"}]
		}]);
		
		this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/all_seeing_4_tentacles.obj"
		,"layer": 20000
		,"position": [{"x":0,"y":0.0,"z":0}
			,{"duration":2*pattern,"y":-50}]
		,"scale": [{"x":0.5,"y":0.5,"z":0.5}]
					,"angle": [{"degreesZ":0,"degreesX":0,"degreesY":"{return -125*getSceneTimeFromStart()-pattern;}"}]
		}]);		
			

	
	//valot pois		
	

		
	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/spacesphere.obj"
		,"layer": 20001
		,"position": [{"z":0,"y":0.0,"x":0.0}]
		,"scale": [{"x":1.2,"y":1.7,"z":1.7}]
		}]);

	this.loader.addAnimation([
		{
		"start": startTime, "duration": duration, "object":"data/spacesphere.obj"
		,"layer": 20001
		,"position": [{"z":0,"y":0.0,"x":0.0}]
		,"angle": [{"degreesX":250,"degreesY":0,"degreesZ":180}]
		,"scale": [{"x":-0.6,"y":-0.6,"z":-0.6}]
		}]);		
		

		this.loader.addAnimation([
					{
					"start": startTime, "duration": 2*pattern, "object":"data/burn.obj"
					,"layer": 22001
					,"image": ["data/noise.png","data/noise.png"]
					,"position": [{"z":-2,"y":-0.45,"x":0.0}]
					
					,"angle": [{"degreesX":15,"degreesZ":180,"degreesY":"{return -30-getSceneTimeFromStart()-pattern*50}"}]

					,"scale": [{"x":-2.385,"y":2.385,"z":2.385}]
						     ,"shader":{
						"name":"data/shader/fire.fs",
						"variable":[
						{"name":"time","value":["{return 10+getSceneTimeFromStart()-pattern;}"]}
						]
        }
					}]);
	

		
		this.loader.addAnimation([
		{
		"start": startTime, "duration": 2*pattern, "object":"data/planet1.obj"
				     ,"shader":{
            "name":"data/shader/tunnel.fs",
            "variable":[
                  {"name":"time","value":["{return getSceneTimeFromStart()-pattern;}"]}
            ]
        }
		,"layer": 20000
		,"position": [{"x":0,"y":5.0,"z":0}]
		,"scale": [{"x":13.5,"y":13.5,"z":13.5}]
			,"angle": [{"degreesZ":0,"degreesX":0,"degreesY":0}]
		}]);
		
			
}

Demo.prototype.distortion = function(startTime, duration, startLayer, endLayer, layer)
{
	this.loader.addAnimation ([
	{
	"start": startTime, "duration": duration
	,"layer": startLayer
	,"fbo":{"name":"fbodist","action":"begin"}
	},
	{
	"start": startTime, "duration": duration
	,"layer": endLayer,"fbo":{"name":"fbodist","action":"unbind"}
	}
	]);
	this.loader.addAnimation ([
	{
		 "start": startTime, "duration": duration
		,"image": "fbodist.color.fbo"
		,"layer": layer
		,"shader":{"name":"data/shader/distortion.fs",
			"variable":[
				 {"name":"time","value":["{return getSceneTimeFromStart()-pattern;}"]}
				,{"name":"timeMultiplier","value":[5.9]}
				,{"name":"pixelSize","value":["{return Math.random()*0.02;}",0.4]}
				,{"name":"noiseWaveSpeed","value":[-1]}
				,{"name":"noiseWaveSize","value":[40]}
				,{"name":"noiseLuminance","value":[1]}
				,{"name":"noiseAlpha","value":[0.0]}
				,{"name":"colorComponentDistortionX","value":[0.1,0.0,0.1,0.5]}
				,{"name":"colorComponentDistortionY","value":[0.1,0.0,0.1,0.5]}
				,{"name":"distortionAmount","value":["{return Sync.getSyncValue('distortionamount');}"]}
			]
			}
		}]);
}

Demo.prototype.brightnessContrast = function (startTime, duration, startLayer, endLayer, layer, brightness, contrast)
{
	this.loader.addAnimation ([
	{
	"start": startTime, "duration": duration
	,"layer": startLayer
	,"fbo":{"name":"fbobc","action":"begin"}
	},
	{
	"start": startTime, "duration": duration
	,"layer": endLayer,"fbo":{"name":"fbobc","action":"unbind"}
	}
	]);
	this.loader.addAnimation ([
	    {
	         "start": startTime, "duration":duration
	        ,"layer": layer, "image": ["fbobc.color.fbo"]
		 ,"initFunction":"{fboBcImage = imageLoadImage('fbobc.color.fbo'); setTextureSizeToScreenSize(fboBcImage.ptr); }"
		 ,"runFunction":"{setTextureSizeToScreenSize(fboBcImage.ptr);}"
		 ,"brightness": brightness
		 ,"contrast": contrast
		 ,"beat": beat
	     ,"shader":{
	            "name":"data/shader/brightnesscontrast.fs",
	            "variable":[
	                  {"name":"time","value":["{return getSceneTimeFromStart()-pattern;}"]}
					 ,{"name":"brightness","value":["{return Sync.getSyncValue('brightnessamount');}"]}
					 ,{"name":"contrast","value":[contrast]}
	            ]
	        }
	    }
	]);
	
	
}

Demo.prototype.edgeGlow = function (startTime, duration, startLayer, endLayer, layer)
{
	this.loader.addAnimation ([
	{
	"start": startTime, "duration": duration
	,"layer": startLayer
	,"fbo":{"name":"fboeg","action":"begin"}
	},
	{
	"start": startTime, "duration": duration
	,"layer": endLayer,"fbo":{"name":"fboeg","action":"unbind"}
	}
	]);
	this.loader.addAnimation ([
	    {
	         "start": startTime, "duration":duration
	        ,"layer": layer, "image": ["fboeg.color.fbo"]
		 ,"initFunction":"{fboegImage = imageLoadImage('fboeg.color.fbo'); setTextureSizeToScreenSize(fboegImage.ptr); }"
		 ,"runFunction":"{setTextureSizeToScreenSize(fboegImage.ptr);}"
	     ,"shader":{
	            "name":"data/shader/edgeglow.fs",
	            "variable":[
	                  {"name":"time","value":["{return getSceneTimeFromStart()-pattern;}"]}
	            ]
	        }
	    }
	]);
}

Demo.prototype.fullScreenNoise = function (sceneStartTime, duration, layer, alpha)
{
	this.loader.addAnimation([
    {
         "start": sceneStartTime, "duration":duration
        ,"layer": layer, "image": ["data/empty.png"]
     ,"shader":{
            "name":"data/shader/noise.fs",
            "variable":[
                  {"name":"time","value":["{return slowTime();}"]},
				  {"name":"alphaBlending","value":[alpha]}
            ]
        }
    }
]);
}

Demo.prototype.explosion = function(startTime, duration, positionX, positionY, positionZ, scale, randomScaler, colorR, colorG, colorB, startRandomScaler,durationScaler)
{

	for(ie=0;ie<150;ie++)
	{
	
	cubeNumber++;
	var randomScale = Math.random();

	
				this.loader.addAnimation([
						{
						"start": startTime, "duration": duration,  "object":"cubes"+cubeNumber,"shape":{"type":"CUBE"}
						,"layer": 39100
						
						,"position": [{"x":positionX+Math.random()*startRandomScaler*.2-Math.random()*startRandomScaler*.2,"y":positionY+Math.random()*startRandomScaler*.2-Math.random()*startRandomScaler*.2,"z":positionZ+Math.random()*startRandomScaler*.2-Math.random()*startRandomScaler*.2}
						,{"duration":duration*durationScaler,
						"x":positionX+Math.random()*randomScaler*3-Math.random()*randomScaler*3,
						"y":positionY+Math.random()*randomScaler*3-Math.random()*randomScaler*3,
						"z":positionZ+Math.random()*randomScaler*3-Math.random()*randomScaler*3}]
						,"scale":[{"x":scale*randomScale,"y":scale*randomScale,"z":scale*randomScale}]
						,"color":[{"r":255*colorR,"g":255*colorG,"b":255*colorB,"a":255}
						,{"duration":duration*durationScaler, "a":0}]
						,"angle": [{"degreesX":Math.random()*360,"degreesY":Math.random()*360,"degreesZ":Math.random()*360}
						,{"duration":duration*durationScaler,"degreesX":Math.random()*360,"degreesY":Math.random()*360,"degreesZ":Math.random()*360}]
						
						//---
						
					}]);
	}
}


Demo.prototype.explosion2 = function(startTime, duration, positionX, positionY, positionZ, scale, randomScaler, colorR, colorG, colorB, startRandomScaler,durationScaler)
{

	for(ie=0;ie<30;ie++)
	{
	
	cubeNumber++;
	var randomScale = Math.random();

	
				this.loader.addAnimation([
						{
						"start": startTime, "duration": duration,  "object":"cubes"+cubeNumber,"shape":{"type":"CUBE"}
						,"layer": 39100
						
						,"position": [{"x":positionX+Math.random()*startRandomScaler*.2-Math.random()*startRandomScaler*.2,"y":positionY+Math.random()*startRandomScaler*.2-Math.random()*startRandomScaler*.2,"z":positionZ+Math.random()*startRandomScaler*.2-Math.random()*startRandomScaler*.2}
						,{"duration":duration*durationScaler,
						"x":positionX+Math.random()*randomScaler*3-Math.random()*randomScaler*3,
						"y":positionY+Math.random()*randomScaler*3-Math.random()*randomScaler*3,
						"z":positionZ+Math.random()*randomScaler*3-Math.random()*randomScaler*3}]
						,"scale":[{"x":scale*randomScale,"y":scale*randomScale,"z":scale*randomScale}]
						,"color":[{"r":255*colorR,"g":255*colorG,"b":255*colorB,"a":255}
						,{"duration":duration*durationScaler, "a":0}]
						,"angle": [{"degreesX":Math.random()*360,"degreesY":Math.random()*360,"degreesZ":Math.random()*360}
						,{"duration":duration*durationScaler,"degreesX":Math.random()*360,"degreesY":Math.random()*360,"degreesZ":Math.random()*360}]
						
						//---
						
					}]);
	}
}


Demo.prototype.hackGlow = function (startTime, duration, startLayer, endLayer, layer)
{
	this.loader.addAnimation ([
	{
	"start": startTime, "duration": duration
	,"layer": startLayer
	,"fbo":{"name":"fbohg","action":"begin"}
	},
	{
	"start": startTime, "duration": duration
	,"layer": endLayer,"fbo":{"name":"fbohg","action":"unbind"}
	}
	]);
	this.loader.addAnimation ([
	    {
	         "start": startTime, "duration":duration
	        ,"layer": layer, "image": ["fbohg.color.fbo"]
		 ,"initFunction":"{fbohgImage = imageLoadImage('fbohg.color.fbo'); setTextureSizeToScreenSize(fbohgImage.ptr); }"
		 ,"runFunction":"{setTextureSizeToScreenSize(fbohgImage.ptr);}"
	     ,"shader":{
	            "name":"data/shader/hackglow.fs",
	            "variable":[
	                  {"name":"time","value":["{return getSceneTimeFromStart()-pattern;}"]}
					
	            ]
	        }
	    }
	]);
}
function slowTime()
{

if (getSceneTimeFromStart()-pattern	> prevTime+.1)
	{
		prevTime=getSceneTimeFromStart()-pattern;
		return getSceneTimeFromStart()-pattern;
	}
	else
	return prevTime;

}


function perFrameCalculations()
{

	while (Input.hasEvents())
	{
		var event = Input.pollEvent();
		if (event.type == Input.type.KEYUP)
		{
			if (event.keyboard.symbol == Input.Keyboard.symbol.KEY_1)
			{
			prevRandTime=0;
			prevTime=0;
			}
		}
	}
	
if (getSceneTimeFromStart()-pattern	> prevRandTime+.1)
	{
		prevRandTime=getSceneTimeFromStart()-pattern;
	
		for (i=0;i<slowRandomValue.length;i++)
			slowRandomValue[i]=Math.random();
	}
 
}

function getSlowRandom(n,range)
{
	if(slowRandomTarget[n]==null)
		slowRandomTarget[n]=(slowRandomValue[n]*range)

	slowRandomTarget[n]=slowRandomTarget[n]+.005*((slowRandomValue[n]*range)-slowRandomTarget[n]);
	

	 print("range"+range);
		
return slowRandomTarget[n];
}

function getsyncValue()
{
	  screenPrint("syncorder "+syncOrder);
 
	if(getSceneTimeFromStart()-pattern>syncTime[syncOrder])
	{
		syncOrder++;
    }
	return syncOrder;

}
