Regalamiunsorriso/www/js/flipbook.webgl.min.js

5 lines
74 KiB
JavaScript
Raw Normal View History

2026-03-14 20:04:39 +01:00
/* v 3.17
author http://codecanyon.net/user/creativeinteractivemedia/portfolio?ref=creativeinteractivemedia
*/
var FLIPBOOK=FLIPBOOK||{};FLIPBOOK.PageWebGL=function(t,e,i,o,s,n){THREE.Object3D.call(this),this.book=t,this.index=e,this.pW=o.pageWidth,this.pH=o.pageHeight,this.nfacesw=o.pageSegmentsW,this.nfacesh=o.pageSegmentsH,this.mats=[],this.pageHardness=i,this.pageThickness=i,this.duration=o.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;var r=(this.options=o).rightToLeft?o.pages.length/2-this.index-1:this.index;this.indexF=o.rightToLeft?2*r+1:2*r,this.indexB=o.rightToLeft?2*r:2*r+1,this.showing=!1,this.preloaderMatF=s,this.preloaderMatB=n;var h=this;0==e&&this.options.cornerCurl&&(this.nfacesw=20,this.nfacesh=20,this.cornerCurlTween=new FLIPBOOK.TWEEN.Tween(0).to(1,1e3).easing(FLIPBOOK.TWEEN.Easing.Sinusoidal.Out).onUpdate(function(t){h.cornerCurl&&(h.b2.force=-1.8*t,h.modF.apply())}).repeat(11e3).start()),this.gF=new THREE.BoxGeometry(this.pW,this.pH,.01,this.nfacesw,this.nfacesh,0);var a=new THREE.MeshBasicMaterial({color:15592941}),p=[a,a,a,a,s,n],c=[a,a,a,a,a,a];this.options.pagePreloader&&(c=[a,a,a,a,s,n]),this.cube=new THREE.Mesh(this.gF,p),this.cube.position.x=.5*this.pW,this.options.shadows&&(this.cube.castShadow=!0,this.cube.receiveShadow=!0),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),c),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.LEFT,this.pH>this.pW&&(this.b2.switchAxes=!0),this.b2.offset=.98,this.b2.setAngle(1),this.modF=new MOD3.ModifierStack(new MOD3.LibraryThree,this.cube),this.modF.addModifier(this.bendF),0==e&&this.options.cornerCurl&&this.modF.addModifier(this.b2),this.modF.apply()},FLIPBOOK.PageWebGL.prototype=new THREE.Object3D,FLIPBOOK.PageWebGL.prototype.constructor=FLIPBOOK.PageWebGL,FLIPBOOK.PageWebGL.prototype.startCornerCurl=function(){this.cornerCurl=!0},FLIPBOOK.PageWebGL.prototype.stopCornerCurl=function(){this.cornerCurl=!1,this.b2.force=0,this.modF.apply()},FLIPBOOK.PageWebGL.prototype.onPageCanvasLoaded=function(t,e,i){var o,s,n;"front"==e&&this.sizeFront!=t.size?(this.sizeFront=t.size,s=t.canvas,(o=new THREE.CanvasTexture(s)).minFilter=THREE.LinearFilter,o.needsUpdate=!0,o.repeat.x=s.scaleX,o.repeat.y=s.scaleY,o.offset.y=1-s.scaleY,s.double&&(o.offset.x=.5),this.frontMaterial=this.createMaterial(o,"front"),this.frontMaterial.needsUpdate=!0,this.setFrontMat(this.frontMaterial)):"back"==e&&this.sizeBack!=t.size&&(this.sizeBack=t.size,s=t.canvas,(n=new THREE.CanvasTexture(s)).minFilter=THREE.LinearFilter,n.needsUpdate=!0,n.repeat.x=s.scaleX,n.repeat.y=s.scaleY,n.offset.y=1-s.scaleY,this.backMaterial=this.createMaterial(n,"back"),this.backMaterial.needsUpdate=!0,this.setBackMat(this.backMaterial)),i.call(this)},FLIPBOOK.PageWebGL.prototype.loadHTML=function(t,e){var i="front"==t?this.indexF:this.indexB,o=this;this.htmlLoaded?e.call(this):this.options.main.loadPageHTML(i,function(t){e.call(o)})},FLIPBOOK.PageWebGL.prototype.load=function(t,i){var e=this.book.model;if(e.wrapperH&&e.zoom){for(var o=this.book.pages,s=this,n=this.book.options,r=0;r<o.length;r++){var h=o[r];if(h.flippingLeft||h.flippingRight)return}this.disposed=!1;var a=e.wrapperH*e.zoom<.8*n.pageTextureSizeSmall?n.pageTextureSizeSmall:n.pageTextureSize;"front"==t?this.sizeFront==a?i&&i.call(this):this.options.main.loadPage(this.indexF,a,function(t){if(t){if(t.canvas)s.onPageCanvasLoaded(t,"front",i);else if(t.image){if(s.loadedFront)return void i.call(s);s.loadedFront=!0;var e=new THREE.Texture;e.image=t.image,e.minFilter=THREE.LinearFilter,e.needsUpdate=!0,"left"==s.options.pages[2*s.index].side?e.repeat.x=.5:"right"==s.options.pages[2*s.index].side&&(e.repeat.x=.5,e.offset.x=.5),s.frontMaterial=s.createMaterial(e),s