mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 07:01:20 +00:00
6 lines
No EOL
76 KiB
JavaScript
6 lines
No EOL
76 KiB
JavaScript
/* Phaser v2.7.2 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.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,d,e,f,g,h,i=b.worldTransform,j=this.worldTransform;return this.rotation%Phaser.Math.PI2?(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,d=this._sr*this.scale.x,e=-this._sr*this.scale.y,f=this._cr*this.scale.y,g=this.position.x,h=this.position.y,(this.pivot.x||this.pivot.y)&&(g-=this.pivot.x*c+this.pivot.y*e,h-=this.pivot.x*d+this.pivot.y*f),j.a=c*i.a+d*i.c,j.b=c*i.b+d*i.d,j.c=e*i.a+f*i.c,j.d=e*i.b+f*i.d,j.tx=g*i.a+h*i.c+i.tx,j.ty=g*i.b+h*i.d+i.ty):(c=this.scale.x,f=this.scale.y,g=this.position.x-this.pivot.x*c,h=this.position.y-this.pivot.y*f,j.a=c*i.a,j.b=c*i.b,j.c=f*i.c,j.d=f*i.d,j.tx=g*i.a+h*i.c+i.tx,j.ty=g*i.b+h*i.d+i.ty),this.worldAlpha=this.alpha*b.worldAlpha,this.worldPosition.set(j.tx,j.ty),this.worldScale.set(this.scale.x*Math.sqrt(j.a*j.a+j.c*j.c),this.scale.y*Math.sqrt(j.b*j.b+j.d*j.d)),this.worldRotation=Math.atan2(-j.c,j.d),this._currentBounds=null,this.transformCallback&&this.transformCallback.call(this.transformCallbackContext,j,i),this},preUpdate:function(){},generateTexture:function(a,b,c){var e=this.getLocalBounds(),f=new Phaser.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 Phaser.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.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=Phaser._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=Phaser._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=Phaser._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=Phaser._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=Phaser._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=Phaser.WEBGL,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(a),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&&Phaser.Math.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&&Phaser.Math.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,Phaser.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.WebGLRenderer.textureArray=[],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 d,e=this.gl,f=c.projection,g=c.offset;1===b.mode?(d=c.shaderManager.complexPrimitiveShader,c.shaderManager.setShader(d),e.uniform1f(d.flipY,c.flipY),e.uniformMatrix3fv(d.translationMatrix,!1,a.worldTransform.toArray(!0)),e.uniform2f(d.projectionVector,f.x,-f.y),e.uniform2f(d.offsetVector,-g.x,-g.y),e.uniform3fv(d.tintColor,Phaser.Color.hexToRGBArray(a.tint)),e.uniform3fv(d.color,b.color),e.uniform1f(d.alpha,a.worldAlpha*b.alpha),e.bindBuffer(e.ARRAY_BUFFER,b.buffer),e.vertexAttribPointer(d.aVertexPosition,2,e.FLOAT,!1,8,0),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,b.indexBuffer)):(d=c.shaderManager.primitiveShader,c.shaderManager.setShader(d),e.uniformMatrix3fv(d.translationMatrix,!1,a.worldTransform.toArray(!0)),e.uniform1f(d.flipY,c.flipY),e.uniform2f(d.projectionVector,f.x,-f.y),e.uniform2f(d.offsetVector,-g.x,-g.y),e.uniform3fv(d.tintColor,Phaser.Color.hexToRGBArray(a.tint)),e.uniform1f(d.alpha,a.worldAlpha),e.bindBuffer(e.ARRAY_BUFFER,b.buffer),e.vertexAttribPointer(d.aVertexPosition,2,e.FLOAT,!1,24,0),e.vertexAttribPointer(d.colorAttribute,4,e.FLOAT,!1,24,8),e.bindBuffer(e.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(a){this.game=a,this.vertSize=5,this.size=2e3,this.vertexSize=24;var b=this.vertexSize*this.size*4,c=6*this.size;this.vertices=new ArrayBuffer(b),this.positions=new Float32Array(this.vertices),this.colors=new Uint32Array(this.vertices),this.indices=new Uint16Array(c),this.lastIndexCount=0;for(var d=0,e=0;d<c;d+=6,e+=4)this.indices[d+0]=e+0,this.indices[d+1]=e+1,this.indices[d+2]=e+2,this.indices[d+3]=e+0,this.indices[d+4]=e+2,this.indices[d+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},d.WebGLSpriteBatch.prototype.setContext=function(a){if(this.MAX_TEXTURES=a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS),this.gl=a,d._enableMultiTextureToggle){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.defaultShader=new Phaser.Filter(this.game,void 0,["//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;","}"])}else this.defaultShader=new Phaser.Filter(this.game,void 0,["//WebGLSpriteBatch Fragment Shader.","precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","varying float vTextureIndex;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, 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,e=c.baseTexture,f=this.gl;d.WebGLRenderer.textureArray[e.textureIndex]!=e&&(this.flush(),f.activeTexture(f.TEXTURE0+e.textureIndex),f.bindTexture(f.TEXTURE_2D,e._glTextures[f.id]),d.WebGLRenderer.textureArray[e.textureIndex]=e);var g=a.worldTransform;b&&(g=b),this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=c.baseTexture);var h=c._uvs;if(h){var i,j,k,l,m=a.anchor.x,n=a.anchor.y;if(c.trim){var o=c.trim;j=o.x-m*o.width,i=j+c.crop.width,l=o.y-n*o.height,k=l+c.crop.height}else i=c.frame.width*(1-m),j=c.frame.width*-m,k=c.frame.height*(1-n),l=c.frame.height*-n;var p=this.currentBatchSize*this.vertexSize,q=(4*this.currentBatchSize,c.baseTexture.resolution),r=c.baseTexture.textureIndex,s=g.a/q,t=g.b/q,u=g.c/q,v=g.d/q,w=g.tx,x=g.ty,y=(c.crop.width,c.crop.height);if(c.rotated){var z=g.a,A=g.b,B=g.c,C=g.d,D=j,E=i;w=g.c*y+w,x=g.d*y+x,s=6.123233995736766e-17*z+-B,t=6.123233995736766e-17*A+-C,u=z+6.123233995736766e-17*B,v=A+6.123233995736766e-17*C,c._updateUvsInverted(),i=k,j=l,k=E,l=D}var F=this.colors,G=this.positions,H=a.tint,I=(H>>16)+(65280&H)+((255&H)<<16)+(255*a.worldAlpha<<24);this.renderSession.roundPixels?(G[p++]=s*j+u*l+w|0,G[p++]=v*l+t*j+x|0,G[p++]=h.x0,G[p++]=h.y0,F[p++]=I,G[p++]=r,G[p++]=s*i+u*l+w|0,G[p++]=v*l+t*i+x|0,G[p++]=h.x1,G[p++]=h.y1,F[p++]=I,G[p++]=r,G[p++]=s*i+u*k+w|0,G[p++]=v*k+t*i+x|0,G[p++]=h.x2,G[p++]=h.y2,F[p++]=I,G[p++]=r,G[p++]=s*j+u*k+w|0,G[p++]=v*k+t*j+x|0,G[p++]=h.x3,G[p++]=h.y3,F[p++]=I,G[p++]=r):(G[p++]=s*j+u*l+w,G[p++]=v*l+t*j+x,G[p++]=h.x0,G[p++]=h.y0,F[p++]=I,G[p++]=r,G[p++]=s*i+u*l+w,G[p++]=v*l+t*i+x,G[p++]=h.x1,G[p++]=h.y1,F[p++]=I,G[p++]=r,G[p++]=s*i+u*k+w,G[p++]=v*k+t*i+x,G[p++]=h.x2,G[p++]=h.y2,F[p++]=I,G[p++]=r,G[p++]=s*j+u*k+w,G[p++]=v*k+t*j+x,G[p++]=h.x3,G[p++]=h.y3,F[p++]=I,G[p++]=r),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;d.WebGLRenderer.textureArray[f]!=c&&(this.flush(),e.activeTexture(e.TEXTURE0+f),e.bindTexture(e.TEXTURE_2D,c._glTextures[e.id]),d.WebGLRenderer.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 Float32Array(b),this.indices=new Uint16Array(c),this.vertexBuffer=null,this.indexBuffer=null,this.lastIndexCount=0;for(var d=0,e=0;d<c;d+=6,e+=4)this.indices[d+0]=e+0,this.indices[d+1]=e+1,this.indices[d+2]=e+2,this.indices[d+3]=e+0,this.indices[d+4]=e+2,this.indices[d+5]=e+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,e=this.gl,f=a.texture.baseTexture.textureIndex;if((d.WebGLRenderer.textureArray[f]==c||!c._glTextures[e.id]||a.texture.baseTexture.skipRender||(this.flush(),e.activeTexture(e.TEXTURE0+f),e.bindTexture(e.TEXTURE_2D,c._glTextures[e.id]),d.WebGLRenderer.textureArray[f]=c,a.texture._uvs))&&a.visible){var g,h,i,j,k,l,m,n,o=this.vertices;if(g=a.texture._uvs,h=a.texture.frame.width,i=a.texture.frame.height,a.texture.trim){var p=a.texture.trim;k=p.x-a.anchor.x*p.width,j=k+a.texture.crop.width,m=p.y-a.anchor.y*p.height,l=m+a.texture.crop.height}else j=a.texture.frame.width*(1-a.anchor.x),k=a.texture.frame.width*-a.anchor.x,l=a.texture.frame.height*(1-a.anchor.y),m=a.texture.frame.height*-a.anchor.y;n=4*this.currentBatchSize*this.vertSize,o[n++]=k,o[n++]=m,o[n++]=a.position.x,o[n++]=a.position.y,o[n++]=a.scale.x,o[n++]=a.scale.y,o[n++]=a.rotation,o[n++]=g.x0,o[n++]=g.y1,o[n++]=a.alpha,o[n++]=f,o[n++]=j,o[n++]=m,o[n++]=a.position.x,o[n++]=a.position.y,o[n++]=a.scale.x,o[n++]=a.scale.y,o[n++]=a.rotation,o[n++]=g.x1,o[n++]=g.y1,o[n++]=a.alpha,o[n++]=f,o[n++]=j,o[n++]=l,o[n++]=a.position.x,o[n++]=a.position.y,o[n++]=a.scale.x,o[n++]=a.scale.y,o[n++]=a.rotation,o[n++]=g.x2,o[n++]=g.y2,o[n++]=a.alpha,o[n++]=f,o[n++]=k,o[n++]=l,o[n++]=a.position.x,o[n++]=a.position.y,o[n++]=a.scale.x,o[n++]=a.scale.y,o[n++]=a.rotation,o[n++]=g.x3,o[n++]=g.y3,o[n++]=a.alpha,o[n++]=f,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])return void this.renderSession.renderer.updateTexture(this.currentBaseTexture,a);if(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 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 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 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=Phaser.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(){Phaser.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||Phaser.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=Phaser.Color.hexToRGBArray(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.CanvasRenderer=function(a){this.game=a,d.defaultRenderer||(d.defaultRenderer=this),this.type=Phaser.CANVAS,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=this.game.device.canUseMultiply;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,c){this.resolution=c||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&&Phaser.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,c){return 0===a.width&&(a.width=1),0===a.height&&(a.height=1),c=c||1,new d.BaseTexture(a,b,c)},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},"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
|