mirror of
https://github.com/photonstorm/phaser
synced 2024-12-30 15:03:16 +00:00
7 lines
No EOL
96 KiB
JavaScript
7 lines
No EOL
96 KiB
JavaScript
/* Phaser v3.0.0 PIXI Build - http://phaser.io - @photonstorm - (c) 2016 Photon Storm Ltd. */
|
|
|
|
(function(){function a(a,b,c,e){var f=a.createTexture();return a.bindTexture(a.TEXTURE_2D,f),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,e===d.scaleModes.LINEAR?a.LINEAR:a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,e===d.scaleModes.LINEAR?a.LINEAR:a.NEAREST),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,b,c,0,a.RGBA,a.UNSIGNED_BYTE,null),f}function b(b,c,d,f,g){var h=b.createFramebuffer(),i=b.createRenderbuffer(),j=null,k=0;return b.activeTexture(b.TEXTURE0+g),b.bindFramebuffer(b.FRAMEBUFFER,h),b.bindRenderbuffer(b.RENDERBUFFER,i),b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_STENCIL_ATTACHMENT,b.RENDERBUFFER,this.renderBuffer),j=a(b,c,d,f),b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,j,0),k=b.checkFramebufferStatus(b.FRAMEBUFFER),k!==b.FRAMEBUFFER_COMPLETE&&console.error("Incomplete GL framebuffer. ",e[k]),h.width=c,h.height=d,h.targetTexture=j,h.renderBuffer=i,h}var c=this,d=d||{};d.game=null,d.WEBGL_RENDERER=0,d.CANVAS_RENDERER=1,d.VERSION="v2.2.9",d._UID=0,"undefined"!=typeof Float32Array?(d.Float32Array=Float32Array,d.Uint16Array=Uint16Array,d.Uint32Array=Uint32Array,d.ArrayBuffer=ArrayBuffer):(d.Float32Array=Array,d.Uint16Array=Array),d.PI_2=2*Math.PI,d.RAD_TO_DEG=180/Math.PI,d.DEG_TO_RAD=Math.PI/180,d.RETINA_PREFIX="@2x",d.DisplayObject=function(){this.position=new d.Point(0,0),this.scale=new d.Point(1,1),this.pivot=new d.Point(0,0),this.rotation=0,this.alpha=1,this.visible=!0,this.hitArea=null,this.renderable=!1,this.parent=null,this.worldAlpha=1,this.worldTransform=new d.Matrix,this.worldPosition=new d.Point(0,0),this.worldScale=new d.Point(1,1),this.worldRotation=0,this.filterArea=null,this._sr=0,this._cr=1,this._bounds=new d.Rectangle(0,0,0,0),this._currentBounds=null,this._mask=null,this._cacheAsBitmap=!1,this._cacheIsDirty=!1},d.DisplayObject.prototype.constructor=d.DisplayObject,d.DisplayObject.prototype={destroy:function(){if(this.children){for(var a=this.children.length;a--;)this.children[a].destroy();this.children=[]}this.hitArea=null,this.parent=null,this.worldTransform=null,this.filterArea=null,this.renderable=!1,this._bounds=null,this._currentBounds=null,this._mask=null,this._destroyCachedSprite()},updateTransform:function(a){if(!a&&!this.parent&&!this.game)return this;var b=this.parent;a?b=a:this.parent||(b=this.game.world);var c,e,f,g,h,i,j=b.worldTransform,k=this.worldTransform;return this.rotation%d.PI_2?(this.rotation!==this.rotationCache&&(this.rotationCache=this.rotation,this._sr=Math.sin(this.rotation),this._cr=Math.cos(this.rotation)),c=this._cr*this.scale.x,e=this._sr*this.scale.x,f=-this._sr*this.scale.y,g=this._cr*this.scale.y,h=this.position.x,i=this.position.y,(this.pivot.x||this.pivot.y)&&(h-=this.pivot.x*c+this.pivot.y*f,i-=this.pivot.x*e+this.pivot.y*g),k.a=c*j.a+e*j.c,k.b=c*j.b+e*j.d,k.c=f*j.a+g*j.c,k.d=f*j.b+g*j.d,k.tx=h*j.a+i*j.c+j.tx,k.ty=h*j.b+i*j.d+j.ty):(c=this.scale.x,g=this.scale.y,h=this.position.x-this.pivot.x*c,i=this.position.y-this.pivot.y*g,k.a=c*j.a,k.b=c*j.b,k.c=g*j.c,k.d=g*j.d,k.tx=h*j.a+i*j.c+j.tx,k.ty=h*j.b+i*j.d+j.ty),this.worldAlpha=this.alpha*b.worldAlpha,this.worldPosition.set(k.tx,k.ty),this.worldScale.set(this.scale.x*Math.sqrt(k.a*k.a+k.c*k.c),this.scale.y*Math.sqrt(k.b*k.b+k.d*k.d)),this.worldRotation=Math.atan2(-k.c,k.d),this._currentBounds=null,this.transformCallback&&this.transformCallback.call(this.transformCallbackContext,k,j),this},preUpdate:function(){},generateTexture:function(a,b,c){var e=this.getLocalBounds(),f=new d.RenderTexture(0|e.width,0|e.height,c,b,a);return d.DisplayObject._tempMatrix.tx=-e.x,d.DisplayObject._tempMatrix.ty=-e.y,f.render(this,d.DisplayObject._tempMatrix),f},updateCache:function(){return this._generateCachedSprite(),this},toGlobal:function(a){return this.updateTransform(),this.worldTransform.apply(a)},toLocal:function(a,b){return b&&(a=b.toGlobal(a)),this.updateTransform(),this.worldTransform.applyInverse(a)},_renderCachedSprite:function(a){this._cachedSprite.worldAlpha=this.worldAlpha,a.gl?d.Sprite.prototype._renderWebGL.call(this._cachedSprite,a):d.Sprite.prototype._renderCanvas.call(this._cachedSprite,a)},_generateCachedSprite:function(){this._cacheAsBitmap=!1;var a=this.getLocalBounds();if(a.width=Math.max(1,Math.ceil(a.width)),a.height=Math.max(1,Math.ceil(a.height)),this.updateTransform(),this._cachedSprite)this._cachedSprite.texture.resize(a.width,a.height);else{var b=0;this.texture&&this.texture.baseTexture&&d._enableMultiTextureToggle&&(b=this.texture.baseTexture.textureIndex);var c=new d.RenderTexture(a.width,a.height,null,null,null,b);this._cachedSprite=new d.Sprite(c),this._cachedSprite.worldTransform=this.worldTransform}var e=this._filters;this._filters=null,this._cachedSprite.filters=e,d.DisplayObject._tempMatrix.tx=-a.x,d.DisplayObject._tempMatrix.ty=-a.y,this._cachedSprite.texture.render(this,d.DisplayObject._tempMatrix,!0),this._cachedSprite.anchor.x=-(a.x/a.width),this._cachedSprite.anchor.y=-(a.y/a.height),this._filters=e,this._cacheAsBitmap=!0},_destroyCachedSprite:function(){this._cachedSprite&&(this._cachedSprite.texture.destroy(!0),this._cachedSprite=null)}},d.DisplayObject.prototype.displayObjectUpdateTransform=d.DisplayObject.prototype.updateTransform,Object.defineProperties(d.DisplayObject.prototype,{x:{get:function(){return this.position.x},set:function(a){this.position.x=a}},y:{get:function(){return this.position.y},set:function(a){this.position.y=a}},worldVisible:{get:function(){if(this.visible){var a=this.parent;if(!a)return this.visible;do{if(!a.visible)return!1;a=a.parent}while(a);return!0}return!1}},mask:{get:function(){return this._mask},set:function(a){this._mask&&(this._mask.isMask=!1),this._mask=a,a&&(this._mask.isMask=!0)}},filters:{get:function(){return this._filters},set:function(a){if(Array.isArray(a)){for(var b=[],c=0;c<a.length;c++)for(var e=a[c].passes,f=0;f<e.length;f++)b.push(e[f]);this._filterBlock={target:this,filterPasses:b}}this._filters=a,this.blendMode&&this.blendMode===d.blendModes.MULTIPLY&&(this.blendMode=d.blendModes.NORMAL)}},cacheAsBitmap:{get:function(){return this._cacheAsBitmap},set:function(a){this._cacheAsBitmap!==a&&(a?this._generateCachedSprite():this._destroyCachedSprite(),this._cacheAsBitmap=a)}}}),d.DisplayObjectContainer=function(){d.DisplayObject.call(this),this.children=[],this.ignoreChildInput=!1},d.DisplayObjectContainer.prototype=Object.create(d.DisplayObject.prototype),d.DisplayObjectContainer.prototype.constructor=d.DisplayObjectContainer,d.DisplayObjectContainer.prototype.addChild=function(a){return this.addChildAt(a,this.children.length)},d.DisplayObjectContainer.prototype.addChildAt=function(a,b){if(b>=0&&b<=this.children.length)return a.parent&&a.parent.removeChild(a),a.parent=this,this.children.splice(b,0,a),a;throw new Error(a+"addChildAt: The index "+b+" supplied is out of bounds "+this.children.length)},d.DisplayObjectContainer.prototype.swapChildren=function(a,b){if(a!==b){var c=this.getChildIndex(a),d=this.getChildIndex(b);if(c<0||d<0)throw new Error("swapChildren: Both the supplied DisplayObjects must be a child of the caller.");this.children[c]=b,this.children[d]=a}},d.DisplayObjectContainer.prototype.getChildIndex=function(a){var b=this.children.indexOf(a);if(b===-1)throw new Error("The supplied DisplayObject must be a child of the caller");return b},d.DisplayObjectContainer.prototype.setChildIndex=function(a,b){if(b<0||b>=this.children.length)throw new Error("The supplied index is out of bounds");var c=this.getChildIndex(a);this.children.splice(c,1),this.children.splice(b,0,a)},d.DisplayObjectContainer.prototype.getChildAt=function(a){if(a<0||a>=this.children.length)throw new Error("getChildAt: Supplied index "+a+" does not exist in the child list, or the supplied DisplayObject must be a child of the caller");return this.children[a]},d.DisplayObjectContainer.prototype.removeChild=function(a){var b=this.children.indexOf(a);if(b!==-1)return this.removeChildAt(b)},d.DisplayObjectContainer.prototype.removeChildAt=function(a){var b=this.getChildAt(a);return b&&(b.parent=void 0,this.children.splice(a,1)),b},d.DisplayObjectContainer.prototype.removeChildren=function(a,b){void 0===a&&(a=0),void 0===b&&(b=this.children.length);var c=b-a;if(c>0&&c<=b){for(var d=this.children.splice(a,c),e=0;e<d.length;e++){var f=d[e];f.parent=void 0}return d}if(0===c&&0===this.children.length)return[];throw new Error("removeChildren: Range Error, numeric values are outside the acceptable range")},d.DisplayObjectContainer.prototype.updateTransform=function(){if(this.visible&&(this.displayObjectUpdateTransform(),!this._cacheAsBitmap))for(var a=0;a<this.children.length;a++)this.children[a].updateTransform()},d.DisplayObjectContainer.prototype.displayObjectContainerUpdateTransform=d.DisplayObjectContainer.prototype.updateTransform,d.DisplayObjectContainer.prototype.getBounds=function(a){var b=a&&a instanceof d.DisplayObject,c=!0;b?c=a instanceof d.DisplayObjectContainer&&a.contains(this):a=this;var e;if(b){var f=a.worldTransform;for(a.worldTransform=d.identityMatrix,e=0;e<a.children.length;e++)a.children[e].updateTransform()}var g,h,i,j=1/0,k=1/0,l=-(1/0),m=-(1/0),n=!1;for(e=0;e<this.children.length;e++){var o=this.children[e];o.visible&&(n=!0,g=this.children[e].getBounds(),j=j<g.x?j:g.x,k=k<g.y?k:g.y,h=g.width+g.x,i=g.height+g.y,l=l>h?l:h,m=m>i?m:i)}var p=this._bounds;if(!n){p=new d.Rectangle;var q=p.x,r=p.width+p.x,s=p.y,t=p.height+p.y,u=this.worldTransform,v=u.a,w=u.b,x=u.c,y=u.d,z=u.tx,A=u.ty,B=v*r+x*t+z,C=y*t+w*r+A,D=v*q+x*t+z,E=y*t+w*q+A,F=v*q+x*s+z,G=y*s+w*q+A,H=v*r+x*s+z,I=y*s+w*r+A;l=B,m=C,j=B,k=C,j=D<j?D:j,j=F<j?F:j,j=H<j?H:j,k=E<k?E:k,k=G<k?G:k,k=I<k?I:k,l=D>l?D:l,l=F>l?F:l,l=H>l?H:l,m=E>m?E:m,m=G>m?G:m,m=I>m?I:m}if(p.x=j,p.y=k,p.width=l-j,p.height=m-k,b)for(a.worldTransform=f,e=0;e<a.children.length;e++)a.children[e].updateTransform();if(!c){var J=a.getBounds();p.x-=J.x,p.y-=J.y}return p},d.DisplayObjectContainer.prototype.getLocalBounds=function(){return this.getBounds(this)},d.DisplayObjectContainer.prototype.contains=function(a){return!!a&&(a===this||this.contains(a.parent))},d.DisplayObjectContainer.prototype._renderWebGL=function(a){if(this.visible&&!(this.alpha<=0)){if(this._cacheAsBitmap)return void this._renderCachedSprite(a);var b;if(this._mask||this._filters){for(this._filters&&(a.spriteBatch.flush(),a.filterManager.pushFilter(this._filterBlock)),this._mask&&(a.spriteBatch.stop(),a.maskManager.pushMask(this.mask,a),a.spriteBatch.start()),b=0;b<this.children.length;b++)this.children[b]._renderWebGL(a);a.spriteBatch.stop(),this._mask&&a.maskManager.popMask(this._mask,a),this._filters&&a.filterManager.popFilter(),a.spriteBatch.start()}else for(b=0;b<this.children.length;b++)this.children[b]._renderWebGL(a)}},d.DisplayObjectContainer.prototype._renderCanvas=function(a){if(this.visible!==!1&&0!==this.alpha){if(this._cacheAsBitmap)return void this._renderCachedSprite(a);this._mask&&a.maskManager.pushMask(this._mask,a);for(var b=0;b<this.children.length;b++)this.children[b]._renderCanvas(a);this._mask&&a.maskManager.popMask(a)}},Object.defineProperty(d.DisplayObjectContainer.prototype,"width",{get:function(){return this.getLocalBounds().width*this.scale.x},set:function(a){var b=this.getLocalBounds().width;0!==b?this.scale.x=a/b:this.scale.x=1,this._width=a}}),Object.defineProperty(d.DisplayObjectContainer.prototype,"height",{get:function(){return this.getLocalBounds().height*this.scale.y},set:function(a){var b=this.getLocalBounds().height;0!==b?this.scale.y=a/b:this.scale.y=1,this._height=a}}),d.Sprite=function(a){d.DisplayObjectContainer.call(this),this.anchor=new d.Point,this.texture=a||d.Texture.emptyTexture,this._width=0,this._height=0,this.tint=16777215,this.cachedTint=-1,this.tintedTexture=null,this.blendMode=d.blendModes.NORMAL,this.shader=null,this.exists=!0,this.texture.baseTexture.hasLoaded&&this.onTextureUpdate(),this.renderable=!0},d.Sprite.prototype=Object.create(d.DisplayObjectContainer.prototype),d.Sprite.prototype.constructor=d.Sprite,Object.defineProperty(d.Sprite.prototype,"width",{get:function(){return this.scale.x*this.texture.frame.width},set:function(a){this.scale.x=a/this.texture.frame.width,this._width=a}}),Object.defineProperty(d.Sprite.prototype,"height",{get:function(){return this.scale.y*this.texture.frame.height},set:function(a){this.scale.y=a/this.texture.frame.height,this._height=a}}),d.Sprite.prototype.setTexture=function(a,b){void 0!==b&&this.texture.baseTexture.destroy(),this.texture.baseTexture.skipRender=!1,this.texture=a,this.texture.valid=!0,this.cachedTint=-1},d.Sprite.prototype.onTextureUpdate=function(){this._width&&(this.scale.x=this._width/this.texture.frame.width),this._height&&(this.scale.y=this._height/this.texture.frame.height)},d.Sprite.prototype.getBounds=function(a){var b=this.texture.frame.width,c=this.texture.frame.height,d=b*(1-this.anchor.x),e=b*-this.anchor.x,f=c*(1-this.anchor.y),g=c*-this.anchor.y,h=a||this.worldTransform,i=h.a,j=h.b,k=h.c,l=h.d,m=h.tx,n=h.ty,o=-(1/0),p=-(1/0),q=1/0,r=1/0;if(0===j&&0===k){if(i<0){i*=-1;var s=d;d=-e,e=-s}if(l<0){l*=-1;var s=f;f=-g,g=-s}q=i*e+m,o=i*d+m,r=l*g+n,p=l*f+n}else{var t=i*e+k*g+m,u=l*g+j*e+n,v=i*d+k*g+m,w=l*g+j*d+n,x=i*d+k*f+m,y=l*f+j*d+n,z=i*e+k*f+m,A=l*f+j*e+n;q=t<q?t:q,q=v<q?v:q,q=x<q?x:q,q=z<q?z:q,r=u<r?u:r,r=w<r?w:r,r=y<r?y:r,r=A<r?A:r,o=t>o?t:o,o=v>o?v:o,o=x>o?x:o,o=z>o?z:o,p=u>p?u:p,p=w>p?w:p,p=y>p?y:p,p=A>p?A:p}var B=this._bounds;return B.x=q,B.width=o-q,B.y=r,B.height=p-r,this._currentBounds=B,B},d.Sprite.prototype.getLocalBounds=function(){var a=this.worldTransform;this.worldTransform=d.identityMatrix;for(var b=0;b<this.children.length;b++)this.children[b].updateTransform();var c=this.getBounds();for(this.worldTransform=a,b=0;b<this.children.length;b++)this.children[b].updateTransform();return c},d.Sprite.prototype._renderWebGL=function(a,b){if(this.visible&&!(this.alpha<=0)&&this.renderable){var c=this.worldTransform;if(b&&(c=b),this._mask||this._filters){var d=a.spriteBatch;this._filters&&(d.flush(),a.filterManager.pushFilter(this._filterBlock)),this._mask&&(d.stop(),a.maskManager.pushMask(this.mask,a),d.start()),d.render(this);for(var e=0;e<this.children.length;e++)this.children[e]._renderWebGL(a);d.stop(),this._mask&&a.maskManager.popMask(this._mask,a),this._filters&&a.filterManager.popFilter(),d.start()}else{a.spriteBatch.render(this);for(var e=0;e<this.children.length;e++)this.children[e]._renderWebGL(a,c)}}},d.Sprite.prototype._renderCanvas=function(a,b){if(!(!this.visible||0===this.alpha||!this.renderable||this.texture.crop.width<=0||this.texture.crop.height<=0)){var c=this.worldTransform;if(b&&(c=b),this.blendMode!==a.currentBlendMode&&(a.currentBlendMode=this.blendMode,a.context.globalCompositeOperation=d.blendModesCanvas[a.currentBlendMode]),this._mask&&a.maskManager.pushMask(this._mask,a),!this.texture.valid){for(var e=0;e<this.children.length;e++)this.children[e]._renderCanvas(a);return void(this._mask&&a.maskManager.popMask(a))}var f=this.texture.baseTexture.resolution/a.resolution;a.context.globalAlpha=this.worldAlpha,a.smoothProperty&&a.scaleMode!==this.texture.baseTexture.scaleMode&&(a.scaleMode=this.texture.baseTexture.scaleMode,a.context[a.smoothProperty]=a.scaleMode===d.scaleModes.LINEAR);var g=this.texture.trim?this.texture.trim.x-this.anchor.x*this.texture.trim.width:this.anchor.x*-this.texture.frame.width,h=this.texture.trim?this.texture.trim.y-this.anchor.y*this.texture.trim.height:this.anchor.y*-this.texture.frame.height,i=c.tx*a.resolution+a.shakeX,j=c.ty*a.resolution+a.shakeY,k=this.texture.crop.width,l=this.texture.crop.height;if(this.texture.rotated){var m=c.a,n=c.b,o=c.c,p=c.d,q=k;i=c.c*l+i,j=c.d*l+j,c.a=6.123233995736766e-17*m+-o,c.b=6.123233995736766e-17*n+-p,c.c=m+6.123233995736766e-17*o,c.d=n+6.123233995736766e-17*p,k=l,l=q}if(a.roundPixels?(a.context.setTransform(c.a,c.b,c.c,c.d,0|i,0|j),g|=0,h|=0):a.context.setTransform(c.a,c.b,c.c,c.d,i,j),g/=f,h/=f,16777215!==this.tint)(this.texture.requiresReTint||this.cachedTint!==this.tint)&&(this.tintedTexture=d.CanvasTinter.getTintedTexture(this,this.tint),this.cachedTint=this.tint,this.texture.requiresReTint=!1),a.context.drawImage(this.tintedTexture,0,0,k,l,g,h,k/f,l/f);else{var r=this.texture.crop.x,s=this.texture.crop.y;a.context.drawImage(this.texture.baseTexture.source,r,s,k,l,g,h,k/f,l/f)}for(var e=0;e<this.children.length;e++)this.children[e]._renderCanvas(a);this._mask&&a.maskManager.popMask(a)}},d.SpriteBatch=function(a){d.DisplayObjectContainer.call(this),this.textureThing=a,this.ready=!1},d.SpriteBatch.prototype=Object.create(d.DisplayObjectContainer.prototype),d.SpriteBatch.prototype.constructor=d.SpriteBatch,d.SpriteBatch.prototype.initWebGL=function(a){this.fastSpriteBatch=new d.WebGLFastSpriteBatch(a),this.ready=!0},d.SpriteBatch.prototype.updateTransform=function(){this.displayObjectUpdateTransform()},d.SpriteBatch.prototype._renderWebGL=function(a){!this.visible||this.alpha<=0||!this.children.length||(this.ready||this.initWebGL(a.gl),this.fastSpriteBatch.gl!==a.gl&&this.fastSpriteBatch.setContext(a.gl),a.spriteBatch.stop(),a.shaderManager.setShader(a.shaderManager.fastShader),this.fastSpriteBatch.begin(this,a),this.fastSpriteBatch.render(this),a.spriteBatch.start())},d.SpriteBatch.prototype._renderCanvas=function(a){if(this.visible&&!(this.alpha<=0)&&this.children.length){var b=a.context;b.globalAlpha=this.worldAlpha,this.displayObjectUpdateTransform();for(var c=this.worldTransform,d=!0,e=0;e<this.children.length;e++){var f=this.children[e];if(f.visible){var g=f.texture,h=g.frame;if(b.globalAlpha=this.worldAlpha*f.alpha,f.rotation%(2*Math.PI)===0)d&&(b.setTransform(c.a,c.b,c.c,c.d,c.tx,c.ty),d=!1),b.drawImage(g.baseTexture.source,h.x,h.y,h.width,h.height,f.anchor.x*(-h.width*f.scale.x)+f.position.x+.5+a.shakeX|0,f.anchor.y*(-h.height*f.scale.y)+f.position.y+.5+a.shakeY|0,h.width*f.scale.x,h.height*f.scale.y);else{d||(d=!0),f.displayObjectUpdateTransform();var i=f.worldTransform,j=i.tx*a.resolution+a.shakeX,k=i.ty*a.resolution+a.shakeY;a.roundPixels?b.setTransform(i.a,i.b,i.c,i.d,0|j,0|k):b.setTransform(i.a,i.b,i.c,i.d,j,k),b.drawImage(g.baseTexture.source,h.x,h.y,h.width,h.height,f.anchor.x*-h.width+.5|0,f.anchor.y*-h.height+.5|0,h.width,h.height)}}}}},d.hex2rgb=function(a){return[(a>>16&255)/255,(a>>8&255)/255,(255&a)/255]},d.rgb2hex=function(a){return(255*a[0]<<16)+(255*a[1]<<8)+255*a[2]},d.canUseNewCanvasBlendModes=function(){if(void 0===document)return!1;var a="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/",b="AAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==",c=new Image;c.src=a+"AP804Oa6"+b;var e=new Image;e.src=a+"/wCKxvRF"+b;var f=d.CanvasPool.create(this,6,1),g=f.getContext("2d");if(g.globalCompositeOperation="multiply",g.drawImage(c,0,0),g.drawImage(e,2,0),!g.getImageData(2,0,1,1))return!1;var h=g.getImageData(2,0,1,1).data;return d.CanvasPool.remove(this),255===h[0]&&0===h[1]&&0===h[2]},d.getNextPowerOfTwo=function(a){if(a>0&&0===(a&a-1))return a;for(var b=1;b<a;)b<<=1;return b},d.isPowerOfTwo=function(a,b){return a>0&&0===(a&a-1)&&b>0&&0===(b&b-1)},d.CanvasPool={create:function(a,b,c){var e,f=d.CanvasPool.getFirst();if(f===-1){var g={parent:a,canvas:document.createElement("canvas")};d.CanvasPool.pool.push(g),e=g.canvas}else d.CanvasPool.pool[f].parent=a,e=d.CanvasPool.pool[f].canvas;return void 0!==b&&(e.width=b,e.height=c),e},getFirst:function(){for(var a=d.CanvasPool.pool,b=0;b<a.length;b++)if(!a[b].parent)return b;return-1},remove:function(a){for(var b=d.CanvasPool.pool,c=0;c<b.length;c++)b[c].parent===a&&(b[c].parent=null,b[c].canvas.width=1,b[c].canvas.height=1)},removeByCanvas:function(a){for(var b=d.CanvasPool.pool,c=0;c<b.length;c++)b[c].canvas===a&&(b[c].parent=null,b[c].canvas.width=1,b[c].canvas.height=1)},getTotal:function(){for(var a=d.CanvasPool.pool,b=0,c=0;c<a.length;c++)a[c].parent&&b++;return b},getFree:function(){for(var a=d.CanvasPool.pool,b=0,c=0;c<a.length;c++)a[c].parent||b++;return b}},d.CanvasPool.pool=[],d.initDefaultShaders=function(){},d.CompileVertexShader=function(a,b){return d._CompileShader(a,b,a.VERTEX_SHADER)},d.CompileFragmentShader=function(a,b){return d._CompileShader(a,b,a.FRAGMENT_SHADER)},d._CompileShader=function(a,b,c){var d=b;Array.isArray(b)&&(d=b.join("\n"));var e=a.createShader(c);return a.shaderSource(e,d),a.compileShader(e),a.getShaderParameter(e,a.COMPILE_STATUS)?e:(window.console.log(a.getShaderInfoLog(e)),null)},d.compileProgram=function(a,b,c){var e=d.CompileFragmentShader(a,c),f=d.CompileVertexShader(a,b),g=a.createProgram();return a.attachShader(g,f),a.attachShader(g,e),a.linkProgram(g),a.getProgramParameter(g,a.LINK_STATUS)||(window.console.log(a.getProgramInfoLog(g)),window.console.log("Could not initialise shaders")),g},d.PixiShader=function(a){this._UID=d._UID++,this.gl=a,this.program=null,this.fragmentSrc=null,this.textureCount=0,this.firstRun=!0,this.dirty=!0,this.attributes=[],this.init()},d.PixiShader.prototype.constructor=d.PixiShader,d.PixiShader.prototype.initMultitexShader=function(){var a=this.gl;this.MAX_TEXTURES=a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS);for(var b="\tif (vTextureIndex == 0.0) gl_FragColor = texture2D(uSamplerArray[0], vTextureCoord) * vColor;\n",c=1;c<this.MAX_TEXTURES;++c)b+="\telse if (vTextureIndex == "+c+".0) gl_FragColor = texture2D(uSamplerArray["+c+"], vTextureCoord) * vColor;\n";this.fragmentSrc=["// PixiShader Fragment Shader.","precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","varying float vTextureIndex;","uniform sampler2D uSamplerArray["+this.MAX_TEXTURES+"];","const vec4 PINK = vec4(1.0, 0.0, 1.0, 1.0);","const vec4 GREEN = vec4(0.0, 1.0, 0.0, 1.0);","void main(void) {",b,"else gl_FragColor = PINK;","}"];var e=d.compileProgram(a,this.vertexSrc||d.PixiShader.defaultVertexSrc,this.fragmentSrc);a.useProgram(e),this.uSamplerArray=a.getUniformLocation(e,"uSamplerArray[0]"),this.projectionVector=a.getUniformLocation(e,"projectionVector"),this.offsetVector=a.getUniformLocation(e,"offsetVector"),this.dimensions=a.getUniformLocation(e,"dimensions"),this.aVertexPosition=a.getAttribLocation(e,"aVertexPosition"),this.aTextureCoord=a.getAttribLocation(e,"aTextureCoord"),this.colorAttribute=a.getAttribLocation(e,"aColor"),this.aTextureIndex=a.getAttribLocation(e,"aTextureIndex");var f=[],g=a.createTexture();a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,g),a.texImage2D(a.TEXTURE_2D,0,a.RGB,1,1,0,a.RGB,a.UNSIGNED_BYTE,null);for(var h=0;h<this.MAX_TEXTURES;++h)a.activeTexture(a.TEXTURE0+h),a.bindTexture(a.TEXTURE_2D,g),f.push(h);a.activeTexture(a.TEXTURE0),a.uniform1iv(this.uSamplerArray,f),this.colorAttribute===-1&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aTextureCoord,this.colorAttribute,this.aTextureIndex];for(var i in this.uniforms)this.uniforms[i].uniformLocation=a.getUniformLocation(e,i);this.initUniforms(),this.program=e},d.PixiShader.prototype.initDefaultShader=function(){null===this.fragmentSrc&&(this.fragmentSrc=["precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","varying float vTextureIndex;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"]);var a=this.gl,b=d.compileProgram(a,this.vertexSrc||d.PixiShader.defaultVertexSrc,this.fragmentSrc);a.useProgram(b),this.uSampler=a.getUniformLocation(b,"uSampler"),this.projectionVector=a.getUniformLocation(b,"projectionVector"),this.offsetVector=a.getUniformLocation(b,"offsetVector"),this.dimensions=a.getUniformLocation(b,"dimensions"),this.aVertexPosition=a.getAttribLocation(b,"aVertexPosition"),this.aTextureCoord=a.getAttribLocation(b,"aTextureCoord"),this.colorAttribute=a.getAttribLocation(b,"aColor"),this.aTextureIndex=a.getAttribLocation(b,"aTextureIndex"),this.colorAttribute===-1&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aTextureCoord,this.colorAttribute,this.aTextureIndex];for(var c in this.uniforms)this.uniforms[c].uniformLocation=a.getUniformLocation(b,c);this.initUniforms(),this.program=b},d.PixiShader.prototype.init=function(a){d._enableMultiTextureToggle&&!a?this.initMultitexShader():this.initDefaultShader()},d.PixiShader.prototype.initUniforms=function(){this.textureCount=1;var a,b=this.gl;for(var c in this.uniforms){a=this.uniforms[c];var d=a.type;"sampler2D"===d?(a._init=!1,null!==a.value&&this.initSampler2D(a)):"mat2"===d||"mat3"===d||"mat4"===d?(a.glMatrix=!0,a.glValueLength=1,"mat2"===d?a.glFunc=b.uniformMatrix2fv:"mat3"===d?a.glFunc=b.uniformMatrix3fv:"mat4"===d&&(a.glFunc=b.uniformMatrix4fv)):(a.glFunc=b["uniform"+d],"2f"===d||"2i"===d?a.glValueLength=2:"3f"===d||"3i"===d?a.glValueLength=3:"4f"===d||"4i"===d?a.glValueLength=4:a.glValueLength=1)}},d.PixiShader.prototype.initSampler2D=function(a){if(a.value&&a.value.baseTexture&&a.value.baseTexture.hasLoaded){var b=this.gl;if(b.activeTexture(b.TEXTURE0+this.textureCount),b.bindTexture(b.TEXTURE_2D,a.value.baseTexture._glTextures[b.id]),a.textureData){var c=a.textureData,d=c.magFilter?c.magFilter:b.LINEAR,e=c.minFilter?c.minFilter:b.LINEAR,f=c.wrapS?c.wrapS:b.CLAMP_TO_EDGE,g=c.wrapT?c.wrapT:b.CLAMP_TO_EDGE,h=c.luminance?b.LUMINANCE:b.RGBA;if(c.repeat&&(f=b.REPEAT,g=b.REPEAT),b.pixelStorei(b.UNPACK_FLIP_Y_WEBGL,!!c.flipY),c.width){var i=c.width?c.width:512,j=c.height?c.height:2,k=c.border?c.border:0;b.texImage2D(b.TEXTURE_2D,0,h,i,j,k,h,b.UNSIGNED_BYTE,null)}else b.texImage2D(b.TEXTURE_2D,0,h,b.RGBA,b.UNSIGNED_BYTE,a.value.baseTexture.source);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,d),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,e),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,f),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,g)}b.uniform1i(a.uniformLocation,this.textureCount),a._init=!0,this.textureCount++}},d.PixiShader.prototype.syncUniforms=function(){this.textureCount=1;var a,b=this.gl;for(var c in this.uniforms)a=this.uniforms[c],1===a.glValueLength?a.glMatrix===!0?a.glFunc.call(b,a.uniformLocation,a.transpose,a.value):a.glFunc.call(b,a.uniformLocation,a.value):2===a.glValueLength?a.glFunc.call(b,a.uniformLocation,a.value.x,a.value.y):3===a.glValueLength?a.glFunc.call(b,a.uniformLocation,a.value.x,a.value.y,a.value.z):4===a.glValueLength?a.glFunc.call(b,a.uniformLocation,a.value.x,a.value.y,a.value.z,a.value.w):"sampler2D"===a.type&&(a._init?(b.activeTexture(b["TEXTURE"+this.textureCount]),a.value.baseTexture._dirty[b.id]?d.instances[b.id].updateTexture(a.value.baseTexture):b.bindTexture(b.TEXTURE_2D,a.value.baseTexture._glTextures[b.id]),b.uniform1i(a.uniformLocation,this.textureCount),this.textureCount++):this.initSampler2D(a))},d.PixiShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},d.PixiShader.defaultVertexSrc=["// PixiShader Vertex Shader","// With multi-texture rendering","attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute vec4 aColor;","attribute float aTextureIndex;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","varying vec2 vTextureCoord;","varying vec4 vColor;","varying float vTextureIndex;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {"," if (aTextureIndex > 0.0) gl_Position = vec4(0.0);"," gl_Position = vec4( ((aVertexPosition + offsetVector) / projectionVector) + center , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vColor = vec4(aColor.rgb * aColor.a, aColor.a);"," vTextureIndex = aTextureIndex;","}"],d.PixiFastShader=function(a){if(this._UID=d._UID++,this.gl=a,this.program=null,d._enableMultiTextureToggle){var a=this.gl;this.MAX_TEXTURES=a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS);for(var b="\tif (vTextureIndex == 0.0) gl_FragColor = texture2D(uSamplerArray[0], vTextureCoord) * vColor;\n",c=1;c<this.MAX_TEXTURES;++c)b+="\telse if (vTextureIndex == "+c+".0) gl_FragColor = texture2D(uSamplerArray["+c+"], vTextureCoord) * vColor;\n";this.fragmentSrc=["// PixiFastShader Fragment Shader.","precision lowp float;","varying vec2 vTextureCoord;","varying float vColor;","varying float vTextureIndex;","uniform sampler2D uSamplerArray["+this.MAX_TEXTURES+"];","const vec4 PINK = vec4(1.0, 0.0, 1.0, 1.0);","const vec4 GREEN = vec4(0.0, 1.0, 0.0, 1.0);","void main(void) {",b,"else gl_FragColor = PINK;","}"]}else this.fragmentSrc=["// PixiFastShader Fragment Shader.","precision lowp float;","varying vec2 vTextureCoord;","varying float vColor;","varying float vTextureIndex;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor;","}"];this.vertexSrc=["// PixiFastShader Vertex Shader.","attribute vec2 aVertexPosition;","attribute vec2 aPositionCoord;","attribute vec2 aScale;","attribute float aRotation;","attribute vec2 aTextureCoord;","attribute float aColor;","attribute float aTextureIndex;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform mat3 uMatrix;","varying vec2 vTextureCoord;","varying float vColor;","varying float vTextureIndex;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {"," vec2 v;"," vec2 sv = aVertexPosition * aScale;"," v.x = (sv.x) * cos(aRotation) - (sv.y) * sin(aRotation);"," v.y = (sv.x) * sin(aRotation) + (sv.y) * cos(aRotation);"," v = ( uMatrix * vec3(v + aPositionCoord , 1.0) ).xy ;"," gl_Position = vec4( ( v / projectionVector) + center , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vTextureIndex = aTextureIndex;"," vColor = aColor;","}"],this.textureCount=0,this.init()},d.PixiFastShader.prototype.constructor=d.PixiFastShader,d.PixiFastShader.prototype.init=function(){var a=this.gl,b=d.compileProgram(a,this.vertexSrc,this.fragmentSrc);if(a.useProgram(b),this.uSampler=d._enableMultiTextureToggle?a.getUniformLocation(b,"uSamplerArray[0]"):a.getUniformLocation(b,"uSampler"),d._enableMultiTextureToggle){var c=[],e=a.createTexture();a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,e),a.texImage2D(a.TEXTURE_2D,0,a.RGB,1,1,0,a.RGB,a.UNSIGNED_BYTE,null);for(var f=0;f<this.MAX_TEXTURES;++f)a.activeTexture(a.TEXTURE0+f),a.bindTexture(a.TEXTURE_2D,e),c.push(f);a.activeTexture(a.TEXTURE0),a.uniform1iv(this.uSampler,c)}this.projectionVector=a.getUniformLocation(b,"projectionVector"),this.offsetVector=a.getUniformLocation(b,"offsetVector"),this.dimensions=a.getUniformLocation(b,"dimensions"),this.uMatrix=a.getUniformLocation(b,"uMatrix"),this.aVertexPosition=a.getAttribLocation(b,"aVertexPosition"),this.aPositionCoord=a.getAttribLocation(b,"aPositionCoord"),this.aScale=a.getAttribLocation(b,"aScale"),this.aRotation=a.getAttribLocation(b,"aRotation"),this.aTextureCoord=a.getAttribLocation(b,"aTextureCoord"),this.colorAttribute=a.getAttribLocation(b,"aColor"),this.aTextureIndex=a.getAttribLocation(b,"aTextureIndex"),this.colorAttribute===-1&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aPositionCoord,this.aScale,this.aRotation,this.aTextureCoord,this.colorAttribute,this.aTextureIndex],this.program=b},d.PixiFastShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},d.StripShader=function(a){if(this._UID=d._UID++,this.gl=a,this.program=null,d._enableMultiTextureToggle){var a=this.gl;this.MAX_TEXTURES=a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS);for(var b="\tif (vTextureIndex == 0.0) gl_FragColor = texture2D(uSamplerArray[0], vTextureCoord);\n",c=1;c<this.MAX_TEXTURES;++c)b+="\telse if (vTextureIndex == "+c+".0) gl_FragColor = texture2D(uSamplerArray["+c+"], vTextureCoord) ;\n";this.fragmentSrc=["//StripShader Fragment Shader.","precision mediump float;","varying vec2 vTextureCoord;","varying float vTextureIndex;","uniform float alpha;","uniform sampler2D uSamplerArray["+this.MAX_TEXTURES+"];","const vec4 PINK = vec4(1.0, 0.0, 1.0, 1.0);","const vec4 GREEN = vec4(0.0, 1.0, 0.0, 1.0);","void main(void) {",b,"else gl_FragColor = PINK;","}"]}else this.fragmentSrc=["//StripShader Fragment Shader.","precision mediump float;","varying vec2 vTextureCoord;","varying float vTextureIndex;","uniform float alpha;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord);","}"];
|
|
this.vertexSrc=["//StripShader Vertex Shader.","attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute float aTextureIndex;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","varying vec2 vTextureCoord;","varying float vTextureIndex;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vTextureIndex = aTextureIndex;","}"],this.init()},d.StripShader.prototype.constructor=d.StripShader,d.StripShader.prototype.init=function(){var a=this.gl,b=d.compileProgram(a,this.vertexSrc,this.fragmentSrc);if(a.useProgram(b),this.uSampler=d._enableMultiTextureToggle?a.getUniformLocation(b,"uSamplerArray[0]"):a.getUniformLocation(b,"uSampler"),d._enableMultiTextureToggle){var c=[],e=a.createTexture();a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,e),a.texImage2D(a.TEXTURE_2D,0,a.RGB,1,1,0,a.RGB,a.UNSIGNED_BYTE,null);for(var f=0;f<this.MAX_TEXTURES;++f)a.activeTexture(a.TEXTURE0+f),a.bindTexture(a.TEXTURE_2D,e),c.push(f);a.activeTexture(a.TEXTURE0),a.uniform1iv(this.uSampler,c)}this.projectionVector=a.getUniformLocation(b,"projectionVector"),this.offsetVector=a.getUniformLocation(b,"offsetVector"),this.colorAttribute=a.getAttribLocation(b,"aColor"),this.aTextureIndex=a.getAttribLocation(b,"aTextureIndex"),this.aVertexPosition=a.getAttribLocation(b,"aVertexPosition"),this.aTextureCoord=a.getAttribLocation(b,"aTextureCoord"),this.attributes=[this.aVertexPosition,this.aTextureCoord,this.aTextureIndex],this.translationMatrix=a.getUniformLocation(b,"translationMatrix"),this.alpha=a.getUniformLocation(b,"alpha"),this.program=b},d.StripShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attribute=null},d.PrimitiveShader=function(a){this._UID=d._UID++,this.gl=a,this.program=null,this.fragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {"," gl_FragColor = vColor;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec4 aColor;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform float alpha;","uniform float flipY;","uniform vec3 tint;","varying vec4 vColor;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);"," vColor = aColor * vec4(tint * alpha, alpha);","}"],this.init()},d.PrimitiveShader.prototype.constructor=d.PrimitiveShader,d.PrimitiveShader.prototype.init=function(){var a=this.gl,b=d.compileProgram(a,this.vertexSrc,this.fragmentSrc);a.useProgram(b),this.projectionVector=a.getUniformLocation(b,"projectionVector"),this.offsetVector=a.getUniformLocation(b,"offsetVector"),this.tintColor=a.getUniformLocation(b,"tint"),this.flipY=a.getUniformLocation(b,"flipY"),this.aVertexPosition=a.getAttribLocation(b,"aVertexPosition"),this.colorAttribute=a.getAttribLocation(b,"aColor"),this.attributes=[this.aVertexPosition,this.colorAttribute],this.translationMatrix=a.getUniformLocation(b,"translationMatrix"),this.alpha=a.getUniformLocation(b,"alpha"),this.program=b},d.PrimitiveShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},d.ComplexPrimitiveShader=function(a){this._UID=d._UID++,this.gl=a,this.program=null,this.fragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {"," gl_FragColor = vColor;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform vec3 tint;","uniform float alpha;","uniform vec3 color;","uniform float flipY;","varying vec4 vColor;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);"," vColor = vec4(color * alpha * tint, alpha);","}"],this.init()},d.ComplexPrimitiveShader.prototype.constructor=d.ComplexPrimitiveShader,d.ComplexPrimitiveShader.prototype.init=function(){var a=this.gl,b=d.compileProgram(a,this.vertexSrc,this.fragmentSrc);a.useProgram(b),this.projectionVector=a.getUniformLocation(b,"projectionVector"),this.offsetVector=a.getUniformLocation(b,"offsetVector"),this.tintColor=a.getUniformLocation(b,"tint"),this.color=a.getUniformLocation(b,"color"),this.flipY=a.getUniformLocation(b,"flipY"),this.aVertexPosition=a.getAttribLocation(b,"aVertexPosition"),this.attributes=[this.aVertexPosition,this.colorAttribute],this.translationMatrix=a.getUniformLocation(b,"translationMatrix"),this.alpha=a.getUniformLocation(b,"alpha"),this.program=b},d.ComplexPrimitiveShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attribute=null},d.glContexts=[],d.instances=[],d._enableMultiTextureToggle=!1,d.WebGLRenderer=function(a){this.game=a,d.defaultRenderer||(d.defaultRenderer=this),this.extensions={},this.type=d.WEBGL_RENDERER,this.resolution=a.resolution,this.transparent=a.transparent,this.autoResize=!1,this.preserveDrawingBuffer=a.preserveDrawingBuffer,this.clearBeforeRender=a.clearBeforeRender,this.width=a.width,this.height=a.height,this.view=a.canvas,this._contextOptions={alpha:this.transparent,antialias:a.antialias,premultipliedAlpha:this.transparent&&"notMultiplied"!==this.transparent,stencil:!0,preserveDrawingBuffer:this.preserveDrawingBuffer},this.projection=new d.Point,this.offset=new d.Point,this.shaderManager=new d.WebGLShaderManager,this.spriteBatch=new d.WebGLSpriteBatch,this.maskManager=new d.WebGLMaskManager,this.filterManager=new d.WebGLFilterManager,this.stencilManager=new d.WebGLStencilManager,this.blendModeManager=new d.WebGLBlendModeManager,this.renderSession={},this.currentBatchedTextures=[],this.renderSession.game=this.game,this.renderSession.gl=this.gl,this.renderSession.drawCount=0,this.renderSession.shaderManager=this.shaderManager,this.renderSession.maskManager=this.maskManager,this.renderSession.filterManager=this.filterManager,this.renderSession.blendModeManager=this.blendModeManager,this.renderSession.spriteBatch=this.spriteBatch,this.renderSession.stencilManager=this.stencilManager,this.renderSession.renderer=this,this.renderSession.resolution=this.resolution,this.initContext(),this.mapBlendModes()},d.WebGLRenderer.prototype.constructor=d.WebGLRenderer,d.WebGLRenderer.prototype.initContext=function(){var a=this.view.getContext("webgl",this._contextOptions)||this.view.getContext("experimental-webgl",this._contextOptions);if(this.gl=a,!a)throw new Error("This browser does not support webGL. Try using the canvas renderer");this.maxTextures=a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS),this.glContextId=a.id=d.WebGLRenderer.glContextId++,d.glContexts[this.glContextId]=a,d.instances[this.glContextId]=this,a.disable(a.DEPTH_TEST),a.disable(a.CULL_FACE),a.enable(a.BLEND),this.shaderManager.setContext(a),this.spriteBatch.setContext(a),this.maskManager.setContext(a),this.filterManager.setContext(a),this.blendModeManager.setContext(a),this.stencilManager.setContext(a),this.renderSession.gl=this.gl,this.resize(this.width,this.height),this.extensions.compression={},etc1=a.getExtension("WEBGL_compressed_texture_etc1")||a.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"),pvrtc=a.getExtension("WEBGL_compressed_texture_pvrtc")||a.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),s3tc=a.getExtension("WEBGL_compressed_texture_s3tc")||a.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"),etc1&&(this.extensions.compression.ETC1=etc1),pvrtc&&(this.extensions.compression.PVRTC=pvrtc),s3tc&&(this.extensions.compression.S3TC=s3tc)},d.WebGLRenderer.prototype.setTexturePriority=function(a){if(!d._enableMultiTextureToggle)return void console.warn("setTexturePriority error: Multi Texture support hasn't been enabled in the Phaser Game Config.");for(var b=this.maxTextures,c=this.game.cache._cache.image,e=null,f=(this.gl,0);f<this.currentBatchedTextures.length;f++)e=a[g],e in c&&(c[e].base.textureIndex=0);this.currentBatchedTextures.length=0;for(var g=0;g<a.length;++g)e=a[g],e in c&&(g+1<b?c[e].base.textureIndex=g+1:c[e].base.textureIndex=b-1,this.currentBatchedTextures.push(e));return this.currentBatchedTextures},d.WebGLRenderer.prototype.render=function(a){if(!this.contextLost){var b=this.gl;b.viewport(0,0,this.width,this.height),b.bindFramebuffer(b.FRAMEBUFFER,null),this.game.clearBeforeRender&&(b.clearColor(a._bgColor.r,a._bgColor.g,a._bgColor.b,a._bgColor.a),b.clear(b.COLOR_BUFFER_BIT)),this.offset.x=this.game.camera._shake.x,this.offset.y=this.game.camera._shake.y,this.renderDisplayObject(a,this.projection)}},d.WebGLRenderer.prototype.renderDisplayObject=function(a,b,c,e){this.renderSession.blendModeManager.setBlendMode(d.blendModes.NORMAL),this.renderSession.drawCount=0,this.renderSession.flipY=c?-1:1,this.renderSession.projection=b,this.renderSession.offset=this.offset,this.spriteBatch.begin(this.renderSession),this.filterManager.begin(this.renderSession,c),a._renderWebGL(this.renderSession,e),this.spriteBatch.end()},d.WebGLRenderer.prototype.resize=function(a,b){this.width=a*this.resolution,this.height=b*this.resolution,this.view.width=this.width,this.view.height=this.height,this.autoResize&&(this.view.style.width=this.width/this.resolution+"px",this.view.style.height=this.height/this.resolution+"px"),this.gl.viewport(0,0,this.width,this.height),this.projection.x=this.width/2/this.resolution,this.projection.y=-this.height/2/this.resolution},d.WebGLRenderer.prototype.updateCompressedTexture=function(a){if(!a.hasLoaded)return!1;var b=this.gl,c=a.source;return a._glTextures[b.id]||(a._glTextures[b.id]=b.createTexture()),b.activeTexture(b.TEXTURE0+a.textureIndex),b.bindTexture(b.TEXTURE_2D,a._glTextures[b.id]),b.compressedTexImage2D(b.TEXTURE_2D,0,c.glExtensionFormat,c.width,c.height,0,c.textureData),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,a.scaleMode===d.scaleModes.LINEAR?b.LINEAR:b.NEAREST),a.mipmap&&d.isPowerOfTwo(a.width,a.height)?(b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,a.scaleMode===d.scaleModes.LINEAR?b.LINEAR_MIPMAP_LINEAR:b.NEAREST_MIPMAP_NEAREST),b.generateMipmap(b.TEXTURE_2D)):b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,a.scaleMode===d.scaleModes.LINEAR?b.LINEAR:b.NEAREST),a._powerOf2?(b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.REPEAT),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.REPEAT)):(b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE)),a._dirty[b.id]=!1,!0},d.WebGLRenderer.prototype.updateTexture=function(a){if(!a.hasLoaded)return!1;if(a.source.compressionAlgorithm)return this.updateCompressedTexture(a);var b=this.gl;return a._glTextures[b.id]||(a._glTextures[b.id]=b.createTexture()),b.activeTexture(b.TEXTURE0+a.textureIndex),b.bindTexture(b.TEXTURE_2D,a._glTextures[b.id]),b.pixelStorei(b.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultipliedAlpha),b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,a.source),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,a.scaleMode===d.scaleModes.LINEAR?b.LINEAR:b.NEAREST),a.mipmap&&d.isPowerOfTwo(a.width,a.height)?(b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,a.scaleMode===d.scaleModes.LINEAR?b.LINEAR_MIPMAP_LINEAR:b.NEAREST_MIPMAP_NEAREST),b.generateMipmap(b.TEXTURE_2D)):b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,a.scaleMode===d.scaleModes.LINEAR?b.LINEAR:b.NEAREST),a._powerOf2?(b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.REPEAT),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.REPEAT)):(b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE)),a._dirty[b.id]=!1,!0},d.WebGLRenderer.prototype.destroy=function(){d.glContexts[this.glContextId]=null,this.projection=null,this.offset=null,this.shaderManager.destroy(),this.spriteBatch.destroy(),this.maskManager.destroy(),this.filterManager.destroy(),this.shaderManager=null,this.spriteBatch=null,this.maskManager=null,this.filterManager=null,this.gl=null,this.renderSession=null,d.CanvasPool.remove(this),d.instances[this.glContextId]=null,d.WebGLRenderer.glContextId--},d.WebGLRenderer.prototype.mapBlendModes=function(){var a=this.gl;if(!d.blendModesWebGL){var b=[],c=d.blendModes;b[c.NORMAL]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b[c.ADD]=[a.SRC_ALPHA,a.DST_ALPHA],b[c.MULTIPLY]=[a.DST_COLOR,a.ONE_MINUS_SRC_ALPHA],b[c.SCREEN]=[a.SRC_ALPHA,a.ONE],b[c.OVERLAY]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b[c.DARKEN]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b[c.LIGHTEN]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b[c.COLOR_DODGE]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b[c.COLOR_BURN]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b[c.HARD_LIGHT]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b[c.SOFT_LIGHT]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b[c.DIFFERENCE]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b[c.EXCLUSION]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b[c.HUE]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b[c.SATURATION]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b[c.COLOR]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b[c.LUMINOSITY]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],d.blendModesWebGL=b}},d.WebGLRenderer.prototype.getMaxTextureUnit=function(){var a=this.gl;return a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS)},d.enableMultiTexture=function(){d._enableMultiTextureToggle=!0},d.WebGLRenderer.glContextId=0,d.WebGLBlendModeManager=function(){this.currentBlendMode=99999},d.WebGLBlendModeManager.prototype.constructor=d.WebGLBlendModeManager,d.WebGLBlendModeManager.prototype.setContext=function(a){this.gl=a},d.WebGLBlendModeManager.prototype.setBlendMode=function(a){if(this.currentBlendMode===a)return!1;this.currentBlendMode=a;var b=d.blendModesWebGL[this.currentBlendMode];return b&&this.gl.blendFunc(b[0],b[1]),!0},d.WebGLBlendModeManager.prototype.destroy=function(){this.gl=null},d.WebGLMaskManager=function(){},d.WebGLMaskManager.prototype.constructor=d.WebGLMaskManager,d.WebGLMaskManager.prototype.setContext=function(a){this.gl=a},d.WebGLMaskManager.prototype.pushMask=function(a,b){var c=b.gl;a.dirty&&d.WebGLGraphics.updateGraphics(a,c),void 0!==a._webGL[c.id]&&void 0!==a._webGL[c.id].data&&0!==a._webGL[c.id].data.length&&b.stencilManager.pushStencil(a,a._webGL[c.id].data[0],b)},d.WebGLMaskManager.prototype.popMask=function(a,b){var c=this.gl;void 0!==a._webGL[c.id]&&void 0!==a._webGL[c.id].data&&0!==a._webGL[c.id].data.length&&b.stencilManager.popStencil(a,a._webGL[c.id].data[0],b)},d.WebGLMaskManager.prototype.destroy=function(){this.gl=null},d.WebGLStencilManager=function(){this.stencilStack=[],this.reverse=!0,this.count=0},d.WebGLStencilManager.prototype.setContext=function(a){this.gl=a},d.WebGLStencilManager.prototype.pushStencil=function(a,b,c){var d=this.gl;this.bindGraphics(a,b,c),0===this.stencilStack.length&&(d.enable(d.STENCIL_TEST),d.clear(d.STENCIL_BUFFER_BIT),this.reverse=!0,this.count=0),this.stencilStack.push(b);var e=this.count;d.colorMask(!1,!1,!1,!1),d.stencilFunc(d.ALWAYS,0,255),d.stencilOp(d.KEEP,d.KEEP,d.INVERT),1===b.mode?(d.drawElements(d.TRIANGLE_FAN,b.indices.length-4,d.UNSIGNED_SHORT,0),this.reverse?(d.stencilFunc(d.EQUAL,255-e,255),d.stencilOp(d.KEEP,d.KEEP,d.DECR)):(d.stencilFunc(d.EQUAL,e,255),d.stencilOp(d.KEEP,d.KEEP,d.INCR)),d.drawElements(d.TRIANGLE_FAN,4,d.UNSIGNED_SHORT,2*(b.indices.length-4)),this.reverse?d.stencilFunc(d.EQUAL,255-(e+1),255):d.stencilFunc(d.EQUAL,e+1,255),this.reverse=!this.reverse):(this.reverse?(d.stencilFunc(d.EQUAL,e,255),d.stencilOp(d.KEEP,d.KEEP,d.INCR)):(d.stencilFunc(d.EQUAL,255-e,255),d.stencilOp(d.KEEP,d.KEEP,d.DECR)),d.drawElements(d.TRIANGLE_STRIP,b.indices.length,d.UNSIGNED_SHORT,0),this.reverse?d.stencilFunc(d.EQUAL,e+1,255):d.stencilFunc(d.EQUAL,255-(e+1),255)),d.colorMask(!0,!0,!0,!0),d.stencilOp(d.KEEP,d.KEEP,d.KEEP),this.count++},d.WebGLStencilManager.prototype.bindGraphics=function(a,b,c){this._currentGraphics=a;var e,f=this.gl,g=c.projection,h=c.offset;1===b.mode?(e=c.shaderManager.complexPrimitiveShader,c.shaderManager.setShader(e),f.uniform1f(e.flipY,c.flipY),f.uniformMatrix3fv(e.translationMatrix,!1,a.worldTransform.toArray(!0)),f.uniform2f(e.projectionVector,g.x,-g.y),f.uniform2f(e.offsetVector,-h.x,-h.y),f.uniform3fv(e.tintColor,d.hex2rgb(a.tint)),f.uniform3fv(e.color,b.color),f.uniform1f(e.alpha,a.worldAlpha*b.alpha),f.bindBuffer(f.ARRAY_BUFFER,b.buffer),f.vertexAttribPointer(e.aVertexPosition,2,f.FLOAT,!1,8,0),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,b.indexBuffer)):(e=c.shaderManager.primitiveShader,c.shaderManager.setShader(e),f.uniformMatrix3fv(e.translationMatrix,!1,a.worldTransform.toArray(!0)),f.uniform1f(e.flipY,c.flipY),f.uniform2f(e.projectionVector,g.x,-g.y),f.uniform2f(e.offsetVector,-h.x,-h.y),f.uniform3fv(e.tintColor,d.hex2rgb(a.tint)),f.uniform1f(e.alpha,a.worldAlpha),f.bindBuffer(f.ARRAY_BUFFER,b.buffer),f.vertexAttribPointer(e.aVertexPosition,2,f.FLOAT,!1,24,0),f.vertexAttribPointer(e.colorAttribute,4,f.FLOAT,!1,24,8),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,b.indexBuffer))},d.WebGLStencilManager.prototype.popStencil=function(a,b,c){var d=this.gl;if(this.stencilStack.pop(),this.count--,0===this.stencilStack.length)d.disable(d.STENCIL_TEST);else{var e=this.count;this.bindGraphics(a,b,c),d.colorMask(!1,!1,!1,!1),1===b.mode?(this.reverse=!this.reverse,this.reverse?(d.stencilFunc(d.EQUAL,255-(e+1),255),d.stencilOp(d.KEEP,d.KEEP,d.INCR)):(d.stencilFunc(d.EQUAL,e+1,255),d.stencilOp(d.KEEP,d.KEEP,d.DECR)),d.drawElements(d.TRIANGLE_FAN,4,d.UNSIGNED_SHORT,2*(b.indices.length-4)),d.stencilFunc(d.ALWAYS,0,255),d.stencilOp(d.KEEP,d.KEEP,d.INVERT),d.drawElements(d.TRIANGLE_FAN,b.indices.length-4,d.UNSIGNED_SHORT,0),this.reverse?d.stencilFunc(d.EQUAL,e,255):d.stencilFunc(d.EQUAL,255-e,255)):(this.reverse?(d.stencilFunc(d.EQUAL,e+1,255),d.stencilOp(d.KEEP,d.KEEP,d.DECR)):(d.stencilFunc(d.EQUAL,255-(e+1),255),d.stencilOp(d.KEEP,d.KEEP,d.INCR)),d.drawElements(d.TRIANGLE_STRIP,b.indices.length,d.UNSIGNED_SHORT,0),this.reverse?d.stencilFunc(d.EQUAL,e,255):d.stencilFunc(d.EQUAL,255-e,255)),d.colorMask(!0,!0,!0,!0),d.stencilOp(d.KEEP,d.KEEP,d.KEEP)}},d.WebGLStencilManager.prototype.destroy=function(){this.stencilStack=null,this.gl=null},d.WebGLShaderManager=function(){this.maxAttibs=10,this.attribState=[],this.tempAttribState=[];for(var a=0;a<this.maxAttibs;a++)this.attribState[a]=!1;this.stack=[]},d.WebGLShaderManager.prototype.constructor=d.WebGLShaderManager,d.WebGLShaderManager.prototype.setContext=function(a){this.gl=a,this.primitiveShader=new d.PrimitiveShader(a),this.complexPrimitiveShader=new d.ComplexPrimitiveShader(a),this.defaultShader=new d.PixiShader(a),this.fastShader=new d.PixiFastShader(a),this.stripShader=new d.StripShader(a),this.setShader(this.defaultShader)},d.WebGLShaderManager.prototype.setAttribs=function(a){var b;for(b=0;b<this.tempAttribState.length;b++)this.tempAttribState[b]=!1;for(b=0;b<a.length;b++){var c=a[b];this.tempAttribState[c]=!0}var d=this.gl;for(b=0;b<this.attribState.length;b++)this.attribState[b]!==this.tempAttribState[b]&&(this.attribState[b]=this.tempAttribState[b],this.tempAttribState[b]?d.enableVertexAttribArray(b):d.disableVertexAttribArray(b))},d.WebGLShaderManager.prototype.setShader=function(a){return this._currentId!==a._UID&&(this._currentId=a._UID,this.currentShader=a,this.gl.useProgram(a.program),this.setAttribs(a.attributes),!0)},d.WebGLShaderManager.prototype.destroy=function(){this.attribState=null,this.tempAttribState=null,this.primitiveShader.destroy(),this.complexPrimitiveShader.destroy(),this.defaultShader.destroy(),this.fastShader.destroy(),this.stripShader.destroy(),this.gl=null},d.WebGLSpriteBatch=function(){this.vertSize=5,this.size=2e3,this.vertexSize=24;var a=this.vertexSize*this.size*4,b=6*this.size;this.vertices=new d.ArrayBuffer(a),this.positions=new d.Float32Array(this.vertices),this.colors=new d.Uint32Array(this.vertices),this.indices=new d.Uint16Array(b),this.lastIndexCount=0;for(var c=0,e=0;c<b;c+=6,e+=4)this.indices[c+0]=e+0,this.indices[c+1]=e+1,this.indices[c+2]=e+2,this.indices[c+3]=e+0,this.indices[c+4]=e+2,this.indices[c+5]=e+3;this.drawing=!1,this.currentBatchSize=0,this.currentBaseTexture=null,this.dirty=!0,this.textures=[],this.blendModes=[],this.shaders=[],this.sprites=[],this.defaultShader=null,this.textureArray=[]},d.WebGLSpriteBatch.prototype.setContext=function(a){this.MAX_TEXTURES=a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS);for(var b="\tif (vTextureIndex == 0.0) gl_FragColor = texture2D(uSamplerArray[0], vTextureCoord) * vColor;\n",c=1;c<this.MAX_TEXTURES;++c)b+="\telse if (vTextureIndex == "+c+".0) gl_FragColor = texture2D(uSamplerArray["+c+"], vTextureCoord) * vColor;\n";this.gl=a,this.defaultShader=new d.AbstractFilter(["//WebGLSpriteBatch Fragment Shader.","precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","varying float vTextureIndex;","uniform sampler2D uSamplerArray["+this.MAX_TEXTURES+"];","void main(void) {",b,"\telse gl_FragColor = texture2D(uSamplerArray[0], vTextureCoord) * vColor;","}"]),this.vertexBuffer=a.createBuffer(),this.indexBuffer=a.createBuffer(),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,this.indices,a.STATIC_DRAW),a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),a.bufferData(a.ARRAY_BUFFER,this.vertices,a.DYNAMIC_DRAW),this.currentBlendMode=99999;var e=new d.PixiShader(a);e.fragmentSrc=this.defaultShader.fragmentSrc,e.uniforms={},e.init(),this.defaultShader.shaders[a.id]=e},d.WebGLSpriteBatch.prototype.begin=function(a){this.renderSession=a,this.shader=this.renderSession.shaderManager.defaultShader,this.start()},d.WebGLSpriteBatch.prototype.end=function(){this.flush()},d.WebGLSpriteBatch.prototype.render=function(a,b){var c=a.texture,d=c.baseTexture,e=this.gl;this.textureArray[d.textureIndex]!=d&&(this.flush(),e.activeTexture(e.TEXTURE0+d.textureIndex),e.bindTexture(e.TEXTURE_2D,d._glTextures[e.id]),this.textureArray[d.textureIndex]=d);var f=a.worldTransform;b&&(f=b),this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=c.baseTexture);var g=c._uvs;if(g){var h,i,j,k,l=a.anchor.x,m=a.anchor.y;if(c.trim){var n=c.trim;i=n.x-l*n.width,h=i+c.crop.width,k=n.y-m*n.height,j=k+c.crop.height}else h=c.frame.width*(1-l),i=c.frame.width*-l,j=c.frame.height*(1-m),k=c.frame.height*-m;var o=this.currentBatchSize*this.vertexSize,p=(4*this.currentBatchSize,c.baseTexture.resolution),q=c.baseTexture.textureIndex,r=f.a/p,s=f.b/p,t=f.c/p,u=f.d/p,v=f.tx,w=f.ty,x=(c.crop.width,c.crop.height);if(c.rotated){var y=f.a,z=f.b,A=f.c,B=f.d,C=i,D=h;v=f.c*x+v,w=f.d*x+w,r=6.123233995736766e-17*y+-A,s=6.123233995736766e-17*z+-B,t=y+6.123233995736766e-17*A,u=z+6.123233995736766e-17*B,c._updateUvsInverted(),h=j,i=k,j=D,k=C}var E=this.colors,F=this.positions,G=a.tint,H=(G>>16)+(65280&G)+((255&G)<<16)+(255*a.worldAlpha<<24);this.renderSession.roundPixels?(F[o++]=r*i+t*k+v|0,F[o++]=u*k+s*i+w|0,F[o++]=g.x0,F[o++]=g.y0,E[o++]=H,F[o++]=q,F[o++]=r*h+t*k+v|0,F[o++]=u*k+s*h+w|0,F[o++]=g.x1,F[o++]=g.y1,E[o++]=H,F[o++]=q,F[o++]=r*h+t*j+v|0,F[o++]=u*j+s*h+w|0,F[o++]=g.x2,F[o++]=g.y2,E[o++]=H,F[o++]=q,F[o++]=r*i+t*j+v|0,F[o++]=u*j+s*i+w|0,F[o++]=g.x3,F[o++]=g.y3,E[o++]=H,F[o++]=q):(F[o++]=r*i+t*k+v,F[o++]=u*k+s*i+w,F[o++]=g.x0,F[o++]=g.y0,E[o++]=H,F[o++]=q,F[o++]=r*h+t*k+v,F[o++]=u*k+s*h+w,F[o++]=g.x1,F[o++]=g.y1,E[o++]=H,F[o++]=q,F[o++]=r*h+t*j+v,F[o++]=u*j+s*h+w,F[o++]=g.x2,F[o++]=g.y2,E[o++]=H,F[o++]=q,F[o++]=r*i+t*j+v,F[o++]=u*j+s*i+w,F[o++]=g.x3,F[o++]=g.y3,E[o++]=H,F[o++]=q),this.sprites[this.currentBatchSize++]=a}},d.WebGLSpriteBatch.prototype.renderTilingSprite=function(a){var b=a.tilingTexture,c=b.baseTexture,e=this.gl,f=a.texture.baseTexture.textureIndex;this.textureArray[f]!=c&&(this.flush(),e.activeTexture(e.TEXTURE0+f),e.bindTexture(e.TEXTURE_2D,c._glTextures[e.id]),this.textureArray[f]=c),this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=b.baseTexture),a._uvs||(a._uvs=new d.TextureUvs);var g=a._uvs,h=b.baseTexture.width,i=b.baseTexture.height;a.tilePosition.x%=h*a.tileScaleOffset.x,a.tilePosition.y%=i*a.tileScaleOffset.y;var j=a.tilePosition.x/(h*a.tileScaleOffset.x),k=a.tilePosition.y/(i*a.tileScaleOffset.y),l=a.width/h/(a.tileScale.x*a.tileScaleOffset.x),m=a.height/i/(a.tileScale.y*a.tileScaleOffset.y);g.x0=0-j,g.y0=0-k,g.x1=1*l-j,g.y1=0-k,g.x2=1*l-j,g.y2=1*m-k,g.x3=0-j,g.y3=1*m-k;var n=a.tint,o=(n>>16)+(65280&n)+((255&n)<<16)+(255*a.worldAlpha<<24),p=this.positions,q=this.colors,r=a.width,s=a.height,t=a.anchor.x,u=a.anchor.y,v=r*(1-t),w=r*-t,x=s*(1-u),y=s*-u,z=this.currentBatchSize*this.vertexSize,A=b.baseTexture.resolution,B=a.worldTransform,C=B.a/A,D=B.b/A,E=B.c/A,F=B.d/A,G=B.tx,H=B.ty;p[z++]=C*w+E*y+G,p[z++]=F*y+D*w+H,p[z++]=g.x0,p[z++]=g.y0,q[z++]=o,p[z++]=f,p[z++]=C*v+E*y+G,p[z++]=F*y+D*v+H,p[z++]=g.x1,p[z++]=g.y1,q[z++]=o,p[z++]=f,p[z++]=C*v+E*x+G,p[z++]=F*x+D*v+H,p[z++]=g.x2,p[z++]=g.y2,q[z++]=o,p[z++]=f,p[z++]=C*w+E*x+G,p[z++]=F*x+D*w+H,p[z++]=g.x3,p[z++]=g.y3,q[z++]=o,p[z++]=f,this.sprites[this.currentBatchSize++]=a},d.WebGLSpriteBatch.prototype.flush=function(){if(0!==this.currentBatchSize){var a,b=this.gl;if(this.dirty){this.dirty=!1,a=this.defaultShader.shaders[b.id],b.activeTexture(b.TEXTURE0),b.bindBuffer(b.ARRAY_BUFFER,this.vertexBuffer),b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var c=this.vertexSize;b.vertexAttribPointer(a.aVertexPosition,2,b.FLOAT,!1,c,0),b.vertexAttribPointer(a.aTextureCoord,2,b.FLOAT,!1,c,8),b.vertexAttribPointer(a.colorAttribute,4,b.UNSIGNED_BYTE,!0,c,16),b.vertexAttribPointer(a.aTextureIndex,1,b.FLOAT,!1,c,20)}if(this.currentBatchSize>.5*this.size)b.bufferSubData(b.ARRAY_BUFFER,0,this.vertices);else{b.bindBuffer(b.ARRAY_BUFFER,this.vertexBuffer);var e=this.positions.subarray(0,this.currentBatchSize*this.vertexSize);b.bufferSubData(b.ARRAY_BUFFER,0,e)}for(var f,g,h,i,j=0,k=0,l=null,m=this.renderSession.blendModeManager.currentBlendMode,n=null,o=!1,p=!1,q=0,r=this.currentBatchSize;q<r;q++){i=this.sprites[q],f=i.tilingTexture?i.tilingTexture.baseTexture:i.texture.baseTexture,g=i.blendMode,h=i.shader||this.defaultShader,o=m!==g,p=n!==h;var s=f.skipRender;if(s&&i.children.length>0&&(s=!1),(o||p)&&(this.renderBatch(l,j,k),k=q,j=0,l=f,o&&(m=g,this.renderSession.blendModeManager.setBlendMode(m)),p)){n=h,a=n.shaders[b.id],a||(a=new d.PixiShader(b),a.fragmentSrc=n.fragmentSrc,a.uniforms=n.uniforms,a.init(),n.shaders[b.id]=a),this.renderSession.shaderManager.setShader(a),a.dirty&&a.syncUniforms();var t=this.renderSession.projection;b.uniform2f(a.projectionVector,t.x,t.y);var u=this.renderSession.offset;b.uniform2f(a.offsetVector,u.x,u.y)}j++}this.renderBatch(l,j,k),this.currentBatchSize=0}},d.WebGLSpriteBatch.prototype.renderBatch=function(a,b,c){if(0!==b){var d=this.gl;a._dirty[d.id]&&!this.renderSession.renderer.updateTexture(a)||(d.drawElements(d.TRIANGLES,6*b,d.UNSIGNED_SHORT,6*c*2),this.renderSession.drawCount++)}},d.WebGLSpriteBatch.prototype.stop=function(){this.flush(),this.dirty=!0},d.WebGLSpriteBatch.prototype.start=function(){this.dirty=!0},d.WebGLSpriteBatch.prototype.destroy=function(){this.vertices=null,this.indices=null,this.gl.deleteBuffer(this.vertexBuffer),this.gl.deleteBuffer(this.indexBuffer),this.currentBaseTexture=null,this.gl=null},d.WebGLFastSpriteBatch=function(a){this.vertSize=11,this.maxSize=6e3,this.size=this.maxSize;var b=4*this.size*this.vertSize,c=6*this.maxSize;this.vertices=new d.Float32Array(b),this.indices=new d.Uint16Array(c),this.vertexBuffer=null,this.indexBuffer=null,this.lastIndexCount=0;for(var e=0,f=0;e<c;e+=6,f+=4)this.indices[e+0]=f+0,this.indices[e+1]=f+1,this.indices[e+2]=f+2,this.indices[e+3]=f+0,this.indices[e+4]=f+2,this.indices[e+5]=f+3;this.drawing=!1,this.currentBatchSize=0,this.currentBaseTexture=null,this.currentBlendMode=0,this.renderSession=null,this.shader=null,this.matrix=null,this.setContext(a)},d.WebGLFastSpriteBatch.prototype.constructor=d.WebGLFastSpriteBatch,d.WebGLFastSpriteBatch.prototype.setContext=function(a){this.gl=a,this.vertexBuffer=a.createBuffer(),this.indexBuffer=a.createBuffer(),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,this.indices,a.STATIC_DRAW),a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),a.bufferData(a.ARRAY_BUFFER,this.vertices,a.DYNAMIC_DRAW)},d.WebGLFastSpriteBatch.prototype.begin=function(a,b){this.renderSession=b,this.shader=this.renderSession.shaderManager.fastShader,this.matrix=a.worldTransform.toArray(!0),this.start()},d.WebGLFastSpriteBatch.prototype.end=function(){this.flush()},d.WebGLFastSpriteBatch.prototype.render=function(a){var b=a.children,c=b[0];if(c.texture._uvs){this.currentBaseTexture=c.texture.baseTexture,c.blendMode!==this.renderSession.blendModeManager.currentBlendMode&&(this.flush(),this.renderSession.blendModeManager.setBlendMode(c.blendMode));for(var d=0,e=b.length;d<e;d++)this.renderSprite(b[d]);this.flush()}},d.WebGLFastSpriteBatch.prototype.renderSprite=function(a){var b=a.texture,c=b.baseTexture,d=this.gl;if(this.textureArray[c.textureIndex]!=c&&(d.activeTexture(d.TEXTURE0+c.textureIndex),d.bindTexture(d.TEXTURE_2D,c._glTextures[d.id]),this.textureArray[c.textureIndex]=c,this.flush()),a.visible&&(a.texture.baseTexture===this.currentBaseTexture||a.texture.baseTexture.skipRender||(this.flush(),this.currentBaseTexture=a.texture.baseTexture,a.texture._uvs))){var e,f,g,h,i,j,k,l,m=this.vertices;if(e=a.texture._uvs,f=a.texture.frame.width,g=a.texture.frame.height,a.texture.trim){var n=a.texture.trim;i=n.x-a.anchor.x*n.width,h=i+a.texture.crop.width,k=n.y-a.anchor.y*n.height,j=k+a.texture.crop.height}else h=a.texture.frame.width*(1-a.anchor.x),i=a.texture.frame.width*-a.anchor.x,j=a.texture.frame.height*(1-a.anchor.y),k=a.texture.frame.height*-a.anchor.y;l=4*this.currentBatchSize*this.vertSize;var o=a.texture.baseTexture.textureIndex;m[l++]=i,m[l++]=k,m[l++]=a.position.x,m[l++]=a.position.y,m[l++]=a.scale.x,m[l++]=a.scale.y,m[l++]=a.rotation,m[l++]=e.x0,m[l++]=e.y1,m[l++]=a.alpha,m[l++]=o,m[l++]=h,m[l++]=k,m[l++]=a.position.x,m[l++]=a.position.y,m[l++]=a.scale.x,m[l++]=a.scale.y,m[l++]=a.rotation,m[l++]=e.x1,m[l++]=e.y1,m[l++]=a.alpha,m[l++]=o,m[l++]=h,m[l++]=j,m[l++]=a.position.x,m[l++]=a.position.y,m[l++]=a.scale.x,m[l++]=a.scale.y,m[l++]=a.rotation,m[l++]=e.x2,m[l++]=e.y2,m[l++]=a.alpha,m[l++]=o,m[l++]=i,m[l++]=j,m[l++]=a.position.x,m[l++]=a.position.y,m[l++]=a.scale.x,m[l++]=a.scale.y,m[l++]=a.rotation,m[l++]=e.x3,m[l++]=e.y3,m[l++]=a.alpha,m[l++]=o,this.currentBatchSize++,this.currentBatchSize>=this.size&&this.flush()}},d.WebGLFastSpriteBatch.prototype.flush=function(){if(0!==this.currentBatchSize){var a=this.gl;if(this.currentBaseTexture._glTextures[a.id]||this.renderSession.renderer.updateTexture(this.currentBaseTexture,a),this.currentBatchSize>.5*this.size)a.bufferSubData(a.ARRAY_BUFFER,0,this.vertices);else{var b=this.vertices.subarray(0,4*this.currentBatchSize*this.vertSize);a.bufferSubData(a.ARRAY_BUFFER,0,b)}a.drawElements(a.TRIANGLES,6*this.currentBatchSize,a.UNSIGNED_SHORT,0),this.currentBatchSize=0,this.renderSession.drawCount++}},d.WebGLFastSpriteBatch.prototype.stop=function(){this.flush()},d.WebGLFastSpriteBatch.prototype.start=function(){var a=this.gl;a.activeTexture(a.TEXTURE0),a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var b=this.renderSession.projection;a.uniform2f(this.shader.projectionVector,b.x,b.y),a.uniformMatrix3fv(this.shader.uMatrix,!1,this.matrix);var c=4*this.vertSize;a.vertexAttribPointer(this.shader.aVertexPosition,2,a.FLOAT,!1,c,0),a.vertexAttribPointer(this.shader.aPositionCoord,2,a.FLOAT,!1,c,8),a.vertexAttribPointer(this.shader.aScale,2,a.FLOAT,!1,c,16),a.vertexAttribPointer(this.shader.aRotation,1,a.FLOAT,!1,c,24),a.vertexAttribPointer(this.shader.aTextureCoord,2,a.FLOAT,!1,c,28),a.vertexAttribPointer(this.shader.colorAttribute,1,a.FLOAT,!1,c,36),
|
|
a.vertexAttribPointer(this.shader.aTextureIndex,1,a.FLOAT,!1,c,40)},d.WebGLFilterManager=function(){this.filterStack=[],this.offsetX=0,this.offsetY=0},d.WebGLFilterManager.prototype.constructor=d.WebGLFilterManager,d.WebGLFilterManager.prototype.setContext=function(a){this.gl=a,this.texturePool=[],this.initShaderBuffers()},d.WebGLFilterManager.prototype.begin=function(a,b){this.renderSession=a,this.defaultShader=a.shaderManager.defaultShader;var c=this.renderSession.projection;this.width=2*c.x,this.height=2*-c.y,this.buffer=b},d.WebGLFilterManager.prototype.pushFilter=function(a){var b=this.gl,c=this.renderSession.projection,e=this.renderSession.offset;a._filterArea=a.target.filterArea||a.target.getBounds(),a._previous_stencil_mgr=this.renderSession.stencilManager,this.renderSession.stencilManager=new d.WebGLStencilManager,this.renderSession.stencilManager.setContext(b),b.disable(b.STENCIL_TEST),this.filterStack.push(a);var f=a.filterPasses[0];this.offsetX+=a._filterArea.x,this.offsetY+=a._filterArea.y;var g=this.texturePool.pop();g?g.resize(this.width*this.renderSession.resolution,this.height*this.renderSession.resolution):g=new d.FilterTexture(this.gl,this.width*this.renderSession.resolution,this.height*this.renderSession.resolution),b.bindTexture(b.TEXTURE_2D,g.texture);var h=a._filterArea,i=f.padding;h.x-=i,h.y-=i,h.width+=2*i,h.height+=2*i,h.x<0&&(h.x=0),h.width>this.width&&(h.width=this.width),h.y<0&&(h.y=0),h.height>this.height&&(h.height=this.height),b.bindFramebuffer(b.FRAMEBUFFER,g.frameBuffer),b.viewport(0,0,h.width*this.renderSession.resolution,h.height*this.renderSession.resolution),c.x=h.width/2,c.y=-h.height/2,e.x=-h.x,e.y=-h.y,b.colorMask(!0,!0,!0,!0),b.clearColor(0,0,0,0),b.clear(b.COLOR_BUFFER_BIT),a._glFilterTexture=g},d.WebGLFilterManager.prototype.popFilter=function(){var a=this.gl,b=this.filterStack.pop(),c=b._filterArea,e=b._glFilterTexture,f=this.renderSession.projection,g=this.renderSession.offset;if(b.filterPasses.length>1){a.viewport(0,0,c.width*this.renderSession.resolution,c.height*this.renderSession.resolution),a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),this.vertexArray[0]=0,this.vertexArray[1]=c.height,this.vertexArray[2]=c.width,this.vertexArray[3]=c.height,this.vertexArray[4]=0,this.vertexArray[5]=0,this.vertexArray[6]=c.width,this.vertexArray[7]=0,a.bufferSubData(a.ARRAY_BUFFER,0,this.vertexArray),a.bindBuffer(a.ARRAY_BUFFER,this.uvBuffer),this.uvArray[2]=c.width/this.width,this.uvArray[5]=c.height/this.height,this.uvArray[6]=c.width/this.width,this.uvArray[7]=c.height/this.height,a.bufferSubData(a.ARRAY_BUFFER,0,this.uvArray);var h=e,i=this.texturePool.pop();i||(i=new d.FilterTexture(this.gl,this.width*this.renderSession.resolution,this.height*this.renderSession.resolution)),i.resize(this.width*this.renderSession.resolution,this.height*this.renderSession.resolution),a.bindFramebuffer(a.FRAMEBUFFER,i.frameBuffer),a.clear(a.COLOR_BUFFER_BIT),a.disable(a.BLEND);for(var j=0;j<b.filterPasses.length-1;j++){var k=b.filterPasses[j];a.bindFramebuffer(a.FRAMEBUFFER,i.frameBuffer),a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,h.texture),this.applyFilterPass(k,c,c.width,c.height);var l=h;h=i,i=l}a.enable(a.BLEND),e=h,this.texturePool.push(i)}var m=b.filterPasses[b.filterPasses.length-1];this.offsetX-=c.x,this.offsetY-=c.y;var n=this.width,o=this.height,p=0,q=0,r=this.buffer;if(0===this.filterStack.length)a.colorMask(!0,!0,!0,!0);else{var s=this.filterStack[this.filterStack.length-1];c=s._filterArea,n=c.width,o=c.height,p=c.x,q=c.y,r=s._glFilterTexture.frameBuffer}f.x=n/2,f.y=-o/2,g.x=p,g.y=q,c=b._filterArea;var t=c.x-p,u=c.y-q;a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),this.vertexArray[0]=t,this.vertexArray[1]=u+c.height,this.vertexArray[2]=t+c.width,this.vertexArray[3]=u+c.height,this.vertexArray[4]=t,this.vertexArray[5]=u,this.vertexArray[6]=t+c.width,this.vertexArray[7]=u,a.bufferSubData(a.ARRAY_BUFFER,0,this.vertexArray),a.bindBuffer(a.ARRAY_BUFFER,this.uvBuffer),this.uvArray[2]=c.width/this.width,this.uvArray[5]=c.height/this.height,this.uvArray[6]=c.width/this.width,this.uvArray[7]=c.height/this.height,a.bufferSubData(a.ARRAY_BUFFER,0,this.uvArray),a.viewport(0,0,n*this.renderSession.resolution,o*this.renderSession.resolution),a.bindFramebuffer(a.FRAMEBUFFER,r),a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,e.texture),this.renderSession.stencilManager&&this.renderSession.stencilManager.destroy(),this.renderSession.stencilManager=b._previous_stencil_mgr,b._previous_stencil_mgr=null,this.renderSession.stencilManager.count>0?a.enable(a.STENCIL_TEST):a.disable(a.STENCIL_TEST),this.applyFilterPass(m,c,n,o),this.texturePool.push(e),b._glFilterTexture=null},d.WebGLFilterManager.prototype.applyFilterPass=function(a,b,c,e){var f=this.gl,g=a.shaders[f.id];g||(g=new d.PixiShader(f),g.fragmentSrc=a.fragmentSrc,g.uniforms=a.uniforms,g.init(!0),a.shaders[f.id]=g),this.renderSession.shaderManager.setShader(g),f.uniform2f(g.projectionVector,c/2,-e/2),f.uniform2f(g.offsetVector,0,0),a.uniforms.dimensions&&(a.uniforms.dimensions.value[0]=this.width,a.uniforms.dimensions.value[1]=this.height,a.uniforms.dimensions.value[2]=this.vertexArray[0],a.uniforms.dimensions.value[3]=this.vertexArray[5]),g.syncUniforms(),f.bindBuffer(f.ARRAY_BUFFER,this.vertexBuffer),f.vertexAttribPointer(g.aVertexPosition,2,f.FLOAT,!1,0,0),f.bindBuffer(f.ARRAY_BUFFER,this.uvBuffer),f.vertexAttribPointer(g.aTextureCoord,2,f.FLOAT,!1,0,0),f.bindBuffer(f.ARRAY_BUFFER,this.colorBuffer),f.vertexAttribPointer(g.colorAttribute,2,f.FLOAT,!1,0,0),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,this.indexBuffer),f.drawElements(f.TRIANGLES,6,f.UNSIGNED_SHORT,0),this.renderSession.drawCount++},d.WebGLFilterManager.prototype.initShaderBuffers=function(){var a=this.gl;this.vertexBuffer=a.createBuffer(),this.uvBuffer=a.createBuffer(),this.colorBuffer=a.createBuffer(),this.indexBuffer=a.createBuffer(),this.vertexArray=new d.Float32Array([0,0,1,0,0,1,1,1]),a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),a.bufferData(a.ARRAY_BUFFER,this.vertexArray,a.STATIC_DRAW),this.uvArray=new d.Float32Array([0,0,1,0,0,1,1,1]),a.bindBuffer(a.ARRAY_BUFFER,this.uvBuffer),a.bufferData(a.ARRAY_BUFFER,this.uvArray,a.STATIC_DRAW),this.colorArray=new d.Float32Array([1,16777215,1,16777215,1,16777215,1,16777215]),a.bindBuffer(a.ARRAY_BUFFER,this.colorBuffer),a.bufferData(a.ARRAY_BUFFER,this.colorArray,a.STATIC_DRAW),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,new Uint16Array([0,1,2,1,3,2]),a.STATIC_DRAW)},d.WebGLFilterManager.prototype.destroy=function(){var a=this.gl;this.filterStack=null,this.offsetX=0,this.offsetY=0;for(var b=0;b<this.texturePool.length;b++)this.texturePool[b].destroy();this.texturePool=null,a.deleteBuffer(this.vertexBuffer),a.deleteBuffer(this.uvBuffer),a.deleteBuffer(this.colorBuffer),a.deleteBuffer(this.indexBuffer)};var e={36054:"Incomplete attachment",36055:"Missing attachment",36057:"Incomplete dimensions",36061:"Framebuffer unsupported"};return d.FilterTexture=function(a,c,e,f,g){g="number"==typeof g?g:0,this.gl=a,this.frameBuffer=b(a,c,e,f||d.scaleModes.DEFAULT,g),this.texture=this.frameBuffer.targetTexture,this.width=c,this.height=e,this.renderBuffer=this.frameBuffer.renderBuffer},d.FilterTexture.prototype.constructor=d.FilterTexture,d.FilterTexture.prototype.clear=function(){var a=this.gl;a.clearColor(0,0,0,0),a.clear(a.COLOR_BUFFER_BIT)},d.FilterTexture.prototype.resize=function(a,b){if(this.width!==a||this.height!==b){this.width=a,this.height=b;var c=this.gl;c.bindTexture(c.TEXTURE_2D,this.texture),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,a,b,0,c.RGBA,c.UNSIGNED_BYTE,null),c.bindRenderbuffer(c.RENDERBUFFER,this.renderBuffer),c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_STENCIL,a,b)}},d.FilterTexture.prototype.destroy=function(){var a=this.gl;a.deleteFramebuffer(this.frameBuffer),a.deleteTexture(this.texture),this.frameBuffer=null,this.texture=null},d.CanvasBuffer=function(a,b){this.width=a,this.height=b,this.canvas=d.CanvasPool.create(this,this.width,this.height),this.context=this.canvas.getContext("2d"),this.canvas.width=a,this.canvas.height=b},d.CanvasBuffer.prototype.constructor=d.CanvasBuffer,d.CanvasBuffer.prototype.clear=function(){this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.width,this.height)},d.CanvasBuffer.prototype.resize=function(a,b){this.width=this.canvas.width=a,this.height=this.canvas.height=b},d.CanvasBuffer.prototype.destroy=function(){d.CanvasPool.remove(this)},d.CanvasMaskManager=function(){},d.CanvasMaskManager.prototype.constructor=d.CanvasMaskManager,d.CanvasMaskManager.prototype.pushMask=function(a,b){var c=b.context;c.save();var e=a.alpha,f=a.worldTransform,g=b.resolution;c.setTransform(f.a*g,f.b*g,f.c*g,f.d*g,f.tx*g,f.ty*g),d.CanvasGraphics.renderGraphicsMask(a,c),c.clip(),a.worldAlpha=e},d.CanvasMaskManager.prototype.popMask=function(a){a.context.restore()},d.CanvasTinter=function(){},d.CanvasTinter.getTintedTexture=function(a,b){var c=a.tintedTexture||d.CanvasPool.create(this);return d.CanvasTinter.tintMethod(a.texture,b,c),c},d.CanvasTinter.tintWithMultiply=function(a,b,c){var d=c.getContext("2d"),e=a.crop,f=e.width,g=e.height;a.rotated&&(f=g,g=e.width),c.width===f&&c.height===g||(c.width=f,c.height=g),d.clearRect(0,0,f,g),d.fillStyle="#"+("00000"+(0|b).toString(16)).substr(-6),d.fillRect(0,0,f,g),d.globalCompositeOperation="multiply",d.drawImage(a.baseTexture.source,e.x,e.y,f,g,0,0,f,g),d.globalCompositeOperation="destination-atop",d.drawImage(a.baseTexture.source,e.x,e.y,f,g,0,0,f,g)},d.CanvasTinter.tintWithPerPixel=function(a,b,c){var e=c.getContext("2d"),f=a.crop,g=f.width,h=f.height;a.rotated&&(g=h,h=f.width),c.width===g&&c.height===h||(c.width=g,c.height=h),e.globalCompositeOperation="copy",e.drawImage(a.baseTexture.source,f.x,f.y,g,h,0,0,g,h);for(var i=d.hex2rgb(b),j=i[0],k=i[1],l=i[2],m=e.getImageData(0,0,g,h),n=m.data,o=0;o<n.length;o+=4)if(n[o+0]*=j,n[o+1]*=k,n[o+2]*=l,!d.CanvasTinter.canHandleAlpha){var p=n[o+3];n[o+0]/=255/p,n[o+1]/=255/p,n[o+2]/=255/p}e.putImageData(m,0,0)},d.CanvasTinter.checkInverseAlpha=function(){var a=new d.CanvasBuffer(2,1);a.context.fillStyle="rgba(10, 20, 30, 0.5)",a.context.fillRect(0,0,1,1);var b=a.context.getImageData(0,0,1,1);if(null===b)return!1;a.context.putImageData(b,1,0);var c=a.context.getImageData(1,0,1,1);return c.data[0]===b.data[0]&&c.data[1]===b.data[1]&&c.data[2]===b.data[2]&&c.data[3]===b.data[3]},d.CanvasTinter.canHandleAlpha=d.CanvasTinter.checkInverseAlpha(),d.CanvasTinter.canUseMultiply=d.canUseNewCanvasBlendModes(),d.CanvasTinter.tintMethod=d.CanvasTinter.canUseMultiply?d.CanvasTinter.tintWithMultiply:d.CanvasTinter.tintWithPerPixel,d.CanvasRenderer=function(a){this.game=a,d.defaultRenderer||(d.defaultRenderer=this),this.type=d.CANVAS_RENDERER,this.resolution=a.resolution,this.clearBeforeRender=a.clearBeforeRender,this.transparent=a.transparent,this.autoResize=!1,this.width=a.width*this.resolution,this.height=a.height*this.resolution,this.view=a.canvas,this.context=this.view.getContext("2d",{alpha:this.transparent}),this.refresh=!0,this.count=0,this.maskManager=new d.CanvasMaskManager,this.renderSession={context:this.context,maskManager:this.maskManager,scaleMode:null,smoothProperty:Phaser.Canvas.getSmoothingPrefix(this.context),roundPixels:!1},this.mapBlendModes(),this.resize(this.width,this.height)},d.CanvasRenderer.prototype.constructor=d.CanvasRenderer,d.CanvasRenderer.prototype.render=function(a){this.context.setTransform(1,0,0,1,0,0),this.context.globalAlpha=1,this.renderSession.currentBlendMode=0,this.renderSession.shakeX=this.game.camera._shake.x,this.renderSession.shakeY=this.game.camera._shake.y,this.context.globalCompositeOperation="source-over",navigator.isCocoonJS&&this.view.screencanvas&&(this.context.fillStyle="black",this.context.clear()),this.clearBeforeRender&&(this.transparent?this.context.clearRect(0,0,this.width,this.height):a._bgColor&&(this.context.fillStyle=a._bgColor.rgba,this.context.fillRect(0,0,this.width,this.height))),this.renderDisplayObject(a)},d.CanvasRenderer.prototype.setTexturePriority=function(a){},d.CanvasRenderer.prototype.destroy=function(a){void 0===a&&(a=!0),a&&this.view.parent&&this.view.parent.removeChild(this.view),this.view=null,this.context=null,this.maskManager=null,this.renderSession=null},d.CanvasRenderer.prototype.resize=function(a,b){this.width=a*this.resolution,this.height=b*this.resolution,this.view.width=this.width,this.view.height=this.height,this.autoResize&&(this.view.style.width=this.width/this.resolution+"px",this.view.style.height=this.height/this.resolution+"px"),this.renderSession.smoothProperty&&(this.context[this.renderSession.smoothProperty]=this.renderSession.scaleMode===d.scaleModes.LINEAR)},d.CanvasRenderer.prototype.renderDisplayObject=function(a,b,c){this.renderSession.context=b||this.context,this.renderSession.resolution=this.resolution,a._renderCanvas(this.renderSession,c)},d.CanvasRenderer.prototype.mapBlendModes=function(){if(!d.blendModesCanvas){var a=[],b=d.blendModes,c=d.canUseNewCanvasBlendModes();a[b.NORMAL]="source-over",a[b.ADD]="lighter",a[b.MULTIPLY]=c?"multiply":"source-over",a[b.SCREEN]=c?"screen":"source-over",a[b.OVERLAY]=c?"overlay":"source-over",a[b.DARKEN]=c?"darken":"source-over",a[b.LIGHTEN]=c?"lighten":"source-over",a[b.COLOR_DODGE]=c?"color-dodge":"source-over",a[b.COLOR_BURN]=c?"color-burn":"source-over",a[b.HARD_LIGHT]=c?"hard-light":"source-over",a[b.SOFT_LIGHT]=c?"soft-light":"source-over",a[b.DIFFERENCE]=c?"difference":"source-over",a[b.EXCLUSION]=c?"exclusion":"source-over",a[b.HUE]=c?"hue":"source-over",a[b.SATURATION]=c?"saturation":"source-over",a[b.COLOR]=c?"color":"source-over",a[b.LUMINOSITY]=c?"luminosity":"source-over",d.blendModesCanvas=a}},d.BaseTexture=function(a,b){this.resolution=1,this.width=100,this.height=100,this.scaleMode=b||d.scaleModes.DEFAULT,this.hasLoaded=!1,this.source=a,this.premultipliedAlpha=!0,this._glTextures=[],this.mipmap=!1,this.textureIndex=0,this._dirty=[!0,!0,!0,!0],a&&((this.source.complete||this.source.getContext)&&this.source.width&&this.source.height&&(this.hasLoaded=!0,this.width=this.source.naturalWidth||this.source.width,this.height=this.source.naturalHeight||this.source.height,this.dirty()),this.skipRender=!1,this._powerOf2=!1)},d.BaseTexture.prototype.constructor=d.BaseTexture,d.BaseTexture.prototype.forceLoaded=function(a,b){this.hasLoaded=!0,this.width=a,this.height=b,this.dirty()},d.BaseTexture.prototype.destroy=function(){this.source&&d.CanvasPool.removeByCanvas(this.source),this.source=null,this.unloadFromGPU()},d.BaseTexture.prototype.updateSourceImage=function(a){console.warn("PIXI.BaseTexture.updateSourceImage is deprecated. Use Phaser.Sprite.loadTexture instead.")},d.BaseTexture.prototype.dirty=function(){for(var a=0;a<this._glTextures.length;a++)this._dirty[a]=!0},d.BaseTexture.prototype.unloadFromGPU=function(){this.dirty();for(var a=this._glTextures.length-1;a>=0;a--){var b=this._glTextures[a],c=d.glContexts[a];c&&b&&c.deleteTexture(b)}this._glTextures.length=0,this.dirty()},d.BaseTexture.fromCanvas=function(a,b){return 0===a.width&&(a.width=1),0===a.height&&(a.height=1),new d.BaseTexture(a,b)},d.TextureSilentFail=!1,d.Texture=function(a,b,c,e){this.noFrame=!1,b||(this.noFrame=!0,b=new d.Rectangle(0,0,1,1)),a instanceof d.Texture&&(a=a.baseTexture),this.baseTexture=a,this.frame=b,this.trim=e,this.valid=!1,this.isTiling=!1,this.requiresUpdate=!1,this.requiresReTint=!1,this._uvs=null,this.width=0,this.height=0,this.crop=c||new d.Rectangle(0,0,1,1),this.rotated=!1,a.hasLoaded&&(this.noFrame&&(b=new d.Rectangle(0,0,a.width,a.height)),this.setFrame(b))},d.Texture.prototype.constructor=d.Texture,d.Texture.prototype.onBaseTextureLoaded=function(){var a=this.baseTexture;this.noFrame&&(this.frame=new d.Rectangle(0,0,a.width,a.height)),this.setFrame(this.frame)},d.Texture.prototype.destroy=function(a){a&&this.baseTexture.destroy(),this.valid=!1},d.Texture.prototype.setFrame=function(a){if(this.noFrame=!1,this.frame=a,this.width=a.width,this.height=a.height,this.crop.x=a.x,this.crop.y=a.y,this.crop.width=a.width,this.crop.height=a.height,!this.trim&&(a.x+a.width>this.baseTexture.width||a.y+a.height>this.baseTexture.height)){if(!d.TextureSilentFail)throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this);return void(this.valid=!1)}this.valid=a&&a.width&&a.height&&this.baseTexture.source&&this.baseTexture.hasLoaded,this.trim&&(this.width=this.trim.width,this.height=this.trim.height,this.frame.width=this.trim.width,this.frame.height=this.trim.height),this.valid&&this._updateUvs()},d.Texture.prototype._updateUvs=function(){this._uvs||(this._uvs=new d.TextureUvs);var a=this.crop,b=this.baseTexture.width,c=this.baseTexture.height;this._uvs.x0=a.x/b,this._uvs.y0=a.y/c,this._uvs.x1=(a.x+a.width)/b,this._uvs.y1=a.y/c,this._uvs.x2=(a.x+a.width)/b,this._uvs.y2=(a.y+a.height)/c,this._uvs.x3=a.x/b,this._uvs.y3=(a.y+a.height)/c},d.Texture.prototype._updateUvsInverted=function(){this._uvs||(this._uvs=new d.TextureUvs);var a=this.crop,b=this.baseTexture.width,c=this.baseTexture.height;this._uvs.x0=a.x/b,this._uvs.y0=a.y/c,this._uvs.x1=(a.x+a.height)/b,this._uvs.y1=a.y/c,this._uvs.x2=(a.x+a.height)/b,this._uvs.y2=(a.y+a.width)/c,this._uvs.x3=a.x/b,this._uvs.y3=(a.y+a.width)/c},d.Texture.fromCanvas=function(a,b){var c=d.BaseTexture.fromCanvas(a,b);return new d.Texture(c)},d.TextureUvs=function(){this.x0=0,this.y0=0,this.x1=0,this.y1=0,this.x2=0,this.y2=0,this.x3=0,this.y3=0},d.RenderTexture=function(a,b,c,e,f,g){if(g="number"==typeof g?g:0,this.width=a||100,this.height=b||100,this.resolution=f||1,this.frame=new d.Rectangle(0,0,this.width*this.resolution,this.height*this.resolution),this.crop=new d.Rectangle(0,0,this.width*this.resolution,this.height*this.resolution),this.baseTexture=new d.BaseTexture,this.baseTexture.width=this.width*this.resolution,this.baseTexture.height=this.height*this.resolution,this.baseTexture._glTextures=[],this.baseTexture.resolution=this.resolution,this.baseTexture.scaleMode=e||d.scaleModes.DEFAULT,this.baseTexture.hasLoaded=!0,d.Texture.call(this,this.baseTexture,new d.Rectangle(0,0,this.width*this.resolution,this.height*this.resolution)),this.renderer=c||d.defaultRenderer,this.renderer.type===d.WEBGL_RENDERER){var h=this.renderer.gl;this.baseTexture.textureIndex=g,this.baseTexture._dirty[h.id]=!1,this.textureBuffer=new d.FilterTexture(h,this.width,this.height,this.baseTexture.scaleMode,g),this.baseTexture._glTextures[h.id]=this.textureBuffer.texture,this.render=this.renderWebGL,this.projection=new d.Point(.5*this.width,.5*-this.height)}else this.render=this.renderCanvas,this.textureBuffer=new d.CanvasBuffer(this.width*this.resolution,this.height*this.resolution),this.baseTexture.source=this.textureBuffer.canvas;this.valid=!0,this.tempMatrix=new Phaser.Matrix,this._updateUvs()},d.RenderTexture.prototype=Object.create(d.Texture.prototype),d.RenderTexture.prototype.constructor=d.RenderTexture,d.RenderTexture.prototype.resize=function(a,b,c){a===this.width&&b===this.height||(this.valid=a>0&&b>0,this.width=a,this.height=b,this.frame.width=this.crop.width=a*this.resolution,this.frame.height=this.crop.height=b*this.resolution,c&&(this.baseTexture.width=this.width*this.resolution,this.baseTexture.height=this.height*this.resolution),this.renderer.type===d.WEBGL_RENDERER&&(this.projection.x=this.width/2,this.projection.y=-this.height/2),this.valid&&this.textureBuffer.resize(this.width,this.height))},d.RenderTexture.prototype.clear=function(){this.valid&&(this.renderer.type===d.WEBGL_RENDERER&&this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER,this.textureBuffer.frameBuffer),this.textureBuffer.clear())},d.RenderTexture.prototype.renderWebGL=function(a,b,c){if(this.valid&&0!==a.alpha){var d=a.worldTransform;d.identity(),d.translate(0,2*this.projection.y),b&&d.append(b),d.scale(1,-1);for(var e=0;e<a.children.length;e++)a.children[e].updateTransform();var f=this.renderer.gl;f.viewport(0,0,this.width*this.resolution,this.height*this.resolution),f.bindFramebuffer(f.FRAMEBUFFER,this.textureBuffer.frameBuffer),c&&this.textureBuffer.clear(),this.renderer.spriteBatch.dirty=!0,this.renderer.renderDisplayObject(a,this.projection,this.textureBuffer.frameBuffer,b),this.renderer.spriteBatch.dirty=!0,f.bindFramebuffer(f.FRAMEBUFFER,null)}},d.RenderTexture.prototype.renderCanvas=function(a,b,c){if(this.valid&&0!==a.alpha){var d=a.worldTransform;d.identity(),b&&d.append(b);for(var e=0;e<a.children.length;e++)a.children[e].updateTransform();c&&this.textureBuffer.clear();var f=this.renderer.resolution;this.renderer.resolution=this.resolution,this.renderer.renderDisplayObject(a,this.textureBuffer.context,b),this.renderer.resolution=f}},d.RenderTexture.prototype.getImage=function(){var a=new Image;return a.src=this.getBase64(),a},d.RenderTexture.prototype.getBase64=function(){return this.getCanvas().toDataURL()},d.RenderTexture.prototype.getCanvas=function(){if(this.renderer.type===d.WEBGL_RENDERER){var a=this.renderer.gl,b=this.textureBuffer.width,c=this.textureBuffer.height,e=new Uint8Array(4*b*c);a.bindFramebuffer(a.FRAMEBUFFER,this.textureBuffer.frameBuffer),a.readPixels(0,0,b,c,a.RGBA,a.UNSIGNED_BYTE,e),a.bindFramebuffer(a.FRAMEBUFFER,null);var f=new d.CanvasBuffer(b,c),g=f.context.getImageData(0,0,b,c);return g.data.set(e),f.context.putImageData(g,0,0),f.canvas}return this.textureBuffer.canvas},d.AbstractFilter=function(a,b){this.passes=[this],this.shaders=[],this.dirty=!0,this.padding=0,this.uniforms=b||{},this.fragmentSrc=a||[]},d.AbstractFilter.prototype.constructor=d.AbstractFilter,d.AbstractFilter.prototype.syncUniforms=function(){for(var a=0,b=this.shaders.length;a<b;a++)this.shaders[a].dirty=!0},d.Strip=function(a){d.DisplayObjectContainer.call(this),this.texture=a,this.uvs=new d.Float32Array([0,1,1,1,1,0,0,1]),this.vertices=new d.Float32Array([0,0,100,0,100,100,0,100]),this.colors=new d.Float32Array([1,1,1,1]),this.indices=new d.Uint16Array([0,1,2,3]),this.dirty=!0,this.blendMode=d.blendModes.NORMAL,this.canvasPadding=0,this.drawMode=d.Strip.DrawModes.TRIANGLE_STRIP},d.Strip.prototype=Object.create(d.DisplayObjectContainer.prototype),d.Strip.prototype.constructor=d.Strip,d.Strip.prototype._renderWebGL=function(a){!this.visible||this.alpha<=0||(a.spriteBatch.stop(),this._vertexBuffer||this._initWebGL(a),a.shaderManager.setShader(a.shaderManager.stripShader),this._renderStrip(a),a.spriteBatch.start())},d.Strip.prototype._initWebGL=function(a){var b=a.gl;this._vertexBuffer=b.createBuffer(),this._indexBuffer=b.createBuffer(),this._uvBuffer=b.createBuffer(),this._colorBuffer=b.createBuffer(),b.bindBuffer(b.ARRAY_BUFFER,this._vertexBuffer),b.bufferData(b.ARRAY_BUFFER,this.vertices,b.DYNAMIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,this._uvBuffer),b.bufferData(b.ARRAY_BUFFER,this.uvs,b.STATIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,this._colorBuffer),b.bufferData(b.ARRAY_BUFFER,this.colors,b.STATIC_DRAW),b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,this._indexBuffer),b.bufferData(b.ELEMENT_ARRAY_BUFFER,this.indices,b.STATIC_DRAW)},d.Strip.prototype._renderStrip=function(a){var b=a.gl,c=a.projection,e=a.offset,f=a.shaderManager.stripShader,g=this.drawMode===d.Strip.DrawModes.TRIANGLE_STRIP?b.TRIANGLE_STRIP:b.TRIANGLES;a.blendModeManager.setBlendMode(this.blendMode),b.uniformMatrix3fv(f.translationMatrix,!1,this.worldTransform.toArray(!0)),b.uniform2f(f.projectionVector,c.x,-c.y),b.uniform2f(f.offsetVector,-e.x,-e.y),b.uniform1f(f.alpha,this.worldAlpha),this.dirty?(this.dirty=!1,b.bindBuffer(b.ARRAY_BUFFER,this._vertexBuffer),b.bufferData(b.ARRAY_BUFFER,this.vertices,b.STATIC_DRAW),b.vertexAttribPointer(f.aVertexPosition,2,b.FLOAT,!1,0,0),b.bindBuffer(b.ARRAY_BUFFER,this._uvBuffer),b.bufferData(b.ARRAY_BUFFER,this.uvs,b.STATIC_DRAW),b.vertexAttribPointer(f.aTextureCoord,2,b.FLOAT,!1,0,0),b.activeTexture(b.TEXTURE0),this.texture.baseTexture._dirty[b.id]?a.renderer.updateTexture(this.texture.baseTexture):b.bindTexture(b.TEXTURE_2D,this.texture.baseTexture._glTextures[b.id]),b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,this._indexBuffer),b.bufferData(b.ELEMENT_ARRAY_BUFFER,this.indices,b.STATIC_DRAW)):(b.bindBuffer(b.ARRAY_BUFFER,this._vertexBuffer),b.bufferSubData(b.ARRAY_BUFFER,0,this.vertices),b.vertexAttribPointer(f.aVertexPosition,2,b.FLOAT,!1,0,0),b.bindBuffer(b.ARRAY_BUFFER,this._uvBuffer),b.vertexAttribPointer(f.aTextureCoord,2,b.FLOAT,!1,0,0),b.activeTexture(b.TEXTURE0),this.texture.baseTexture._dirty[b.id]?a.renderer.updateTexture(this.texture.baseTexture):b.bindTexture(b.TEXTURE_2D,this.texture.baseTexture._glTextures[b.id]),b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,this._indexBuffer)),b.drawElements(g,this.indices.length,b.UNSIGNED_SHORT,0)},d.Strip.prototype._renderCanvas=function(a){var b=a.context,c=this.worldTransform,e=c.tx*a.resolution+a.shakeX,f=c.ty*a.resolution+a.shakeY;a.roundPixels?b.setTransform(c.a,c.b,c.c,c.d,0|e,0|f):b.setTransform(c.a,c.b,c.c,c.d,e,f),this.drawMode===d.Strip.DrawModes.TRIANGLE_STRIP?this._renderCanvasTriangleStrip(b):this._renderCanvasTriangles(b)},d.Strip.prototype._renderCanvasTriangleStrip=function(a){var b=this.vertices,c=this.uvs,d=b.length/2;this.count++;for(var e=0;e<d-2;e++){var f=2*e;this._renderCanvasDrawTriangle(a,b,c,f,f+2,f+4)}},d.Strip.prototype._renderCanvasTriangles=function(a){var b=this.vertices,c=this.uvs,d=this.indices,e=d.length;this.count++;for(var f=0;f<e;f+=3){var g=2*d[f],h=2*d[f+1],i=2*d[f+2];this._renderCanvasDrawTriangle(a,b,c,g,h,i)}},d.Strip.prototype._renderCanvasDrawTriangle=function(a,b,c,d,e,f){var g=this.texture.baseTexture.source,h=this.texture.width,i=this.texture.height,j=b[d],k=b[e],l=b[f],m=b[d+1],n=b[e+1],o=b[f+1],p=c[d]*h,q=c[e]*h,r=c[f]*h,s=c[d+1]*i,t=c[e+1]*i,u=c[f+1]*i;if(this.canvasPadding>0){var v=this.canvasPadding/this.worldTransform.a,w=this.canvasPadding/this.worldTransform.d,x=(j+k+l)/3,y=(m+n+o)/3,z=j-x,A=m-y,B=Math.sqrt(z*z+A*A);j=x+z/B*(B+v),m=y+A/B*(B+w),z=k-x,A=n-y,B=Math.sqrt(z*z+A*A),k=x+z/B*(B+v),n=y+A/B*(B+w),z=l-x,A=o-y,B=Math.sqrt(z*z+A*A),l=x+z/B*(B+v),o=y+A/B*(B+w)}a.save(),a.beginPath(),a.moveTo(j,m),a.lineTo(k,n),a.lineTo(l,o),a.closePath(),a.clip();var C=p*t+s*r+q*u-t*r-s*q-p*u,D=j*t+s*l+k*u-t*l-s*k-j*u,E=p*k+j*r+q*l-k*r-j*q-p*l,F=p*t*l+s*k*r+j*q*u-j*t*r-s*q*l-p*k*u,G=m*t+s*o+n*u-t*o-s*n-m*u,H=p*n+m*r+q*o-n*r-m*q-p*o,I=p*t*o+s*n*r+m*q*u-m*t*r-s*q*o-p*n*u;a.transform(D/C,G/C,E/C,H/C,F/C,I/C),a.drawImage(g,0,0),a.restore()},d.Strip.prototype.renderStripFlat=function(a){var b=this.context,c=a.vertices,d=c.length/2;this.count++,b.beginPath();for(var e=1;e<d-2;e++){var f=2*e,g=c[f],h=c[f+2],i=c[f+4],j=c[f+1],k=c[f+3],l=c[f+5];b.moveTo(g,j),b.lineTo(h,k),b.lineTo(i,l)}b.fillStyle="#FF0000",b.fill(),b.closePath()},d.Strip.prototype.onTextureUpdate=function(){this.updateFrame=!0},d.Strip.prototype.getBounds=function(a){for(var b=a||this.worldTransform,c=b.a,e=b.b,f=b.c,g=b.d,h=b.tx,i=b.ty,j=-(1/0),k=-(1/0),l=1/0,m=1/0,n=this.vertices,o=0,p=n.length;o<p;o+=2){var q=n[o],r=n[o+1],s=c*q+f*r+h,t=g*r+e*q+i;l=s<l?s:l,m=t<m?t:m,j=s>j?s:j,k=t>k?t:k}if(l===-(1/0)||k===1/0)return d.EmptyRectangle;var u=this._bounds;return u.x=l,u.width=j-l,u.y=m,u.height=k-m,this._currentBounds=u,u},d.Strip.DrawModes={TRIANGLE_STRIP:0,TRIANGLES:1},d.Rope=function(a,b){d.Strip.call(this,a),this.points=b,this.vertices=new d.Float32Array(4*b.length),this.uvs=new d.Float32Array(4*b.length),this.colors=new d.Float32Array(2*b.length),this.indices=new d.Uint16Array(2*b.length),this.refresh()},d.Rope.prototype=Object.create(d.Strip.prototype),d.Rope.prototype.constructor=d.Rope,d.Rope.prototype.refresh=function(){var a=this.points;if(!(a.length<1)){var b=this.uvs,c=a[0],d=this.indices,e=this.colors;this.count-=.2,b[0]=0,b[1]=0,b[2]=0,b[3]=1,e[0]=1,e[1]=1,d[0]=0,d[1]=1;for(var f,g,h,i=a.length,j=1;j<i;j++)f=a[j],g=4*j,h=j/(i-1),j%2?(b[g]=h,b[g+1]=0,b[g+2]=h,b[g+3]=1):(b[g]=h,b[g+1]=0,b[g+2]=h,b[g+3]=1),g=2*j,e[g]=1,e[g+1]=1,g=2*j,d[g]=g,d[g+1]=g+1,c=f}},d.Rope.prototype.updateTransform=function(){var a=this.points;if(!(a.length<1)){var b,c=a[0],e={x:0,y:0};this.count-=.2;for(var f,g,h,i,j,k=this.vertices,l=a.length,m=0;m<l;m++)f=a[m],g=4*m,b=m<a.length-1?a[m+1]:f,e.y=-(b.x-c.x),e.x=b.y-c.y,h=10*(1-m/(l-1)),h>1&&(h=1),i=Math.sqrt(e.x*e.x+e.y*e.y),j=this.texture.height/2,e.x/=i,e.y/=i,e.x*=j,e.y*=j,k[g]=f.x+e.x,k[g+1]=f.y+e.y,k[g+2]=f.x-e.x,k[g+3]=f.y-e.y,c=f;d.DisplayObjectContainer.prototype.updateTransform.call(this)}},d.Rope.prototype.setTexture=function(a){this.texture=a},d.TilingSprite=function(a,b,c){d.Sprite.call(this,a),this._width=b||128,this._height=c||128,this.tileScale=new d.Point(1,1),this.tileScaleOffset=new d.Point(1,1),this.tilePosition=new d.Point,this.renderable=!0,this.tint=16777215,this.textureDebug=!1,this.blendMode=d.blendModes.NORMAL,this.canvasBuffer=null,this.tilingTexture=null,this.tilePattern=null,this.refreshTexture=!0,this.frameWidth=0,this.frameHeight=0},d.TilingSprite.prototype=Object.create(d.Sprite.prototype),d.TilingSprite.prototype.constructor=d.TilingSprite,d.TilingSprite.prototype.setTexture=function(a){this.texture!==a&&(this.texture=a,this.refreshTexture=!0,this.cachedTint=16777215)},d.TilingSprite.prototype._renderWebGL=function(a){if(this.visible&&this.renderable&&0!==this.alpha){if(this._mask&&(a.spriteBatch.stop(),a.maskManager.pushMask(this.mask,a),a.spriteBatch.start()),this._filters&&(a.spriteBatch.flush(),a.filterManager.pushFilter(this._filterBlock)),this.refreshTexture){if(this.generateTilingTexture(!0,a),!this.tilingTexture)return;this.tilingTexture.needsUpdate&&(this.tilingTexture.baseTexture.textureIndex=this.texture.baseTexture.textureIndex,a.renderer.updateTexture(this.tilingTexture.baseTexture),this.tilingTexture.needsUpdate=!1)}a.spriteBatch.renderTilingSprite(this);for(var b=0;b<this.children.length;b++)this.children[b]._renderWebGL(a);var c=!1;this._filters&&(c=!0,a.spriteBatch.stop(),a.filterManager.popFilter()),this._mask&&(c||a.spriteBatch.stop(),a.maskManager.popMask(this._mask,a)),c&&a.spriteBatch.start()}},d.TilingSprite.prototype._renderCanvas=function(a){if(this.visible&&this.renderable&&0!==this.alpha){var b=a.context;this._mask&&a.maskManager.pushMask(this._mask,a),b.globalAlpha=this.worldAlpha;var c=this.worldTransform,e=a.resolution,f=c.tx*e+a.shakeX,g=c.ty*e+a.shakeY;if(b.setTransform(c.a*e,c.b*e,c.c*e,c.d*e,f,g),this.refreshTexture){if(this.generateTilingTexture(!1,a),!this.tilingTexture)return;this.tilePattern=b.createPattern(this.tilingTexture.baseTexture.source,"repeat")}var h=a.currentBlendMode;this.blendMode!==a.currentBlendMode&&(a.currentBlendMode=this.blendMode,b.globalCompositeOperation=d.blendModesCanvas[a.currentBlendMode]);var i=this.tilePosition,j=this.tileScale;i.x%=this.tilingTexture.baseTexture.width,i.y%=this.tilingTexture.baseTexture.height,b.scale(j.x,j.y),b.translate(i.x+this.anchor.x*-this._width,i.y+this.anchor.y*-this._height),b.fillStyle=this.tilePattern;var f=-i.x,g=-i.y,k=this._width/j.x,l=this._height/j.y;a.roundPixels&&(f|=0,g|=0,k|=0,l|=0),b.fillRect(f,g,k,l),b.scale(1/j.x,1/j.y),b.translate(-i.x+this.anchor.x*this._width,-i.y+this.anchor.y*this._height),this._mask&&a.maskManager.popMask(a);for(var m=0;m<this.children.length;m++)this.children[m]._renderCanvas(a);h!==this.blendMode&&(a.currentBlendMode=h,b.globalCompositeOperation=d.blendModesCanvas[h])}},d.TilingSprite.prototype.onTextureUpdate=function(){},d.TilingSprite.prototype.generateTilingTexture=function(a,b){if(this.texture.baseTexture.hasLoaded){var c=this.texture,e=c.frame,f=this._frame.sourceSizeW||this._frame.width,g=this._frame.sourceSizeH||this._frame.height,h=0,i=0;this._frame.trimmed&&(h=this._frame.spriteSourceSizeX,i=this._frame.spriteSourceSizeY),a&&(f=d.getNextPowerOfTwo(f),g=d.getNextPowerOfTwo(g)),this.canvasBuffer?(this.canvasBuffer.resize(f,g),this.tilingTexture.baseTexture.width=f,this.tilingTexture.baseTexture.height=g,this.tilingTexture.needsUpdate=!0):(this.canvasBuffer=new d.CanvasBuffer(f,g),this.tilingTexture=d.Texture.fromCanvas(this.canvasBuffer.canvas),this.tilingTexture.isTiling=!0,
|
|
this.tilingTexture.needsUpdate=!0),this.textureDebug&&(this.canvasBuffer.context.strokeStyle="#00ff00",this.canvasBuffer.context.strokeRect(0,0,f,g));var j=c.crop.width,k=c.crop.height;j===f&&k===g||(j=f,k=g),this.canvasBuffer.context.drawImage(c.baseTexture.source,c.crop.x,c.crop.y,c.crop.width,c.crop.height,h,i,j,k),this.tileScaleOffset.x=e.width/f,this.tileScaleOffset.y=e.height/g,this.refreshTexture=!1,this.tilingTexture.baseTexture._powerOf2=!0}},d.TilingSprite.prototype.getBounds=function(){var a=this._width,b=this._height,c=a*(1-this.anchor.x),d=a*-this.anchor.x,e=b*(1-this.anchor.y),f=b*-this.anchor.y,g=this.worldTransform,h=g.a,i=g.b,j=g.c,k=g.d,l=g.tx,m=g.ty,n=h*d+j*f+l,o=k*f+i*d+m,p=h*c+j*f+l,q=k*f+i*c+m,r=h*c+j*e+l,s=k*e+i*c+m,t=h*d+j*e+l,u=k*e+i*d+m,v=-(1/0),w=-(1/0),x=1/0,y=1/0;x=n<x?n:x,x=p<x?p:x,x=r<x?r:x,x=t<x?t:x,y=o<y?o:y,y=q<y?q:y,y=s<y?s:y,y=u<y?u:y,v=n>v?n:v,v=p>v?p:v,v=r>v?r:v,v=t>v?t:v,w=o>w?o:w,w=q>w?q:w,w=s>w?s:w,w=u>w?u:w;var z=this._bounds;return z.x=x,z.width=v-x,z.y=y,z.height=w-y,this._currentBounds=z,z},d.TilingSprite.prototype.destroy=function(){d.Sprite.prototype.destroy.call(this),this.canvasBuffer&&(this.canvasBuffer.destroy(),this.canvasBuffer=null),this.tileScale=null,this.tileScaleOffset=null,this.tilePosition=null,this.tilingTexture&&(this.tilingTexture.destroy(!0),this.tilingTexture=null)},Object.defineProperty(d.TilingSprite.prototype,"width",{get:function(){return this._width},set:function(a){this._width=a}}),Object.defineProperty(d.TilingSprite.prototype,"height",{get:function(){return this._height},set:function(a){this._height=a}}),"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=d),exports.PIXI=d):"undefined"!=typeof define&&define.amd?define("PIXI",function(){return c.PIXI=d}()):c.PIXI=d,d}).call(this);
|
|
//# sourceMappingURL=pixi.map
|