var Utils=function(){};Utils.debugPrintStackTrace=function(){for(var c=["stack trace:"],a=0,b=-3;;b--){var e=Duktape.act(b);if(!e)break;if(""!=e.function.name){var k="\tstack: "+b,k=k+(", function: "+e.function.name),k=k+(", line: "+e.lineNumber),k=k+(", info: "+Duktape.enc("jx",e));c[++a]=k}}1<c.length&&debugPrint(c.join("\n"))};Utils.isString=function(c){return"string"===typeof c||c instanceof String?!0:!1};
Utils.evaluateVariable=function(c,a){return Utils.isString(a)&&"{"===a.charAt(0)?(new Function("animation",a))(c):a};Utils.deepCopyJson=function(c){var a=JSON.parse(JSON.stringify(c));void 0!==c.ptr&&(a.ptr=c.ptr);void 0!==c.ref&&void 0!==c.ref.ptr&&(a.ref.ptr=c.ref.ptr);return a};Utils.getRandomArrayIndex=function(c){if(void 0!==c.length)return Math.floor(random()*c.length)};
Utils.setTimeVariables=function(c,a,b,e){Utils.isString(c.start)&&(c.start=convertTimeToSeconds(c.start));Utils.isString(c.duration)&&(c.duration=convertTimeToSeconds(c.duration));Utils.isString(c.end)&&(c.end=convertTimeToSeconds(c.end));void 0===c.start&&(c.start=a);void 0===c.duration&&(void 0!==c.end?c.duration=c.end-c.start:(c.duration=e,c.end=c.start+c.duration));void 0===c.end&&(c.end=c.start+c.duration)};
Utils.preprocessTimeAnimation=function(c,a,b,e){if(void 0!==e)for(var k=0;k<e.length;k++){var f=e[k];this.setTimeVariables(f,c,b,a);c=f.end;a=f.duration;b=c+a}};var Shader=function(c){this.animation=c};
Shader.prototype.enableShader=function(){if(void 0!==this.animation.shader&&(activateShaderProgram(this.animation.shader.name),void 0!==this.animation.shader.variable))for(var c=getUniformLocation,a=glUniformi,b=glUniformf,e,k=this.animation.shader.variable.length,f=0;f<k;f++){var d=this.animation.shader.variable[f],h=c(d.name);e=b;"int"===d.type&&(e=a);for(var g=[],l=d.value.length,m=0;m<l;m++)g.push(Utils.evaluateVariable(this.animation,d.value[m]));switch(l){case 1:e(h,g[0]);break;case 2:e(h,g[0],
g[1]);break;case 3:e(h,g[0],g[1],g[2]);break;case 4:e(h,g[0],g[1],g[2],g[3])}}};Shader.prototype.disableShader=function(){void 0!==this.animation.shader&&disableShaderProgram()};var Sync=function(){};Sync.syncDefinitions={};Sync.addSync=function(c){for(var a=0,b=0,e=0,k=0;k<c.length;k++){var f=c[k];Utils.setTimeVariables(f,a,b,e);a=f.start;b=f.end;e=b-a;"rocket"===f.type&&(f.ref=syncEditorGetTrack(f.name));void 0===f.pattern&&(f.pattern=[{}],void 0===f.ref&&(f.pattern=[{start:a,duration:e}]));Utils.preprocessTimeAnimation(a,e,b,f.pattern);for(var d=0;d<f.pattern.length;d++){var h=f.pattern[d];h.started=!1;h.counter=0}Sync.syncDefinitions[f.name]=f}};
Sync.getSyncValue=function(c){c=Sync.syncDefinitions[c];return void 0!==c&&void 0!==c.ref?syncEditorGetTrackCurrentValue(c.ref.ptr):0};
Sync.calculateAnimationSync=function(c,a){if(void 0!==a.sync){var b=Sync.syncDefinitions[a.sync.name];if(void 0!==b){var e=c%b.end;a.sync.progress=0;if(void 0!==b.ref)a.sync.progress=syncEditorGetTrackCurrentValue(b.ref.ptr),void 0!==b.syncStartFunction&&void 0===b.started&&(b.started=!0,Utils.evaluateVariable(a,b.syncStartFunction)),void 0!==b.syncRunFunction&&Utils.evaluateVariable(a,b.syncRunFunction);else for(var k=b.pattern.length,f=0;f<k;f++){var d=b.pattern[f];e>=d.start&&e<d.end&&(a.sync.progress=
(e-d.start)/d.duration,1<a.sync.progress&&(a.sync.progress=1),d.started||(d.started=!0,d.startTime=c,void 0!==d.syncStartFunction?Utils.evaluateVariable(a,d.syncStartFunction):void 0!==b.syncStartFunction&&Utils.evaluateVariable(a,b.syncStartFunction)),void 0!==d.syncRunFunction?Utils.evaluateVariable(a,d.syncRunFunction):void 0!==b.syncRunFunction&&Utils.evaluateVariable(a,b.syncRunFunction));d.started&&(c>=d.startTime+d.duration||d.startTime>c)&&(d.started=!1,a.sync.progress=0,void 0!==d.syncEndFunction?
Utils.evaluateVariable(a,d.syncEndFunction):void 0!==b.syncEndFunction&&Utils.evaluateVariable(a,b.syncEndFunction))}}}};var Settings=function(){};Settings.demoScript="";Settings.sceneVariables={};Settings.processVariables=function(c){if(c.hasOwnProperty("variables")){Settings.sceneVariables[c.name]=c.variables;for(var a in c.variables){var b=c.variables[a];addTwVariable(c.name,a,b.type,b.definition)}}};
Settings.processDemoScript=function(){var c=readFile("data/js/script.json");Settings.demoScript=JSON.parse(c);Settings.sceneVariables={};setPlaylistMusic(Settings.demoScript.music);setPlaylistLength(Settings.demoScript.totalTime);void 0!==Settings.demoScript.screen&&(setScreenDimensions(Settings.demoScript.screen.width,Settings.demoScript.screen.height),void 0!==Settings.demoScript.screen.aspectRatio?setWindowScreenAreaAspectRatio(Settings.demoScript.screen.aspectRatio.width,Settings.demoScript.screen.aspectRatio.height):
setWindowScreenAreaAspectRatio(Settings.demoScript.screen.width,Settings.demoScript.screen.height));void 0!==Settings.demoScript.window&&void 0!==Settings.demoScript.window.title&&windowSetTitle(Settings.demoScript.window.title);void 0!==Settings.demoScript.clearColor&&setClearColor(Settings.demoScript.clearColor.r,Settings.demoScript.clearColor.g,Settings.demoScript.clearColor.b,Settings.demoScript.clearColor.a);void 0!==Settings.demoScript.beatsPerMinute&&timerSetBeatsPerMinute(Settings.demoScript.beatsPerMinute);
void 0!==Settings.demoScript.rowsPerBeat&&syncEditorSetRowsPerBeat(Settings.demoScript.rowsPerBeat);if(void 0!==Settings.demoScript.resolutions)for(c=0;c<Settings.demoScript.resolutions.length;c++)setMenuResolution(c,Settings.demoScript.resolutions[c].width+"x"+Settings.demoScript.resolutions[c].height),!0===Settings.demoScript.resolutions[c].default&&setMenuComponentSelected(c)};
Settings.processPlayer=function(){for(var c=0;void 0!==Settings.demoScript.shaders&&c<Settings.demoScript.shaders.length;c++){var a=Settings.demoScript.shaders[c];!0!==a.skip&&addShader(a.name,a.filename)}for(var b=0;void 0!==Settings.demoScript.shaderPrograms&&b<Settings.demoScript.shaderPrograms.length;b++){var e=Settings.demoScript.shaderPrograms[b];if(!0!==e.skip)for(addShaderProgram(e.name),c=0;c<e.shaders.length;c++)a=e.shaders[c],addShaderToProgramByName(e.name,a.name)}for(c=0;c<Settings.demoScript.effects.length;c++)a=
Settings.demoScript.effects[c],!0!==a.skip&&addPlayerEffect(a.name,a.reference);for(c=0;c<Settings.demoScript.scenes.length;c++)if(a=Settings.demoScript.scenes[c],!0!==a.skip&&(void 0===a.startTime&&(a.startTime="0:00"),void 0===a.durationTime&&(a.durationTime=Settings.demoScript.totalTime),addPlayerScene("",a.name,a.effect,a.startTime,a.durationTime),Settings.processVariables(a),!a.hasOwnProperty("effect")))for(b=0;b<a.scenes.length;b++)e=a.scenes[b],!0!==e.skip&&(addPlayerScene(a.name,e.name,e.effect,
e.startTime,e.durationTime),Settings.processVariables(e))};var Effect=function(){};Effect.effects=[];Effect.init=function(c){var a=eval("new "+c);Effect.effects[c]=a;void 0!==a.init&&a.init()};Effect.run=function(c){c=Effect.effects[c];void 0!==c.run&&c.run()};Effect.deinit=function(c){var a=Effect.effects[c];void 0!==a.deinit&&a.deinit();delete Effect.effects[c]};var Loader=function(){this.resourceCount=0;this.resourceUniqueList=[];this.animationLayers={}};Loader.prototype.preprocess3dCoordinateAnimation=function(c,a,b,e,k){if(void 0!==e)for(b=a=c=0,void 0!==k&&(c=k.x,a=k.y,b=k.z),k=0;k<e.length;k++){var f=e[k];void 0===f.x&&(f.x=c);void 0===f.y&&(f.y=a);void 0===f.z&&(f.z=b);c=f.x;a=f.y;b=f.z}};
Loader.prototype.preprocessColorAnimation=function(c,a,b,e,k){void 0!==e.sync&&void 0===e.sync.color&&(e.sync.color=!0===e.sync.all?!0:!1);var f=e=255,d=255,h=255;void 0===k&&(k=[{}]);Utils.preprocessTimeAnimation(c,a,b,k);for(c=0;c<k.length;c++)a=k[c],void 0===a.r&&(a.r=e),void 0===a.g&&(a.g=f),void 0===a.b&&(a.b=d),void 0===a.a&&(a.a=h),e=a.r,f=a.g,d=a.b,h=a.a};
Loader.prototype.preprocessAngleAnimation=function(c,a,b,e){if(void 0!==e.angle){void 0!==e.sync&&void 0===e.sync.angle&&(e.sync.angle=!0===e.sync.all?!0:!1);Utils.preprocessTimeAnimation(c,a,b,e.angle);this.preprocess3dCoordinateAnimation(c,a,b,e.angle,{x:1,y:1,z:1});for(var k=b=a=c=0,f=0,d=0,h=0;h<e.angle.length;h++){var g=e.angle[h];void 0===g.degreesX&&(g.degreesX=c);void 0===g.degreesY&&(g.degreesY=a);void 0===g.degreesZ&&(g.degreesZ=b);void 0!==g.pivot?(void 0===g.pivot.x&&(g.pivot.x=k),void 0===
g.pivot.y&&(g.pivot.y=f),void 0===g.pivot.z&&(g.pivot.z=d)):(g.pivot={},g.pivot.x=k,g.pivot.y=f,g.pivot.z=d);c=g.degreesX;a=g.degreesY;b=g.degreesZ;k=g.pivot.x;f=g.pivot.y;d=g.pivot.z}}};
Loader.prototype.preprocessPerspectiveAnimation=function(c,a,b,e){void 0!==e.sync&&void 0===e.sync.perspective&&(e.sync.perspective=!0===e.sync.all?!0:!1);void 0===e.perspective&&(e.perspective=[{}]);Utils.preprocessTimeAnimation(c,a,b,e.perspective);c=45;a=getWindowScreenAreaAspectRatio();b=1;for(var k=1E3,f=0;f<e.perspective.length;f++){var d=e.perspective[f];void 0===d.fov&&(d.fov=c);void 0===d.aspect&&(d.aspect=a);void 0===d.near&&(d.near=b);void 0===d.far&&(d.far=k);c=d.fov;a=d.aspect;b=d.near;
k=d.far}};Loader.prototype.preprocessScaleAnimation=function(c,a,b,e){void 0!==e.sync&&void 0===e.sync.scale&&(e.sync.scale=!0===e.sync.all?!0:!1);void 0===e.scale&&(e.scale=[{}]);Utils.preprocessTimeAnimation(c,a,b,e.scale);this.preprocess3dCoordinateAnimation(c,a,b,e.scale,{x:1,y:1,z:1})};
Loader.prototype.preprocessDimensionAnimation=function(c,a,b,e){void 0!==e.sync&&void 0===e.sync.dimension&&(e.sync.dimension=!0===e.sync.all?!0:!1);void 0===e.dimension&&(e.dimension=[{}]);Utils.preprocessTimeAnimation(c,a,b,e.dimension);this.preprocess3dCoordinateAnimation(c,a,b,e.dimension,{x:1,y:1,z:1})};
Loader.prototype.preprocessPositionAnimation=function(c,a,b,e,k){void 0!==e.position&&(void 0!==e.sync&&void 0===e.sync.position&&(e.sync.position=!0===e.sync.all?!0:!1),Utils.preprocessTimeAnimation(c,a,b,e.position),this.preprocess3dCoordinateAnimation(c,a,b,e.position,k))};
Loader.prototype.preprocessAnimationDefinitions=function(c,a,b,e){b=c=a=c;this.preprocessColorAnimation(c,b-c,b,e,e.color);b=c=a;this.preprocessAngleAnimation(c,b-c,b,e);b=c=a;this.preprocessScaleAnimation(c,b-c,b,e);b=c=a;this.preprocessPositionAnimation(c,b-c,b,e,{x:0,y:0,z:0})};Loader.prototype.addNotifyResource=function(c){return void 0!==c&&void 0===this.resourceUniqueList[c]?(this.resourceCount++,this.resourceUniqueList[c]=!1,setResourceCount(1),!0):!1};
Loader.prototype.notifyResourceLoaded=function(c){return void 0!==c&&!1===this.resourceUniqueList[c]?(this.resourceUniqueList[c]=!0,notifyResourceLoaded(),!0):!1};Loader.prototype.sortArray=function(c){return Object.keys(c).sort().reduce(function(a,b){a[b]=c[b];return a},{})};
Loader.prototype.addAnimation=function(c){for(var a="00001",b=0;b<c.length;b++){var e=c[b];void 0!==e.layer&&(a=e.layer);e.layer=a;void 0===this.animationLayers[a]&&(this.animationLayers[a]=[]);void 0!==e.object?this.addNotifyResource(e.object):void 0!==e.image?this.addNotifyResource(e.image)&&imageLoadImageAsync(e.image):void 0!==e.fbo&&this.addNotifyResource(e.fbo.name);void 0!==e.initFunction&&this.resourceCount++;this.animationLayers[a].push(e)}this.animationLayers=this.sortArray(this.animationLayers)};
Loader.prototype.processAnimation=function(){threadWaitAsyncCalls();var c=getSceneStartTime(),a=getSceneEndTime(),b=0,e;for(e in this.animationLayers)if(this.animationLayers.hasOwnProperty(e))for(var k=this.animationLayers[e].length,f=0;f<k;f++){var d=this.animationLayers[e][f];Utils.setTimeVariables(d,c,a,b);c=d.start;a=d.end;b=a-c;void 0!==d.sync&&void 0===d.sync.all&&(d.sync.all=!0);if(void 0!==d.object||void 0!==d.objectFunction){d.type="object";if(void 0!==d.object){if(void 0!==d.shape)if("SPHERE"===
d.shape.type){var h=1;void 0!==d.shape.radius&&(h=d.shape.radius);var g=30;void 0!==d.shape.lats&&(g=d.shape.lats);var l=30;void 0!==d.shape.longs&&(l=d.shape.longs);d.ref=setObjectSphereData(d.object,h,g,l)}else if("CYLINDER"===d.shape.type){g=1;void 0!==d.shape.base&&(g=d.shape.base);l=1;void 0!==d.shape.top&&(l=d.shape.top);var m=1;void 0!==d.shape.height&&(m=d.shape.height);h=30;void 0!==d.shape.slices&&(h=d.shape.slices);var n=30;void 0!==d.shape.stacks&&(n=d.shape.stacks);d.ref=setObjectCylinderData(d.object,
g,l,m,h,n)}else if("DISK"===d.shape.type)g=0,void 0!==d.shape.inner&&(g=d.shape.inner),l=1,void 0!==d.shape.outer&&(l=d.shape.outer),h=30,void 0!==d.shape.slices&&(h=d.shape.slices),m=30,void 0!==d.shape.loops&&(m=d.shape.loops),d.ref=setObjectDiskData(d.object,g,l,h,m);else if("CUBE"===d.shape.type)d.ref=setObjectCubeData(d.object);else{if("MATRIX"===d.shape.type||"CUSTOM"===d.shape.type)d.ref=loadObjectBasicShape(d.object,d.shape.type)}else d.ref=loadObject(d.object);!1===d.objectLighting&&useObjectLighting(d.ref.ptr,
0);!1===d.objectCamera&&useObjectCamera(d.ref.ptr,0);!0===Settings.demoScript.kanttuCompatibility&&void 0===d.objectLighting&&(d.objectLighting=!1)}void 0===d.fps&&(d.fps=0);void 0===d.camera&&(d.camera="Camera01");d.clearDepthBuffer=void 0===d.clearDepthBuffer?0:!0===d.clearDepthBuffer?1:0;h=c;g=a;l=g-h;this.preprocessAnimationDefinitions(h,l,g,d);this.notifyResourceLoaded(d.object)}else if(void 0!==d.image){d.type="image";d.image.constructor!==Array&&(d.image=[d.image]);d.ref=imageLoadImage(d.image[0]);
d.multiTexRef=[d.ref];for(h=1;h<d.image.length;h++)d.multiTexRef.push(imageLoadImage(d.image[h]));void 0===d.perspective&&(d.perspective="2d");h=c;g=a;l=g-h;this.preprocessAnimationDefinitions(h,l,g,d);this.notifyResourceLoaded(d.image)}else void 0!==d.text?(d.type="text",void 0===d.text.perspective?d.text.perspective="2d":"3d"===d.text.perspective&&(d.clearDepthBuffer=void 0===d.clearDepthBuffer?0:!0===d.clearDepthBuffer?1:0),h=c,g=a,l=g-h,this.preprocessAnimationDefinitions(h,l,g,d)):void 0!==d.fbo?
(d.type="fbo",void 0===d.fbo.name&&(d.fbo.name="fbo"),d.ref=fboInit(d.fbo.name),0===d.ref.id&&(fboStoreDepth(d.ref.ptr,!0===d.fbo.storeDepth?1:0),void 0!==d.fbo.width&&void 0!==d.fbo.height&&fboSetDimensions(d.ref.ptr,d.fbo.width,d.fbo.height),fboGenerateFramebuffer(d.ref.ptr)),g=h=c,l=g-h,this.preprocessDimensionAnimation(h,l,g,d),this.notifyResourceLoaded(d.fbo.name)):void 0!==d.light?(d.type="light",g=h=c,l=g-h,this.preprocessPositionAnimation(h,l,g,d,{x:0,y:0,z:1}),void 0!==d.ambientColor&&(g=
h=c,l=g-h,this.preprocessColorAnimation(h,l,g,d,d.ambientColor)),void 0!==d.diffuseColor&&(g=h=c,l=g-h,this.preprocessColorAnimation(h,l,g,d,d.diffuseColor)),void 0!==d.specularColor&&(g=h=c,l=g-h,this.preprocessColorAnimation(h,l,g,d,d.specularColor))):void 0!==d.camera&&(d.type="camera",g=h=c,l=g-h,this.preprocessPerspectiveAnimation(h,l,g,d),g=h=c,l=g-h,this.preprocessPositionAnimation(h,l,g,d,{x:0,y:0,z:2}),g=h=c,l=g-h,void 0!==d.sync&&void 0===d.sync.target&&(d.sync.target=!0===d.sync.all?!0:
!1),Utils.preprocessTimeAnimation(h,l,g,d.target),this.preprocess3dCoordinateAnimation(h,l,g,d.target,{x:0,y:0,z:0}),g=h=c,l=g-h,void 0!==d.sync&&void 0===d.sync.up&&(d.sync.up=!0===d.sync.all?!0:!1),Utils.preprocessTimeAnimation(h,l,g,d.up),this.preprocess3dCoordinateAnimation(h,l,g,d.up,{x:0,y:1,z:0}));void 0!==d.initFunction&&(Utils.evaluateVariable(d,d.initFunction),notifyResourceLoaded());c=a;a=c+b}};var Player=function(){};
Player.prototype.calculate3dCoordinateAnimation=function(c,a,b){var e={x:0,y:0,z:0};void 0!==b&&(e.x=b.x,e.y=b.y,e.z=b.z,void 0===b.sync&&void 0!==a.sync&&(b.sync=a.sync));if(void 0!==a){e.x=Utils.evaluateVariable(a,a[0].x);e.y=Utils.evaluateVariable(a,a[0].y);e.z=Utils.evaluateVariable(a,a[0].z);if(void 0!==a.sync&&!0===b.sync&&(c=a.start+a.duration*a.sync.progress,0==a.sync.progress))return e;b=interpolate;for(var k=a.length,f=0;f<k;f++){var d=a[f];if(c>=d.start){var h=(c-d.start)/d.duration;e.x=
b(h,e.x,Utils.evaluateVariable(a,d.x));e.y=b(h,e.y,Utils.evaluateVariable(a,d.y));e.z=b(h,e.z,Utils.evaluateVariable(a,d.z))}}}return e};Player.prototype.calculateScaleAnimation=function(c,a){return this.calculate3dCoordinateAnimation(c,a.scale,{x:1,y:1,z:1})};Player.prototype.calculatePositionAnimation=function(c,a){return this.calculate3dCoordinateAnimation(c,a.position,{x:0,y:0,z:0})};
Player.prototype.calculatePerspectiveAnimation=function(c,a){var b={fov:45,aspect:getWindowScreenAreaAspectRatio(),near:1,far:1E3};if(void 0!==a.perspective){b.fov=Utils.evaluateVariable(a,a.perspective[0].fov);b.aspect=Utils.evaluateVariable(a,a.perspective[0].aspect);b.near=Utils.evaluateVariable(a,a.perspective[0].near);b.far=Utils.evaluateVariable(a,a.perspective[0].far);var e=c;if(void 0!==a.sync&&!0===a.sync.perspective&&(e=a.start+a.duration*a.sync.progress,0==a.sync.progress))return b;for(var k=
interpolate,f=a.perspective.length,d=0;d<f;d++){var h=a.perspective[d];if(e>=h.start){var g=(e-h.start)/h.duration;b.fov=k(g,b.fov,Utils.evaluateVariable(a,h.fov));b.aspect=k(g,b.aspect,Utils.evaluateVariable(a,h.aspect));b.near=k(g,b.near,Utils.evaluateVariable(a,h.near));b.far=k(g,b.far,Utils.evaluateVariable(a,h.far))}}}return b};
Player.prototype.calculateColorAnimation=function(c,a,b){var e={r:255,g:255,b:255,a:255};if(void 0!==b){e.r=Utils.evaluateVariable(b,b[0].r);e.g=Utils.evaluateVariable(b,b[0].g);e.b=Utils.evaluateVariable(b,b[0].b);e.a=Utils.evaluateVariable(b,b[0].a);if(void 0!==a.sync&&!0===a.sync.color&&(c=a.start+a.duration*a.sync.progress,0==a.sync.progress))return e;for(var k=interpolate,f=0;f<b.length;f++){var d=b[f];if(c>=d.start){var h=(c-d.start)/d.duration;e.r=k(h,e.r,Utils.evaluateVariable(a,d.r));e.g=
k(h,e.g,Utils.evaluateVariable(a,d.g));e.b=k(h,e.b,Utils.evaluateVariable(a,d.b));e.a=k(h,e.a,Utils.evaluateVariable(a,d.a))}}}return e};
Player.prototype.calculateAngleAnimation=function(c,a){var b={degreesX:0,degreesY:0,degreesZ:0,x:1,y:1,z:1,pivot:{x:0,y:0,z:0}};if(void 0!==a.angle){b.degreesX=Utils.evaluateVariable(a,a.angle[0].degreesX);b.degreesY=Utils.evaluateVariable(a,a.angle[0].degreesY);b.degreesZ=Utils.evaluateVariable(a,a.angle[0].degreesZ);b.x=Utils.evaluateVariable(a,a.angle[0].x);b.y=Utils.evaluateVariable(a,a.angle[0].y);b.z=Utils.evaluateVariable(a,a.angle[0].z);b.pivot.x=Utils.evaluateVariable(a,a.angle[0].pivot.x);
b.pivot.y=Utils.evaluateVariable(a,a.angle[0].pivot.y);b.pivot.z=Utils.evaluateVariable(a,a.angle[0].pivot.z);var e=c;if(void 0!==a.sync&&!0===a.sync.angle&&(e=a.start+a.duration*a.sync.progress,0==a.sync.progress))return b;for(var k=interpolate,f=a.angle.length,d=0;d<f;d++){var h=a.angle[d];if(e>=h.start){var g=(e-h.start)/h.duration;b.degreesX=k(g,b.degreesX,Utils.evaluateVariable(a,h.degreesX));b.degreesY=k(g,b.degreesY,Utils.evaluateVariable(a,h.degreesY));b.degreesZ=k(g,b.degreesZ,Utils.evaluateVariable(a,
h.degreesZ));b.x=k(g,b.x,Utils.evaluateVariable(a,h.x));b.y=k(g,b.y,Utils.evaluateVariable(a,h.y));b.z=k(g,b.z,Utils.evaluateVariable(a,h.z));b.pivot.x=k(g,b.pivot.x,Utils.evaluateVariable(a,h.pivot.x));b.pivot.y=k(g,b.pivot.y,Utils.evaluateVariable(a,h.pivot.y));b.pivot.z=k(g,b.pivot.z,Utils.evaluateVariable(a,h.pivot.z))}}}return b};
Player.prototype.drawImageAnimation=function(c,a){!0===a.additive&&setTextureBlendFunc(a.ref.ptr,GL_SRC_ALPHA,GL_ONE);var b=0;"3d"===a.perspective&&(b=1);setTexturePerspective3d(a.ref.ptr,b);void 0!==a.canvasWidth&&void 0!==a.canvasHeight&&setTextureCanvasDimensions(a.ref.ptr,a.canvasWidth,a.canvasHeight);for(b=1;b<a.multiTexRef.length;b++)setTextureUnitTexture(a.ref.ptr,b,a.multiTexRef[b].ptr);void 0!==a.angle&&(b=this.calculateAngleAnimation(c,a),setTexturePivot(a.ref.ptr,b.pivot.x,b.pivot.y,b.pivot.z),
setTextureRotation(a.ref.ptr,b.degreesX,b.degreesY,b.degreesZ,b.x,b.y,b.z));b=this.calculateScaleAnimation(c,a);setTextureScale(a.ref.ptr,b.x,b.y);if(void 0!==a.position){var e=this.calculatePositionAnimation(c,a),k=e.x,f=e.y,d=e.z;Settings.demoScript.kanttuCompatibility&&(f=-(a.ref.h*b.y)/2,k=-(a.ref.w*b.x)/2+e.x,f=getScreenHeight()-(e.y-f));setTexturePosition(a.ref.ptr,k,f,d)}else setTextureCenterAlignment(a.ref.ptr,1);b=this.calculateColorAnimation(c,a,a.color);glColor4ub(b.r,b.g,b.b,b.a);drawTexture(a.ref.ptr);
setTextureDefaults(a.ref.ptr)};
Player.prototype.drawTextAnimation=function(c,a){setDrawTextString(a.text.string);if(void 0!==a.angle){var b=this.calculateAngleAnimation(c,a);setTextPivot(b.pivot.x,b.pivot.y,b.pivot.z);setTextRotation(b.degreesX,b.degreesY,b.degreesZ)}b=this.calculateScaleAnimation(c,a);setTextSize(b.x,b.y);if("2d"===a.text.perspective)if(void 0!==a.position){var e=f.x,k=f.y;Settings.demoScript.kanttuCompatibility&&(e=-(getTextStringWidth()*b.x)/2,b=-(getTextStringHeight()*b.y)/2,e+=f.x,k=getScreenHeight()-(f.y-
b));setTextPosition(e,k,0)}else alignTextCenter(1);else if(void 0!==a.position){var f=this.calculatePositionAnimation(c,a);setTextPosition(f.x,f.y,f.z)}f=this.calculateColorAnimation(c,a,a.color);glColor4ub(f.r,f.g,f.b,f.a);"2d"===a.text.perspective?drawText2d():(a.clearDepthBuffer&&glClear(GL_DEPTH_BUFFER_BIT),drawText3d());setTextDefaults()};
Player.prototype.drawObjectAnimation=function(c,a){var b=!1;if(void 0!==a.ref){if(void 0!==a.position){var e=this.calculatePositionAnimation(c,a);setObjectPosition(a.ref.ptr,e.x,e.y,e.z)}void 0!==a.angle&&(e=this.calculateAngleAnimation(c,a),setObjectPivot(a.ref.ptr,e.pivot.x,e.pivot.y,e.pivot.z),setObjectRotation(a.ref.ptr,e.degreesX,e.degreesY,e.degreesZ,e.x,e.y,e.z));void 0!==a.scale&&(e=this.calculateScaleAnimation(c,a),setObjectScale(a.ref.ptr,e.x,e.y,e.z));void 0!==a.color&&(e=this.calculateColorAnimation(c,
a,a.color),setObjectColor(a.ref.ptr,e.r/255,e.g/255,e.b/255,e.a/255));var e=a.camera,k=(c-a.start)*a.fps;void 0!==a.frame&&(k=a.frame);var f=a.clearDepthBuffer;void 0!==a.shape&&"CUSTOM"===a.shape.type&&(b=!0);b&&glPushMatrix();f&&glClear(GL_DEPTH_BUFFER_BIT);drawObject(a.ref.ptr,e,k,f)}void 0!==a.objectFunction&&Utils.evaluateVariable(a,a.objectFunction);b&&glPopMatrix()};
Player.prototype.drawFboAnimation=function(c,a){if(void 0!==a.fbo.dimension){var b=this.calculate3dCoordinateAnimation(c,a.fbo.dimension,{x:1,y:1,z:1});fboSetRenderDimensions(a.ref.ptr,b.x,b.y)}"begin"===a.fbo.action?(fboBind(a.ref.ptr),fboUpdateViewport(a.ref.ptr)):"end"===a.fbo.action?(fboBind(),fboUpdateViewport(),fboBindTextures(a.ref.ptr),glColor4f(1,1,1,1),void 0!==a.ref.color&&setTextureSizeToScreenSize(a.ref.color.ptr),void 0!==a.ref.depth&&setTextureSizeToScreenSize(a.ref.depth.ptr),drawTexture(a.ref.color.ptr),
fboBindTextures()):"unbind"===a.fbo.action?(fboBind(),fboUpdateViewport()):"draw"===a.fbo.action&&(fboBindTextures(a.ref.ptr),glColor4f(1,1,1,1),void 0!==a.ref.color&&setTextureSizeToScreenSize(a.ref.color.ptr),void 0!==a.ref.depth&&setTextureSizeToScreenSize(a.ref.depth.ptr),drawTexture(a.ref.color.ptr),fboBindTextures())};
Player.prototype.drawLightAnimation=function(c,a){if(void 0!==a.ambientColor){var b=this.calculateColorAnimation(c,a,a.ambientColor);lightSetAmbientColor(a.light.index,b.r/255,b.g/255,b.b/255,b.a/255)}void 0!==a.diffuseColor&&(b=this.calculateColorAnimation(c,a,a.diffuseColor),lightSetDiffuseColor(a.light.index,b.r/255,b.g/255,b.b/255,b.a/255));void 0!==a.specularColor&&(b=this.calculateColorAnimation(c,a,a.specularColor),lightSetSpecularColor(a.light.index,b.r/255,b.g/255,b.b/255,b.a/255));void 0!==
a.position&&(b=this.calculate3dCoordinateAnimation(c,a.position,{x:0,y:0,z:1}),lightSetPosition(a.light.index,b.x,b.y,b.z));lightSetPositionObject(a.light.index);void 0!==a.positionObject?lightSetPositionObject(a.light.index,a.positionObject.ptr):void 0!==a.lightRelativePosition&&(a.positionObject=getObjectFromMemory(a.lightRelativePosition));"begin"===a.light.action?lightSetOn(a.light.index):"end"===a.light.action&&lightSetOff(a.light.index)};
Player.prototype.drawCameraAnimation=function(c,a){if(void 0!==a.perspective){var b=this.calculatePerspectiveAnimation(c,a);setCameraPerspective(b.fov,b.aspect,b.near,b.far)}void 0!==a.position&&(b=this.calculate3dCoordinateAnimation(c,a.position,{x:0,y:0,z:2}),setCameraPosition(b.x,b.y,b.z));void 0!==a.target&&(b=this.calculate3dCoordinateAnimation(c,a.target,{x:0,y:0,z:0}),setCameraLookAt(b.x,b.y,b.z));void 0!==a.up&&(b=this.calculate3dCoordinateAnimation(c,a.up,{x:0,y:1,z:0}),setCameraUpVector(b.x,
b.y,b.z));setCameraPositionObject();void 0!==a.positionObject?setCameraPositionObject(a.positionObject.ptr):void 0!==a.cameraRelativePosition&&(a.positionObject=getObjectFromMemory(a.cameraRelativePosition));setCameraTargetObject();void 0!==a.targetObject?setCameraTargetObject(a.targetObject.ptr):void 0!==a.cameraRelativeTarget&&(a.targetObject=getObjectFromMemory(a.cameraRelativeTarget));viewReset()};
Player.prototype.drawAnimation=function(c){var a=getSceneTimeFromStart(),b;for(b in c){glPushMatrix();if(c.hasOwnProperty(b))for(var e=c[b].length,k=0;k<e;k++){glPushAttrib(GL_CURRENT_BIT);var f=c[b][k];if(a>=f.start&&a<f.end){Sync.calculateAnimationSync(a,f);var d;void 0!==f.shader&&(d=new Shader(f),d.enableShader());"image"===f.type?this.drawImageAnimation(a,f):"text"===f.type?this.drawTextAnimation(a,f):"object"===f.type?this.drawObjectAnimation(a,f):"fbo"===f.type?this.drawFboAnimation(a,f):"light"===
f.type?this.drawLightAnimation(a,f):"camera"===f.type&&this.drawCameraAnimation(a,f);void 0!==f.runFunction&&Utils.evaluateVariable(f,f.runFunction);void 0!==f.shader&&d.disableShader()}glPopAttrib()}glPopMatrix()}};
