/* 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=-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=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;c1&&(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=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;d1&&(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").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("
").css("pointer-events","all").appendTo(this.$pageR),this.$pageL=jQuery("
").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("
").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?"":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.rightIndexa;)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;a0?setTimeout(function(){c.goToPage(a,b)},d):c.goToPage(a,b)):(this.nextPage(),setTimeout(function(){if("undefined"!=typeof b&&b)for(var a=0;athis.pagesArr.length)||this.options.rightToLeft)){var b,c=0;for(b=0;b=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;bd.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;bthis.options.zoomMax?this.options.zoomMax:a,newZoom=a0?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=dthis.options.panMax?this.options.panMax:d,d=d0,!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&&c0?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=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=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),cd&&(l=1)):c>d?(l=1-l,l>c&&(l=0),l>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;c1?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;y1?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[c1;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}}};