/* v 2.35
author http://codecanyon.net/user/creativeinteractivemedia/portfolio?ref=creativeinteractivemedia
*/

var FLIPBOOK=FLIPBOOK||{};FLIPBOOK.PageWebGL=function(a,b,c,d,e,f,g,h){THREE.Object3D.call(this),this.book=a,this.frontTexture=c,this.backTexture=d,this.index=b,this.materialType=f.pageMaterial,this.pW=f.pageWidth,this.pH=f.pageHeight,this.nfacesw=f.pageSegmentsW,this.nfacesh=f.pageSegmentsH,this.mats=[],this.pageHardness=e,this.pageThickness=e,this.duration=f.pageFlipDuration,this.angle=.25*Math.PI*this.pW/this.pH,this.force=10,this.offset=0,this.to=null,this.mod=null,this.bend=null,this.pivot=null,this.isFlippedLeft=!1,this.isFlippedRight=!0,this.flippingLeft=!1,this.flippingRight=!1,this.options=f,this.loadedF={},this.loadedB={},this.frontMaterials={},this.backMaterials={},this.frontTextures={},this.backTextures={},this.showing=!1,this.preloaderMatF=g,this.preloaderMatB=h,this.gF=new THREE.BoxGeometry(this.pW,this.pH,.01,this.nfacesw,this.nfacesh,0);var i=new THREE.MeshBasicMaterial({color:15592941}),j=[i,i,i,i,g,h],k=[i,i,i,i,i,i];new THREE.MeshBasicMaterial({color:16711680});this.cube=new THREE.Mesh(this.gF,new THREE.MeshFaceMaterial(j)),this.cube.position.x=.5*this.pW,this.gF.faceVertexUvs[1]=this.gF.faceVertexUvs[0],this.showMat(),this.cubeEmpty=new THREE.Mesh(new THREE.BoxGeometry(this.pW,this.pH,.01,1,1,0),new THREE.MeshFaceMaterial(k)),this.cubeEmpty.position.x=.5*this.pW,this.pageFlippedAngle=Math.PI*this.options.pageFlippedAngle/180,this.bendF=new MOD3.Bend(0,0,0),this.bendF.constraint=MOD3.ModConstant.LEFT,this.pH>this.pW&&(this.bendF.switchAxes=!0),this.b2=new MOD3.Bend(0,0,0),this.b2.constraint=MOD3.ModConstant.RIGHT,this.pH>this.pW&&(this.b2.switchAxes=!0),this.b2.force=Math.PI/2,this.b2.offset=.1,this.modF=new MOD3.ModifierStack(new MOD3.LibraryThree,this.cube),this.modF.addModifier(this.bendF),this.modF.apply(),this.frontMaterials={},this.backMaterials={};var n=this;jQuery(f.main).bind("pageLoaded",function(a,b,c){var d=n.options.rightToLeft?n.book.pages.length-n.index-1:n.index,e=n.options.rightToLeft?2*d+1:2*d,f=n.options.rightToLeft?2*d:2*d+1;if(b==e){if(n.frontTextureSize>=c)return;if(n.frontTextureSize=c,n.frontTextures[c])n.frontMaterial.map=n.frontTextures[c],n.frontMaterial.needsUpdate=!0;else{var g=n.options.pages[e].canvas[c],h=new THREE.CanvasTexture(g);h.anisotropy=n.book.renderer.getMaxAnisotropy(),h.needsUpdate=!0,h.repeat.x=g.scaleX,h.repeat.y=g.scaleY,h.repeat.y=g.scaleY,h.offset.y=1-g.scaleY,n.frontTextures[c]=h,n.frontMaterial=n.createMaterial(h,"back"),n.frontMaterial.needsUpdate=!0,n.setFrontMat(n.frontMaterial),delete g}n.book.updateHtmlLayer()}else if(b==f){if(n.backTextureSize>=c)return;if(n.backTextureSize=c,n.backTextures[c])n.backMaterial.map=n.backTextures[c],n.backMaterial.needsUpdate=!0;else{var i=n.options.pages[f].canvas[c],j=new THREE.CanvasTexture(i);j.anisotropy=n.book.renderer.getMaxAnisotropy(),j.needsUpdate=!0,j.repeat.x=i.scaleX,j.repeat.y=i.scaleY,j.repeat.y=i.scaleY,j.offset.y=1-i.scaleY,n.backTextures[c]=j,n.backMaterial=n.createMaterial(j,"back"),n.backMaterial.needsUpdate=!0,n.setBackMat(n.backMaterial),delete i}n.book.updateHtmlLayer()}})},FLIPBOOK.PageWebGL.prototype=new THREE.Object3D,FLIPBOOK.PageWebGL.prototype.constructor=FLIPBOOK.PageWebGL,FLIPBOOK.PageWebGL.prototype.load=function(a,b,c){function o(a){return r.isPowerOfTwo(a.width)&&r.isPowerOfTwo(a.height)}function p(a){if(a instanceof HTMLImageElement||a instanceof HTMLCanvasElement){var b=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");b.width=r.nearestPowerOfTwo(a.width),b.height=r.nearestPowerOfTwo(a.height);var c=b.getContext("2d");return c.drawImage(a,0,0,b.width,b.height),b}return a}b=b||128;for(var d=this.book.pages,e=0;e<d.length;e++){var f=d[e];if(f.flippingLeft||f.flippingRight)return}this.disposed=!1;var h=this,i=this.book.options,j=i.main,k=h.options.rightToLeft?this.book.pages.length-this.index-1:this.index,l=h.options.rightToLeft?2*k+1:2*k,m=h.options.rightToLeft?2*k:2*k+1;if(i.pdfMode){var n;switch(a){case"front":n=[l];break;case"back":n=[m];break;default:n=[l,m]}j.loadPagesFromPdf(n,b,function(){c.call(h)})}else{if(this.loaded)return void c.call(this);if(this.loaded=!0,h.frontMaterial&&h.backMaterial)return h.setFrontMat(h.frontMaterial),h.setBackMat(h.backMaterial),void c.call(h);this.callback=c;var r={isPowerOfTwo:function(a){return 0===(a&a-1)&&0!==a},nearestPowerOfTwo:function(a){return Math.min(Math.pow(2,Math.round(Math.log(a)/Math.LN2)),h.options.pageTextureSize)}},s=new THREE.TextureLoader;h.options.main.setLoadingProgress(.3),s.load(h.frontTexture,function(a){o(a.image)||(a.image=p(a.image)),a.anisotropy=h.book.renderer.getMaxAnisotropy(),a.needsUpdate=!0,"left"==h.options.pages[2*h.index].side?a.repeat.x=.5:"right"==h.options.pages[2*h.index].side&&(a.repeat.x=.5,a.offset.x=.5),h.frontMaterial=h.createMaterial(a),h.setFrontMat(h.frontMaterial),s.load(h.backTexture,function(a){o(a.image)||(a.image=p(a.image)),a.anisotropy=h.book.renderer.getMaxAnisotropy(),a.needsUpdate=!0,"left"==h.options.pages[2*h.index+1].side?a.repeat.x=.5:"right"==h.options.pages[2*h.index+1].side&&(a.repeat.x=.5,a.offset.x=.5),h.backMaterial=h.createMaterial(a,"back"),h.setBackMat(h.backMaterial),h.loaded=!0,h.callback.call(h),h.options.main.setLoadingProgress(1)})})}},FLIPBOOK.PageWebGL.prototype.createMaterial=function(a,b){var c;if(this.options.lights){var d="back"==b?this.book.specularB:this.book.specularF,e=this.options;c=new THREE.MeshStandardMaterial({map:a,roughness:e.pageRoughness,metalness:e.pageMetalness,emissive:0,color:16777215,lightMap:d})}else c=new THREE.MeshBasicMaterial({map:a});return c},FLIPBOOK.PageWebGL.prototype._setAngle=function(a,b){if(a<=180&&a>=-180){if(a=a/180*Math.PI,this.singlePage&&(a>=90&&(a=90),a<0&&(a-=90),a<-180&&(a=-180),this.index==this.book.pages.length-1))return;a<0&&(a+=Math.PI),this.angle=a,this.positionZ(200),this.dragging=!0,this.rotation.y=-a,this.isFlippedLeft?this.bendF.force=1.35*Math.pow(-Math.abs(Math.cos(-a/2)),1)/Math.pow(this.pageHardness,1.5):this.bendF.force=1.35*Math.pow(Math.abs(Math.sin(-a/2)),1)/Math.pow(this.pageHardness,1.5),this.updateBend(),this.book.htmlLayerVisible&&(this.book.$pageL.hide(),this.book.$pageR.hide(),this.book.htmlLayerVisible=!1)}},FLIPBOOK.PageWebGL.prototype.updateBend=function(){this.b2.force=this.rotation.y+Math.PI/2,this.modF.apply(),this.gF.computeFaceNormals(),this.gF.computeVertexNormals(!0)},FLIPBOOK.PageWebGL.prototype.flipLeft=function(a){if(this.onComplete=a,this.dragging=!1,!this.isFlippedLeft&&!this.flippingLeft&&!this.flippingRight&&this.index==this.book.flippedleft){if(this.duration>0){this.flippingLeft=!0,this.flipping=!0,this.force=0;var b=(1+.5*Math.random())/this.pageHardness,c=.1+.2*Math.random();this.to={angle:this.rotation.y,t:-1,xx:0,thiss:this,force:this.force,offset:this.offset},this.bendIn(-Math.PI,b,c)}else this.rotation.y=-Math.PI,this.flippingLeft=!1,this.isFlippedLeft=!0,this.flippingRight=!1,this.isFlippedRight=!1;this.correctZOrder()}},FLIPBOOK.PageWebGL.prototype.correctZOrder=function(){var b,a=4;for(this.position.z=a/2+1,b=this.index-1;b>=0;b--)this.book.pages[b].position.z=this.book.pages[b+1].position.z-a/2-a/2-1;for(b=this.index+1;b<this.book.pages.length;b++)this.book.pages[b].position.z=this.book.pages[b-1].position.z-a/2-a/2-1},FLIPBOOK.PageWebGL.prototype.flipLeftInstant=function(a){if(this.onComplete=a,this.dragging=!1,!this.isFlippedLeft&&!this.flippingLeft&&!this.flippingRight&&this.index==this.book.flippedleft){this.thiss=this,this.xx=0,this.angle=-Math.PI,this.flippingLeft=!0,this.isFlippedLeft=!1,this.renderFlip(),this.flippingLeft=!1,this.isFlippedLeft=!0,this.flippingRight=!1,this.isFlippedRight=!1;var b=4;this.position.z=b/2+1;for(var c=this.index+1;c<this.book.pages.length;c++)this.book.pages[c].position.z=this.book.pages[c-1].position.z-b/2-b/2-1;if(this.index<this.book.pages.length-1){this.position.z=this.book.pages[this.index+1].position.z;for(var c=this.index-1;c>=0;c--)this.book.pages[c].position.z=this.book.pages[c+1].position.z-b/2-b/2-1}else this.index>0&&(this.book.pages[this.index].position.z=this.book.pages[this.index-1].position.z+b/2+b/2-1);this.flipFinished()}},FLIPBOOK.PageWebGL.prototype.hideMat=function(){this.showing&&(this.remove(this.cube),this.add(this.cubeEmpty),this.showing=!1)},FLIPBOOK.PageWebGL.prototype.showMat=function(){this.showing||(this.add(this.cube),this.remove(this.cubeEmpty),this.showing=!0)},FLIPBOOK.PageWebGL.prototype.setFrontMat=function(a){this.cube.material.materials[4]!==a&&(this.cube.material.materials[4]=a)},FLIPBOOK.PageWebGL.prototype.setBackMat=function(a){this.cube.material.materials[5]!==a&&(this.cube.material.materials[5]=a)},FLIPBOOK.PageWebGL.prototype.disposeMat=function(){var a=this.cube.material.materials[4],b=this.cube.material.materials[5],c=a.map,d=b.map;a.dispose(),b.dispose(),c&&c.dispose(),d&&d.dispose(),this.disposed=!0},FLIPBOOK.PageWebGL.prototype.flipRightInstant=function(a){if(this.onComplete=a,this.dragging=!1,!this.isFlippedRight&&!this.flippingRight&&!this.flippingLeft&&this.index==this.book.getNumPages()-this.book.flippedright-1){this.thiss=this,this.xx=0,this.angle=0,this.flippingRight=!0,this.isFlippedRight=!1,this.renderFlip(),this.flippingLeft=!1,this.isFlippedLeft=!1,this.flippingRight=!1,this.isFlippedRight=!0;var b=4;this.position.z=b/2+1;for(var c=this.index-1;c>=0;c--)this.book.pages[c].position.z=this.book.pages[c+1].position.z-b/2-b/2-1;if(this.index>0){this.position.z=this.book.pages[this.index-1].position.z;for(var c=this.index+1;c<this.book.pages.length;c++)this.book.pages[c].position.z=this.book.pages[c-1].position.z-b/2-b/2-1}else this.book.pages.length>1&&(this.position.z=this.book.pages[this.index+1].position.z+b/2+b/2-1);this.flipFinished()}},FLIPBOOK.PageWebGL.prototype.flipRight=function(a){if(this.onComplete=a,this.dragging=!1,!this.isFlippedRight&&!this.flippingRight&&!this.flippingLeft&&this.index==this.book.getNumPages()-this.book.flippedright-1){if(this.duration>0){this.flippingRight=!0,this.flipping=!0,this.force=0,this.to={angle:this.rotation.y,t:-1,xx:0,thiss:this,force:this.force,offset:this.offset};var b=(-1-.5*Math.random())/this.pageHardness,c=.1+.2*Math.random();this.bendIn(0,b,c)}else this.rotation.y=0,this.flippingLeft=!1,this.isFlippedLeft=!1,this.flippingRight=!1,this.isFlippedRight=!0;this.correctZOrder()}},FLIPBOOK.PageWebGL.prototype.bendIn=function(a,b,c){this.bendF.force=0,this.bendF.offset=0,this.updateBend();var d=2*this.duration*240*Math.pow(Math.abs(this.rotation.y-a)/Math.PI,.5)*Math.pow(this.pageHardness,.25);new TWEEN.Tween(this.to).to({angle:a,xx:1,t:1},d).easing(TWEEN.Easing.Sinusoidal.In).onUpdate(this.renderFlip).onComplete(this.bendOut).start(),this.book.options.main.playFlipSound()},FLIPBOOK.PageWebGL.prototype.bendOut=function(){var a=this.thiss,b=a.duration*Math.pow(Math.abs(a.bendF.force),.5)*1e3;new TWEEN.Tween(a.bendF).to({force:0,offset:1},b).easing(TWEEN.Easing.Sinusoidal.Out).onUpdate(function(){a.updateBend()}).onComplete(function(){a.flipFinished(a)}).start();var c=4;if(a.flippingLeft)if(a.index<a.book.pages.length-1){a.position.z=a.book.pages[a.index+1].position.z;for(var d=a.index-1;d>=0;d--)a.book.pages[d].position.z=a.book.pages[d+1].position.z-c/2-c/2-1}else a.book.pages.length>1&&(a.book.pages[a.index].position.z=a.book.pages[a.index-1].position.z+c/2+c/2-1);if(a.flippingRight)if(a.index>0){a.position.z=a.book.pages[a.index-1].position.z;for(var d=a.index+1;d<a.book.pages.length;d++)a.book.pages[d].position.z=a.book.pages[d-1].position.z-c/2-c/2-1}else a.book.pages.length>1&&(a.position.z=a.book.pages[a.index+1].position.z+c/2+c/2-1)},FLIPBOOK.PageWebGL.prototype.modApply=function(){this.thiss.bendF.force=this.thiss.bendB.force=this.force,this.thiss.bendF.offset=this.thiss.bendB.offset=this.offset,this.thiss.updateBend()},FLIPBOOK.PageWebGL.prototype.renderFlip=function(){this.thiss._setAngle(180*-this.angle/Math.PI)},FLIPBOOK.PageWebGL.prototype.flipFinished=function(){var a=this;a.flippingLeft?(a.flippingLeft=!1,a.isFlippedLeft=!0,a.flippingRight=!1,a.isFlippedRight=!1):a.flippingRight&&(a.flippingLeft=!1,a.isFlippedRight=!0,a.flippingRight=!1,a.isFlippedLeft=!1),a.bendF.force=0,a.bendF.offset=0,a.updateBend(),a.flipping=!1,a.dragging=!1,"undefined"!=typeof a.onComplete&&a.onComplete(a),a.book.flipFinnished()},FLIPBOOK.PageWebGL.prototype.isFlippedLeft=function(){return this.thiss.isFlippedLeft},FLIPBOOK.PageWebGL.prototype.isFlippedRight=function(){return this.thiss.isFlippedRight},FLIPBOOK.PageWebGL.prototype.positionZ=function(){},FLIPBOOK.BookWebGL=function(a,b){this.elementId=jQuery(b.main.elem).attr("id"),this.wrapper="object"==typeof a?a:document.getElementById(a),this.options=b,this.options.cameraDistance=2800,this.main=b.main,this.pageW=b.pageWidth,this.pageH=b.pageHeight,this.pageW=1e3*b.pageWidth/b.pageHeight,this.pageH=1e3,this.main.options.pageWidth=this.pageW,this.main.options.pageHeight=this.pageH,this.scroll=b.scroll,this.pagesArr=b.pagesArr,this.pages=[],this.animating=!1,this.rightIndex=0,this.sc=1;var c=this.wrapper.style;c.width="100%",c.height="100%",c.position="absolute",c.overflow="hidden",b.lightBox&&!b.lightBoxOpened||this.enable(),this.options.cameraDistance=this.options.cameraDistance/1.5,this.enable()},FLIPBOOK.BookWebGL.prototype=new THREE.Object3D,FLIPBOOK.BookWebGL.prototype.constructor=FLIPBOOK.BookWebGL,FLIPBOOK.BookWebGL.prototype.init3d=function(){var a=this,b=30,c=jQuery(a.wrapper).width(),d=jQuery(a.wrapper).height(),e=c/d,f=1,g=1e4,h=this.options;this.Scene=new THREE.Scene,this.centerContainer=new THREE.Object3D,this.Scene.add(this.centerContainer),this.Camera=new THREE.PerspectiveCamera(b,e,f,g),this.Scene.add(this.Camera),this.zoom=h.zoom,this.pan=h.pan,this.tilt=h.tilt,this.updateCameraPosition();var i=this.wrapper,j=document.createElement("canvas"),l=(j.getContext("webgl"),new THREE.WebGLRenderer({antialias:this.options.antialias,alpha:!0}));window.renderer=l,l.gammaInput=!0,l.gammaOutput=!0,window.webglrenderer=this.renderer=l,this.renderer.setSize(i.clientWidth,i.clientHeight);var m=window.devicePixelRatio<h.minPixelRatio?h.minPixelRatio:window.devicePixelRatio;this.renderer.setPixelRatio(m),i.appendChild(this.renderer.domElement);for(var n=!1,o=this.options.pages,p=0;p<o.length;p++)o[p].htmlContent&&(n=!0);if(this.options.hasHtmlContent=n||h.pdfMode,this.options.hasHtmlContent&&this.initHtmlContent(),this.canvas=this.renderer.domElement,this._bind("mousedown",this.canvas),this._bind("mousemove",this.canvas),this._bind("mouseout",this.canvas),this._bind("mouseup",this.canvas),this._bind("touchstart",this.canvas),this._bind("touchmove",this.canvas),this._bind("touchend",this.canvas),this._bind("touchcancel",this.canvas),this.options.lights){var q=h.spotlightColor||16777215,r=h.spotlightIntensity||.14,s=new THREE.SpotLight(q);s.intensity=r,s.position.set(1e3,0,2e3),s.distance=4e3,s.penumbra=.1,s.decay=0,this.Scene.add(s);var t=h.ambientLightColor||3355443,u=new THREE.AmbientLight(t);this.Scene.add(u)}this.centerContainer.position.set(0,0,0),this.htmlLayer&&(this.htmlLayer.position.x=this.centerContainer.position.x,this.htmlLayer.position.y=this.centerContainer.position.y),this.onResize(),this.centerContainer.position.x=.5*-this.pageW*this.centerContainer.scale.x,this.htmlLayer&&(this.htmlLayer.position.x=this.centerContainer.position.x,this.htmlLayer.position.y=this.centerContainer.position.y),this.flippedleft=0,this.flippedright=0,this.cameraZMin=300,this.cameraZMax=5e3,function b(){if(a.rendering){if(!a.enabled)return;TWEEN.update(),a.renderer.render(a.Scene,a.Camera),a.htmlLayer&&a.cssRenderer.render(a.Scene,a.Camera)}requestAnimationFrame(b)}()},FLIPBOOK.BookWebGL.prototype.initHtmlContent=function(){THREE.CSS3DObject=function(a){THREE.Object3D.call(this),this.element=a,this.element.style.position="absolute",this.addEventListener("removed",function(a){null!==this.element.parentNode&&this.element.parentNode.removeChild(this.element)})},THREE.CSS3DObject.prototype=Object.create(THREE.Object3D.prototype),THREE.CSS3DObject.prototype.constructor=THREE.CSS3DObject,THREE.CSS3DSprite=function(a){THREE.CSS3DObject.call(this,a)},THREE.CSS3DSprite.prototype=Object.create(THREE.CSS3DObject.prototype),THREE.CSS3DSprite.prototype.constructor=THREE.CSS3DSprite,THREE.CSS3DRenderer=function(){var a,b,c,d,e=new THREE.Matrix4,f={camera:{fov:0,style:""},objects:{}},g=document.createElement("div");g.style.overflow="hidden",g.style.WebkitTransformStyle="preserve-3d",g.style.MozTransformStyle="preserve-3d",g.style.oTransformStyle="preserve-3d",g.style.transformStyle="preserve-3d",this.domElement=g;var h=document.createElement("div");h.style.WebkitTransformStyle="preserve-3d",h.style.MozTransformStyle="preserve-3d",h.style.oTransformStyle="preserve-3d",h.style.transformStyle="preserve-3d",g.appendChild(h),this.setClearColor=function(){},this.getSize=function(){return{width:a,height:b}},this.setSize=function(e,f){a=e,b=f,c=a/2,d=b/2,g.style.width=e+"px",g.style.height=f+"px",h.style.width=e+"px",h.style.height=f+"px"};var i=function(a){return Math.abs(a)<Number.EPSILON?0:a},j=function(a){var b=a.elements;return"matrix3d("+i(b[0])+","+i(-b[1])+","+i(b[2])+","+i(b[3])+","+i(b[4])+","+i(-b[5])+","+i(b[6])+","+i(b[7])+","+i(b[8])+","+i(-b[9])+","+i(b[10])+","+i(b[11])+","+i(b[12])+","+i(-b[13])+","+i(b[14])+","+i(b[15])+")"},k=function(a){var b=a.elements;return"translate3d(-50%,-50%,0) matrix3d("+i(b[0])+","+i(b[1])+","+i(b[2])+","+i(b[3])+","+i(-b[4])+","+i(-b[5])+","+i(-b[6])+","+i(-b[7])+","+i(b[8])+","+i(b[9])+","+i(b[10])+","+i(b[11])+","+i(b[12])+","+i(b[13])+","+i(b[14])+","+i(b[15])+")"},l=function(a,b){if(a instanceof THREE.CSS3DObject){var c;a instanceof THREE.CSS3DSprite?(e.copy(b.matrixWorldInverse),e.transpose(),e.copyPosition(a.matrixWorld),e.scale(a.scale),e.elements[3]=0,e.elements[7]=0,e.elements[11]=0,e.elements[15]=1,c=k(e)):c=k(a.matrixWorld);var d=a.element,g=f.objects[a.id];void 0!==g&&g===c||(d.style.WebkitTransform=c,d.style.MozTransform=c,d.style.oTransform=c,d.style.transform=c,f.objects[a.id]=c),d.parentNode!==h&&h.appendChild(d)}for(var i=0,j=a.children.length;i<j;i++)l(a.children[i],b)};this.render=function(a,e){var i=.5/Math.tan(THREE.Math.degToRad(.5*e.fov))*b;f.camera.fov!==i&&(g.style.WebkitPerspective=i+"px",g.style.MozPerspective=i+"px",g.style.oPerspective=i+"px",g.style.perspective=i+"px",f.camera.fov=i),a.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),e.matrixWorldInverse.getInverse(e.matrixWorld);var k="translate3d(0,0,"+i+"px)"+j(e.matrixWorldInverse)+" translate3d("+c+"px,"+d+"px, 0)";f.camera.style!==k&&(h.style.WebkitTransform=k,h.style.MozTransform=k,h.style.oTransform=k,h.style.transform=k,f.camera.style=k),l(a,e)}};var a=document.createElement("div");a.className="htmlLayer";var b=jQuery(a);this.$htmlLayer=b,this.$pageR=jQuery("<div>").css("width",1e3*this.options.pageWidth/this.options.pageHeight+"px").css("height","1000px").css("position","absolute").css("top","-500px").css("pointer-events","none").appendTo(b),this.$pageRInner=jQuery("<div>").css("pointer-events","all").appendTo(this.$pageR),this.$pageL=jQuery("<div>").css("width",1e3*this.options.pageWidth/this.options.pageHeight+"px").css("height","1000px").css("position","absolute").css("top","-500px").css("left",-1e3*this.options.pageWidth/this.options.pageHeight+"px").css("pointer-events","none").appendTo(b),this.$pageLInner=jQuery("<div>").css("pointer-events","all").appendTo(this.$pageL),this.htmlLayer=new THREE.CSS3DObject(a),this.Scene.add(this.htmlLayer),this.cssRenderer=new THREE.CSS3DRenderer;this.wrapper;this.wrapper.appendChild(this.cssRenderer.domElement),this.cssRenderer.domElement.style.position="absolute",this.cssRenderer.domElement.style.top="0",this.cssRenderer.domElement.style.left="0",this.cssRenderer.domElement.style.pointerEvents="none"},FLIPBOOK.BookWebGL.prototype.enablePrev=function(a){this.prevEnabled=a},FLIPBOOK.BookWebGL.prototype.enableNext=function(a){this.nextEnabled=a},FLIPBOOK.BookWebGL.prototype.isZoomed=function(){return this.main.zoom>this.options.zoomLevels[0]&&this.main.zoom>1},FLIPBOOK.BookWebGL.prototype.getRightPage=function(){return this.pages[this.flippedleft]},FLIPBOOK.BookWebGL.prototype.getNextPage=function(){return this.pages[this.flippedleft+1]},FLIPBOOK.BookWebGL.prototype.getLeftPage=function(){return this.pages[this.flippedleft-1]},FLIPBOOK.BookWebGL.prototype.getPrevPage=function(){return this.pages[this.flippedleft-2]},FLIPBOOK.BookWebGL.prototype.onSwipe=function(a,b,c,d,e,f,g){if(!this.isZoomed()){d=g[0].start.x-g[0].end.x;var h=this.getLeftPage(),i=this.getRightPage(),j=this.getNextPage(),k=this.getPrevPage();if(!this.options.rotateCameraOnMouseDrag||i&&i.dragging||h&&h.dragging||"rotate"!=this.onMouseMove&&"scroll"!=this.onMouseMove){if(("cancel"==b||"end"==b)&&f<=1){if(1==this.view&&this.draggingBook&&"left"==c)return this.nextPage(),void(this.draggingBook=!1);if(1==this.view&&this.draggingBook&&"right"==c)return this.prevPage(),void(this.draggingBook=!1);!(d<0)||i&&i.dragging?!(d>0)||h&&h.dragging?0==d&&(this.clickedPage?this.clickedPage.isFlippedLeft?this.prevPage():this.nextPage():null):this.nextPage():this.prevPage(),i&&(i.dragging=!1),h&&(h.dragging=!1)}if("move"==b&&f<=1){if(this.draggingBook)return this.centerContainer.position.x=this.draggingBookStartX-d,void this.updateHtmlLayerPosition();if(1==this.view&&this.isFocusedLeft()&&"left"==c)return this.draggingBookStartX=this.centerContainer.position.x,void(this.draggingBook=!0);if(1==this.view&&this.isFocusedRight()&&"right"==c)return this.draggingBookStartX=this.centerContainer.position.x,void(this.draggingBook=!0);if(d=180*(g[0].start.x-g[0].end.x)/jQuery(this.wrapper).width(),h&&h.flipping||i&&i.flipping)return;i&&i.dragging||h&&h.dragging?h&&!i||h&&!i.dragging?d<=0&&h._setAngle(d,c):(i&&!h||i&&!h.dragging)&&d>=0&&i._setAngle(d,c):0!=d&&("right"!=c||!h||i&&i.dragging||!this.prevEnabled?"left"==c&&i&&this.nextEnabled&&(i._setAngle(d,c),i.positionZ(200),j&&j.showMat()):(h._setAngle(d,c),h.positionZ(200),k&&k.showMat()))}}}},FLIPBOOK.BookWebGL.prototype.onResize=function(){var a=jQuery(this.wrapper).width(),b=jQuery(this.wrapper).height(),c=this.options.pageWidth,d=this.options.pageHeight,e=a/b,f=c/d,g=Math.min(this.zoom,1),h=Number(this.options.zoomLevels[0]);e>2*f*g?(this.options.responsiveView?(this.view=2,0==this.rightIndex?this.focusRighttPage():this.focusBothPages()):0==this.flippedleft?this.focusRighttPage():0==this.flippedright?this.focusLeftPage():this.focusBothPages(),this.sc=1):this.options.responsiveView&&a<=this.options.responsiveViewTreshold?(this.view=1,0==this.rightIndex||this.isFocusedRight()?this.focusRighttPage():this.focusLeftPage(),f>e?this.sc=h*e/(f*g):this.sc=1):(this.sc=h*e/(2*f*g),0==this.flippedleft?this.focusRighttPage():0==this.flippedright?this.focusLeftPage():this.focusBothPages()),this.renderer.setSize(a,b),this.htmlLayer&&(this.cssRenderer.setSize(a,b),this.htmlLayer.scale.set(this.sc,this.sc,this.sc)),this.Camera.aspect=a/b,this.Camera.updateProjectionMatrix(),this.updateCameraPosition(),this.updateBookPosition(),this.wrapperW=a,this.wrapperH=b},FLIPBOOK.BookWebGL.prototype.updateCameraPosition=function(){var a=Math.PI*this.tilt/180,b=0,c=this.options.cameraDistance*Math.sin(a)/this.zoom,d=this.options.cameraDistance*Math.cos(a)/this.zoom;this.centerContainer.scale.set(this.sc,this.sc,this.sc),a=Math.PI*this.pan/180,b=Math.sin(a)*d,d=Math.cos(a)*d,this.cameraZ=d,this.Camera.position.set(Math.round(b),Math.round(c),Math.round(d)),this.Camera.lookAt(this.Scene.position)},FLIPBOOK.BookWebGL.prototype.createPages=function(){var b,c,d,e,f,a=this,g=a.options,h=g.pageMiddleShadowSize,i=document.createElement("canvas");i.width=64,i.height=64;var j=i.getContext("2d"),k=j.createLinearGradient(64-h,0,64,0);k.addColorStop(0,"#AAAAAA"),k.addColorStop(1,g.pageMiddleShadowColorL),j.fillStyle=k,j.fillRect(0,0,64,64);var l=new THREE.CanvasTexture(i);l.needsUpdate=!0,a.specularB=l;var m=document.createElement("canvas");m.width=64,m.height=64;var n=m.getContext("2d"),o=n.createLinearGradient(0,0,h,0);o.addColorStop(0,g.pageMiddleShadowColorR),o.addColorStop(1,"#AAAAAA"),n.fillStyle=o,n.fillRect(0,0,64,64);var p=new THREE.CanvasTexture(m);p.needsUpdate=!0,a.specularF=p;var q,r;a.options.lights?(q=new THREE.MeshStandardMaterial({roughness:a.options.pageRoughness,metalness:a.options.pageMetalness,emissive:0,color:15592941,lightMap:a.specularF}),r=new THREE.MeshStandardMaterial({roughness:a.options.pageRoughness,metalness:a.options.pageMetalness,emissive:0,color:15592941,lightMap:a.specularB})):q=r=new THREE.MeshBasicMaterial({color:15592941});var s=a.pagesArr;for(f=0;f<s.length/2;f++){b=s[2*f].src,c=2*f+1>=s.length?"":s[2*f+1].src,d=0==f||f==s.length/2-1?a.options.coverHardness:a.options.pageHardness,e=new FLIPBOOK.PageWebGL(a,f,b,c,d,a.options,q,r),a.pages.push(e),a.centerContainer.add(e),a.flippedright++;var t=4;f>0?(e.position.z=a.pages[f-1].position.z-t/2-t/2-1,this.bg&&(this.bg.position.z=e.position.z-5)):e.position.z=t/2}a.initialized=!0,this.updateHtmlLayer()},FLIPBOOK.BookWebGL.prototype.getNumPages=function(){return this.pages.length},FLIPBOOK.BookWebGL.prototype.centerContainer=function(){return this.centerContainer},FLIPBOOK.BookWebGL.prototype.goToPage=function(a,b){if(!this.initialized){var c=this;return void setTimeout(function(){c.goToPage(a,b)},100)}if(a<0&&(a=0),a>this.options.pages.length&&(a=this.options.pages.length),a%2!=0&&a--,a==this.rightIndex)return void this.turnPageComplete();this.goingToPage=a;var c=this,d=1e3*this.options.pageFlipDuration/6;if("undefined"!=typeof b&&b){if(a>c.rightIndex)for(;c.rightIndex<a;)this.nextPageInstant();else for(;c.rightIndex>a;)this.prevPageInstant();return this.updateBookPosition(),this.turnPageComplete(),void this.updateHtmlLayer()}this.rightIndex>a?(d=1/(this.rightIndex-a)*this.options.pageFlipDuration*1e3/6,this.rightIndex-a>10&&(d=0),this.rightIndex-2>a?(this.prevPage(!1),d>0?setTimeout(function(){c.goToPage(a,b)},d):c.goToPage(a,b)):(this.prevPage(),setTimeout(function(){if("undefined"!=typeof b&&b)for(var a=0;a<c.pages.length;a++)c.pages[a].duration=c.options.pageFlipDuration;c.turnPageComplete()},d))):this.rightIndex<a&&(d=-1/(this.rightIndex-a)*this.options.pageFlipDuration*1e3/6,this.rightIndex-a<-10&&(d=0),this.rightIndex+2<a?(this.nextPage(!1),d>0?setTimeout(function(){c.goToPage(a,b)},d):c.goToPage(a,b)):(this.nextPage(),setTimeout(function(){if("undefined"!=typeof b&&b)for(var a=0;a<c.pages.length;a++)c.pages[a].duration=c.options.pageFlipDuration;c.turnPageComplete()},d)))},FLIPBOOK.BookWebGL.prototype.nextPageInstant=function(a){if(0!=this.flippedright){var b;for(b=0;b<this.pages.length;b++)if(this.pages[b].flippingRight)return;var c=this.pages[this.pages.length-this.flippedright];c.flipLeftInstant(),this.flippedleft++,this.flippedright--,this.rightIndex+=2,this.updateBookPosition()}},FLIPBOOK.BookWebGL.prototype.prevPageInstant=function(a){if(0!=this.flippedleft){var b;for(b=0;b<this.pages.length;b++)if(this.pages[b].flippingLeft)return;var c=this.pages[this.flippedleft-1];c.flipRightInstant(),this.flippedleft--,this.flippedright++,this.rightIndex-=2,this.updateBookPosition()}},FLIPBOOK.BookWebGL.prototype.nextPage=function(a){if(0!=this.flippedright&&this.nextEnabled&&(this.clickedPage=null,!(1==this.flippedright&&2*this.pages.length>this.pagesArr.length)||this.options.rightToLeft)){var b,c=0;for(b=0;b<this.pages.length;b++){if(this.pages[b].flippingRight)return;this.pages[b].flipping&&c++}var d=this.pages[this.pages.length-this.flippedright],g=(this.pages[d.index-2],this.pages[d.index-3],this.pages[d.index+1]);if(g&&c<5&&g.showMat(),1==this.view){if(this.isFocusedLeft())return void this.focusRighttPage(300);this.focusLeftPage(600,200)}else 0==this.flippedleft?this.focusBothPages(500):1==this.flippedright&&this.focusLeftPage(500);if(!d.flipping){var i,h=this;("undefined"==typeof a||a)&&(i=function(a){h.turnPageComplete()}),d.flipLeft(i)}this.flippedleft++,this.flippedright--,this.rightIndex+=2}},FLIPBOOK.BookWebGL.prototype.updateBookPosition=function(){1==this.view||(0==this.rightIndex?this.focusRighttPage():this.rightIndex>=this.options.pagesArr.length?this.focusLeftPage():this.focusBothPages()),this.updateHtmlLayerPosition()},FLIPBOOK.BookWebGL.prototype.updateHtmlLayerPosition=function(){this.htmlLayer&&(this.htmlLayer.position.x=this.centerContainer.position.x,this.htmlLayer.position.y=this.centerContainer.position.y)},FLIPBOOK.BookWebGL.prototype.turnPageComplete=function(){for(var a=this.pages,b=0;b<a.length;b++){var c=a[b];if(c.flippingLeft||c.flippingRight)return}for(var d=this.pages[this.flippedleft],e=this.pages[this.flippedleft-1],f=this.pages[this.flippedleft-2],g=this.pages[this.flippedleft+1],h=this.main,b=0;b<a.length;b++){var c=a[b];c!==d&&c!==e||c.showMat(),e&&c.index<e.index-2&&(c.hideMat(),c.disposeMat()),d&&c.index>d.index+2&&(c.hideMat(),c.disposeMat())}h.setLoadingProgress(.1);var i=this.options.pageTextureSize,j=this.options.pageTextureSize;e?e.load("back",i,function(){d?d.load("front",i,function(){h.setLoadingProgress(1),e.load("front",j,function(){}),d.load("back",j,function(){}),f&&f.load("back",j,function(){}),g&&g.load("front",j,function(){})}):(h.setLoadingProgress(1),e.load("front",j,function(){f&&f.load("back",j,function(){})}))}):d&&d.load("front",i,function(){h.setLoadingProgress(1),d.load("back",j,function(){g&&g.load("front",j,function(){})})}),this.main.turnPageComplete()},FLIPBOOK.BookWebGL.prototype.focusLeftPage=function(a,b){var c=.5*this.options.pageWidth*this.centerContainer.scale.x;this.moveToPos(c,a,b)},FLIPBOOK.BookWebGL.prototype.focusRighttPage=function(a,b){var c=.5*-this.options.pageWidth*this.centerContainer.scale.x;this.moveToPos(c,a,b)},FLIPBOOK.BookWebGL.prototype.focusBothPages=function(a,b){this.moveToPos(0,a,b)},FLIPBOOK.BookWebGL.prototype.moveToPos=function(a,b,c){if(b&&this.movingTo!=a&&this.centerContainer.position.x!=a){var d=this;this.movingTo=a;new TWEEN.Tween(this.centerContainer.position).to({x:a},b).easing(TWEEN.Easing.Sinusoidal.Out).onUpdate(function(){d.updateHtmlLayerPosition()}).onComplete(function(){d.movingTo=null,d.htmlLayer&&(d.htmlLayer.position.x=d.centerContainer.position.x,d.htmlLayer.position.y=d.centerContainer.position.y)}).delay(c||0).start()}else this.centerContainer.position.x=a},FLIPBOOK.BookWebGL.prototype.isFocusedLeft=function(){return this.centerContainer.position.x>0},FLIPBOOK.BookWebGL.prototype.isFocusedRight=function(){return this.centerContainer.position.x<0},FLIPBOOK.BookWebGL.prototype.prevPage=function(a){if(0!=this.flippedleft&&this.prevEnabled&&(this.clickedPage=null,1!=this.flippedleft||2*this.pages.length!=this.pagesArr.length||!this.options.rightToLeft||!this.options.oddPages)){var b,c=0;for(b=0;b<this.pages.length;b++){if(this.pages[b].flippingLeft)return;this.pages[b].flipping&&c++}var d=this.pages[this.flippedleft-1],e=this.pages[d.index-1];this.pages[d.index+2],this.pages[d.index+3];if(e&&c<5&&e.showMat(),1==this.view){if(this.isFocusedRight())return void this.focusLeftPage(300);this.focusRighttPage(600,200)}else 1==this.flippedleft?this.focusRighttPage(500):0==this.flippedright&&this.focusBothPages(500);if(!d.flipping){var i,h=this;("undefined"==typeof a||a)&&(i=function(a){h.turnPageComplete()}),d.flipRight(i)}this.flippedleft--,this.flippedright++,this.rightIndex-=2}},FLIPBOOK.BookWebGL.prototype.firstPage=function(){},FLIPBOOK.BookWebGL.prototype.flipFinnished=function(){this.updateHtmlLayer()},FLIPBOOK.BookWebGL.prototype.lastPage=function(){},FLIPBOOK.BookWebGL.prototype.updateVisiblePages=function(){},FLIPBOOK.BookWebGL.prototype.updateHtmlLayer=function(){if(this.htmlLayer){for(var a=0;a<this.pages.length;a++)if(this.pages[a].flipping)return;if(this.htmlContentRightIndex=this.rightIndex,this.htmlLayerVisible=!1,0==this.rightIndex)this.$pageL.hide();else if(this.options.pages[this.rightIndex-1].htmlContent){this.$pageLInner.empty();jQuery(this.options.pages[this.rightIndex-1].htmlContent).appendTo(this.$pageLInner);this.$pageL.show(),
this.htmlLayerVisible=!0}else this.$pageL.hide();if(this.rightIndex==2*this.pages.length)this.$pageR.hide();else if(this.options.pages[this.rightIndex].htmlContent){this.$pageRInner.empty();jQuery(this.options.pages[this.rightIndex].htmlContent).appendTo(this.$pageRInner);this.$pageR.show(),this.htmlLayerVisible=!0}else this.$pageR.hide()}},FLIPBOOK.BookWebGL.prototype.onZoom=function(){this.enabled&&setTimeout(function(){},100)},FLIPBOOK.BookWebGL.prototype.render=function(a){var b=this;b.rendering=a},FLIPBOOK.BookWebGL.prototype.zoomTo=function(a,b){"undefined"==typeof b&&(b=50);var c=this;if(newZoom=a>this.options.zoomMax?this.options.zoomMax:a,newZoom=a<this.options.zoomMin?this.options.zoomMin:a,newZoom==this.options.zoom){var e=(this.options,this.isFocusedLeft());this.centerContainer.position.set(0,0,0),1==this.view&&(e?this.focusLeftPage():this.focusRighttPage()),this.updateBookPosition()}b>0?this.zooming||(this.zooming=!0,new TWEEN.Tween(this).to({zoom:newZoom},b).easing(TWEEN.Easing.Sinusoidal.InOut).onUpdate(this.updateCameraPosition).onComplete(function(){c.zooming=!1}).start()):(this.zoom=newZoom,this.zooming=!1,this.updateCameraPosition()),c.options.parent.onZoom(newZoom)},FLIPBOOK.BookWebGL.prototype.tiltTo=function(a){var c=.3,d=this.tilt+a*c;d=d>this.options.tiltMax?this.options.tiltMax:d,d=d<this.options.tiltMin?this.options.tiltMin:d,this.tilt=d,this.updateCameraPosition()},FLIPBOOK.BookWebGL.prototype.panTo=function(a){var c=.2,d=this.pan-a*c;d=d>this.options.panMax?this.options.panMax:d,d=d<this.options.panMin?this.options.panMin:d,this.pan=d,this.updateCameraPosition()},FLIPBOOK.BookWebGL.prototype._bind=function(a,b,c){(b||this.wrapper).addEventListener(a,this,!!c)},FLIPBOOK.BookWebGL.prototype.handleEvent=function(a){var b=this;switch(a.preventDefault(),a.type){case"mousedown":b._start(a);break;case"touchstart":b._touchstart(a);break;case"touchmove":b._touchmove(a);break;case"mousemove":b._move(a);break;case"mouseout":case"mouseup":case"touchend":b._end(a)}},FLIPBOOK.BookWebGL.prototype.resetCameraPosition=function(){this.centerContainer.position.set(0,0,0)},FLIPBOOK.BookWebGL.prototype._start=function(a){this.mouseDown=!0,this.onMouseMove="",this.pointX=a.pageX,this.pointY=a.pageY,this.startPoint=a;var b=this._getVector(a);b.unproject(this.Camera);var c=new THREE.Raycaster(this.Camera.position,b.sub(this.Camera.position).normalize()),d=c.intersectObjects(this.pages,!0);this.pageMouseDown=d.length>0,!this.pageMouseDown&&this.options.lightBox&&this.options.lightboxCloseOnClick&&this.options.main.lightbox.closeLightbox()},FLIPBOOK.BookWebGL.prototype._touchstart=function(a){if(a.touches.length>1){this.touches=[],this.touches[0]={pageX:a.touches[0].pageX,pageY:a.touches[0].pageY},this.touches[1]={pageX:a.touches[1].pageX,pageY:a.touches[1].pageY};var b=Math.abs(this.touches[0].pageX-this.touches[1].pageX),c=Math.abs(this.touches[0].pageY-this.touches[1].pageY);return void(this.touchesDistStart=Math.sqrt(b*b+c*c))}a=a.touches[0],this._start(a)},FLIPBOOK.BookWebGL.prototype._getVector=function(a){var b=jQuery(this.canvas).width(),c=jQuery(this.canvas).height(),d=a.pageX-jQuery(this.canvas).offset().left,e=a.pageY-jQuery(this.canvas).offset().top;jQuery(this.canvas).offset().x,jQuery(this.canvas).offset().y;return new THREE.Vector3(d/b*2-1,2*-(e/c)+1,.5)},FLIPBOOK.BookWebGL.prototype._touchmove=function(a){if(a.touches.length>1){this.touches=[],this.touches[0]={pageX:a.touches[0].pageX,pageY:a.touches[0].pageY},this.touches[1]={pageX:a.touches[1].pageX,pageY:a.touches[1].pageY};var c=Math.abs(this.touches[0].pageX-this.touches[1].pageX),d=Math.abs(this.touches[0].pageY-this.touches[1].pageY);return this.touchesDist=Math.sqrt(c*c+d*d),this.zoomTo(this.zoom*Math.pow(this.touchesDist/this.touchesDistStart,.125),0),void this.updateCameraPosition()}a=a.touches[0],this._move(a)},FLIPBOOK.BookWebGL.prototype._move=function(a){var b=this._getVector(a);b.unproject(this.Camera);var c=new THREE.Raycaster(this.Camera.position,b.sub(this.Camera.position).normalize()),d=c.intersectObjects(this.pages,!0),e=a,f=.5*(e.pageX-this.pointX),g=.5*(e.pageY-this.pointY);if(this.pointX=e.pageX,this.pointY=e.pageY,!this.mouseDown)return this.onMouseMove="",void(this.options.rotateCameraOnMouseMove&&(this.tilt=this.options.tiltMin2+(this.options.tiltMax2-this.options.tiltMin2)*(1-this.pointY/jQuery(this.canvas).height()),this.pan=this.options.panMin2+(this.options.panMax2-this.options.panMin2)*this.pointX/jQuery(this.canvas).width(),this.updateCameraPosition()));if(d.length>0?""==this.onMouseMove&&this.zoom>1&&(this.onMouseMove="scroll"):""==this.onMouseMove&&(this.onMouseMove="rotate"),"scroll"==this.onMouseMove)0==f&&0==g||(this.moved=!0,this.centerContainer.position.x+=1e4*f/(this.cameraZ*this.zoom*this.zoom),this.centerContainer.position.y-=1e4*g/(this.cameraZ*this.zoom*this.zoom)),this.htmlLayer&&(this.htmlLayer.position.x=this.centerContainer.position.x,this.htmlLayer.position.y=this.centerContainer.position.y);else if("rotate"==this.onMouseMove){var h=this.getRightPage(),i=this.getLeftPage();this.options.rotateCameraOnMouseMove||!this.options.rotateCameraOnMouseDrag||i&&i.dragging||h&&h.dragging||this.tiltTo(g)}},FLIPBOOK.BookWebGL.prototype._end=function(a){this.mouseDown=!1,"undefined"!=typeof a.changedTouches&&(a=a.changedTouches[0]),this.pointX=a.pageX,this.pointY=a.pageY,this.endPoint=a;var b=this._getVector(this.endPoint);b.unproject(this.Camera);var c=new THREE.Raycaster(this.Camera.position,b.sub(this.Camera.position).normalize()),d=c.intersectObjects(this.pages,!0);if(d.length>0&&this.pageMouseDown&&!this.moved){var e=d[0];this.clickedPage=e.object.parent}this.pageMouseDown=!1,this.moved=!1},FLIPBOOK.BookWebGL.prototype.moveCamera=function(a,b){},FLIPBOOK.BookWebGL.prototype.enable=function(){return this.enabled?void this.onResize():(this.enabled=!0,this.initialized||(this.init3d(),this.createPages(),this.rendering=!1,this.onResize()),this.render(!0),void this.onResize())},FLIPBOOK.BookWebGL.prototype.disable=function(){this.enabled=!1,this.render(!1)};var MOD3=MOD3||{};!function(a){a.Constants={PI:Math.PI,invPI:1/Math.PI,halfPI:.5*Math.PI,doublePI:2*Math.PI,toRad:1/180*Math.PI,toDeg:1/180*Math.PI},a.ModConstant={LEFT:-1,RIGHT:1,NONE:0,X:1,Y:2,Z:4}}(MOD3),function(a){var b=a.Constants;a.XMath={},a.XMath.normalize=function(b,c,d){return c-b==0?1:a.XMath.trim(0,1,(d-b)/c)},a.XMath.toRange=function(a,b,c){return b-a==0?0:a+(b-a)*c},a.XMath.inRange=function(a,b,c,d){return"undefined"==typeof d&&(d=!1),d?c>=a&&c<=b:c>a&&c<b},a.XMath.sign=function(a,b){return"undefined"==typeof b&&(b=0),0==a?b:a>0?1:-1},a.XMath.trim=function(a,b,c){return Math.min(b,Math.max(a,c))},a.XMath.wrap=function(a,b,c){return c<a?c+(b-a):c>=b?c-(b-a):c},a.XMath.degToRad=function(a){return a*b.toRad},a.XMath.radToDeg=function(a){return a*b.toDeg},a.XMath.presicion=function(a,b){var c=Math.pow(10,b);return Math.round(a*c)/c},a.XMath.uceil=function(a){return a<0?Math.floor(a):Math.ceil(a)}}(MOD3),function(a){a.Range=function(a,b){this.start=0,this.end=1,"undefined"!=typeof a&&(this.start=a),"undefined"!=typeof b&&(this.end=b)},a.Range.prototype.getSize=function(){return this.end-this.start},a.Range.prototype.move=function(a){this.start+=a,this.end+=a},a.Range.prototype.isIn=function(a){return a>=this.start&&a<=this.end},a.Range.prototype.normalize=function(b){return a.XMath.normalize(this.start,this.end,b)},a.Range.prototype.toRange=function(b){return a.XMath.toRange(this.start,this.end,b)},a.Range.prototype.trim=function(b){return a.XMath.trim(this.start,this.end,b)},a.Range.prototype.interpolate=function(a,b){return this.toRange(b.normalize(a))},a.Range.prototype.toString=function(){return"["+this.start+" - "+this.end+"]"}}(MOD3),function(a){a.Phase=function(a){this.value=0,"undefined"!=typeof a&&(this.value=a)},a.Phase.prototype.getPhasedValue=function(){return Math.sin(this.value)},a.Phase.prototype.getAbsPhasedValue=function(){return Math.abs(this.getPhasedValue())},a.Phase.prototype.getNormValue=function(){return.5*(this.getPhasedValue()+1)}}(MOD3),function(a){a.Point=function(a,b){this.y=this.x=0,"undefined"!=typeof a&&(this.x=a),"undefined"!=typeof b&&(this.y=b)},a.Point.prototype.clone=function(){return new a.Point(this.x,this.y)}}(MOD3),function(a){a.Matrix=function(a,b,c,d){this.m11=1,this.m21=this.m12=0,this.m22=1,"undefined"!=typeof a&&(this.m11=a),"undefined"!=typeof b&&(this.m12=b),"undefined"!=typeof c&&(this.m21=c),"undefined"!=typeof d&&(this.m22=d)},a.Matrix.prototype.rotate=function(a){var b=Math.cos(a),a=Math.sin(a);return this.m11=b,this.m12=-a,this.m21=a,this.m22=b,this},a.Matrix.prototype.scale=function(a,b){return this.m21=this.m12=0,"undefined"!=typeof a&&(this.m22=this.m11=a),"undefined"!=typeof b&&(this.m22=b),this},a.Matrix.prototype.multiply=function(a){var b=this.m11,c=this.m12,d=this.m21,e=this.m22,f=a.m11,g=a.m12,h=a.m21,a=a.m22;return this.m11=b*f+c*h,this.m12=b*g+c*a,this.m21=d*f+e*h,this.m22=d*g+e*a,this},a.Matrix.prototype.transformPoint=function(b){return new a.Point(this.m11*b.x+this.m12*b.y,this.m21*b.x+this.m22*b.y)}}(MOD3),function(a){a.Vector3=function(a,b,c){this.z=this.y=this.x=null,this.x=a,this.y=b,this.z=c},a.Vector3.ZERO=function(){return new a.Vector3(0,0,0)},a.Vector3.dot=function(a,b){return a.x*b.x+a.y*b.y+a.z*b.z},a.Vector3.prototype.clone=function(){return new a.Vector3(this.x,this.y,this.z)},a.Vector3.prototype.equals=function(a){return this.x==a.x&&this.y==a.y&&this.z==a.z},a.Vector3.prototype.zero=function(){this.x=this.y=this.z=0},a.Vector3.prototype.negate=function(){return new a.Vector3(-this.x,-this.y,-this.z)},a.Vector3.prototype.add=function(b){return new a.Vector3(this.x+b.x,this.y+b.y,this.z+b.z)},a.Vector3.prototype.subtract=function(b){return new a.Vector3(this.x-b.x,this.y-b.y,this.z-b.z)},a.Vector3.prototype.multiplyScalar=function(b){return new a.Vector3(this.x*b,this.y*b,this.z*b)},a.Vector3.prototype.multiply=function(b){return new a.Vector3(this.x*b.x,this.y*b.y,this.z*b.z)},a.Vector3.prototype.divide=function(b){return b=1/b,new a.Vector3(this.x*b,this.y*b,this.z*b)},a.Vector3.prototype.normalize=function(){var a=this.x,b=this.y,c=this.z,a=a*a+b*b+c*c;a>0&&(a=1/Math.sqrt(a),this.x*=a,this.y*=a,this.z*=a)},a.Vector3.prototype.getMagnitude=function(){var a=this.x,b=this.y,c=this.z;return Math.sqrt(a*a+b*b+c*c)},a.Vector3.prototype.setMagnitude=function(a){this.normalize(),this.x*=a,this.y*=a,this.z*=a},a.Vector3.prototype.toString=function(){return"["+this.x+" , "+this.y+" , "+this.z+"]"},a.Vector3.prototype.sum=function(a,b){return a.add(b)},a.Vector3.prototype.dot=function(a,b){return a.x*b.x+a.y*b.y+a.z*b.z},a.Vector3.prototype.cross=function(b,c){var d=b.x,e=b.y,f=b.z,g=c.x,h=c.y,i=c.z;return new a.Vector3(e*i-f*h,f*g-d*i,d*h-e*g)},a.Vector3.prototype.distance=function(a,b){var c=a.x-b.x,d=a.y-b.y,e=a.z-b.z;return Math.sqrt(c*c+d*d+e*e)}}(MOD3),function(a){a.Matrix4=function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p){this.n11=1,this.n21=this.n14=this.n13=this.n12=0,this.n22=1,this.n32=this.n31=this.n24=this.n23=0,this.n33=1,this.n43=this.n42=this.n41=this.n34=0,this.n44=1,"undefined"!=typeof a&&(this.n11=a),"undefined"!=typeof b&&(this.n12=b),"undefined"!=typeof c&&(this.n13=c),"undefined"!=typeof d&&(this.n14=d),"undefined"!=typeof e&&(this.n21=e),"undefined"!=typeof f&&(this.n22=f),"undefined"!=typeof g&&(this.n23=g),"undefined"!=typeof h&&(this.n24=h),"undefined"!=typeof i&&(this.n31=i),"undefined"!=typeof j&&(this.n32=j),"undefined"!=typeof k&&(this.n33=k),"undefined"!=typeof l&&(this.n34=l),"undefined"!=typeof m&&(this.n41=m),"undefined"!=typeof n&&(this.n42=n),"undefined"!=typeof o&&(this.n43=o),"undefined"!=typeof p&&(this.n44=p)},a.Matrix4.prototype.translationMatrix=function(a,b,c){return this.n14=a,this.n24=b,this.n34=c,this},a.Matrix4.prototype.scaleMatrix=function(a,b,c){return this.n11=a,this.n22=b,this.n33=c,this},a.Matrix4.prototype.rotationMatrix=function(a,b,c,d){var e=Math.cos(d),f=Math.sin(d),d=1-e,g=a*b*d,h=b*c*d,i=a*c*d,j=f*c,k=f*b;return f*=a,this.n11=e+a*a*d,this.n12=-j+g,this.n13=k+i,this.n14=0,this.n21=j+g,this.n22=e+b*b*d,this.n23=-f+h,this.n24=0,this.n31=-k+i,this.n32=f+h,this.n33=e+c*c*d,this.n34=0,this},a.Matrix4.prototype.calculateMultiply=function(a,b){var c=a.n11,d=b.n11,e=a.n21,f=b.n21,g=a.n31,h=b.n31,i=a.n12,j=b.n12,k=a.n22,l=b.n22,m=a.n32,n=b.n32,o=a.n13,p=b.n13,q=a.n23,r=b.n23,s=a.n33,t=b.n33,u=a.n14,v=b.n14,w=a.n24,x=b.n24,y=a.n34,z=b.n34;this.n11=c*d+i*f+o*h,this.n12=c*j+i*l+o*n,this.n13=c*p+i*r+o*t,this.n14=c*v+i*x+o*z+u,this.n21=e*d+k*f+q*h,this.n22=e*j+k*l+q*n,this.n23=e*p+k*r+q*t,this.n24=e*v+k*x+q*z+w,this.n31=g*d+m*f+s*h,this.n32=g*j+m*l+s*n,this.n33=g*p+m*r+s*t,this.n34=g*v+m*x+s*z+y},a.Matrix4.prototype.multiply=function(a,b){return this.calculateMultiply(a,b),this},a.Matrix4.prototype.multiplyVector=function(a,b){var c=b.x,d=b.y,e=b.z;b.x=c*a.n11+d*a.n12+e*a.n13+a.n14,b.y=c*a.n21+d*a.n22+e*a.n23+a.n24,b.z=c*a.n31+d*a.n32+e*a.n33+a.n34}}(MOD3),function(a){a.VertexProxy=function(a){this.originalZ=this.originalY=this.originalX=this.ratioZ=this.ratioY=this.ratioX=null,"undefined"!=typeof a&&(this.vertex=a)},a.VertexProxy.prototype.setVertex=function(){},a.VertexProxy.prototype.setRatios=function(a,b,c){this.ratioX=a,this.ratioY=b,this.ratioZ=c},a.VertexProxy.prototype.setOriginalPosition=function(a,b,c){this.originalX=a,this.originalY=b,this.originalZ=c},a.VertexProxy.prototype.getX=function(){},a.VertexProxy.prototype.getY=function(){},a.VertexProxy.prototype.getZ=function(){},a.VertexProxy.prototype.setX=function(){},a.VertexProxy.prototype.setY=function(){},a.VertexProxy.prototype.setZ=function(){},a.VertexProxy.prototype.getValue=function(b){switch(b){case a.ModConstant.X:return this.getX();case a.ModConstant.Y:return this.getY();case a.ModConstant.Z:return this.getZ()}return 0},a.VertexProxy.prototype.setValue=function(b,c){switch(b){case a.ModConstant.X:this.setX(c);break;case a.ModConstant.Y:this.setY(c);break;case a.ModConstant.Z:this.setZ(c)}},a.VertexProxy.prototype.getRatio=function(b){switch(b){case a.ModConstant.X:return this.ratioX;case a.ModConstant.Y:return this.ratioY;case a.ModConstant.Z:return this.ratioZ}return-1},a.VertexProxy.prototype.getOriginalValue=function(b){switch(b){case a.ModConstant.X:return this.originalX;case a.ModConstant.Y:return this.originalY;case a.ModConstant.Z:return this.originalZ}return 0},a.VertexProxy.prototype.reset=function(){this.setX(this.originalX),this.setY(this.originalY),this.setZ(this.originalZ)},a.VertexProxy.prototype.collapse=function(){this.originalX=this.getX(),this.originalY=this.getY(),this.originalZ=this.getZ()},a.VertexProxy.prototype.getVector=function(){return new a.Vector3(this.getX(),this.getY(),this.getZ())},a.VertexProxy.prototype.setVector=function(a){this.setX(a.x),this.setY(a.y),this.setZ(a.z)},a.VertexProxy.prototype.getRatioVector=function(){return new a.Vector3(this.ratioX,this.ratioY,this.ratioZ)}}(MOD3),function(a){a.FaceProxy=function(){this.vertices=[]},a.FaceProxy.prototype.addVertex=function(a){this.vertices.push(a)},a.FaceProxy.prototype.getVertices=function(){return this.vertices}}(MOD3),function(a){a.MeshProxy=function(){this.depth=this.height=this.width=this.minAxis=this.midAxis=this.maxAxis=this.minZ=this.minY=this.minX=this.maxZ=this.maxY=this.maxX=null,this.vertices=[],this.faces=[],this.mesh=null},a.MeshProxy.prototype.getVertices=function(){return this.vertices},a.MeshProxy.prototype.getFaces=function(){return this.faces},a.MeshProxy.prototype.analyzeGeometry=function(){for(var e,f,g,h,i,j,k,l,m,n,b=this.getVertices(),c=b.length,d=c,o=!0,p=Math.min,q=Math.max;--d>=0;)e=b[d],f=e.getX(),g=e.getY(),h=e.getZ(),o?(i=j=f,k=l=g,m=n=h,o=!1):(i=p(i,f),k=p(k,g),m=p(m,h),j=q(j,f),l=q(l,g),n=q(n,h)),e.setOriginalPosition(f,g,h);for(f=j-i,g=l-k,depth=n-m,this.width=f,this.height=g,this.depth=depth,this.minX=i,this.maxX=j,this.minY=k,this.maxY=l,this.minZ=m,this.maxZ=n,d=q(f,q(g,depth)),p=p(f,p(g,depth)),d==f&&p==g?(this.minAxis=a.ModConstant.Y,this.midAxis=a.ModConstant.Z,this.maxAxis=a.ModConstant.X):d==f&&p==depth?(this.minAxis=a.ModConstant.Z,this.midAxis=a.ModConstant.Y,this.maxAxis=a.ModConstant.X):d==g&&p==f?(this.minAxis=a.ModConstant.X,this.midAxis=a.ModConstant.Z,this.maxAxis=a.ModConstant.Y):d==g&&p==depth?(this.minAxis=a.ModConstant.Z,this.midAxis=a.ModConstant.X,this.maxAxis=a.ModConstant.Y):d==depth&&p==f?(this.minAxis=a.ModConstant.X,this.midAxis=a.ModConstant.Y,this.maxAxis=a.ModConstant.Z):d==depth&&p==g&&(this.minAxis=a.ModConstant.Y,this.midAxis=a.ModConstant.X,this.maxAxis=a.ModConstant.Z),d=c;--d>=0;)e=b[d],e.setRatios((e.getX()-i)/f,(e.getY()-k)/g,(e.getZ()-m)/depth)},a.MeshProxy.prototype.resetGeometry=function(){for(var a=this.getVertices(),b=a.length;--b>=0;)a[b].reset()},a.MeshProxy.prototype.collapseGeometry=function(){for(var a=this.getVertices(),b=a.length;--b>=0;)a[b].collapse();this.analyzeGeometry()},a.MeshProxy.prototype.getMin=function(b){switch(b){case a.ModConstant.X:return this.minX;case a.ModConstant.Y:return this.minY;case a.ModConstant.Z:return this.minZ}return-1},a.MeshProxy.prototype.getMax=function(b){switch(b){case a.ModConstant.X:return this.maxX;case a.ModConstant.Y:return this.maxY;case a.ModConstant.Z:return this.maxZ}return-1},a.MeshProxy.prototype.getSize=function(b){switch(b){case a.ModConstant.X:return this.width;case a.ModConstant.Y:return this.height;case a.ModConstant.Z:return this.depth}return-1},a.MeshProxy.prototype.setMesh=function(a){this.mesh=a,this.vertices=[],this.faces=[]},a.MeshProxy.prototype.postApply=function(){},a.MeshProxy.prototype.updateMeshPosition=function(){}}(MOD3),function(a){a.Modifier=function(){this.mod=null},a.Modifier.prototype.setModifiable=function(a){this.mod=a},a.Modifier.prototype.getVertices=function(){return this.mod.getVertices()},a.Modifier.prototype.apply=function(){}}(MOD3),function(a){a.Library3d=function(){this.id="",this.vertexClass=this.meshClass=null}}(MOD3),function(a){a.PluginFactory={},a.PluginFactory.getMeshProxy=function(a){return new a.meshClass}}(MOD3),function(a){a.ModifierStack=function(b,c){this.lib3d=b,this.stack=this.baseMesh=null,this.baseMesh=a.PluginFactory.getMeshProxy(b),this.baseMesh.setMesh(c),this.baseMesh.analyzeGeometry(),this.stack=[]},a.ModifierStack.prototype.addModifier=function(a){a.setModifiable(this.baseMesh),this.stack.push(a)},a.ModifierStack.prototype.apply=function(){this.baseMesh.resetGeometry();for(var a=this.stack,b=a.length,c=0;c<b;)a[c++].apply();this.baseMesh.postApply()},a.ModifierStack.prototype.collapse=function(){this.apply(),this.baseMesh.collapseGeometry(),this.stack=[]},a.ModifierStack.prototype.clear=function(){this.stack=[]},a.ModifierStack.prototype.getMeshInfo=function(){return this.baseMesh}}(MOD3),function(a){a.Pivot=function(b,c,d){this.pivot=new a.Vector3(b,c,d)},a.Pivot.prototype=new a.Modifier,a.Pivot.prototype.constructor=a.Pivot,a.Pivot.prototype.setMeshCenter=function(){var b=this.mod;this.pivot=new a.Vector3(-(b.minX+.5*b.width),-(b.minY+.5*b.height),-(b.minZ+.5*b.depth))},a.Pivot.prototype.apply=function(){for(var d,e,a=this.mod.getVertices(),b=a.length,c=this.pivot;--b>=0;)d=a[b],e=d.getVector().clone(),d.setVector(e.add(c));this.mod.updateMeshPosition(c.clone().negate())}}(MOD3),function(a){a.Bend=function(b,c,d){this.diagAngle=this.angle=this.offset=this.force=null,this.constraint=a.ModConstant.NONE,this.m2=this.m1=this.origin=this.height=this.width=this.mid=this.min=this.max=null,this.switchAxes=!1,this.force=b,this.offset=c,this.setAngle(d)},a.Bend.prototype=new a.Modifier,a.Bend.prototype.constructor=a.Bend,a.Bend.prototype.setAngle=function(b){this.angle=b,this.m1=new a.Matrix,this.m1.rotate(b),this.m2=new a.Matrix,this.m2.rotate(-b)},a.Bend.prototype.setModifiable=function(b){a.Modifier.prototype.setModifiable.call(this,b),this.max=this.switchAxes?this.mod.midAxis:this.mod.maxAxis,this.min=this.mod.minAxis,this.mid=this.switchAxes?this.mod.maxAxis:this.mod.midAxis,this.width=this.mod.getSize(this.max),this.height=this.mod.getSize(this.mid),this.origin=this.mod.getMin(this.max),this.diagAngle=Math.atan(this.width/this.height)},a.Bend.prototype.apply=function(){if(0!=this.force)for(var o,p,q,r,b=this.mod.getVertices(),c=b.length,d=this.width,e=this.offset,f=this.origin,g=this.max,h=this.min,i=this.mid,j=this.m1,k=this.m2,l=f+d*e,m=d/Math.PI/this.force,n=a.Constants.doublePI*(d/(m*a.Constants.doublePI)),s=1/d,t=a.Constants.halfPI,u=Math.sin,v=Math.cos;--c>=0;)d=b[c],o=d.getValue(g),p=d.getValue(i),q=d.getValue(h),p=j.transformPoint(new a.Point(o,p)),o=p.x,p=p.y,r=(o-f)*s,this.constraint==a.ModConstant.LEFT&&r<=e||this.constraint==a.ModConstant.RIGHT&&r>=e||(r=t-n*e+n*r,o=u(r)*(m+q),r=v(r)*(m+q),q=o-m,o=l-r),p=k.transformPoint(new a.Point(o,p)),o=p.x,p=p.y,d.setValue(g,o),d.setValue(i,p),d.setValue(h,q)}}(MOD3),function(a){a.Bloat=function(){this.center=a.Vector3.ZERO(),this.radius=0,this.a=.01,this.u=a.Vector3.ZERO()},a.Bloat.prototype=new a.Modifier,a.Bloat.prototype.constructor=a.Bloat,a.Bloat.prototype.setRadius=function(a){this.radius=Math.max(0,a)},a.Bloat.prototype.setA=function(a){this.a=Math.max(0,a)},a.Bloat.prototype.apply=function(){for(var f,g,a=this.mod.getVertices(),b=a.length,c=this.center,d=this.radius,e=this.a;--b>=0;)f=a[b],this.u.x=f.getX()-c.x,this.u.y=f.getY()-c.y,this.u.z=f.getZ()-c.z,g=this.u.getMagnitude(),this.u.setMagnitude(g+d*Math.exp(-g*e)),f.setX(this.u.x+c.x),f.setY(this.u.y+c.y),f.setZ(this.u.z+c.z)}}(MOD3),function(a){a.Twist=function(b){this.vector=new a.Vector3(0,1,0),this.angle=b,this.center=a.Vector3.ZERO()},a.Twist.prototype=new a.Modifier,a.Twist.prototype.constructor=a.Twist,a.Twist.prototype.apply=function(){this.vector.normalize();for(var h,b=this.mod,c=b.getVertices(),d=c.length,e=this.vector,f=this.angle,g=this.center,b=1/new a.Vector3(.5*b.maxX,.5*b.maxY,.5*b.maxZ).getMagnitude()*f,g=-a.Vector3.dot(e,g);--d>=0;)f=c[d],h=f.getX()*e.x+f.getY()*e.y+f.getZ()*e.z+g,this.twistPoint(f,h*b)},a.Twist.prototype.twistPoint=function(b,c){var d=(new a.Matrix4).translationMatrix(b.getX(),b.getY(),b.getZ()),d=(new a.Matrix4).multiply((new a.Matrix4).rotationMatrix(this.vector.x,this.vector.y,this.vector.z,c),d);b.setX(d.n14),b.setY(d.n24),b.setZ(d.n34)}}(MOD3),function(a){a.Skew=function(b){this.force=0,this.skewAxis=null,"undefined"!=typeof b&&(this.force=b),this.offset=.5,this.constraint=a.ModConstant.NONE,this.falloff=this.power=1,this.swapAxes=this.oneSide=this.inverseFalloff=!1},a.Skew.prototype=new a.Modifier,a.Skew.prototype.constructor=a.Skew,a.Skew.prototype.setModifiable=function(b){a.Modifier.prototype.setModifiable.call(this,b),this.skewAxis=this.skewAxis||this.mod.maxAxis},a.Skew.prototype.apply=function(){for(var n,o,p,b=this.mod.getVertices(),c=b.length,d=this.constraint,e=this.skewAxis,f=this.offset,g=this.oneSide,h=this.inverseFalloff,i=this.falloff,j=1-i,k=this.power,l=this.force,m=this.getDisplaceAxis();--c>=0;)n=b[c],!(d==a.ModConstant.LEFT&&n.getRatio(e)<=f)&&!(d==a.ModConstant.RIGHT&&n.getRatio(e)>f)&&(o=n.getRatio(e)-f,g&&(o=Math.abs(o)),p=n.getRatio(m),h&&(p=1-p),p=i+p*j,o=Math.pow(Math.abs(o),k)*a.XMath.sign(o,1),o=n.getValue(m)+l*o*p,n.setValue(m,o))},a.Skew.prototype.getDisplaceAxis=function(){switch(this.skewAxis){case a.ModConstant.X:return this.swapAxes?a.ModConstant.Z:a.ModConstant.Y;case a.ModConstant.Y:return this.swapAxes?a.ModConstant.Z:a.ModConstant.X;case a.ModConstant.Z:return this.swapAxes?a.ModConstant.Y:a.ModConstant.X;default:return 0}}}(MOD3),function(a){a.Taper=function(b){this.power=this.force=null,this.start=0,this.end=1,this.vector=new a.Vector3(1,0,1),this.vector2=new a.Vector3(0,1,0),"undefined"!=typeof b&&(this.force=b),this.power=1},a.Taper.prototype=new a.Modifier,a.Taper.prototype.constructor=a.Taper,a.Taper.prototype.setFalloff=function(a,b){this.start=0,this.end=1,"undefined"!=typeof a&&(this.start=a),"undefined"!=typeof b&&(this.end=b)},a.Taper.prototype.apply=function(){for(var h,i,j,b=this.mod.getVertices(),c=b.length,d=this.vector,e=this.vector2,f=this.force,g=this.power;--c>=0;)h=b[c],i=h.getRatioVector().multiply(e),i=f*Math.pow(i.getMagnitude(),g),i=(new a.Matrix4).scaleMatrix(1+i*d.x,1+i*d.y,1+i*d.z),j=h.getVector(),(new a.Matrix4).multiplyVector(i,j),h.setVector(j)}}(MOD3),function(a){a.Wheel=function(){this.radius=this.roll=this.turn=this.speed=null,this.steerVector=new a.Vector3(0,1,0),this.rollVector=new a.Vector3(0,0,1),this.roll=this.turn=this.speed=0},a.Wheel.prototype=new a.Modifier,a.Wheel.prototype.constructor=a.Wheel,a.Wheel.prototype.setModifiable=function(b){a.Modifier.prototype.setModifiable.call(this,b),this.radius=.5*this.mod.width},a.Wheel.prototype.apply=function(){this.roll+=this.speed;var h,b=this.mod.getVertices(),c=b.length,d=this.steerVector,e=this.turn,f=this.rollVector,g=this.roll;for(0!=e?(h=(new a.Matrix4).rotationMatrix(d.x,d.y,d.z,e),d=f.clone(),(new a.Matrix4).multiplyVector(h,d),g=(new a.Matrix4).rotationMatrix(d.x,d.y,d.z,g)):g=(new a.Matrix4).rotationMatrix(f.x,f.y,f.z,g);--c>=0;)d=b[c],f=d.getVector().clone(),0!=e&&(new a.Matrix4).multiplyVector(h,f),(new a.Matrix4).multiplyVector(g,f),d.setX(f.x),d.setY(f.y),d.setZ(f.z)},a.Wheel.prototype.getStep=function(){return this.radius*this.speed*a.Constants.invPI},a.Wheel.prototype.getPerimeter=function(){return this.radius*a.Constants.doublePI}}(MOD3),function(a){a.Break=function(b,c){this.bv=new a.Vector3(0,1,0),this.angle=this.offset=0,"undefined"!=typeof b&&(this.offset=b),"undefined"!=typeof c&&(this.angle=c),this.range=new a.Range(0,1)},a.Break.prototype=new a.Modifier,a.Break.prototype.constructor=a.Break,a.Break.prototype.apply=function(){var h,i,b=this.mod,c=b.getVertices(),d=c.length,e=this.range,f=this.angle,g=this.bv,b=new a.Vector3(0,0,-(b.minZ+b.depth*this.offset));for(h=b.negate(),i=(new a.Matrix4).rotationMatrix(g.x,g.y,g.z,f);--d>=0;)f=c[d],g=f.getVector(),g=g.add(b),g.z>=0&&e.isIn(f.ratioY)&&(new a.Matrix4).multiplyVector(i,g),g=g.add(h),f.setX(g.x),f.setY(g.y),f.setZ(g.z)}}(MOD3),function(a){a.Noise=function(b){this.force=0,this.axc=a.ModConstant.NONE,this.end=this.start=0,"undefined"!=typeof b&&(this.force=b)},a.Noise.prototype=new a.Modifier,a.Noise.prototype.constructor=a.Noise,a.Noise.prototype.constraintAxes=function(a){this.axc=a},a.Noise.prototype.setFalloff=function(a,b){this.start=0,this.end=1,"undefined"!=typeof a&&(this.start=a),"undefined"!=typeof b&&(this.end=b)},a.Noise.prototype.apply=function(){for(var j,k,l,a=this.mod,b=this.axc,c=this.start,d=this.end,e=a.getVertices(),f=e.length,g=this.force,h=.5*g,i=Math.random;--f>=0;)j=e[f],k=i()*g-h,l=j.getRatio(a.maxAxis),c<d?(l<c&&(l=0),l>d&&(l=1)):c>d?(l=1-l,l>c&&(l=0),l<d&&(l=1)):l=1,1&b||j.setX(j.getX()+k*l),b>>1&1||j.setY(j.getY()+k*l),b>>2&1||j.setZ(j.getZ()+k*l)}}(MOD3),function(a){a.LibraryThree=function(){this.id="Three.js",this.meshClass=a.MeshThree,this.vertexClass=a.VertexThree},a.LibraryThree.prototype=new a.Library3d,a.LibraryThree.prototype.constructor=a.LibraryThree}(MOD3),function(a){a.VertexThree=function(a){this.mesh=a},a.VertexThree.prototype=new a.VertexProxy,a.VertexThree.prototype.setVertex=function(a){this.vertex=a,this.originalX=a.x,this.originalY=a.y,this.originalZ=a.z},a.VertexThree.prototype.getX=function(){return this.vertex.x},a.VertexThree.prototype.getY=function(){return this.vertex.y},a.VertexThree.prototype.getZ=function(){return this.vertex.z},a.VertexThree.prototype.setX=function(a){this.vertex.x=a,a=this.mesh,a.geometry.verticesNeedUpdate=!0,a.geometry.normalsNeedUpdate=!0,a.geometry.buffersNeedUpdate=!0,a.geometry.dynamic=!0},a.VertexThree.prototype.setY=function(a){this.vertex.y=a,a=this.mesh,a.geometry.verticesNeedUpdate=!0,a.geometry.normalsNeedUpdate=!0,a.geometry.buffersNeedUpdate=!0,a.geometry.dynamic=!0},a.VertexThree.prototype.setZ=function(a){this.vertex.z=a,a=this.mesh,a.geometry.verticesNeedUpdate=!0,a.geometry.normalsNeedUpdate=!0,a.geometry.buffersNeedUpdate=!0,a.geometry.dynamic=!0}}(MOD3),function(a){a.MeshThree=function(){},a.MeshThree.prototype=new a.MeshProxy,a.MeshThree.prototype.setMesh=function(b){a.MeshProxy.prototype.setMesh.call(this,b);for(var h,b=[],c=0,d=this.mesh.geometry.vertices,e=d.length,f=this.mesh.geometry.faces,g=f.length,c=0;c<e;)h=new a.VertexThree(this.mesh),h.setVertex(d[c]),this.vertices.push(h),b[d[c]]=h,c++;for(c=0;c<g;)e=new a.FaceProxy,f[c]instanceof THREE.Face3?(e.addVertex(b[d[f[c].a]]),e.addVertex(b[d[f[c].b]]),e.addVertex(b[d[f[c].c]])):f[c]instanceof THREE.Face4&&(e.addVertex(b[d[f[c].a]]),e.addVertex(b[d[f[c].b]]),e.addVertex(b[d[f[c].c]]),e.addVertex(b[d[f[c].d]])),this.faces.push(e),c++;delete lookup},a.MeshThree.prototype.updateMeshPosition=function(a){var b=this.mesh;b.position.x+=a.x,b.position.y+=a.y,b.position.z+=a.z}}(MOD3),function(a){a.LibraryPre3D=function(){this.id="pre3d.js",this.meshClass=a.MeshPre3D,this.vertexClass=a.VertexPre3D},a.LibraryThree.prototype=new a.Library3d,a.LibraryThree.prototype.constructor=a.LibraryPre3D}(MOD3),function(a){a.VertexPre3D=function(){},a.VertexPre3D.prototype=new a.VertexProxy,a.VertexPre3D.prototype.setVertex=function(a){this.vertex=a,this.originalX=a.x,this.originalY=a.y,this.originalZ=a.z},a.VertexPre3D.prototype.getX=function(){return this.vertex.x},a.VertexPre3D.prototype.getY=function(){return this.vertex.y},a.VertexPre3D.prototype.getZ=function(){return this.vertex.z},a.VertexPre3D.prototype.setX=function(a){this.vertex.x=a},a.VertexPre3D.prototype.setY=function(a){this.vertex.y=a},a.VertexPre3D.prototype.setZ=function(a){this.vertex.z=a}}(MOD3),function(a){a.MeshPre3D=function(){},a.MeshPre3D.prototype=new a.MeshProxy,a.MeshPre3D.prototype.setMesh=function(b){a.MeshProxy.prototype.setMesh.call(this,b);for(var b=[],c=this.mesh.vertices,d=this.mesh.quads,e=c.length,f=d.length,g=0;g<e;g++){var h=new a.VertexPre3D;h.setVertex(c[g]),this.vertices.push(h),b[c[g]]=h}for(g=0;g<f;g++)e=new a.FaceProxy,d[g]instanceof Pre3d.QuadFace&&(e.addVertex(b[c[d[g].i0]]),e.addVertex(b[c[d[g].i1]]),e.addVertex(b[c[d[g].i2]]),null!=d[g].i3&&e.addVertex(b[c[d[g].i3]])),this.faces.push(e);delete lookup},a.MeshPre3D.prototype.updateMeshPosition=function(){}}(MOD3),function(a){a.LibraryJ3D=function(){this.id="J3D",this.meshClass=a.MeshJ3D,this.vertexClass=a.VertexJ3D},a.LibraryJ3D.prototype=new a.Library3d,a.LibraryJ3D.prototype.constructor=a.LibraryJ3D}(MOD3),function(a){a.VertexJ3D=function(a){this.geometry=a},a.VertexJ3D.prototype=new a.VertexProxy,a.VertexJ3D.prototype.setVertex=function(a){this.vertex=a;var b=this.geometry;this.originalX=b.vertexPositionBuffer.data[a],this.originalY=b.vertexPositionBuffer.data[a+1],this.originalZ=b.vertexPositionBuffer.data[a+2]},a.VertexJ3D.prototype.getX=function(){return this.geometry.vertexPositionBuffer.data[this.vertex]},a.VertexJ3D.prototype.getY=function(){return this.geometry.vertexPositionBuffer.data[this.vertex+1]},a.VertexJ3D.prototype.getZ=function(){return this.geometry.vertexPositionBuffer.data[this.vertex+2]},a.VertexJ3D.prototype.setX=function(a){var b=this.geometry;b.vertexPositionBuffer.data[this.vertex]=a,b.replaceArray(b.vertexPositionBuffer,b.vertexPositionBuffer.data)},a.VertexJ3D.prototype.setY=function(a){var b=this.geometry;b.vertexPositionBuffer.data[this.vertex+1]=a,b.replaceArray(b.vertexPositionBuffer,b.vertexPositionBuffer.data)},a.VertexJ3D.prototype.setZ=function(a){var b=this.geometry;b.vertexPositionBuffer.data[this.vertex+2]=a,b.replaceArray(b.vertexPositionBuffer,b.vertexPositionBuffer.data)}}(MOD3),function(a){a.MeshJ3D=function(){},a.MeshJ3D.prototype=new a.MeshProxy,a.MeshJ3D.prototype.setMesh=function(b){a.MeshProxy.prototype.setMesh.call(this,b);for(var f,c=0,d=b.geometry.vertexPositionBuffer.data.length,e=b.geometry.vertexPositionBuffer.itemSize,c=0;c<d;)f=new a.VertexJ3D(b.geometry),f.setVertex(c),this.vertices.push(f),c+=e;this.faces=null},a.MeshJ3D.prototype.updateMeshPosition=function(a){var b=this.mesh;b.position.x+=a.x,b.position.y+=a.y,b.position.z+=a.z}}(MOD3),function(a){a.LibraryCopperlicht=function(){this.id="Copperlicht",
this.meshClass=a.MeshCopperlicht,this.vertexClass=a.VertexCopperlicht},a.LibraryCopperlicht.prototype=new a.Library3d,a.LibraryCopperlicht.prototype.constructor=a.LibraryCopperlicht}(MOD3),function(a){a.VertexCopperlicht=function(a,b){this.node=a,this.buffer=b},a.VertexCopperlicht.prototype=new a.VertexProxy,a.VertexCopperlicht.prototype.setVertex=function(a){this.vertex=a,this.originalX=this.vertex.Pos.X,this.originalY=this.vertex.Pos.Y,this.originalZ=this.vertex.Pos.Z},a.VertexCopperlicht.prototype.getX=function(){return this.vertex.Pos.X},a.VertexCopperlicht.prototype.getY=function(){return this.vertex.Pos.Y},a.VertexCopperlicht.prototype.getZ=function(){return this.vertex.Pos.Z},a.VertexCopperlicht.prototype.setX=function(a){this.vertex.Pos.X=a,this.buffer.update(!0)},a.VertexCopperlicht.prototype.setY=function(a){this.vertex.Pos.Y=a,this.buffer.update(!0)},a.VertexCopperlicht.prototype.setZ=function(a){this.vertex.Pos.Z=a,this.buffer.update(!0)}}(MOD3),function(a){a.MeshCopperlicht=function(){},a.MeshCopperlicht.prototype=new a.MeshProxy,a.MeshCopperlicht.prototype.setMesh=function(b){a.MeshProxy.prototype.setMesh.call(this,b);for(var b=this.mesh.getMesh().GetMeshBuffers(),c=[],d=0;d<b.length;d++)for(var c=b[d].Vertices,e=c.length,f=0;f<e;f++){var g=new a.VertexCopperlicht(this.mesh,b[d]);g.setVertex(c[f]),this.vertices.push(g)}this.faces=null,delete lookup},a.MeshCopperlicht.prototype.updateMeshPosition=function(a){this.mesh.Pos.X+=a.x,this.mesh.Pos.Y+=a.y,this.mesh.Pos.Z+=a.z}}(MOD3),!function(a){if("performance"in a==!1&&(a.performance={}),Date.now=Date.now||function(){return(new Date).getTime()},"now"in a.performance==!1){var b=a.performance.timing&&a.performance.timing.navigationStart?performance.timing.navigationStart:Date.now();a.performance.now=function(){return Date.now()-b}}}(this);var TWEEN=TWEEN||function(){var a=[];return{REVISION:"14",getAll:function(){return a},removeAll:function(){a=[]},add:function(b){a.push(b)},remove:function(b){var c=a.indexOf(b);c!==-1&&a.splice(c,1)},update:function(b){if(0===a.length)return!1;var c=0;for(b=void 0!==b?b:window.performance.now();c<a.length;)a[c].update(b)?c++:a.splice(c,1);return!0}}}();TWEEN.Tween=function(a){var b=a,c={},d={},e={},f=1e3,g=0,h=!1,i=!1,j=!1,k=0,l=null,m=TWEEN.Easing.Linear.None,n=TWEEN.Interpolation.Linear,o=[],p=null,q=!1,r=null,s=null,t=null;for(var u in a)c[u]=parseFloat(a[u],10);this.to=function(a,b){return void 0!==b&&(f=b),d=a,this},this.start=function(a){TWEEN.add(this),i=!0,q=!1,l=void 0!==a?a:window.performance.now(),l+=k;for(var f in d){if(d[f]instanceof Array){if(0===d[f].length)continue;d[f]=[b[f]].concat(d[f])}c[f]=b[f],c[f]instanceof Array==!1&&(c[f]*=1),e[f]=c[f]||0}return this},this.stop=function(){return i?(TWEEN.remove(this),i=!1,null!==t&&t.call(b),this.stopChainedTweens(),this):this},this.stopChainedTweens=function(){for(var a=0,b=o.length;a<b;a++)o[a].stop()},this.delay=function(a){return k=a,this},this.repeat=function(a){return g=a,this},this.yoyo=function(a){return h=a,this},this.easing=function(a){return m=a,this},this.interpolation=function(a){return n=a,this},this.chain=function(){return o=arguments,this},this.onStart=function(a){return p=a,this},this.onUpdate=function(a){return r=a,this},this.onComplete=function(a){return s=a,this},this.onStop=function(a){return t=a,this},this.update=function(a){var i;if(a<l)return!0;q===!1&&(null!==p&&p.call(b),q=!0);var t=(a-l)/f;t=t>1?1:t;var u=m(t);for(i in d){var v=c[i]||0,w=d[i];w instanceof Array?b[i]=n(w,u):("string"==typeof w&&(w=v+parseFloat(w,10)),"number"==typeof w&&(b[i]=v+(w-v)*u))}if(null!==r&&r.call(b,u),1==t){if(g>0){isFinite(g)&&g--;for(i in e){if("string"==typeof d[i]&&(e[i]=e[i]+parseFloat(d[i],10)),h){var x=e[i];e[i]=d[i],d[i]=x}c[i]=e[i]}return h&&(j=!j),l=a+k,!0}null!==s&&s.call(b);for(var y=0,z=o.length;y<z;y++)o[y].start(a);return!1}return!0}},TWEEN.Easing={Linear:{None:function(a){return a}},Quadratic:{In:function(a){return a*a},Out:function(a){return a*(2-a)},InOut:function(a){return(a*=2)<1?.5*a*a:-.5*(--a*(a-2)-1)}},Cubic:{In:function(a){return a*a*a},Out:function(a){return--a*a*a+1},InOut:function(a){return(a*=2)<1?.5*a*a*a:.5*((a-=2)*a*a+2)}},Quartic:{In:function(a){return a*a*a*a},Out:function(a){return 1- --a*a*a*a},InOut:function(a){return(a*=2)<1?.5*a*a*a*a:-.5*((a-=2)*a*a*a-2)}},Quintic:{In:function(a){return a*a*a*a*a},Out:function(a){return--a*a*a*a*a+1},InOut:function(a){return(a*=2)<1?.5*a*a*a*a*a:.5*((a-=2)*a*a*a*a+2)}},Sinusoidal:{In:function(a){return 1-Math.cos(a*Math.PI/2)},Out:function(a){return Math.sin(a*Math.PI/2)},InOut:function(a){return.5*(1-Math.cos(Math.PI*a))}},Exponential:{In:function(a){return 0===a?0:Math.pow(1024,a-1)},Out:function(a){return 1===a?1:1-Math.pow(2,-10*a)},InOut:function(a){return 0===a?0:1===a?1:(a*=2)<1?.5*Math.pow(1024,a-1):.5*(-Math.pow(2,-10*(a-1))+2)}},Circular:{In:function(a){return 1-Math.sqrt(1-a*a)},Out:function(a){return Math.sqrt(1- --a*a)},InOut:function(a){return(a*=2)<1?-.5*(Math.sqrt(1-a*a)-1):.5*(Math.sqrt(1-(a-=2)*a)+1)}},Elastic:{In:function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||c<1?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),-(c*Math.pow(2,10*(a-=1))*Math.sin((a-b)*(2*Math.PI)/d)))},Out:function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||c<1?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),c*Math.pow(2,-10*a)*Math.sin((a-b)*(2*Math.PI)/d)+1)},InOut:function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||c<1?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),(a*=2)<1?-.5*(c*Math.pow(2,10*(a-=1))*Math.sin((a-b)*(2*Math.PI)/d)):c*Math.pow(2,-10*(a-=1))*Math.sin((a-b)*(2*Math.PI)/d)*.5+1)}},Back:{In:function(a){var b=1.70158;return a*a*((b+1)*a-b)},Out:function(a){var b=1.70158;return--a*a*((b+1)*a+b)+1},InOut:function(a){var b=2.5949095;return(a*=2)<1?.5*(a*a*((b+1)*a-b)):.5*((a-=2)*a*((b+1)*a+b)+2)}},Bounce:{In:function(a){return 1-TWEEN.Easing.Bounce.Out(1-a)},Out:function(a){return a<1/2.75?7.5625*a*a:a<2/2.75?7.5625*(a-=1.5/2.75)*a+.75:a<2.5/2.75?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375},InOut:function(a){return a<.5?.5*TWEEN.Easing.Bounce.In(2*a):.5*TWEEN.Easing.Bounce.Out(2*a-1)+.5}}},TWEEN.Interpolation={Linear:function(a,b){var c=a.length-1,d=c*b,e=Math.floor(d),f=TWEEN.Interpolation.Utils.Linear;return b<0?f(a[0],a[1],d):b>1?f(a[c],a[c-1],c-d):f(a[e],a[e+1>c?c:e+1],d-e)},Bezier:function(a,b){var g,c=0,d=a.length-1,e=Math.pow,f=TWEEN.Interpolation.Utils.Bernstein;for(g=0;g<=d;g++)c+=e(1-b,d-g)*e(b,g)*a[g]*f(d,g);return c},CatmullRom:function(a,b){var c=a.length-1,d=c*b,e=Math.floor(d),f=TWEEN.Interpolation.Utils.CatmullRom;return a[0]===a[c]?(b<0&&(e=Math.floor(d=c*(1+b))),f(a[(e-1+c)%c],a[e],a[(e+1)%c],a[(e+2)%c],d-e)):b<0?a[0]-(f(a[0],a[0],a[1],a[1],-d)-a[0]):b>1?a[c]-(f(a[c],a[c],a[c-1],a[c-1],d-c)-a[c]):f(a[e?e-1:0],a[e],a[c<e+1?c:e+1],a[c<e+2?c:e+2],d-e)},Utils:{Linear:function(a,b,c){return(b-a)*c+a},Bernstein:function(a,b){var c=TWEEN.Interpolation.Utils.Factorial;return c(a)/c(b)/c(a-b)},Factorial:function(){var a=[1];return function(b){var d,c=1;if(a[b])return a[b];for(d=b;d>1;d--)c*=d;return a[b]=c}}(),CatmullRom:function(a,b,c,d,e){var f=.5*(c-a),g=.5*(d-b),h=e*e,i=e*h;return(2*b-2*c+f+g)*i+(-3*b+3*c-2*f-g)*h+f*e+b}}};