diff --git a/bin/pixi.js b/bin/pixi.js index cd497a4..ff131c0 100644 --- a/bin/pixi.js +++ b/bin/pixi.js @@ -8715,7 +8715,7 @@ core.WebGLRenderer.registerPlugin('accessibility', AccessibilityManager); core.CanvasRenderer.registerPlugin('accessibility', AccessibilityManager); -},{"../core":57,"./accessibleTarget":37}],37:[function(require,module,exports){ +},{"../core":58,"./accessibleTarget":37}],37:[function(require,module,exports){ /** * Default property values of accessible objects * used by {@link PIXI.accessibility.AccessibilityManager}. @@ -8791,6 +8791,43 @@ }; },{"./AccessibilityManager":36,"./accessibleTarget":37}],39:[function(require,module,exports){ +var GLShader = require('pixi-gl-core').GLShader; +var Const = require('./const'); + +function checkPrecision(src) { + if (src instanceof Array) { + if (src[0].substring(0,9) !== 'precision') { + var copy = src.slice(0); + copy.unshift('precision ' + Const.PRECISION.DEFAULT + ' float;'); + return copy; + } + } else { + if (src.substring(0,9) !== 'precision') { + return 'precision ' + Const.PRECISION.DEFAULT + ' float;\n' + src; + } + } + return src; +} + +/** + * Wrapper class, webGL Shader for Pixi. + * Adds precision string if vertexSrc or fragmentSrc have no mention of it. + * + * @class + * @memberof PIXI + * @param gl {WebGLRenderingContext} + * @param vertexSrc {string|string[]} The vertex shader source as an array of strings. + * @param fragmentSrc {string|string[]} The fragment shader source as an array of strings. + */ +var Shader = function(gl, vertexSrc, fragmentSrc) { + GLShader.call(this, gl, checkPrecision(vertexSrc), checkPrecision(fragmentSrc)); +}; + +Shader.prototype = Object.create(GLShader.prototype); +Shader.prototype.constructor = Shader; +module.exports = Shader; + +},{"./const":40,"pixi-gl-core":1}],40:[function(require,module,exports){ /** * Constant values used in pixi @@ -8809,7 +8846,7 @@ /** * Two Pi. - * + * * @property {number} PI_2 * @constant * @static @@ -8818,7 +8855,7 @@ /** * Conversion factor for converting radians to degrees. - * + * * @property {number} RAD_TO_DEG * @constant * @static @@ -8827,7 +8864,7 @@ /** * Conversion factor for converting degrees to radians. - * + * * @property {number} DEG_TO_RAD * @constant * @static @@ -8861,7 +8898,7 @@ /** * Various blend modes supported by PIXI. - * + * * IMPORTANT - The WebGL renderer only supports the NORMAL, ADD, MULTIPLY and SCREEN blend modes. * Anything else will silently act like NORMAL. * @@ -8957,7 +8994,7 @@ * It can be re-assigned to either CLAMP or REPEAT, depending upon suitability. * If the texture is non power of two then clamp will be used regardless as webGL can only use REPEAT if the texture is po2. * This property only affects WebGL. - * + * * @static * @constant * @property {object} WRAP_MODES @@ -8983,7 +9020,7 @@ * This property only affects WebGL * Handy for mobile devices! * This property only affects WebGL. - * + * * @static * @constant * @property {object} GC_MODES @@ -9000,7 +9037,7 @@ /** * If set to true WebGL will attempt make textures mimpaped by default. * Mipmapping will only succeed if the base texture uploaded has power of two dimensions. - * + * * @static * @constant * @property {bool} MIPMAP_TEXTURES @@ -9019,7 +9056,7 @@ /** * Default resolution of the renderer. - * + * * @property {number} RESOLUTION * @constant * @static @@ -9028,7 +9065,7 @@ /** * Default filter resolution. - * + * * @property {number} FILTER_RESOLUTION * @constant * @static @@ -9086,16 +9123,34 @@ RREC: 4 }, + /** + * Constants that specify float precision in shaders. + * + * @static + * @constant + * @property {object} PRECISION + * @property {number} PRECISION.DEFAULT='mediump' + * @property {number} PRECISION.LOW='lowp' + * @property {number} PRECISION.MEDIUM='mediump' + * @property {number} PRECISION.HIGH='highp' + */ + PRECISION: { + DEFAULT: 'mediump', + LOW: 'lowp', + MEDIUM: 'mediump', + HIGH: 'highp' + }, + // TODO: maybe change to SPRITE.BATCH_SIZE: 2000 // TODO: maybe add PARTICLE.BATCH_SIZE: 15000 SPRITE_BATCH_SIZE: 4096, //nice balance between mobile and desktop machines SPRITE_MAX_TEXTURES: require('./utils/maxRecommendedTextures')(32), //this is the MAXIMUM - various gpus will have there own limits. - TEXT_STYLE_CHANGED: 'changed' //Name of the event that fires when a text style is changed + TEXT_STYLE_CHANGED: 'changed' //Name of the event that fires when a text style is changed }; module.exports = CONST; -},{"./utils/maxRecommendedTextures":110}],40:[function(require,module,exports){ +},{"./utils/maxRecommendedTextures":111}],41:[function(require,module,exports){ var math = require('../math'), utils = require('../utils'), DisplayObject = require('./DisplayObject'); @@ -9723,7 +9778,7 @@ this.children = null; }; -},{"../math":61,"../utils":109,"./DisplayObject":41}],41:[function(require,module,exports){ +},{"../math":62,"../utils":110,"./DisplayObject":42}],42:[function(require,module,exports){ var math = require('../math'), EventEmitter = require('eventemitter3'), Transform = require('./Transform'), @@ -10226,7 +10281,7 @@ this.filterArea = null; }; -},{"../math":61,"./Transform":43,"eventemitter3":26}],42:[function(require,module,exports){ +},{"../math":62,"./Transform":44,"eventemitter3":26}],43:[function(require,module,exports){ /** * An observable point is a point that triggers a callback when the point's position is changed. * @@ -10304,7 +10359,7 @@ this.transform._versionLocal++; // TODO: Pretty sure this doesn't exist. }; -},{}],43:[function(require,module,exports){ +},{}],44:[function(require,module,exports){ var math = require('../math'), ObservablePoint = require('./ObservablePoint'); @@ -10440,7 +10495,7 @@ module.exports = Transform; -},{"../math":61,"./ObservablePoint":42}],44:[function(require,module,exports){ +},{"../math":62,"./ObservablePoint":43}],45:[function(require,module,exports){ var math = require('../math'); var ObservablePoint = require('./ObservablePoint'); @@ -10561,7 +10616,7 @@ module.exports = TransformStatic; -},{"../math":61,"./ObservablePoint":42}],45:[function(require,module,exports){ +},{"../math":62,"./ObservablePoint":43}],46:[function(require,module,exports){ var Container = require('../display/Container'), RenderTexture = require('../textures/RenderTexture'), Texture = require('../textures/Texture'), @@ -11292,8 +11347,8 @@ this._spriteRect.worldAlpha = this.worldAlpha; - Graphics._SPRITE_TEXTURE.frame.width = rect.width; - Graphics._SPRITE_TEXTURE.frame.height = rect.height; + Graphics._SPRITE_TEXTURE._frame.width = rect.width; + Graphics._SPRITE_TEXTURE._frame.height = rect.height; this._spriteRect.transform.worldTransform = this.transform.worldTransform; @@ -11643,6 +11698,10 @@ } } + if(this._spriteRect) + { + this._spriteRect.destroy(); + } this.graphicsData = null; this.currentPath = null; @@ -11650,7 +11709,7 @@ this._localBounds = null; }; -},{"../const":39,"../display/Container":40,"../math":61,"../renderers/canvas/CanvasRenderer":68,"../sprites/Sprite":91,"../textures/RenderTexture":101,"../textures/Texture":102,"./GraphicsData":46,"./utils/bezierCurveTo":48}],46:[function(require,module,exports){ +},{"../const":40,"../display/Container":41,"../math":62,"../renderers/canvas/CanvasRenderer":69,"../sprites/Sprite":92,"../textures/RenderTexture":102,"../textures/Texture":103,"./GraphicsData":47,"./utils/bezierCurveTo":49}],47:[function(require,module,exports){ /** * A GraphicsData object. * @@ -11752,7 +11811,7 @@ this.holes = null; }; -},{}],47:[function(require,module,exports){ +},{}],48:[function(require,module,exports){ var CanvasRenderer = require('../../renderers/canvas/CanvasRenderer'), CONST = require('../../const'); @@ -12035,7 +12094,7 @@ this.renderer = null; }; -},{"../../const":39,"../../renderers/canvas/CanvasRenderer":68}],48:[function(require,module,exports){ +},{"../../const":40,"../../renderers/canvas/CanvasRenderer":69}],49:[function(require,module,exports){ /** * Calculate the points for a bezier curve and then draws it. @@ -12086,7 +12145,7 @@ module.exports = bezierCurveTo; -},{}],49:[function(require,module,exports){ +},{}],50:[function(require,module,exports){ var utils = require('../../utils'), CONST = require('../../const'), ObjectRenderer = require('../../renderers/webgl/utils/ObjectRenderer'), @@ -12307,7 +12366,7 @@ return webGLData; }; -},{"../../const":39,"../../renderers/webgl/WebGLRenderer":75,"../../renderers/webgl/utils/ObjectRenderer":85,"../../utils":109,"./WebGLGraphicsData":50,"./shaders/PrimitiveShader":51,"./utils/buildCircle":52,"./utils/buildPoly":54,"./utils/buildRectangle":55,"./utils/buildRoundedRectangle":56}],50:[function(require,module,exports){ +},{"../../const":40,"../../renderers/webgl/WebGLRenderer":76,"../../renderers/webgl/utils/ObjectRenderer":86,"../../utils":110,"./WebGLGraphicsData":51,"./shaders/PrimitiveShader":52,"./utils/buildCircle":53,"./utils/buildPoly":55,"./utils/buildRectangle":56,"./utils/buildRoundedRectangle":57}],51:[function(require,module,exports){ var glCore = require('pixi-gl-core'); @@ -12434,8 +12493,8 @@ this.glIndices = null; }; -},{"pixi-gl-core":1}],51:[function(require,module,exports){ -var Shader = require('pixi-gl-core').GLShader; +},{"pixi-gl-core":1}],52:[function(require,module,exports){ +var Shader = require('../../../Shader'); /** * This shader is used to draw simple primitive shapes for {@link PIXI.Graphics}. @@ -12469,8 +12528,6 @@ ].join('\n'), // fragment shader [ - 'precision mediump float;', - 'varying vec4 vColor;', 'void main(void){', @@ -12485,7 +12542,7 @@ module.exports = PrimitiveShader; -},{"pixi-gl-core":1}],52:[function(require,module,exports){ +},{"../../../Shader":39}],53:[function(require,module,exports){ var buildLine = require('./buildLine'), CONST = require('../../../const'), utils = require('../../../utils'); @@ -12574,7 +12631,7 @@ module.exports = buildCircle; -},{"../../../const":39,"../../../utils":109,"./buildLine":53}],53:[function(require,module,exports){ +},{"../../../const":40,"../../../utils":110,"./buildLine":54}],54:[function(require,module,exports){ var math = require('../../../math'), utils = require('../../../utils'); @@ -12795,7 +12852,7 @@ module.exports = buildLine; -},{"../../../math":61,"../../../utils":109}],54:[function(require,module,exports){ +},{"../../../math":62,"../../../utils":110}],55:[function(require,module,exports){ var buildLine = require('./buildLine'), utils = require('../../../utils'), earcut = require('earcut'); @@ -12874,7 +12931,7 @@ module.exports = buildPoly; -},{"../../../utils":109,"./buildLine":53,"earcut":25}],55:[function(require,module,exports){ +},{"../../../utils":110,"./buildLine":54,"earcut":25}],56:[function(require,module,exports){ var buildLine = require('./buildLine'), utils = require('../../../utils'); @@ -12946,7 +13003,7 @@ module.exports = buildRectangle; -},{"../../../utils":109,"./buildLine":53}],56:[function(require,module,exports){ +},{"../../../utils":110,"./buildLine":54}],57:[function(require,module,exports){ var earcut = require('earcut'), buildLine = require('./buildLine'), utils = require('../../../utils'); @@ -13076,7 +13133,7 @@ module.exports = buildRoundedRectangle; -},{"../../../utils":109,"./buildLine":53,"earcut":25}],57:[function(require,module,exports){ +},{"../../../utils":110,"./buildLine":54,"earcut":25}],58:[function(require,module,exports){ /** * @file Main export of the PIXI core library * @author Mat Groves @@ -13127,6 +13184,7 @@ CanvasRenderTarget: require('./renderers/canvas/utils/CanvasRenderTarget'), // renderers - webgl + Shader: require('./Shader'), WebGLRenderer: require('./renderers/webgl/WebGLRenderer'), WebGLManager: require('./renderers/webgl/managers/WebGLManager'), ObjectRenderer: require('./renderers/webgl/utils/ObjectRenderer'), @@ -13172,7 +13230,7 @@ } }); -},{"./const":39,"./display/Container":40,"./display/DisplayObject":41,"./display/Transform":43,"./display/TransformStatic":44,"./graphics/Graphics":45,"./graphics/GraphicsData":46,"./graphics/canvas/CanvasGraphicsRenderer":47,"./graphics/webgl/GraphicsRenderer":49,"./math":61,"./renderers/canvas/CanvasRenderer":68,"./renderers/canvas/utils/CanvasRenderTarget":70,"./renderers/webgl/WebGLRenderer":75,"./renderers/webgl/filters/Filter":77,"./renderers/webgl/filters/spriteMask/SpriteMaskFilter":80,"./renderers/webgl/managers/WebGLManager":84,"./renderers/webgl/utils/ObjectRenderer":85,"./renderers/webgl/utils/Quad":86,"./renderers/webgl/utils/RenderTarget":87,"./sprites/Sprite":91,"./sprites/canvas/CanvasSpriteRenderer":92,"./sprites/canvas/CanvasTinter":93,"./sprites/webgl/SpriteRenderer":95,"./text/Text":97,"./text/TextStyle":98,"./textures/BaseRenderTexture":99,"./textures/BaseTexture":100,"./textures/RenderTexture":101,"./textures/Texture":102,"./textures/TextureUvs":103,"./textures/VideoBaseTexture":104,"./ticker":106,"./utils":109,"pixi-gl-core":1}],58:[function(require,module,exports){ +},{"./Shader":39,"./const":40,"./display/Container":41,"./display/DisplayObject":42,"./display/Transform":44,"./display/TransformStatic":45,"./graphics/Graphics":46,"./graphics/GraphicsData":47,"./graphics/canvas/CanvasGraphicsRenderer":48,"./graphics/webgl/GraphicsRenderer":50,"./math":62,"./renderers/canvas/CanvasRenderer":69,"./renderers/canvas/utils/CanvasRenderTarget":71,"./renderers/webgl/WebGLRenderer":76,"./renderers/webgl/filters/Filter":78,"./renderers/webgl/filters/spriteMask/SpriteMaskFilter":81,"./renderers/webgl/managers/WebGLManager":85,"./renderers/webgl/utils/ObjectRenderer":86,"./renderers/webgl/utils/Quad":87,"./renderers/webgl/utils/RenderTarget":88,"./sprites/Sprite":92,"./sprites/canvas/CanvasSpriteRenderer":93,"./sprites/canvas/CanvasTinter":94,"./sprites/webgl/SpriteRenderer":96,"./text/Text":98,"./text/TextStyle":99,"./textures/BaseRenderTexture":100,"./textures/BaseTexture":101,"./textures/RenderTexture":102,"./textures/Texture":103,"./textures/TextureUvs":104,"./textures/VideoBaseTexture":105,"./ticker":107,"./utils":110,"pixi-gl-core":1}],59:[function(require,module,exports){ // Your friendly neighbour https://en.wikipedia.org/wiki/Dihedral_group of order 16 var ux = [1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1, 0, 1]; @@ -13336,7 +13394,7 @@ module.exports = GroupD8; -},{"./Matrix":59}],59:[function(require,module,exports){ +},{"./Matrix":60}],60:[function(require,module,exports){ // @todo - ignore the too many parameters warning for now // should either fix it or change the jshint config // jshint -W072 @@ -13777,7 +13835,7 @@ */ Matrix.TEMP_MATRIX = new Matrix(); -},{"./Point":60}],60:[function(require,module,exports){ +},{"./Point":61}],61:[function(require,module,exports){ /** * The Point object represents a location in a two-dimensional coordinate system, where x represents * the horizontal axis and y represents the vertical axis. @@ -13847,7 +13905,7 @@ this.y = y || ( (y !== 0) ? this.x : 0 ) ; }; -},{}],61:[function(require,module,exports){ +},{}],62:[function(require,module,exports){ /** * Math classes and utilities mixed into PIXI namespace. * @@ -13870,7 +13928,7 @@ RoundedRectangle: require('./shapes/RoundedRectangle') }; -},{"./GroupD8":58,"./Matrix":59,"./Point":60,"./shapes/Circle":62,"./shapes/Ellipse":63,"./shapes/Polygon":64,"./shapes/Rectangle":65,"./shapes/RoundedRectangle":66}],62:[function(require,module,exports){ +},{"./GroupD8":59,"./Matrix":60,"./Point":61,"./shapes/Circle":63,"./shapes/Ellipse":64,"./shapes/Polygon":65,"./shapes/Rectangle":66,"./shapes/RoundedRectangle":67}],63:[function(require,module,exports){ var Rectangle = require('./Rectangle'), CONST = require('../../const'); @@ -13958,7 +14016,7 @@ return new Rectangle(this.x - this.radius, this.y - this.radius, this.radius * 2, this.radius * 2); }; -},{"../../const":39,"./Rectangle":65}],63:[function(require,module,exports){ +},{"../../const":40,"./Rectangle":66}],64:[function(require,module,exports){ var Rectangle = require('./Rectangle'), CONST = require('../../const'); @@ -14053,7 +14111,7 @@ return new Rectangle(this.x - this.width, this.y - this.height, this.width, this.height); }; -},{"../../const":39,"./Rectangle":65}],64:[function(require,module,exports){ +},{"../../const":40,"./Rectangle":66}],65:[function(require,module,exports){ var Point = require('../Point'), CONST = require('../../const'); @@ -14168,7 +14226,7 @@ return inside; }; -},{"../../const":39,"../Point":60}],65:[function(require,module,exports){ +},{"../../const":40,"../Point":61}],66:[function(require,module,exports){ var CONST = require('../../const'); /** @@ -14340,7 +14398,7 @@ this.height = y2 - y1; }; -},{"../../const":39}],66:[function(require,module,exports){ +},{"../../const":40}],67:[function(require,module,exports){ var CONST = require('../../const'); /** @@ -14432,7 +14490,7 @@ return false; }; -},{"../../const":39}],67:[function(require,module,exports){ +},{"../../const":40}],68:[function(require,module,exports){ var utils = require('../utils'), math = require('../math'), CONST = require('../const'), @@ -14722,7 +14780,7 @@ this._lastObjectRendered = null; }; -},{"../const":39,"../display/Container":40,"../math":61,"../textures/RenderTexture":101,"../utils":109,"eventemitter3":26}],68:[function(require,module,exports){ +},{"../const":40,"../display/Container":41,"../math":62,"../textures/RenderTexture":102,"../utils":110,"eventemitter3":26}],69:[function(require,module,exports){ var SystemRenderer = require('../SystemRenderer'), CanvasMaskManager = require('./utils/CanvasMaskManager'), CanvasRenderTarget = require('./utils/CanvasRenderTarget'), @@ -14983,7 +15041,7 @@ }; -},{"../../const":39,"../../utils":109,"../SystemRenderer":67,"./utils/CanvasMaskManager":69,"./utils/CanvasRenderTarget":70,"./utils/mapCanvasBlendModesToPixi":72}],69:[function(require,module,exports){ +},{"../../const":40,"../../utils":110,"../SystemRenderer":68,"./utils/CanvasMaskManager":70,"./utils/CanvasRenderTarget":71,"./utils/mapCanvasBlendModesToPixi":73}],70:[function(require,module,exports){ var CONST = require('../../../const'); /** * A set of functions used to handle masking. @@ -15145,7 +15203,7 @@ CanvasMaskManager.prototype.destroy = function () {}; -},{"../../../const":39}],70:[function(require,module,exports){ +},{"../../../const":40}],71:[function(require,module,exports){ var CONST = require('../../../const'); /** @@ -15250,7 +15308,7 @@ this.canvas = null; }; -},{"../../../const":39}],71:[function(require,module,exports){ +},{"../../../const":40}],72:[function(require,module,exports){ /** * Checks whether the Canvas BlendModes are supported by the current browser @@ -15289,7 +15347,7 @@ module.exports = canUseNewCanvasBlendModes; -},{}],72:[function(require,module,exports){ +},{}],73:[function(require,module,exports){ var CONST = require('../../../const'), canUseNewCanvasBlendModes = require('./canUseNewCanvasBlendModes'); @@ -15349,7 +15407,7 @@ module.exports = mapWebGLBlendModesToPixi; -},{"../../../const":39,"./canUseNewCanvasBlendModes":71}],73:[function(require,module,exports){ +},{"../../../const":40,"./canUseNewCanvasBlendModes":72}],74:[function(require,module,exports){ var CONST = require('../../const'); @@ -15460,7 +15518,7 @@ } }; -},{"../../const":39}],74:[function(require,module,exports){ +},{"../../const":40}],75:[function(require,module,exports){ var GLTexture = require('pixi-gl-core').GLTexture, CONST = require('../../const'), RenderTarget = require('./utils/RenderTarget'), @@ -15667,7 +15725,7 @@ module.exports = TextureManager; -},{"../../const":39,"../../utils":109,"./utils/RenderTarget":87,"pixi-gl-core":1}],75:[function(require,module,exports){ +},{"../../const":40,"../../utils":110,"./utils/RenderTarget":88,"pixi-gl-core":1}],76:[function(require,module,exports){ var SystemRenderer = require('../SystemRenderer'), MaskManager = require('./managers/MaskManager'), StencilManager = require('./managers/StencilManager'), @@ -16222,7 +16280,7 @@ // this = null; }; -},{"../../const":39,"../../utils":109,"../SystemRenderer":67,"./TextureGarbageCollector":73,"./TextureManager":74,"./WebGLState":76,"./managers/FilterManager":81,"./managers/MaskManager":82,"./managers/StencilManager":83,"./utils/ObjectRenderer":85,"./utils/RenderTarget":87,"./utils/mapWebGLDrawModesToPixi":90,"pixi-gl-core":1}],76:[function(require,module,exports){ +},{"../../const":40,"../../utils":110,"../SystemRenderer":68,"./TextureGarbageCollector":74,"./TextureManager":75,"./WebGLState":77,"./managers/FilterManager":82,"./managers/MaskManager":83,"./managers/StencilManager":84,"./utils/ObjectRenderer":86,"./utils/RenderTarget":88,"./utils/mapWebGLDrawModesToPixi":91,"pixi-gl-core":1}],77:[function(require,module,exports){ var mapWebGLBlendModesToPixi = require('./utils/mapWebGLBlendModesToPixi'); /** @@ -16495,7 +16553,7 @@ module.exports = WebGLState; -},{"./utils/mapWebGLBlendModesToPixi":89}],77:[function(require,module,exports){ +},{"./utils/mapWebGLBlendModesToPixi":90}],78:[function(require,module,exports){ var extractUniformsFromSrc = require('./extractUniformsFromSrc'), utils = require('../../../utils'), SOURCE_KEY_MAP = {}; @@ -16578,7 +16636,6 @@ * @constant */ Filter.defaultVertexSrc = [ - 'precision lowp float;', 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -16602,8 +16659,6 @@ * @constant */ Filter.defaultFragmentSrc = [ - 'precision lowp float;', - 'varying vec2 vTextureCoord;', 'varying vec2 vFilterCoord;', @@ -16628,7 +16683,7 @@ '}' ].join('\n'); -},{"../../../utils":109,"./extractUniformsFromSrc":78}],78:[function(require,module,exports){ +},{"../../../utils":110,"./extractUniformsFromSrc":79}],79:[function(require,module,exports){ var defaultValue = require('pixi-gl-core/lib/shader/defaultValue'); var mapSize = require('pixi-gl-core/lib/shader/mapSize'); @@ -16691,7 +16746,7 @@ module.exports = extractUniformsFromSrc; -},{"pixi-gl-core/lib/shader/defaultValue":10,"pixi-gl-core/lib/shader/mapSize":14}],79:[function(require,module,exports){ +},{"pixi-gl-core/lib/shader/defaultValue":10,"pixi-gl-core/lib/shader/mapSize":14}],80:[function(require,module,exports){ var math = require('../../../math'); /* @@ -16800,7 +16855,7 @@ calculateSpriteMatrix:calculateSpriteMatrix }; -},{"../../../math":61}],80:[function(require,module,exports){ +},{"../../../math":62}],81:[function(require,module,exports){ var Filter = require('../Filter'), math = require('../../../../math'); @@ -16820,7 +16875,7 @@ Filter.call(this, "#define GLSLIFY 1\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 otherMatrix;\n\nvarying vec2 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy;\n}\n", - "precision lowp float;\n#define GLSLIFY 1\n\nvarying vec2 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float alpha;\nuniform sampler2D mask;\n\nvoid main(void)\n{\n // check clip! this will stop the mask bleeding out from the edges\n vec2 text = abs( vMaskCoord - 0.5 );\n text = step(0.5, text);\n float clip = 1.0 - max(text.y, text.x);\n vec4 original = texture2D(uSampler, vTextureCoord);\n vec4 masky = texture2D(mask, vMaskCoord);\n original *= (masky.r * masky.a * alpha * clip);\n gl_FragColor = original;\n}\n" + "#define GLSLIFY 1\nvarying vec2 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float alpha;\nuniform sampler2D mask;\n\nvoid main(void)\n{\n // check clip! this will stop the mask bleeding out from the edges\n vec2 text = abs( vMaskCoord - 0.5 );\n text = step(0.5, text);\n float clip = 1.0 - max(text.y, text.x);\n vec4 original = texture2D(uSampler, vTextureCoord);\n vec4 masky = texture2D(mask, vMaskCoord);\n original *= (masky.r * masky.a * alpha * clip);\n gl_FragColor = original;\n}\n" ); sprite.renderable = false; @@ -16851,13 +16906,13 @@ filterManager.applyFilter(this, input, output); }; -},{"../../../../math":61,"../Filter":77}],81:[function(require,module,exports){ +},{"../../../../math":62,"../Filter":78}],82:[function(require,module,exports){ var WebGLManager = require('./WebGLManager'), RenderTarget = require('../utils/RenderTarget'), Quad = require('../utils/Quad'), math = require('../../../math'), - Shader = require('pixi-gl-core').GLShader, + Shader = require('../../../Shader'), filterTransforms = require('../filters/filterTransforms'), bitTwiddle = require('bit-twiddle'); @@ -17189,7 +17244,7 @@ FilterManager.pool[key].push(renderTarget); }; -},{"../../../math":61,"../filters/filterTransforms":79,"../utils/Quad":86,"../utils/RenderTarget":87,"./WebGLManager":84,"bit-twiddle":17,"pixi-gl-core":1}],82:[function(require,module,exports){ +},{"../../../Shader":39,"../../../math":62,"../filters/filterTransforms":80,"../utils/Quad":87,"../utils/RenderTarget":88,"./WebGLManager":85,"bit-twiddle":17}],83:[function(require,module,exports){ var WebGLManager = require('./WebGLManager'), AlphaMaskFilter = require('../filters/spriteMask/SpriteMaskFilter'); @@ -17365,7 +17420,7 @@ gl.disable(gl.SCISSOR_TEST); }; -},{"../filters/spriteMask/SpriteMaskFilter":80,"./WebGLManager":84}],83:[function(require,module,exports){ +},{"../filters/spriteMask/SpriteMaskFilter":81,"./WebGLManager":85}],84:[function(require,module,exports){ var WebGLManager = require('./WebGLManager'); /** @@ -17478,7 +17533,7 @@ this.stencilMaskStack.stencilStack = null; }; -},{"./WebGLManager":84}],84:[function(require,module,exports){ +},{"./WebGLManager":85}],85:[function(require,module,exports){ /** * @class * @memberof PIXI @@ -17519,7 +17574,7 @@ this.renderer = null; }; -},{}],85:[function(require,module,exports){ +},{}],86:[function(require,module,exports){ var WebGLManager = require('../managers/WebGLManager'); /** @@ -17577,7 +17632,7 @@ // render the object }; -},{"../managers/WebGLManager":84}],86:[function(require,module,exports){ +},{"../managers/WebGLManager":85}],87:[function(require,module,exports){ var glCore = require('pixi-gl-core'), createIndicesForQuads = require('../../../utils/createIndicesForQuads'); @@ -17750,7 +17805,7 @@ module.exports = Quad; -},{"../../../utils/createIndicesForQuads":107,"pixi-gl-core":1}],87:[function(require,module,exports){ +},{"../../../utils/createIndicesForQuads":108,"pixi-gl-core":1}],88:[function(require,module,exports){ var math = require('../../../math'), CONST = require('../../../const'), GLFramebuffer = require('pixi-gl-core').GLFramebuffer; @@ -18076,11 +18131,11 @@ this.texture = null; }; -},{"../../../const":39,"../../../math":61,"pixi-gl-core":1}],88:[function(require,module,exports){ +},{"../../../const":40,"../../../math":62,"pixi-gl-core":1}],89:[function(require,module,exports){ var glCore = require('pixi-gl-core'); var fragTemplate = [ - 'precision lowp float;', + 'precision mediump float;', 'void main(void){', 'float test = 0.1;', '%forloop%', @@ -18105,7 +18160,7 @@ while(true) { - var fragmentSrc = fragTemplate.replace(/\%forloop\%/gi, generateIfTestSrc(maxIfs)); + var fragmentSrc = fragTemplate.replace(/%forloop%/gi, generateIfTestSrc(maxIfs)); gl.shaderSource(shader, fragmentSrc); gl.compileShader(shader); @@ -18157,7 +18212,7 @@ module.exports = checkMaxIfStatmentsInShader; -},{"pixi-gl-core":1}],89:[function(require,module,exports){ +},{"pixi-gl-core":1}],90:[function(require,module,exports){ var CONST = require('../../../const'); /** @@ -18194,7 +18249,7 @@ module.exports = mapWebGLBlendModesToPixi; -},{"../../../const":39}],90:[function(require,module,exports){ +},{"../../../const":40}],91:[function(require,module,exports){ var CONST = require('../../../const'); /** @@ -18218,7 +18273,7 @@ module.exports = mapWebGLDrawModesToPixi; -},{"../../../const":39}],91:[function(require,module,exports){ +},{"../../../const":40}],92:[function(require,module,exports){ var math = require('../math'), Texture = require('../textures/Texture'), Container = require('../display/Container'), @@ -18698,7 +18753,7 @@ return new Sprite(Texture.fromImage(imageId, crossorigin, scaleMode)); }; -},{"../const":39,"../display/Container":40,"../math":61,"../textures/Texture":102,"../utils":109}],92:[function(require,module,exports){ +},{"../const":40,"../display/Container":41,"../math":62,"../textures/Texture":103,"../utils":110}],93:[function(require,module,exports){ var CanvasRenderer = require('../../renderers/canvas/CanvasRenderer'), CONST = require('../../const'), math = require('../../math'), @@ -18864,7 +18919,7 @@ this.renderer = null; }; -},{"../../const":39,"../../math":61,"../../renderers/canvas/CanvasRenderer":68,"./CanvasTinter":93}],93:[function(require,module,exports){ +},{"../../const":40,"../../math":62,"../../renderers/canvas/CanvasRenderer":69,"./CanvasTinter":94}],94:[function(require,module,exports){ var utils = require('../../utils'), canUseNewCanvasBlendModes = require('../../renderers/canvas/utils/canUseNewCanvasBlendModes'); /** @@ -19097,7 +19152,7 @@ */ CanvasTinter.tintMethod = CanvasTinter.canUseMultiply ? CanvasTinter.tintWithMultiply : CanvasTinter.tintWithPerPixel; -},{"../../renderers/canvas/utils/canUseNewCanvasBlendModes":71,"../../utils":109}],94:[function(require,module,exports){ +},{"../../renderers/canvas/utils/canUseNewCanvasBlendModes":72,"../../utils":110}],95:[function(require,module,exports){ var Buffer = function(size) @@ -19128,7 +19183,7 @@ this.uvs = null; this.colors = null; }; -},{}],95:[function(require,module,exports){ +},{}],96:[function(require,module,exports){ var ObjectRenderer = require('../../renderers/webgl/utils/ObjectRenderer'), WebGLRenderer = require('../../renderers/webgl/WebGLRenderer'), createIndicesForQuads = require('../../utils/createIndicesForQuads'), @@ -19192,11 +19247,12 @@ this.indices = createIndicesForQuads(this.size); /** - * The default shader that is used if a sprite doesn't have a more specific one. - * + * The default shaders that is used if a sprite doesn't have a more specific one. + * there is a shader for each number of textures that can be rendererd. + * These shaders will also be generated on the fly as required. * @member {PIXI.Shader} */ - this.shader = null; + this.shaders = null; this.textureCount = 0; this.currentIndex = 0; @@ -19241,19 +19297,23 @@ // step 2: check the maximum number of if statements the shader can have too.. this.MAX_TEXTURES = checkMaxIfStatmentsInShader( this.MAX_TEXTURES, gl ); - this.shader = generateMultiTextureShader(gl, this.MAX_TEXTURES); + this.shaders = new Array(this.MAX_TEXTURES); + this.shaders[0] = generateMultiTextureShader(gl, 1); + // create a couple of buffers this.indexBuffer = glCore.GLBuffer.createIndexBuffer(gl, this.indices, gl.STATIC_DRAW); + var shader = this.shaders[0]; + for (var i = 0; i < this.vaoMax; i++) { this.vertexBuffers[i] = glCore.GLBuffer.createVertexBuffer(gl, null, gl.STREAM_DRAW); // build the vao object that will render.. this.vaos[i] = this.renderer.createVao() .addIndex(this.indexBuffer) - .addAttribute(this.vertexBuffers[i], this.shader.attributes.aVertexPosition, gl.FLOAT, false, this.vertByteSize, 0) - .addAttribute(this.vertexBuffers[i], this.shader.attributes.aTextureCoord, gl.UNSIGNED_SHORT, true, this.vertByteSize, 2 * 4) - .addAttribute(this.vertexBuffers[i], this.shader.attributes.aColor, gl.UNSIGNED_BYTE, true, this.vertByteSize, 3 * 4) - .addAttribute(this.vertexBuffers[i], this.shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); + .addAttribute(this.vertexBuffers[i], shader.attributes.aVertexPosition, gl.FLOAT, false, this.vertByteSize, 0) + .addAttribute(this.vertexBuffers[i], shader.attributes.aTextureCoord, gl.UNSIGNED_SHORT, true, this.vertByteSize, 2 * 4) + .addAttribute(this.vertexBuffers[i], shader.attributes.aColor, gl.UNSIGNED_BYTE, true, this.vertByteSize, 3 * 4) + .addAttribute(this.vertexBuffers[i], shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); } this.vao = this.vaos[0]; @@ -19327,6 +19387,7 @@ var uvs; var textureId; var blendMode = sprites[0].blendMode; + var shader; currentGroup.textureCount = 0; currentGroup.start = 0; @@ -19424,14 +19485,15 @@ if(this.vaoMax <= this.vertexCount) { this.vaoMax++; + shader = this.shaders[0]; this.vertexBuffers[this.vertexCount] = glCore.GLBuffer.createVertexBuffer(gl, null, gl.STREAM_DRAW); // build the vao object that will render.. this.vaos[this.vertexCount] = this.renderer.createVao() .addIndex(this.indexBuffer) - .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aVertexPosition, gl.FLOAT, false, this.vertByteSize, 0) - .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aTextureCoord, gl.UNSIGNED_SHORT, true, this.vertByteSize, 2 * 4) - .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aColor, gl.UNSIGNED_BYTE, true, this.vertByteSize, 3 * 4) - .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); + .addAttribute(this.vertexBuffers[this.vertexCount], shader.attributes.aVertexPosition, gl.FLOAT, false, this.vertByteSize, 0) + .addAttribute(this.vertexBuffers[this.vertexCount], shader.attributes.aTextureCoord, gl.UNSIGNED_SHORT, true, this.vertByteSize, 2 * 4) + .addAttribute(this.vertexBuffers[this.vertexCount], shader.attributes.aColor, gl.UNSIGNED_BYTE, true, this.vertByteSize, 3 * 4) + .addAttribute(this.vertexBuffers[this.vertexCount], shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); } this.vertexBuffers[this.vertexCount].upload(buffer.vertices, 0); @@ -19441,8 +19503,19 @@ for (i = 0; i < groupCount; i++) { var group = groups[i]; + var groupTextureCount = group.textureCount; + shader = this.shaders[groupTextureCount-1]; - for (var j = 0; j < group.textureCount; j++) { + if(!shader) + { + shader = this.shaders[groupTextureCount-1] = generateMultiTextureShader(gl, groupTextureCount); + //console.log("SHADER generated for " + textureCount + " textures") + } + + this.renderer.bindShader(shader); + + for (var j = 0; j < groupTextureCount; j++) + { this.renderer.bindTexture(group.textures[j], j); } @@ -19462,7 +19535,7 @@ */ SpriteRenderer.prototype.start = function () { - this.renderer.bindShader(this.shader); + // this.renderer.bindShader(this.shader); this.tick %= 1000; }; @@ -19487,7 +19560,13 @@ this.renderer.off('prerender', this.onPrerender, this); ObjectRenderer.prototype.destroy.call(this); - this.shader.destroy(); + for (i = 0; i < this.shaders.length; i++) { + + if(this.shaders[i]) + { + this.shaders[i].destroy(); + } + } this.vertexBuffers = null; this.vaos = null; @@ -19495,7 +19574,6 @@ this.indices = null; this.sprites = null; - this.shader = null; for (i = 0; i < this.buffers.length; i++) { this.buffers[i].destroy(); @@ -19503,12 +19581,11 @@ }; -},{"../../const":39,"../../renderers/webgl/WebGLRenderer":75,"../../renderers/webgl/utils/ObjectRenderer":85,"../../renderers/webgl/utils/checkMaxIfStatmentsInShader":88,"../../utils/createIndicesForQuads":107,"./BatchBuffer":94,"./generateMultiTextureShader":96,"bit-twiddle":17,"pixi-gl-core":1}],96:[function(require,module,exports){ -var Shader = require('pixi-gl-core').GLShader; +},{"../../const":40,"../../renderers/webgl/WebGLRenderer":76,"../../renderers/webgl/utils/ObjectRenderer":86,"../../renderers/webgl/utils/checkMaxIfStatmentsInShader":89,"../../utils/createIndicesForQuads":108,"./BatchBuffer":95,"./generateMultiTextureShader":97,"bit-twiddle":17,"pixi-gl-core":1}],97:[function(require,module,exports){ +var Shader = require('../../Shader'); + var fragTemplate = [ - - 'precision lowp float;', 'varying vec2 vTextureCoord;', 'varying vec4 vColor;', 'varying float vTextureId;', @@ -19523,11 +19600,11 @@ function generateMultiTextureShader(gl, maxTextures) { - var vertexSrc = "precision lowp float;\n#define GLSLIFY 1\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\nattribute float aTextureId;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nvoid main(void){\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n vTextureId = aTextureId;\n vColor = vec4(aColor.rgb * aColor.a, aColor.a);\n}"; + var vertexSrc = "#define GLSLIFY 1\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\nattribute float aTextureId;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nvoid main(void){\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n vTextureId = aTextureId;\n vColor = vec4(aColor.rgb * aColor.a, aColor.a);\n}\n"; var fragmentSrc = fragTemplate; - fragmentSrc = fragmentSrc.replace(/\%count\%/gi, maxTextures); - fragmentSrc = fragmentSrc.replace(/\%forloop\%/gi, generateSampleSrc(maxTextures)); + fragmentSrc = fragmentSrc.replace(/%count%/gi, maxTextures); + fragmentSrc = fragmentSrc.replace(/%forloop%/gi, generateSampleSrc(maxTextures)); var shader = new Shader(gl, vertexSrc, fragmentSrc); @@ -19577,7 +19654,7 @@ module.exports = generateMultiTextureShader; -},{"pixi-gl-core":1}],97:[function(require,module,exports){ +},{"../../Shader":39}],98:[function(require,module,exports){ var Sprite = require('../sprites/Sprite'), Texture = require('../textures/Texture'), math = require('../math'), @@ -20277,7 +20354,7 @@ this._texture.destroy(destroyBaseTexture === undefined ? true : destroyBaseTexture); }; -},{"../const":39,"../math":61,"../sprites/Sprite":91,"../textures/Texture":102,"../utils":109}],98:[function(require,module,exports){ +},{"../const":40,"../math":62,"../sprites/Sprite":92,"../textures/Texture":103,"../utils":110}],99:[function(require,module,exports){ var EventEmitter = require('eventemitter3'), CONST = require('../const'), utils = require('../utils'); @@ -20613,7 +20690,7 @@ } } -},{"../const":39,"../utils":109,"eventemitter3":26}],99:[function(require,module,exports){ +},{"../const":40,"../utils":110,"eventemitter3":26}],100:[function(require,module,exports){ var BaseTexture = require('./BaseTexture'), CONST = require('../const'); @@ -20749,7 +20826,7 @@ }; -},{"../const":39,"./BaseTexture":100}],100:[function(require,module,exports){ +},{"../const":40,"./BaseTexture":101}],101:[function(require,module,exports){ var utils = require('../utils'), CONST = require('../const'), EventEmitter = require('eventemitter3'), @@ -21198,7 +21275,7 @@ return baseTexture; }; -},{"../const":39,"../utils":109,"../utils/determineCrossOrigin":108,"bit-twiddle":17,"eventemitter3":26}],101:[function(require,module,exports){ +},{"../const":40,"../utils":110,"../utils/determineCrossOrigin":109,"bit-twiddle":17,"eventemitter3":26}],102:[function(require,module,exports){ var BaseRenderTexture = require('./BaseRenderTexture'), Texture = require('./Texture'); @@ -21320,7 +21397,7 @@ return new RenderTexture(new BaseRenderTexture(width, height, scaleMode, resolution)); }; -},{"./BaseRenderTexture":99,"./Texture":102}],102:[function(require,module,exports){ +},{"./BaseRenderTexture":100,"./Texture":103}],103:[function(require,module,exports){ var BaseTexture = require('./BaseTexture'), VideoBaseTexture = require('./VideoBaseTexture'), TextureUvs = require('./TextureUvs'), @@ -21821,7 +21898,7 @@ Texture.EMPTY.emit = function() {}; -},{"../math":61,"../utils":109,"./BaseTexture":100,"./TextureUvs":103,"./VideoBaseTexture":104,"eventemitter3":26}],103:[function(require,module,exports){ +},{"../math":62,"../utils":110,"./BaseTexture":101,"./TextureUvs":104,"./VideoBaseTexture":105,"eventemitter3":26}],104:[function(require,module,exports){ /** * A standard object to store the Uvs of a texture @@ -21906,7 +21983,7 @@ this.uvsUint32[3] = (((this.y3 * 65535) & 0xFFFF) << 16) | ((this.x3 * 65535) & 0xFFFF); }; -},{"../math/GroupD8":58}],104:[function(require,module,exports){ +},{"../math/GroupD8":59}],105:[function(require,module,exports){ var BaseTexture = require('./BaseTexture'), utils = require('../utils'); @@ -22143,7 +22220,7 @@ return source; } -},{"../utils":109,"./BaseTexture":100}],105:[function(require,module,exports){ +},{"../utils":110,"./BaseTexture":101}],106:[function(require,module,exports){ var CONST = require('../const'), EventEmitter = require('eventemitter3'), // Internal event used by composed emitter @@ -22496,7 +22573,7 @@ module.exports = Ticker; -},{"../const":39,"eventemitter3":26}],106:[function(require,module,exports){ +},{"../const":40,"eventemitter3":26}],107:[function(require,module,exports){ var Ticker = require('./Ticker'); /** @@ -22552,7 +22629,7 @@ Ticker: Ticker }; -},{"./Ticker":105}],107:[function(require,module,exports){ +},{"./Ticker":106}],108:[function(require,module,exports){ /** * Generic Mask Stack data structure * @class @@ -22583,7 +22660,7 @@ module.exports = createIndicesForQuads; -},{}],108:[function(require,module,exports){ +},{}],109:[function(require,module,exports){ var tempAnchor; var _url = require('url'); @@ -22628,7 +22705,7 @@ module.exports = determineCrossOrigin; -},{"url":24}],109:[function(require,module,exports){ +},{"url":24}],110:[function(require,module,exports){ var CONST = require('../const'); /** @@ -22838,7 +22915,7 @@ BaseTextureCache: {} }; -},{"../const":39,"./pluginTarget":111,"eventemitter3":26}],110:[function(require,module,exports){ +},{"../const":40,"./pluginTarget":112,"eventemitter3":26}],111:[function(require,module,exports){ var Device = require('ismobilejs'); @@ -22859,7 +22936,7 @@ }; module.exports = maxRecommendedTextures; -},{"ismobilejs":27}],111:[function(require,module,exports){ +},{"ismobilejs":27}],112:[function(require,module,exports){ /** * Mixins functionality to make an object have "plugins". * @@ -22929,7 +23006,7 @@ } }; -},{}],112:[function(require,module,exports){ +},{}],113:[function(require,module,exports){ /*global console */ var core = require('./core'), mesh = require('./mesh'), @@ -23390,7 +23467,7 @@ }; -},{"./core":57,"./extras":122,"./filters":134,"./mesh":149,"./particles":152}],113:[function(require,module,exports){ +},{"./core":58,"./extras":123,"./filters":135,"./mesh":150,"./particles":153}],114:[function(require,module,exports){ var core = require('../../core'), tempRect = new core.Rectangle(); @@ -23529,13 +23606,13 @@ core.CanvasRenderer.registerPlugin('extract', WebGLExtract); -},{"../../core":57}],114:[function(require,module,exports){ +},{"../../core":58}],115:[function(require,module,exports){ module.exports = { webGL: require('./webgl/WebGLExtract'), canvas: require('./canvas/CanvasExtract') }; -},{"./canvas/CanvasExtract":113,"./webgl/WebGLExtract":115}],115:[function(require,module,exports){ +},{"./canvas/CanvasExtract":114,"./webgl/WebGLExtract":116}],116:[function(require,module,exports){ var core = require('../../core'), tempRect = new core.Rectangle(); @@ -23719,7 +23796,7 @@ core.WebGLRenderer.registerPlugin('extract', Extract); -},{"../../core":57}],116:[function(require,module,exports){ +},{"../../core":58}],117:[function(require,module,exports){ var core = require('../core'); /** @@ -24107,7 +24184,7 @@ BitmapText.fonts = {}; -},{"../core":57}],117:[function(require,module,exports){ +},{"../core":58}],118:[function(require,module,exports){ var core = require('../core'); /** * A MovieClip is a simple way to display an animation depicted by a list of textures. @@ -24430,7 +24507,7 @@ return new MovieClip(textures); }; -},{"../core":57}],118:[function(require,module,exports){ +},{"../core":58}],119:[function(require,module,exports){ var core = require('../core'), tempPoint = new core.Point(), CanvasTinter = require('../core/sprites/canvas/CanvasTinter'), @@ -24861,7 +24938,7 @@ return new TilingSprite(core.Texture.fromImage(imageId, crossorigin, scaleMode),width,height); }; -},{"../core":57,"../core/sprites/canvas/CanvasTinter":93,"./webgl/TilingShader":123}],119:[function(require,module,exports){ +},{"../core":58,"../core/sprites/canvas/CanvasTinter":94,"./webgl/TilingShader":124}],120:[function(require,module,exports){ var core = require('../core'), DisplayObject = core.DisplayObject, _tempMatrix = new core.Matrix(); @@ -24996,7 +25073,7 @@ var stack = renderer.filterManager.filterStack; // this renderTexture will be used to store the cached DisplayObject - + var renderTexture = core.RenderTexture.create(bounds.width | 0, bounds.height | 0); // need to set // @@ -25010,9 +25087,9 @@ renderer.render(this, renderTexture, true, m, true); // now restore the state be setting the new properties - + renderer.bindRenderTarget(cachedRenderTarget); - + renderer.filterManager.filterStack = stack; this.renderWebGL = this._renderCachedWebGL; @@ -25117,7 +25194,7 @@ { this._cachedSprite._currentBounds = null; - return this._cachedSprite.getBounds(); + return this._cachedSprite.getBounds(core.math.Matrix.IDENTITY); }; /** @@ -25137,7 +25214,7 @@ this._originalDestroy(); }; -},{"../core":57}],120:[function(require,module,exports){ +},{"../core":58}],121:[function(require,module,exports){ var core = require('../core'); /** @@ -25167,7 +25244,7 @@ return null; }; -},{"../core":57}],121:[function(require,module,exports){ +},{"../core":58}],122:[function(require,module,exports){ var core = require('../core'); /** @@ -25197,7 +25274,7 @@ return point; }; -},{"../core":57}],122:[function(require,module,exports){ +},{"../core":58}],123:[function(require,module,exports){ /** * @file Main export of the PIXI extras library * @author Mat Groves @@ -25218,8 +25295,8 @@ BitmapText: require('./BitmapText') }; -},{"./BitmapText":116,"./MovieClip":117,"./TilingSprite":118,"./cacheAsBitmap":119,"./getChildByName":120,"./getGlobalPosition":121}],123:[function(require,module,exports){ -var Shader = require('pixi-gl-core').GLShader; +},{"./BitmapText":117,"./MovieClip":118,"./TilingSprite":119,"./cacheAsBitmap":120,"./getChildByName":121,"./getGlobalPosition":122}],124:[function(require,module,exports){ +var Shader = require('../../core/Shader'); /** @@ -25232,8 +25309,8 @@ { Shader.call(this, gl, - "precision lowp float;\n#define GLSLIFY 1\n\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\n\nuniform vec4 uFrame;\nuniform vec4 uTransform;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n \n vec2 coord = aTextureCoord;\n coord -= uTransform.xy;\n coord /= uTransform.zw;\n vTextureCoord = coord;\n \n vColor = vec4(aColor.rgb * aColor.a, aColor.a);\n}", - "precision lowp float;\n#define GLSLIFY 1\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nuniform sampler2D uSampler;\nuniform vec4 uFrame;\nuniform vec2 uPixelSize;\n\nvoid main(void)\n{\n\n vec2 coord = mod(vTextureCoord, uFrame.zw);\n coord = clamp(coord, uPixelSize, uFrame.zw - uPixelSize);\n coord += uFrame.xy;\n\n gl_FragColor = texture2D(uSampler, coord) ;\n}" + "#define GLSLIFY 1\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\n\nuniform vec4 uFrame;\nuniform vec4 uTransform;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vec2 coord = aTextureCoord;\n coord -= uTransform.xy;\n coord /= uTransform.zw;\n vTextureCoord = coord;\n\n vColor = vec4(aColor.rgb * aColor.a, aColor.a);\n}\n", + "#define GLSLIFY 1\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nuniform sampler2D uSampler;\nuniform vec4 uFrame;\nuniform vec2 uPixelSize;\n\nvoid main(void)\n{\n\n vec2 coord = mod(vTextureCoord, uFrame.zw);\n coord = clamp(coord, uPixelSize, uFrame.zw - uPixelSize);\n coord += uFrame.xy;\n\n gl_FragColor = texture2D(uSampler, coord) ;\n}\n" ); } @@ -25242,7 +25319,7 @@ module.exports = TilingShader; -},{"pixi-gl-core":1}],124:[function(require,module,exports){ +},{"../../core/Shader":39}],125:[function(require,module,exports){ var core = require('../../core'), BlurXFilter = require('./BlurXFilter'), BlurYFilter = require('./BlurYFilter'); @@ -25362,7 +25439,7 @@ } }); -},{"../../core":57,"./BlurXFilter":125,"./BlurYFilter":126}],125:[function(require,module,exports){ +},{"../../core":58,"./BlurXFilter":126,"./BlurYFilter":127}],126:[function(require,module,exports){ var core = require('../../core'); var generateBlurVertSource = require('./generateBlurVertSource'); var generateBlurFragSource = require('./generateBlurFragSource'); @@ -25470,7 +25547,7 @@ } }); -},{"../../core":57,"./generateBlurFragSource":127,"./generateBlurVertSource":128,"./getMaxBlurKernelSize":129}],126:[function(require,module,exports){ +},{"../../core":58,"./generateBlurFragSource":128,"./generateBlurVertSource":129,"./getMaxBlurKernelSize":130}],127:[function(require,module,exports){ var core = require('../../core'); var generateBlurVertSource = require('./generateBlurVertSource'); var generateBlurFragSource = require('./generateBlurFragSource'); @@ -25568,7 +25645,7 @@ } }); -},{"../../core":57,"./generateBlurFragSource":127,"./generateBlurVertSource":128,"./getMaxBlurKernelSize":129}],127:[function(require,module,exports){ +},{"../../core":58,"./generateBlurFragSource":128,"./generateBlurVertSource":129,"./getMaxBlurKernelSize":130}],128:[function(require,module,exports){ var GAUSSIAN_VALUES = { 5:[0.153388, 0.221461, 0.250301], 7:[0.071303, 0.131514, 0.189879, 0.214607], @@ -25579,9 +25656,6 @@ }; var fragTemplate = [ - - 'precision mediump float;', - 'varying vec2 vBlurTexCoords[%size%];', 'uniform sampler2D uSampler;', @@ -25633,7 +25707,7 @@ module.exports = generateFragBlurSource; -},{}],128:[function(require,module,exports){ +},{}],129:[function(require,module,exports){ var vertTemplate = [ 'attribute vec2 aVertexPosition;', @@ -25699,7 +25773,7 @@ module.exports = generateVertBlurSource; -},{}],129:[function(require,module,exports){ +},{}],130:[function(require,module,exports){ var getMaxKernelSize = function(gl) @@ -25717,7 +25791,7 @@ module.exports = getMaxKernelSize; -},{}],130:[function(require,module,exports){ +},{}],131:[function(require,module,exports){ var core = require('../../core'); // @see https://github.com/substack/brfs/issues/25 @@ -25741,9 +25815,9 @@ { core.Filter.call(this, // vertex shader - "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nvarying vec2 vTextureCoord;\n\nvoid main(void){\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}", + "#define GLSLIFY 1\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nvarying vec2 vTextureCoord;\n\nvoid main(void){\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}\n", // fragment shader - "precision mediump float;\n#define GLSLIFY 1\n\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform float m[20];\n\nvoid main(void)\n{\n\n vec4 c = texture2D(uSampler, vTextureCoord);\n\n gl_FragColor.r = (m[0] * c.r);\n gl_FragColor.r += (m[1] * c.g);\n gl_FragColor.r += (m[2] * c.b);\n gl_FragColor.r += (m[3] * c.a);\n gl_FragColor.r += m[4] * c.a;\n\n gl_FragColor.g = (m[5] * c.r);\n gl_FragColor.g += (m[6] * c.g);\n gl_FragColor.g += (m[7] * c.b);\n gl_FragColor.g += (m[8] * c.a);\n gl_FragColor.g += m[9] * c.a;\n\n gl_FragColor.b = (m[10] * c.r);\n gl_FragColor.b += (m[11] * c.g);\n gl_FragColor.b += (m[12] * c.b);\n gl_FragColor.b += (m[13] * c.a);\n gl_FragColor.b += m[14] * c.a;\n\n gl_FragColor.a = (m[15] * c.r);\n gl_FragColor.a += (m[16] * c.g);\n gl_FragColor.a += (m[17] * c.b);\n gl_FragColor.a += (m[18] * c.a);\n gl_FragColor.a += m[19] * c.a;\n\n// gl_FragColor = vec4(m[0]);\n}\n" + "#define GLSLIFY 1\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform float m[20];\n\nvoid main(void)\n{\n\n vec4 c = texture2D(uSampler, vTextureCoord);\n\n gl_FragColor.r = (m[0] * c.r);\n gl_FragColor.r += (m[1] * c.g);\n gl_FragColor.r += (m[2] * c.b);\n gl_FragColor.r += (m[3] * c.a);\n gl_FragColor.r += m[4] * c.a;\n\n gl_FragColor.g = (m[5] * c.r);\n gl_FragColor.g += (m[6] * c.g);\n gl_FragColor.g += (m[7] * c.b);\n gl_FragColor.g += (m[8] * c.a);\n gl_FragColor.g += m[9] * c.a;\n\n gl_FragColor.b = (m[10] * c.r);\n gl_FragColor.b += (m[11] * c.g);\n gl_FragColor.b += (m[12] * c.b);\n gl_FragColor.b += (m[13] * c.a);\n gl_FragColor.b += m[14] * c.a;\n\n gl_FragColor.a = (m[15] * c.r);\n gl_FragColor.a += (m[16] * c.g);\n gl_FragColor.a += (m[17] * c.b);\n gl_FragColor.a += (m[18] * c.a);\n gl_FragColor.a += m[19] * c.a;\n\n// gl_FragColor = vec4(m[0]);\n}\n" ); this.uniforms.m = [ @@ -26250,7 +26324,7 @@ } }); -},{"../../core":57}],131:[function(require,module,exports){ +},{"../../core":58}],132:[function(require,module,exports){ var core = require('../../core'); @@ -26274,7 +26348,7 @@ // vertex shader "#define GLSLIFY 1\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\n\nuniform mat3 projectionMatrix;\nuniform mat3 otherMatrix;\n\nvarying vec2 vMapCoord;\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n vMapCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy;\n vColor = vec4(aColor.rgb * aColor.a, aColor.a);\n}\n", // fragment shader - "precision mediump float;\n#define GLSLIFY 1\n\nvarying vec2 vMapCoord;\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nuniform vec2 scale;\n\nuniform sampler2D uSampler;\nuniform sampler2D mapSampler;\n\nvoid main(void)\n{\n vec4 map = texture2D(mapSampler, vMapCoord);\n\n map -= 0.5;\n map.xy *= scale;\n\n gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y));\n}\n" + "#define GLSLIFY 1\nvarying vec2 vMapCoord;\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nuniform vec2 scale;\n\nuniform sampler2D uSampler;\nuniform sampler2D mapSampler;\n\nvoid main(void)\n{\n vec4 map = texture2D(mapSampler, vMapCoord);\n\n map -= 0.5;\n map.xy *= scale;\n\n gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y));\n}\n" ); @@ -26330,7 +26404,7 @@ } }); -},{"../../core":57}],132:[function(require,module,exports){ +},{"../../core":58}],133:[function(require,module,exports){ var core = require('../../core'); @@ -26348,7 +26422,7 @@ "#define GLSLIFY 1\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}\n\n", // fragment shader - "precision mediump float;\n#define GLSLIFY 1\n\nvarying vec2 vTextureCoord;\nuniform float exposure;\nuniform float decay;\nuniform float density;\nuniform float weight;\nuniform vec2 lightPositionOnScreen;\nuniform sampler2D uSampler;\n\nconst int NUM_SAMPLES = 100;\n\nvoid main()\n{\n vec2 deltaTextCoord = vec2( vTextureCoord - lightPositionOnScreen.xy );\n vec2 textCoo = vTextureCoord;\n deltaTextCoord *= 1.0 / float(NUM_SAMPLES) * density;\n float illuminationDecay = 1.0;\n \n for(int i=0; i < NUM_SAMPLES ; i++)\n {\n textCoo -= deltaTextCoord;\n vec4 sample = texture2D(uSampler, textCoo );\n\n sample *= illuminationDecay * weight;\n\n gl_FragColor += sample;\n\n illuminationDecay *= decay;\n }\n \n gl_FragColor *= exposure;\n}" + "#define GLSLIFY 1\nvarying vec2 vTextureCoord;\nuniform float exposure;\nuniform float decay;\nuniform float density;\nuniform float weight;\nuniform vec2 lightPositionOnScreen;\nuniform sampler2D uSampler;\n\nconst int NUM_SAMPLES = 100;\n\nvoid main()\n{\n vec2 deltaTextCoord = vec2( vTextureCoord - lightPositionOnScreen.xy );\n vec2 textCoo = vTextureCoord;\n deltaTextCoord *= 1.0 / float(NUM_SAMPLES) * density;\n float illuminationDecay = 1.0;\n\n for(int i=0; i < NUM_SAMPLES ; i++)\n {\n textCoo -= deltaTextCoord;\n vec4 sample = texture2D(uSampler, textCoo );\n\n sample *= illuminationDecay * weight;\n\n gl_FragColor += sample;\n\n illuminationDecay *= decay;\n }\n\n gl_FragColor *= exposure;\n}\n" ); this.uniforms.exposure = 0.0034; @@ -26423,7 +26497,7 @@ } }); -},{"../../core":57}],133:[function(require,module,exports){ +},{"../../core":58}],134:[function(require,module,exports){ var core = require('../../core'); // @see https://github.com/substack/brfs/issues/25 @@ -26439,9 +26513,9 @@ { core.Filter.call(this, // vertex shader - "precision lowp float;\n#define GLSLIFY 1\n\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nvarying vec2 vTextureCoord;\n\nvoid main(void){\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}", + "#define GLSLIFY 1\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nvarying vec2 vTextureCoord;\n\nvoid main(void){\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}\n", // fragment shader - "precision mediump float;\n#define GLSLIFY 1\n\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float gray;\n\nvoid main(void)\n{\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(0.2126*gl_FragColor.r + 0.7152*gl_FragColor.g + 0.0722*gl_FragColor.b), gray);\n}\n" + "#define GLSLIFY 1\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float gray;\n\nvoid main(void)\n{\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(0.2126*gl_FragColor.r + 0.7152*gl_FragColor.g + 0.0722*gl_FragColor.b), gray);\n}\n" ); this.uniforms.gray = 1; @@ -26472,7 +26546,7 @@ } }); -},{"../../core":57}],134:[function(require,module,exports){ +},{"../../core":58}],135:[function(require,module,exports){ /** * @file Main export of the PIXI filters library * @author Mat Groves @@ -26513,7 +26587,7 @@ GodrayFilter: require('./godray/GodrayFilter') }; -},{"./blur/BlurFilter":124,"./blur/BlurXFilter":125,"./blur/BlurYFilter":126,"./colormatrix/ColorMatrixFilter":130,"./displacement/DisplacementFilter":131,"./godray/GodrayFilter":132,"./gray/GrayFilter":133,"./twist/TwistFilter":135}],135:[function(require,module,exports){ +},{"./blur/BlurFilter":125,"./blur/BlurXFilter":126,"./blur/BlurYFilter":127,"./colormatrix/ColorMatrixFilter":131,"./displacement/DisplacementFilter":132,"./godray/GodrayFilter":133,"./gray/GrayFilter":134,"./twist/TwistFilter":136}],136:[function(require,module,exports){ var core = require('../../core'); @@ -26531,7 +26605,7 @@ "#define GLSLIFY 1\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}\n\n", // fragment shader - "precision mediump float;\n#define GLSLIFY 1\n\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float radius;\nuniform float angle;\nuniform vec2 offset;\nuniform vec4 filterArea;\n\nvec2 mapCoord( vec2 coord )\n{\n coord *= filterArea.xy;\n coord += filterArea.zw;\n\n return coord;\n}\n\nvec2 unmapCoord( vec2 coord )\n{\n coord -= filterArea.zw;\n coord /= filterArea.xy;\n\n return coord;\n}\n\nvec2 twist(vec2 coord)\n{\n coord -= offset;\n\n float dist = length(coord);\n\n if (dist < radius)\n {\n float ratioDist = (radius - dist) / radius;\n float angleMod = ratioDist * ratioDist * angle;\n float s = sin(angleMod);\n float c = cos(angleMod);\n coord = vec2(coord.x * c - coord.y * s, coord.x * s + coord.y * c);\n }\n\n coord += offset;\n\n return coord;\n}\n\nvoid main(void)\n{\n\n vec2 coord = mapCoord(vTextureCoord);\n\n coord = twist(coord);\n\n coord = unmapCoord(coord);\n\n gl_FragColor = texture2D(uSampler, coord );\n\n}\n" + "#define GLSLIFY 1\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float radius;\nuniform float angle;\nuniform vec2 offset;\nuniform vec4 filterArea;\n\nvec2 mapCoord( vec2 coord )\n{\n coord *= filterArea.xy;\n coord += filterArea.zw;\n\n return coord;\n}\n\nvec2 unmapCoord( vec2 coord )\n{\n coord -= filterArea.zw;\n coord /= filterArea.xy;\n\n return coord;\n}\n\nvec2 twist(vec2 coord)\n{\n coord -= offset;\n\n float dist = length(coord);\n\n if (dist < radius)\n {\n float ratioDist = (radius - dist) / radius;\n float angleMod = ratioDist * ratioDist * angle;\n float s = sin(angleMod);\n float c = cos(angleMod);\n coord = vec2(coord.x * c - coord.y * s, coord.x * s + coord.y * c);\n }\n\n coord += offset;\n\n return coord;\n}\n\nvoid main(void)\n{\n\n vec2 coord = mapCoord(vTextureCoord);\n\n coord = twist(coord);\n\n coord = unmapCoord(coord);\n\n gl_FragColor = texture2D(uSampler, coord );\n\n}\n" ); this.uniforms.radius = 400; @@ -26611,7 +26685,7 @@ } }); -},{"../../core":57}],136:[function(require,module,exports){ +},{"../../core":58}],137:[function(require,module,exports){ (function (global){ // run the polyfills require('./polyfill'); @@ -26645,7 +26719,7 @@ global.PIXI = core; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./accessibility":38,"./core":57,"./deprecation":112,"./extract":114,"./extras":122,"./filters":134,"./interaction":139,"./loaders":142,"./mesh":149,"./particles":152,"./polyfill":158}],137:[function(require,module,exports){ +},{"./accessibility":38,"./core":58,"./deprecation":113,"./extract":115,"./extras":123,"./filters":135,"./interaction":140,"./loaders":143,"./mesh":150,"./particles":153,"./polyfill":159}],138:[function(require,module,exports){ var core = require('../core'); /** @@ -26694,7 +26768,7 @@ return displayObject.worldTransform.applyInverse(globalPos || this.global, point); }; -},{"../core":57}],138:[function(require,module,exports){ +},{"../core":58}],139:[function(require,module,exports){ var core = require('../core'), InteractionData = require('./InteractionData'); @@ -27162,7 +27236,6 @@ { displayObject.worldTransform.applyInverse(point, this._tempPoint); hit = displayObject.hitArea.contains( this._tempPoint.x, this._tempPoint.y ); - } else if(displayObject.containsPoint) { @@ -27635,7 +27708,7 @@ core.WebGLRenderer.registerPlugin('interaction', InteractionManager); core.CanvasRenderer.registerPlugin('interaction', InteractionManager); -},{"../core":57,"./InteractionData":137,"./interactiveTarget":140}],139:[function(require,module,exports){ +},{"../core":58,"./InteractionData":138,"./interactiveTarget":141}],140:[function(require,module,exports){ /** * @file Main export of the PIXI interactions library * @author Mat Groves @@ -27652,7 +27725,7 @@ interactiveTarget: require('./interactiveTarget') }; -},{"./InteractionData":137,"./InteractionManager":138,"./interactiveTarget":140}],140:[function(require,module,exports){ +},{"./InteractionData":138,"./InteractionManager":139,"./interactiveTarget":141}],141:[function(require,module,exports){ /** * Default property values of interactive objects * Used by {@link PIXI.interaction.InteractionManager} to automatically give all DisplayObjects these properties @@ -27741,7 +27814,7 @@ module.exports = interactiveTarget; -},{}],141:[function(require,module,exports){ +},{}],142:[function(require,module,exports){ var Resource = require('resource-loader').Resource, core = require('../core'), extras = require('../extras'), @@ -27865,7 +27938,7 @@ }; }; -},{"../core":57,"../extras":122,"path":18,"resource-loader":33}],142:[function(require,module,exports){ +},{"../core":58,"../extras":123,"path":18,"resource-loader":33}],143:[function(require,module,exports){ /** * @file Main export of the PIXI loaders library * @author Mat Groves @@ -27886,7 +27959,7 @@ Resource: require('resource-loader').Resource }; -},{"./bitmapFontParser":141,"./loader":143,"./spritesheetParser":144,"./textureParser":145,"resource-loader":33}],143:[function(require,module,exports){ +},{"./bitmapFontParser":142,"./loader":144,"./spritesheetParser":145,"./textureParser":146,"resource-loader":33}],144:[function(require,module,exports){ var ResourceLoader = require('resource-loader'), textureParser = require('./textureParser'), spritesheetParser = require('./spritesheetParser'), @@ -27948,7 +28021,7 @@ Resource.setExtensionXhrType('fnt', Resource.XHR_RESPONSE_TYPE.DOCUMENT); -},{"./bitmapFontParser":141,"./spritesheetParser":144,"./textureParser":145,"resource-loader":33}],144:[function(require,module,exports){ +},{"./bitmapFontParser":142,"./spritesheetParser":145,"./textureParser":146,"resource-loader":33}],145:[function(require,module,exports){ var Resource = require('resource-loader').Resource, path = require('path'), core = require('../core'), @@ -28065,7 +28138,7 @@ }; }; -},{"../core":57,"async":16,"path":18,"resource-loader":33}],145:[function(require,module,exports){ +},{"../core":58,"async":16,"path":18,"resource-loader":33}],146:[function(require,module,exports){ var core = require('../core'); module.exports = function () @@ -28087,7 +28160,7 @@ }; }; -},{"../core":57}],146:[function(require,module,exports){ +},{"../core":58}],147:[function(require,module,exports){ var core = require('../core'), glCore = require('pixi-gl-core'), Shader = require('./webgl/MeshShader'), @@ -28624,7 +28697,7 @@ TRIANGLES: 1 }; -},{"../core":57,"./webgl/MeshShader":150,"pixi-gl-core":1}],147:[function(require,module,exports){ +},{"../core":58,"./webgl/MeshShader":151,"pixi-gl-core":1}],148:[function(require,module,exports){ var Mesh = require('./Mesh'); /** @@ -28749,7 +28822,7 @@ } }; -},{"./Mesh":146}],148:[function(require,module,exports){ +},{"./Mesh":147}],149:[function(require,module,exports){ var Mesh = require('./Mesh'); var core = require('../core'); @@ -28964,7 +29037,7 @@ this.containerUpdateTransform(); }; -},{"../core":57,"./Mesh":146}],149:[function(require,module,exports){ +},{"../core":58,"./Mesh":147}],150:[function(require,module,exports){ /** * @file Main export of the PIXI extras library * @author Mat Groves @@ -28982,8 +29055,8 @@ MeshShader: require('./webgl/MeshShader') }; -},{"./Mesh":146,"./Plane":147,"./Rope":148,"./webgl/MeshShader":150}],150:[function(require,module,exports){ -var Shader = require('pixi-gl-core').GLShader; +},{"./Mesh":147,"./Plane":148,"./Rope":149,"./webgl/MeshShader":151}],151:[function(require,module,exports){ +var Shader = require('../../core/Shader'); /** * @class @@ -28997,7 +29070,6 @@ gl, // vertex shader [ - 'precision lowp float;', 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -29012,8 +29084,6 @@ '}' ].join('\n'), [ - 'precision lowp float;', - 'varying vec2 vTextureCoord;', 'uniform float alpha;', @@ -29032,7 +29102,7 @@ module.exports = MeshShader; -},{"pixi-gl-core":1}],151:[function(require,module,exports){ +},{"../../core/Shader":39}],152:[function(require,module,exports){ var core = require('../core'); /** @@ -29364,7 +29434,7 @@ this._buffers = null; }; -},{"../core":57}],152:[function(require,module,exports){ +},{"../core":58}],153:[function(require,module,exports){ /** * @file Main export of the PIXI extras library * @author Mat Groves @@ -29380,7 +29450,7 @@ ParticleRenderer: require('./webgl/ParticleRenderer') }; -},{"./ParticleContainer":151,"./webgl/ParticleRenderer":154}],153:[function(require,module,exports){ +},{"./ParticleContainer":152,"./webgl/ParticleRenderer":155}],154:[function(require,module,exports){ var glCore = require('pixi-gl-core'), createIndicesForQuads = require('../../core/utils/createIndicesForQuads'); @@ -29601,7 +29671,7 @@ this.staticBuffer.destroy(); }; -},{"../../core/utils/createIndicesForQuads":107,"pixi-gl-core":1}],154:[function(require,module,exports){ +},{"../../core/utils/createIndicesForQuads":108,"pixi-gl-core":1}],155:[function(require,module,exports){ var core = require('../../core'), ParticleShader = require('./ParticleShader'), ParticleBuffer = require('./ParticleBuffer'); @@ -30033,8 +30103,8 @@ this.tempMatrix = null; }; -},{"../../core":57,"./ParticleBuffer":153,"./ParticleShader":155}],155:[function(require,module,exports){ -var Shader = require('pixi-gl-core').GLShader; +},{"../../core":58,"./ParticleBuffer":154,"./ParticleShader":156}],156:[function(require,module,exports){ +var Shader = require('../../core/Shader'); /** * @class @@ -30076,8 +30146,6 @@ ].join('\n'), // hello [ - 'precision lowp float;', - 'varying vec2 vTextureCoord;', 'varying float vColor;', @@ -30101,7 +30169,7 @@ module.exports = ParticleShader; -},{"pixi-gl-core":1}],156:[function(require,module,exports){ +},{"../../core/Shader":39}],157:[function(require,module,exports){ // References: // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign @@ -30117,7 +30185,7 @@ }; } -},{}],157:[function(require,module,exports){ +},{}],158:[function(require,module,exports){ // References: // https://github.com/sindresorhus/object-assign // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign @@ -30127,7 +30195,7 @@ Object.assign = require('object-assign'); } -},{"object-assign":28}],158:[function(require,module,exports){ +},{"object-assign":28}],159:[function(require,module,exports){ require('./Object.assign'); require('./requestAnimationFrame'); require('./Math.sign'); @@ -30145,7 +30213,7 @@ window.Uint16Array = Array; } -},{"./Math.sign":156,"./Object.assign":157,"./requestAnimationFrame":159}],159:[function(require,module,exports){ +},{"./Math.sign":157,"./Object.assign":158,"./requestAnimationFrame":160}],160:[function(require,module,exports){ (function (global){ // References: // http://paulirish.com/2011/requestanimationframe-for-smart-animating/ @@ -30215,6 +30283,6 @@ } }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}]},{},[136])(136) +},{}]},{},[137])(137) }); //# sourceMappingURL=pixi.js.map diff --git a/bin/pixi.js b/bin/pixi.js index cd497a4..ff131c0 100644 --- a/bin/pixi.js +++ b/bin/pixi.js @@ -8715,7 +8715,7 @@ core.WebGLRenderer.registerPlugin('accessibility', AccessibilityManager); core.CanvasRenderer.registerPlugin('accessibility', AccessibilityManager); -},{"../core":57,"./accessibleTarget":37}],37:[function(require,module,exports){ +},{"../core":58,"./accessibleTarget":37}],37:[function(require,module,exports){ /** * Default property values of accessible objects * used by {@link PIXI.accessibility.AccessibilityManager}. @@ -8791,6 +8791,43 @@ }; },{"./AccessibilityManager":36,"./accessibleTarget":37}],39:[function(require,module,exports){ +var GLShader = require('pixi-gl-core').GLShader; +var Const = require('./const'); + +function checkPrecision(src) { + if (src instanceof Array) { + if (src[0].substring(0,9) !== 'precision') { + var copy = src.slice(0); + copy.unshift('precision ' + Const.PRECISION.DEFAULT + ' float;'); + return copy; + } + } else { + if (src.substring(0,9) !== 'precision') { + return 'precision ' + Const.PRECISION.DEFAULT + ' float;\n' + src; + } + } + return src; +} + +/** + * Wrapper class, webGL Shader for Pixi. + * Adds precision string if vertexSrc or fragmentSrc have no mention of it. + * + * @class + * @memberof PIXI + * @param gl {WebGLRenderingContext} + * @param vertexSrc {string|string[]} The vertex shader source as an array of strings. + * @param fragmentSrc {string|string[]} The fragment shader source as an array of strings. + */ +var Shader = function(gl, vertexSrc, fragmentSrc) { + GLShader.call(this, gl, checkPrecision(vertexSrc), checkPrecision(fragmentSrc)); +}; + +Shader.prototype = Object.create(GLShader.prototype); +Shader.prototype.constructor = Shader; +module.exports = Shader; + +},{"./const":40,"pixi-gl-core":1}],40:[function(require,module,exports){ /** * Constant values used in pixi @@ -8809,7 +8846,7 @@ /** * Two Pi. - * + * * @property {number} PI_2 * @constant * @static @@ -8818,7 +8855,7 @@ /** * Conversion factor for converting radians to degrees. - * + * * @property {number} RAD_TO_DEG * @constant * @static @@ -8827,7 +8864,7 @@ /** * Conversion factor for converting degrees to radians. - * + * * @property {number} DEG_TO_RAD * @constant * @static @@ -8861,7 +8898,7 @@ /** * Various blend modes supported by PIXI. - * + * * IMPORTANT - The WebGL renderer only supports the NORMAL, ADD, MULTIPLY and SCREEN blend modes. * Anything else will silently act like NORMAL. * @@ -8957,7 +8994,7 @@ * It can be re-assigned to either CLAMP or REPEAT, depending upon suitability. * If the texture is non power of two then clamp will be used regardless as webGL can only use REPEAT if the texture is po2. * This property only affects WebGL. - * + * * @static * @constant * @property {object} WRAP_MODES @@ -8983,7 +9020,7 @@ * This property only affects WebGL * Handy for mobile devices! * This property only affects WebGL. - * + * * @static * @constant * @property {object} GC_MODES @@ -9000,7 +9037,7 @@ /** * If set to true WebGL will attempt make textures mimpaped by default. * Mipmapping will only succeed if the base texture uploaded has power of two dimensions. - * + * * @static * @constant * @property {bool} MIPMAP_TEXTURES @@ -9019,7 +9056,7 @@ /** * Default resolution of the renderer. - * + * * @property {number} RESOLUTION * @constant * @static @@ -9028,7 +9065,7 @@ /** * Default filter resolution. - * + * * @property {number} FILTER_RESOLUTION * @constant * @static @@ -9086,16 +9123,34 @@ RREC: 4 }, + /** + * Constants that specify float precision in shaders. + * + * @static + * @constant + * @property {object} PRECISION + * @property {number} PRECISION.DEFAULT='mediump' + * @property {number} PRECISION.LOW='lowp' + * @property {number} PRECISION.MEDIUM='mediump' + * @property {number} PRECISION.HIGH='highp' + */ + PRECISION: { + DEFAULT: 'mediump', + LOW: 'lowp', + MEDIUM: 'mediump', + HIGH: 'highp' + }, + // TODO: maybe change to SPRITE.BATCH_SIZE: 2000 // TODO: maybe add PARTICLE.BATCH_SIZE: 15000 SPRITE_BATCH_SIZE: 4096, //nice balance between mobile and desktop machines SPRITE_MAX_TEXTURES: require('./utils/maxRecommendedTextures')(32), //this is the MAXIMUM - various gpus will have there own limits. - TEXT_STYLE_CHANGED: 'changed' //Name of the event that fires when a text style is changed + TEXT_STYLE_CHANGED: 'changed' //Name of the event that fires when a text style is changed }; module.exports = CONST; -},{"./utils/maxRecommendedTextures":110}],40:[function(require,module,exports){ +},{"./utils/maxRecommendedTextures":111}],41:[function(require,module,exports){ var math = require('../math'), utils = require('../utils'), DisplayObject = require('./DisplayObject'); @@ -9723,7 +9778,7 @@ this.children = null; }; -},{"../math":61,"../utils":109,"./DisplayObject":41}],41:[function(require,module,exports){ +},{"../math":62,"../utils":110,"./DisplayObject":42}],42:[function(require,module,exports){ var math = require('../math'), EventEmitter = require('eventemitter3'), Transform = require('./Transform'), @@ -10226,7 +10281,7 @@ this.filterArea = null; }; -},{"../math":61,"./Transform":43,"eventemitter3":26}],42:[function(require,module,exports){ +},{"../math":62,"./Transform":44,"eventemitter3":26}],43:[function(require,module,exports){ /** * An observable point is a point that triggers a callback when the point's position is changed. * @@ -10304,7 +10359,7 @@ this.transform._versionLocal++; // TODO: Pretty sure this doesn't exist. }; -},{}],43:[function(require,module,exports){ +},{}],44:[function(require,module,exports){ var math = require('../math'), ObservablePoint = require('./ObservablePoint'); @@ -10440,7 +10495,7 @@ module.exports = Transform; -},{"../math":61,"./ObservablePoint":42}],44:[function(require,module,exports){ +},{"../math":62,"./ObservablePoint":43}],45:[function(require,module,exports){ var math = require('../math'); var ObservablePoint = require('./ObservablePoint'); @@ -10561,7 +10616,7 @@ module.exports = TransformStatic; -},{"../math":61,"./ObservablePoint":42}],45:[function(require,module,exports){ +},{"../math":62,"./ObservablePoint":43}],46:[function(require,module,exports){ var Container = require('../display/Container'), RenderTexture = require('../textures/RenderTexture'), Texture = require('../textures/Texture'), @@ -11292,8 +11347,8 @@ this._spriteRect.worldAlpha = this.worldAlpha; - Graphics._SPRITE_TEXTURE.frame.width = rect.width; - Graphics._SPRITE_TEXTURE.frame.height = rect.height; + Graphics._SPRITE_TEXTURE._frame.width = rect.width; + Graphics._SPRITE_TEXTURE._frame.height = rect.height; this._spriteRect.transform.worldTransform = this.transform.worldTransform; @@ -11643,6 +11698,10 @@ } } + if(this._spriteRect) + { + this._spriteRect.destroy(); + } this.graphicsData = null; this.currentPath = null; @@ -11650,7 +11709,7 @@ this._localBounds = null; }; -},{"../const":39,"../display/Container":40,"../math":61,"../renderers/canvas/CanvasRenderer":68,"../sprites/Sprite":91,"../textures/RenderTexture":101,"../textures/Texture":102,"./GraphicsData":46,"./utils/bezierCurveTo":48}],46:[function(require,module,exports){ +},{"../const":40,"../display/Container":41,"../math":62,"../renderers/canvas/CanvasRenderer":69,"../sprites/Sprite":92,"../textures/RenderTexture":102,"../textures/Texture":103,"./GraphicsData":47,"./utils/bezierCurveTo":49}],47:[function(require,module,exports){ /** * A GraphicsData object. * @@ -11752,7 +11811,7 @@ this.holes = null; }; -},{}],47:[function(require,module,exports){ +},{}],48:[function(require,module,exports){ var CanvasRenderer = require('../../renderers/canvas/CanvasRenderer'), CONST = require('../../const'); @@ -12035,7 +12094,7 @@ this.renderer = null; }; -},{"../../const":39,"../../renderers/canvas/CanvasRenderer":68}],48:[function(require,module,exports){ +},{"../../const":40,"../../renderers/canvas/CanvasRenderer":69}],49:[function(require,module,exports){ /** * Calculate the points for a bezier curve and then draws it. @@ -12086,7 +12145,7 @@ module.exports = bezierCurveTo; -},{}],49:[function(require,module,exports){ +},{}],50:[function(require,module,exports){ var utils = require('../../utils'), CONST = require('../../const'), ObjectRenderer = require('../../renderers/webgl/utils/ObjectRenderer'), @@ -12307,7 +12366,7 @@ return webGLData; }; -},{"../../const":39,"../../renderers/webgl/WebGLRenderer":75,"../../renderers/webgl/utils/ObjectRenderer":85,"../../utils":109,"./WebGLGraphicsData":50,"./shaders/PrimitiveShader":51,"./utils/buildCircle":52,"./utils/buildPoly":54,"./utils/buildRectangle":55,"./utils/buildRoundedRectangle":56}],50:[function(require,module,exports){ +},{"../../const":40,"../../renderers/webgl/WebGLRenderer":76,"../../renderers/webgl/utils/ObjectRenderer":86,"../../utils":110,"./WebGLGraphicsData":51,"./shaders/PrimitiveShader":52,"./utils/buildCircle":53,"./utils/buildPoly":55,"./utils/buildRectangle":56,"./utils/buildRoundedRectangle":57}],51:[function(require,module,exports){ var glCore = require('pixi-gl-core'); @@ -12434,8 +12493,8 @@ this.glIndices = null; }; -},{"pixi-gl-core":1}],51:[function(require,module,exports){ -var Shader = require('pixi-gl-core').GLShader; +},{"pixi-gl-core":1}],52:[function(require,module,exports){ +var Shader = require('../../../Shader'); /** * This shader is used to draw simple primitive shapes for {@link PIXI.Graphics}. @@ -12469,8 +12528,6 @@ ].join('\n'), // fragment shader [ - 'precision mediump float;', - 'varying vec4 vColor;', 'void main(void){', @@ -12485,7 +12542,7 @@ module.exports = PrimitiveShader; -},{"pixi-gl-core":1}],52:[function(require,module,exports){ +},{"../../../Shader":39}],53:[function(require,module,exports){ var buildLine = require('./buildLine'), CONST = require('../../../const'), utils = require('../../../utils'); @@ -12574,7 +12631,7 @@ module.exports = buildCircle; -},{"../../../const":39,"../../../utils":109,"./buildLine":53}],53:[function(require,module,exports){ +},{"../../../const":40,"../../../utils":110,"./buildLine":54}],54:[function(require,module,exports){ var math = require('../../../math'), utils = require('../../../utils'); @@ -12795,7 +12852,7 @@ module.exports = buildLine; -},{"../../../math":61,"../../../utils":109}],54:[function(require,module,exports){ +},{"../../../math":62,"../../../utils":110}],55:[function(require,module,exports){ var buildLine = require('./buildLine'), utils = require('../../../utils'), earcut = require('earcut'); @@ -12874,7 +12931,7 @@ module.exports = buildPoly; -},{"../../../utils":109,"./buildLine":53,"earcut":25}],55:[function(require,module,exports){ +},{"../../../utils":110,"./buildLine":54,"earcut":25}],56:[function(require,module,exports){ var buildLine = require('./buildLine'), utils = require('../../../utils'); @@ -12946,7 +13003,7 @@ module.exports = buildRectangle; -},{"../../../utils":109,"./buildLine":53}],56:[function(require,module,exports){ +},{"../../../utils":110,"./buildLine":54}],57:[function(require,module,exports){ var earcut = require('earcut'), buildLine = require('./buildLine'), utils = require('../../../utils'); @@ -13076,7 +13133,7 @@ module.exports = buildRoundedRectangle; -},{"../../../utils":109,"./buildLine":53,"earcut":25}],57:[function(require,module,exports){ +},{"../../../utils":110,"./buildLine":54,"earcut":25}],58:[function(require,module,exports){ /** * @file Main export of the PIXI core library * @author Mat Groves @@ -13127,6 +13184,7 @@ CanvasRenderTarget: require('./renderers/canvas/utils/CanvasRenderTarget'), // renderers - webgl + Shader: require('./Shader'), WebGLRenderer: require('./renderers/webgl/WebGLRenderer'), WebGLManager: require('./renderers/webgl/managers/WebGLManager'), ObjectRenderer: require('./renderers/webgl/utils/ObjectRenderer'), @@ -13172,7 +13230,7 @@ } }); -},{"./const":39,"./display/Container":40,"./display/DisplayObject":41,"./display/Transform":43,"./display/TransformStatic":44,"./graphics/Graphics":45,"./graphics/GraphicsData":46,"./graphics/canvas/CanvasGraphicsRenderer":47,"./graphics/webgl/GraphicsRenderer":49,"./math":61,"./renderers/canvas/CanvasRenderer":68,"./renderers/canvas/utils/CanvasRenderTarget":70,"./renderers/webgl/WebGLRenderer":75,"./renderers/webgl/filters/Filter":77,"./renderers/webgl/filters/spriteMask/SpriteMaskFilter":80,"./renderers/webgl/managers/WebGLManager":84,"./renderers/webgl/utils/ObjectRenderer":85,"./renderers/webgl/utils/Quad":86,"./renderers/webgl/utils/RenderTarget":87,"./sprites/Sprite":91,"./sprites/canvas/CanvasSpriteRenderer":92,"./sprites/canvas/CanvasTinter":93,"./sprites/webgl/SpriteRenderer":95,"./text/Text":97,"./text/TextStyle":98,"./textures/BaseRenderTexture":99,"./textures/BaseTexture":100,"./textures/RenderTexture":101,"./textures/Texture":102,"./textures/TextureUvs":103,"./textures/VideoBaseTexture":104,"./ticker":106,"./utils":109,"pixi-gl-core":1}],58:[function(require,module,exports){ +},{"./Shader":39,"./const":40,"./display/Container":41,"./display/DisplayObject":42,"./display/Transform":44,"./display/TransformStatic":45,"./graphics/Graphics":46,"./graphics/GraphicsData":47,"./graphics/canvas/CanvasGraphicsRenderer":48,"./graphics/webgl/GraphicsRenderer":50,"./math":62,"./renderers/canvas/CanvasRenderer":69,"./renderers/canvas/utils/CanvasRenderTarget":71,"./renderers/webgl/WebGLRenderer":76,"./renderers/webgl/filters/Filter":78,"./renderers/webgl/filters/spriteMask/SpriteMaskFilter":81,"./renderers/webgl/managers/WebGLManager":85,"./renderers/webgl/utils/ObjectRenderer":86,"./renderers/webgl/utils/Quad":87,"./renderers/webgl/utils/RenderTarget":88,"./sprites/Sprite":92,"./sprites/canvas/CanvasSpriteRenderer":93,"./sprites/canvas/CanvasTinter":94,"./sprites/webgl/SpriteRenderer":96,"./text/Text":98,"./text/TextStyle":99,"./textures/BaseRenderTexture":100,"./textures/BaseTexture":101,"./textures/RenderTexture":102,"./textures/Texture":103,"./textures/TextureUvs":104,"./textures/VideoBaseTexture":105,"./ticker":107,"./utils":110,"pixi-gl-core":1}],59:[function(require,module,exports){ // Your friendly neighbour https://en.wikipedia.org/wiki/Dihedral_group of order 16 var ux = [1, 1, 0, -1, -1, -1, 0, 1, 1, 1, 0, -1, -1, -1, 0, 1]; @@ -13336,7 +13394,7 @@ module.exports = GroupD8; -},{"./Matrix":59}],59:[function(require,module,exports){ +},{"./Matrix":60}],60:[function(require,module,exports){ // @todo - ignore the too many parameters warning for now // should either fix it or change the jshint config // jshint -W072 @@ -13777,7 +13835,7 @@ */ Matrix.TEMP_MATRIX = new Matrix(); -},{"./Point":60}],60:[function(require,module,exports){ +},{"./Point":61}],61:[function(require,module,exports){ /** * The Point object represents a location in a two-dimensional coordinate system, where x represents * the horizontal axis and y represents the vertical axis. @@ -13847,7 +13905,7 @@ this.y = y || ( (y !== 0) ? this.x : 0 ) ; }; -},{}],61:[function(require,module,exports){ +},{}],62:[function(require,module,exports){ /** * Math classes and utilities mixed into PIXI namespace. * @@ -13870,7 +13928,7 @@ RoundedRectangle: require('./shapes/RoundedRectangle') }; -},{"./GroupD8":58,"./Matrix":59,"./Point":60,"./shapes/Circle":62,"./shapes/Ellipse":63,"./shapes/Polygon":64,"./shapes/Rectangle":65,"./shapes/RoundedRectangle":66}],62:[function(require,module,exports){ +},{"./GroupD8":59,"./Matrix":60,"./Point":61,"./shapes/Circle":63,"./shapes/Ellipse":64,"./shapes/Polygon":65,"./shapes/Rectangle":66,"./shapes/RoundedRectangle":67}],63:[function(require,module,exports){ var Rectangle = require('./Rectangle'), CONST = require('../../const'); @@ -13958,7 +14016,7 @@ return new Rectangle(this.x - this.radius, this.y - this.radius, this.radius * 2, this.radius * 2); }; -},{"../../const":39,"./Rectangle":65}],63:[function(require,module,exports){ +},{"../../const":40,"./Rectangle":66}],64:[function(require,module,exports){ var Rectangle = require('./Rectangle'), CONST = require('../../const'); @@ -14053,7 +14111,7 @@ return new Rectangle(this.x - this.width, this.y - this.height, this.width, this.height); }; -},{"../../const":39,"./Rectangle":65}],64:[function(require,module,exports){ +},{"../../const":40,"./Rectangle":66}],65:[function(require,module,exports){ var Point = require('../Point'), CONST = require('../../const'); @@ -14168,7 +14226,7 @@ return inside; }; -},{"../../const":39,"../Point":60}],65:[function(require,module,exports){ +},{"../../const":40,"../Point":61}],66:[function(require,module,exports){ var CONST = require('../../const'); /** @@ -14340,7 +14398,7 @@ this.height = y2 - y1; }; -},{"../../const":39}],66:[function(require,module,exports){ +},{"../../const":40}],67:[function(require,module,exports){ var CONST = require('../../const'); /** @@ -14432,7 +14490,7 @@ return false; }; -},{"../../const":39}],67:[function(require,module,exports){ +},{"../../const":40}],68:[function(require,module,exports){ var utils = require('../utils'), math = require('../math'), CONST = require('../const'), @@ -14722,7 +14780,7 @@ this._lastObjectRendered = null; }; -},{"../const":39,"../display/Container":40,"../math":61,"../textures/RenderTexture":101,"../utils":109,"eventemitter3":26}],68:[function(require,module,exports){ +},{"../const":40,"../display/Container":41,"../math":62,"../textures/RenderTexture":102,"../utils":110,"eventemitter3":26}],69:[function(require,module,exports){ var SystemRenderer = require('../SystemRenderer'), CanvasMaskManager = require('./utils/CanvasMaskManager'), CanvasRenderTarget = require('./utils/CanvasRenderTarget'), @@ -14983,7 +15041,7 @@ }; -},{"../../const":39,"../../utils":109,"../SystemRenderer":67,"./utils/CanvasMaskManager":69,"./utils/CanvasRenderTarget":70,"./utils/mapCanvasBlendModesToPixi":72}],69:[function(require,module,exports){ +},{"../../const":40,"../../utils":110,"../SystemRenderer":68,"./utils/CanvasMaskManager":70,"./utils/CanvasRenderTarget":71,"./utils/mapCanvasBlendModesToPixi":73}],70:[function(require,module,exports){ var CONST = require('../../../const'); /** * A set of functions used to handle masking. @@ -15145,7 +15203,7 @@ CanvasMaskManager.prototype.destroy = function () {}; -},{"../../../const":39}],70:[function(require,module,exports){ +},{"../../../const":40}],71:[function(require,module,exports){ var CONST = require('../../../const'); /** @@ -15250,7 +15308,7 @@ this.canvas = null; }; -},{"../../../const":39}],71:[function(require,module,exports){ +},{"../../../const":40}],72:[function(require,module,exports){ /** * Checks whether the Canvas BlendModes are supported by the current browser @@ -15289,7 +15347,7 @@ module.exports = canUseNewCanvasBlendModes; -},{}],72:[function(require,module,exports){ +},{}],73:[function(require,module,exports){ var CONST = require('../../../const'), canUseNewCanvasBlendModes = require('./canUseNewCanvasBlendModes'); @@ -15349,7 +15407,7 @@ module.exports = mapWebGLBlendModesToPixi; -},{"../../../const":39,"./canUseNewCanvasBlendModes":71}],73:[function(require,module,exports){ +},{"../../../const":40,"./canUseNewCanvasBlendModes":72}],74:[function(require,module,exports){ var CONST = require('../../const'); @@ -15460,7 +15518,7 @@ } }; -},{"../../const":39}],74:[function(require,module,exports){ +},{"../../const":40}],75:[function(require,module,exports){ var GLTexture = require('pixi-gl-core').GLTexture, CONST = require('../../const'), RenderTarget = require('./utils/RenderTarget'), @@ -15667,7 +15725,7 @@ module.exports = TextureManager; -},{"../../const":39,"../../utils":109,"./utils/RenderTarget":87,"pixi-gl-core":1}],75:[function(require,module,exports){ +},{"../../const":40,"../../utils":110,"./utils/RenderTarget":88,"pixi-gl-core":1}],76:[function(require,module,exports){ var SystemRenderer = require('../SystemRenderer'), MaskManager = require('./managers/MaskManager'), StencilManager = require('./managers/StencilManager'), @@ -16222,7 +16280,7 @@ // this = null; }; -},{"../../const":39,"../../utils":109,"../SystemRenderer":67,"./TextureGarbageCollector":73,"./TextureManager":74,"./WebGLState":76,"./managers/FilterManager":81,"./managers/MaskManager":82,"./managers/StencilManager":83,"./utils/ObjectRenderer":85,"./utils/RenderTarget":87,"./utils/mapWebGLDrawModesToPixi":90,"pixi-gl-core":1}],76:[function(require,module,exports){ +},{"../../const":40,"../../utils":110,"../SystemRenderer":68,"./TextureGarbageCollector":74,"./TextureManager":75,"./WebGLState":77,"./managers/FilterManager":82,"./managers/MaskManager":83,"./managers/StencilManager":84,"./utils/ObjectRenderer":86,"./utils/RenderTarget":88,"./utils/mapWebGLDrawModesToPixi":91,"pixi-gl-core":1}],77:[function(require,module,exports){ var mapWebGLBlendModesToPixi = require('./utils/mapWebGLBlendModesToPixi'); /** @@ -16495,7 +16553,7 @@ module.exports = WebGLState; -},{"./utils/mapWebGLBlendModesToPixi":89}],77:[function(require,module,exports){ +},{"./utils/mapWebGLBlendModesToPixi":90}],78:[function(require,module,exports){ var extractUniformsFromSrc = require('./extractUniformsFromSrc'), utils = require('../../../utils'), SOURCE_KEY_MAP = {}; @@ -16578,7 +16636,6 @@ * @constant */ Filter.defaultVertexSrc = [ - 'precision lowp float;', 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -16602,8 +16659,6 @@ * @constant */ Filter.defaultFragmentSrc = [ - 'precision lowp float;', - 'varying vec2 vTextureCoord;', 'varying vec2 vFilterCoord;', @@ -16628,7 +16683,7 @@ '}' ].join('\n'); -},{"../../../utils":109,"./extractUniformsFromSrc":78}],78:[function(require,module,exports){ +},{"../../../utils":110,"./extractUniformsFromSrc":79}],79:[function(require,module,exports){ var defaultValue = require('pixi-gl-core/lib/shader/defaultValue'); var mapSize = require('pixi-gl-core/lib/shader/mapSize'); @@ -16691,7 +16746,7 @@ module.exports = extractUniformsFromSrc; -},{"pixi-gl-core/lib/shader/defaultValue":10,"pixi-gl-core/lib/shader/mapSize":14}],79:[function(require,module,exports){ +},{"pixi-gl-core/lib/shader/defaultValue":10,"pixi-gl-core/lib/shader/mapSize":14}],80:[function(require,module,exports){ var math = require('../../../math'); /* @@ -16800,7 +16855,7 @@ calculateSpriteMatrix:calculateSpriteMatrix }; -},{"../../../math":61}],80:[function(require,module,exports){ +},{"../../../math":62}],81:[function(require,module,exports){ var Filter = require('../Filter'), math = require('../../../../math'); @@ -16820,7 +16875,7 @@ Filter.call(this, "#define GLSLIFY 1\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 otherMatrix;\n\nvarying vec2 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy;\n}\n", - "precision lowp float;\n#define GLSLIFY 1\n\nvarying vec2 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float alpha;\nuniform sampler2D mask;\n\nvoid main(void)\n{\n // check clip! this will stop the mask bleeding out from the edges\n vec2 text = abs( vMaskCoord - 0.5 );\n text = step(0.5, text);\n float clip = 1.0 - max(text.y, text.x);\n vec4 original = texture2D(uSampler, vTextureCoord);\n vec4 masky = texture2D(mask, vMaskCoord);\n original *= (masky.r * masky.a * alpha * clip);\n gl_FragColor = original;\n}\n" + "#define GLSLIFY 1\nvarying vec2 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float alpha;\nuniform sampler2D mask;\n\nvoid main(void)\n{\n // check clip! this will stop the mask bleeding out from the edges\n vec2 text = abs( vMaskCoord - 0.5 );\n text = step(0.5, text);\n float clip = 1.0 - max(text.y, text.x);\n vec4 original = texture2D(uSampler, vTextureCoord);\n vec4 masky = texture2D(mask, vMaskCoord);\n original *= (masky.r * masky.a * alpha * clip);\n gl_FragColor = original;\n}\n" ); sprite.renderable = false; @@ -16851,13 +16906,13 @@ filterManager.applyFilter(this, input, output); }; -},{"../../../../math":61,"../Filter":77}],81:[function(require,module,exports){ +},{"../../../../math":62,"../Filter":78}],82:[function(require,module,exports){ var WebGLManager = require('./WebGLManager'), RenderTarget = require('../utils/RenderTarget'), Quad = require('../utils/Quad'), math = require('../../../math'), - Shader = require('pixi-gl-core').GLShader, + Shader = require('../../../Shader'), filterTransforms = require('../filters/filterTransforms'), bitTwiddle = require('bit-twiddle'); @@ -17189,7 +17244,7 @@ FilterManager.pool[key].push(renderTarget); }; -},{"../../../math":61,"../filters/filterTransforms":79,"../utils/Quad":86,"../utils/RenderTarget":87,"./WebGLManager":84,"bit-twiddle":17,"pixi-gl-core":1}],82:[function(require,module,exports){ +},{"../../../Shader":39,"../../../math":62,"../filters/filterTransforms":80,"../utils/Quad":87,"../utils/RenderTarget":88,"./WebGLManager":85,"bit-twiddle":17}],83:[function(require,module,exports){ var WebGLManager = require('./WebGLManager'), AlphaMaskFilter = require('../filters/spriteMask/SpriteMaskFilter'); @@ -17365,7 +17420,7 @@ gl.disable(gl.SCISSOR_TEST); }; -},{"../filters/spriteMask/SpriteMaskFilter":80,"./WebGLManager":84}],83:[function(require,module,exports){ +},{"../filters/spriteMask/SpriteMaskFilter":81,"./WebGLManager":85}],84:[function(require,module,exports){ var WebGLManager = require('./WebGLManager'); /** @@ -17478,7 +17533,7 @@ this.stencilMaskStack.stencilStack = null; }; -},{"./WebGLManager":84}],84:[function(require,module,exports){ +},{"./WebGLManager":85}],85:[function(require,module,exports){ /** * @class * @memberof PIXI @@ -17519,7 +17574,7 @@ this.renderer = null; }; -},{}],85:[function(require,module,exports){ +},{}],86:[function(require,module,exports){ var WebGLManager = require('../managers/WebGLManager'); /** @@ -17577,7 +17632,7 @@ // render the object }; -},{"../managers/WebGLManager":84}],86:[function(require,module,exports){ +},{"../managers/WebGLManager":85}],87:[function(require,module,exports){ var glCore = require('pixi-gl-core'), createIndicesForQuads = require('../../../utils/createIndicesForQuads'); @@ -17750,7 +17805,7 @@ module.exports = Quad; -},{"../../../utils/createIndicesForQuads":107,"pixi-gl-core":1}],87:[function(require,module,exports){ +},{"../../../utils/createIndicesForQuads":108,"pixi-gl-core":1}],88:[function(require,module,exports){ var math = require('../../../math'), CONST = require('../../../const'), GLFramebuffer = require('pixi-gl-core').GLFramebuffer; @@ -18076,11 +18131,11 @@ this.texture = null; }; -},{"../../../const":39,"../../../math":61,"pixi-gl-core":1}],88:[function(require,module,exports){ +},{"../../../const":40,"../../../math":62,"pixi-gl-core":1}],89:[function(require,module,exports){ var glCore = require('pixi-gl-core'); var fragTemplate = [ - 'precision lowp float;', + 'precision mediump float;', 'void main(void){', 'float test = 0.1;', '%forloop%', @@ -18105,7 +18160,7 @@ while(true) { - var fragmentSrc = fragTemplate.replace(/\%forloop\%/gi, generateIfTestSrc(maxIfs)); + var fragmentSrc = fragTemplate.replace(/%forloop%/gi, generateIfTestSrc(maxIfs)); gl.shaderSource(shader, fragmentSrc); gl.compileShader(shader); @@ -18157,7 +18212,7 @@ module.exports = checkMaxIfStatmentsInShader; -},{"pixi-gl-core":1}],89:[function(require,module,exports){ +},{"pixi-gl-core":1}],90:[function(require,module,exports){ var CONST = require('../../../const'); /** @@ -18194,7 +18249,7 @@ module.exports = mapWebGLBlendModesToPixi; -},{"../../../const":39}],90:[function(require,module,exports){ +},{"../../../const":40}],91:[function(require,module,exports){ var CONST = require('../../../const'); /** @@ -18218,7 +18273,7 @@ module.exports = mapWebGLDrawModesToPixi; -},{"../../../const":39}],91:[function(require,module,exports){ +},{"../../../const":40}],92:[function(require,module,exports){ var math = require('../math'), Texture = require('../textures/Texture'), Container = require('../display/Container'), @@ -18698,7 +18753,7 @@ return new Sprite(Texture.fromImage(imageId, crossorigin, scaleMode)); }; -},{"../const":39,"../display/Container":40,"../math":61,"../textures/Texture":102,"../utils":109}],92:[function(require,module,exports){ +},{"../const":40,"../display/Container":41,"../math":62,"../textures/Texture":103,"../utils":110}],93:[function(require,module,exports){ var CanvasRenderer = require('../../renderers/canvas/CanvasRenderer'), CONST = require('../../const'), math = require('../../math'), @@ -18864,7 +18919,7 @@ this.renderer = null; }; -},{"../../const":39,"../../math":61,"../../renderers/canvas/CanvasRenderer":68,"./CanvasTinter":93}],93:[function(require,module,exports){ +},{"../../const":40,"../../math":62,"../../renderers/canvas/CanvasRenderer":69,"./CanvasTinter":94}],94:[function(require,module,exports){ var utils = require('../../utils'), canUseNewCanvasBlendModes = require('../../renderers/canvas/utils/canUseNewCanvasBlendModes'); /** @@ -19097,7 +19152,7 @@ */ CanvasTinter.tintMethod = CanvasTinter.canUseMultiply ? CanvasTinter.tintWithMultiply : CanvasTinter.tintWithPerPixel; -},{"../../renderers/canvas/utils/canUseNewCanvasBlendModes":71,"../../utils":109}],94:[function(require,module,exports){ +},{"../../renderers/canvas/utils/canUseNewCanvasBlendModes":72,"../../utils":110}],95:[function(require,module,exports){ var Buffer = function(size) @@ -19128,7 +19183,7 @@ this.uvs = null; this.colors = null; }; -},{}],95:[function(require,module,exports){ +},{}],96:[function(require,module,exports){ var ObjectRenderer = require('../../renderers/webgl/utils/ObjectRenderer'), WebGLRenderer = require('../../renderers/webgl/WebGLRenderer'), createIndicesForQuads = require('../../utils/createIndicesForQuads'), @@ -19192,11 +19247,12 @@ this.indices = createIndicesForQuads(this.size); /** - * The default shader that is used if a sprite doesn't have a more specific one. - * + * The default shaders that is used if a sprite doesn't have a more specific one. + * there is a shader for each number of textures that can be rendererd. + * These shaders will also be generated on the fly as required. * @member {PIXI.Shader} */ - this.shader = null; + this.shaders = null; this.textureCount = 0; this.currentIndex = 0; @@ -19241,19 +19297,23 @@ // step 2: check the maximum number of if statements the shader can have too.. this.MAX_TEXTURES = checkMaxIfStatmentsInShader( this.MAX_TEXTURES, gl ); - this.shader = generateMultiTextureShader(gl, this.MAX_TEXTURES); + this.shaders = new Array(this.MAX_TEXTURES); + this.shaders[0] = generateMultiTextureShader(gl, 1); + // create a couple of buffers this.indexBuffer = glCore.GLBuffer.createIndexBuffer(gl, this.indices, gl.STATIC_DRAW); + var shader = this.shaders[0]; + for (var i = 0; i < this.vaoMax; i++) { this.vertexBuffers[i] = glCore.GLBuffer.createVertexBuffer(gl, null, gl.STREAM_DRAW); // build the vao object that will render.. this.vaos[i] = this.renderer.createVao() .addIndex(this.indexBuffer) - .addAttribute(this.vertexBuffers[i], this.shader.attributes.aVertexPosition, gl.FLOAT, false, this.vertByteSize, 0) - .addAttribute(this.vertexBuffers[i], this.shader.attributes.aTextureCoord, gl.UNSIGNED_SHORT, true, this.vertByteSize, 2 * 4) - .addAttribute(this.vertexBuffers[i], this.shader.attributes.aColor, gl.UNSIGNED_BYTE, true, this.vertByteSize, 3 * 4) - .addAttribute(this.vertexBuffers[i], this.shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); + .addAttribute(this.vertexBuffers[i], shader.attributes.aVertexPosition, gl.FLOAT, false, this.vertByteSize, 0) + .addAttribute(this.vertexBuffers[i], shader.attributes.aTextureCoord, gl.UNSIGNED_SHORT, true, this.vertByteSize, 2 * 4) + .addAttribute(this.vertexBuffers[i], shader.attributes.aColor, gl.UNSIGNED_BYTE, true, this.vertByteSize, 3 * 4) + .addAttribute(this.vertexBuffers[i], shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); } this.vao = this.vaos[0]; @@ -19327,6 +19387,7 @@ var uvs; var textureId; var blendMode = sprites[0].blendMode; + var shader; currentGroup.textureCount = 0; currentGroup.start = 0; @@ -19424,14 +19485,15 @@ if(this.vaoMax <= this.vertexCount) { this.vaoMax++; + shader = this.shaders[0]; this.vertexBuffers[this.vertexCount] = glCore.GLBuffer.createVertexBuffer(gl, null, gl.STREAM_DRAW); // build the vao object that will render.. this.vaos[this.vertexCount] = this.renderer.createVao() .addIndex(this.indexBuffer) - .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aVertexPosition, gl.FLOAT, false, this.vertByteSize, 0) - .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aTextureCoord, gl.UNSIGNED_SHORT, true, this.vertByteSize, 2 * 4) - .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aColor, gl.UNSIGNED_BYTE, true, this.vertByteSize, 3 * 4) - .addAttribute(this.vertexBuffers[this.vertexCount], this.shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); + .addAttribute(this.vertexBuffers[this.vertexCount], shader.attributes.aVertexPosition, gl.FLOAT, false, this.vertByteSize, 0) + .addAttribute(this.vertexBuffers[this.vertexCount], shader.attributes.aTextureCoord, gl.UNSIGNED_SHORT, true, this.vertByteSize, 2 * 4) + .addAttribute(this.vertexBuffers[this.vertexCount], shader.attributes.aColor, gl.UNSIGNED_BYTE, true, this.vertByteSize, 3 * 4) + .addAttribute(this.vertexBuffers[this.vertexCount], shader.attributes.aTextureId, gl.FLOAT, false, this.vertByteSize, 4 * 4); } this.vertexBuffers[this.vertexCount].upload(buffer.vertices, 0); @@ -19441,8 +19503,19 @@ for (i = 0; i < groupCount; i++) { var group = groups[i]; + var groupTextureCount = group.textureCount; + shader = this.shaders[groupTextureCount-1]; - for (var j = 0; j < group.textureCount; j++) { + if(!shader) + { + shader = this.shaders[groupTextureCount-1] = generateMultiTextureShader(gl, groupTextureCount); + //console.log("SHADER generated for " + textureCount + " textures") + } + + this.renderer.bindShader(shader); + + for (var j = 0; j < groupTextureCount; j++) + { this.renderer.bindTexture(group.textures[j], j); } @@ -19462,7 +19535,7 @@ */ SpriteRenderer.prototype.start = function () { - this.renderer.bindShader(this.shader); + // this.renderer.bindShader(this.shader); this.tick %= 1000; }; @@ -19487,7 +19560,13 @@ this.renderer.off('prerender', this.onPrerender, this); ObjectRenderer.prototype.destroy.call(this); - this.shader.destroy(); + for (i = 0; i < this.shaders.length; i++) { + + if(this.shaders[i]) + { + this.shaders[i].destroy(); + } + } this.vertexBuffers = null; this.vaos = null; @@ -19495,7 +19574,6 @@ this.indices = null; this.sprites = null; - this.shader = null; for (i = 0; i < this.buffers.length; i++) { this.buffers[i].destroy(); @@ -19503,12 +19581,11 @@ }; -},{"../../const":39,"../../renderers/webgl/WebGLRenderer":75,"../../renderers/webgl/utils/ObjectRenderer":85,"../../renderers/webgl/utils/checkMaxIfStatmentsInShader":88,"../../utils/createIndicesForQuads":107,"./BatchBuffer":94,"./generateMultiTextureShader":96,"bit-twiddle":17,"pixi-gl-core":1}],96:[function(require,module,exports){ -var Shader = require('pixi-gl-core').GLShader; +},{"../../const":40,"../../renderers/webgl/WebGLRenderer":76,"../../renderers/webgl/utils/ObjectRenderer":86,"../../renderers/webgl/utils/checkMaxIfStatmentsInShader":89,"../../utils/createIndicesForQuads":108,"./BatchBuffer":95,"./generateMultiTextureShader":97,"bit-twiddle":17,"pixi-gl-core":1}],97:[function(require,module,exports){ +var Shader = require('../../Shader'); + var fragTemplate = [ - - 'precision lowp float;', 'varying vec2 vTextureCoord;', 'varying vec4 vColor;', 'varying float vTextureId;', @@ -19523,11 +19600,11 @@ function generateMultiTextureShader(gl, maxTextures) { - var vertexSrc = "precision lowp float;\n#define GLSLIFY 1\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\nattribute float aTextureId;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nvoid main(void){\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n vTextureId = aTextureId;\n vColor = vec4(aColor.rgb * aColor.a, aColor.a);\n}"; + var vertexSrc = "#define GLSLIFY 1\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\nattribute float aTextureId;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nvarying float vTextureId;\n\nvoid main(void){\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n vTextureId = aTextureId;\n vColor = vec4(aColor.rgb * aColor.a, aColor.a);\n}\n"; var fragmentSrc = fragTemplate; - fragmentSrc = fragmentSrc.replace(/\%count\%/gi, maxTextures); - fragmentSrc = fragmentSrc.replace(/\%forloop\%/gi, generateSampleSrc(maxTextures)); + fragmentSrc = fragmentSrc.replace(/%count%/gi, maxTextures); + fragmentSrc = fragmentSrc.replace(/%forloop%/gi, generateSampleSrc(maxTextures)); var shader = new Shader(gl, vertexSrc, fragmentSrc); @@ -19577,7 +19654,7 @@ module.exports = generateMultiTextureShader; -},{"pixi-gl-core":1}],97:[function(require,module,exports){ +},{"../../Shader":39}],98:[function(require,module,exports){ var Sprite = require('../sprites/Sprite'), Texture = require('../textures/Texture'), math = require('../math'), @@ -20277,7 +20354,7 @@ this._texture.destroy(destroyBaseTexture === undefined ? true : destroyBaseTexture); }; -},{"../const":39,"../math":61,"../sprites/Sprite":91,"../textures/Texture":102,"../utils":109}],98:[function(require,module,exports){ +},{"../const":40,"../math":62,"../sprites/Sprite":92,"../textures/Texture":103,"../utils":110}],99:[function(require,module,exports){ var EventEmitter = require('eventemitter3'), CONST = require('../const'), utils = require('../utils'); @@ -20613,7 +20690,7 @@ } } -},{"../const":39,"../utils":109,"eventemitter3":26}],99:[function(require,module,exports){ +},{"../const":40,"../utils":110,"eventemitter3":26}],100:[function(require,module,exports){ var BaseTexture = require('./BaseTexture'), CONST = require('../const'); @@ -20749,7 +20826,7 @@ }; -},{"../const":39,"./BaseTexture":100}],100:[function(require,module,exports){ +},{"../const":40,"./BaseTexture":101}],101:[function(require,module,exports){ var utils = require('../utils'), CONST = require('../const'), EventEmitter = require('eventemitter3'), @@ -21198,7 +21275,7 @@ return baseTexture; }; -},{"../const":39,"../utils":109,"../utils/determineCrossOrigin":108,"bit-twiddle":17,"eventemitter3":26}],101:[function(require,module,exports){ +},{"../const":40,"../utils":110,"../utils/determineCrossOrigin":109,"bit-twiddle":17,"eventemitter3":26}],102:[function(require,module,exports){ var BaseRenderTexture = require('./BaseRenderTexture'), Texture = require('./Texture'); @@ -21320,7 +21397,7 @@ return new RenderTexture(new BaseRenderTexture(width, height, scaleMode, resolution)); }; -},{"./BaseRenderTexture":99,"./Texture":102}],102:[function(require,module,exports){ +},{"./BaseRenderTexture":100,"./Texture":103}],103:[function(require,module,exports){ var BaseTexture = require('./BaseTexture'), VideoBaseTexture = require('./VideoBaseTexture'), TextureUvs = require('./TextureUvs'), @@ -21821,7 +21898,7 @@ Texture.EMPTY.emit = function() {}; -},{"../math":61,"../utils":109,"./BaseTexture":100,"./TextureUvs":103,"./VideoBaseTexture":104,"eventemitter3":26}],103:[function(require,module,exports){ +},{"../math":62,"../utils":110,"./BaseTexture":101,"./TextureUvs":104,"./VideoBaseTexture":105,"eventemitter3":26}],104:[function(require,module,exports){ /** * A standard object to store the Uvs of a texture @@ -21906,7 +21983,7 @@ this.uvsUint32[3] = (((this.y3 * 65535) & 0xFFFF) << 16) | ((this.x3 * 65535) & 0xFFFF); }; -},{"../math/GroupD8":58}],104:[function(require,module,exports){ +},{"../math/GroupD8":59}],105:[function(require,module,exports){ var BaseTexture = require('./BaseTexture'), utils = require('../utils'); @@ -22143,7 +22220,7 @@ return source; } -},{"../utils":109,"./BaseTexture":100}],105:[function(require,module,exports){ +},{"../utils":110,"./BaseTexture":101}],106:[function(require,module,exports){ var CONST = require('../const'), EventEmitter = require('eventemitter3'), // Internal event used by composed emitter @@ -22496,7 +22573,7 @@ module.exports = Ticker; -},{"../const":39,"eventemitter3":26}],106:[function(require,module,exports){ +},{"../const":40,"eventemitter3":26}],107:[function(require,module,exports){ var Ticker = require('./Ticker'); /** @@ -22552,7 +22629,7 @@ Ticker: Ticker }; -},{"./Ticker":105}],107:[function(require,module,exports){ +},{"./Ticker":106}],108:[function(require,module,exports){ /** * Generic Mask Stack data structure * @class @@ -22583,7 +22660,7 @@ module.exports = createIndicesForQuads; -},{}],108:[function(require,module,exports){ +},{}],109:[function(require,module,exports){ var tempAnchor; var _url = require('url'); @@ -22628,7 +22705,7 @@ module.exports = determineCrossOrigin; -},{"url":24}],109:[function(require,module,exports){ +},{"url":24}],110:[function(require,module,exports){ var CONST = require('../const'); /** @@ -22838,7 +22915,7 @@ BaseTextureCache: {} }; -},{"../const":39,"./pluginTarget":111,"eventemitter3":26}],110:[function(require,module,exports){ +},{"../const":40,"./pluginTarget":112,"eventemitter3":26}],111:[function(require,module,exports){ var Device = require('ismobilejs'); @@ -22859,7 +22936,7 @@ }; module.exports = maxRecommendedTextures; -},{"ismobilejs":27}],111:[function(require,module,exports){ +},{"ismobilejs":27}],112:[function(require,module,exports){ /** * Mixins functionality to make an object have "plugins". * @@ -22929,7 +23006,7 @@ } }; -},{}],112:[function(require,module,exports){ +},{}],113:[function(require,module,exports){ /*global console */ var core = require('./core'), mesh = require('./mesh'), @@ -23390,7 +23467,7 @@ }; -},{"./core":57,"./extras":122,"./filters":134,"./mesh":149,"./particles":152}],113:[function(require,module,exports){ +},{"./core":58,"./extras":123,"./filters":135,"./mesh":150,"./particles":153}],114:[function(require,module,exports){ var core = require('../../core'), tempRect = new core.Rectangle(); @@ -23529,13 +23606,13 @@ core.CanvasRenderer.registerPlugin('extract', WebGLExtract); -},{"../../core":57}],114:[function(require,module,exports){ +},{"../../core":58}],115:[function(require,module,exports){ module.exports = { webGL: require('./webgl/WebGLExtract'), canvas: require('./canvas/CanvasExtract') }; -},{"./canvas/CanvasExtract":113,"./webgl/WebGLExtract":115}],115:[function(require,module,exports){ +},{"./canvas/CanvasExtract":114,"./webgl/WebGLExtract":116}],116:[function(require,module,exports){ var core = require('../../core'), tempRect = new core.Rectangle(); @@ -23719,7 +23796,7 @@ core.WebGLRenderer.registerPlugin('extract', Extract); -},{"../../core":57}],116:[function(require,module,exports){ +},{"../../core":58}],117:[function(require,module,exports){ var core = require('../core'); /** @@ -24107,7 +24184,7 @@ BitmapText.fonts = {}; -},{"../core":57}],117:[function(require,module,exports){ +},{"../core":58}],118:[function(require,module,exports){ var core = require('../core'); /** * A MovieClip is a simple way to display an animation depicted by a list of textures. @@ -24430,7 +24507,7 @@ return new MovieClip(textures); }; -},{"../core":57}],118:[function(require,module,exports){ +},{"../core":58}],119:[function(require,module,exports){ var core = require('../core'), tempPoint = new core.Point(), CanvasTinter = require('../core/sprites/canvas/CanvasTinter'), @@ -24861,7 +24938,7 @@ return new TilingSprite(core.Texture.fromImage(imageId, crossorigin, scaleMode),width,height); }; -},{"../core":57,"../core/sprites/canvas/CanvasTinter":93,"./webgl/TilingShader":123}],119:[function(require,module,exports){ +},{"../core":58,"../core/sprites/canvas/CanvasTinter":94,"./webgl/TilingShader":124}],120:[function(require,module,exports){ var core = require('../core'), DisplayObject = core.DisplayObject, _tempMatrix = new core.Matrix(); @@ -24996,7 +25073,7 @@ var stack = renderer.filterManager.filterStack; // this renderTexture will be used to store the cached DisplayObject - + var renderTexture = core.RenderTexture.create(bounds.width | 0, bounds.height | 0); // need to set // @@ -25010,9 +25087,9 @@ renderer.render(this, renderTexture, true, m, true); // now restore the state be setting the new properties - + renderer.bindRenderTarget(cachedRenderTarget); - + renderer.filterManager.filterStack = stack; this.renderWebGL = this._renderCachedWebGL; @@ -25117,7 +25194,7 @@ { this._cachedSprite._currentBounds = null; - return this._cachedSprite.getBounds(); + return this._cachedSprite.getBounds(core.math.Matrix.IDENTITY); }; /** @@ -25137,7 +25214,7 @@ this._originalDestroy(); }; -},{"../core":57}],120:[function(require,module,exports){ +},{"../core":58}],121:[function(require,module,exports){ var core = require('../core'); /** @@ -25167,7 +25244,7 @@ return null; }; -},{"../core":57}],121:[function(require,module,exports){ +},{"../core":58}],122:[function(require,module,exports){ var core = require('../core'); /** @@ -25197,7 +25274,7 @@ return point; }; -},{"../core":57}],122:[function(require,module,exports){ +},{"../core":58}],123:[function(require,module,exports){ /** * @file Main export of the PIXI extras library * @author Mat Groves @@ -25218,8 +25295,8 @@ BitmapText: require('./BitmapText') }; -},{"./BitmapText":116,"./MovieClip":117,"./TilingSprite":118,"./cacheAsBitmap":119,"./getChildByName":120,"./getGlobalPosition":121}],123:[function(require,module,exports){ -var Shader = require('pixi-gl-core').GLShader; +},{"./BitmapText":117,"./MovieClip":118,"./TilingSprite":119,"./cacheAsBitmap":120,"./getChildByName":121,"./getGlobalPosition":122}],124:[function(require,module,exports){ +var Shader = require('../../core/Shader'); /** @@ -25232,8 +25309,8 @@ { Shader.call(this, gl, - "precision lowp float;\n#define GLSLIFY 1\n\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\n\nuniform vec4 uFrame;\nuniform vec4 uTransform;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n \n vec2 coord = aTextureCoord;\n coord -= uTransform.xy;\n coord /= uTransform.zw;\n vTextureCoord = coord;\n \n vColor = vec4(aColor.rgb * aColor.a, aColor.a);\n}", - "precision lowp float;\n#define GLSLIFY 1\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nuniform sampler2D uSampler;\nuniform vec4 uFrame;\nuniform vec2 uPixelSize;\n\nvoid main(void)\n{\n\n vec2 coord = mod(vTextureCoord, uFrame.zw);\n coord = clamp(coord, uPixelSize, uFrame.zw - uPixelSize);\n coord += uFrame.xy;\n\n gl_FragColor = texture2D(uSampler, coord) ;\n}" + "#define GLSLIFY 1\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\n\nuniform vec4 uFrame;\nuniform vec4 uTransform;\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vec2 coord = aTextureCoord;\n coord -= uTransform.xy;\n coord /= uTransform.zw;\n vTextureCoord = coord;\n\n vColor = vec4(aColor.rgb * aColor.a, aColor.a);\n}\n", + "#define GLSLIFY 1\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nuniform sampler2D uSampler;\nuniform vec4 uFrame;\nuniform vec2 uPixelSize;\n\nvoid main(void)\n{\n\n vec2 coord = mod(vTextureCoord, uFrame.zw);\n coord = clamp(coord, uPixelSize, uFrame.zw - uPixelSize);\n coord += uFrame.xy;\n\n gl_FragColor = texture2D(uSampler, coord) ;\n}\n" ); } @@ -25242,7 +25319,7 @@ module.exports = TilingShader; -},{"pixi-gl-core":1}],124:[function(require,module,exports){ +},{"../../core/Shader":39}],125:[function(require,module,exports){ var core = require('../../core'), BlurXFilter = require('./BlurXFilter'), BlurYFilter = require('./BlurYFilter'); @@ -25362,7 +25439,7 @@ } }); -},{"../../core":57,"./BlurXFilter":125,"./BlurYFilter":126}],125:[function(require,module,exports){ +},{"../../core":58,"./BlurXFilter":126,"./BlurYFilter":127}],126:[function(require,module,exports){ var core = require('../../core'); var generateBlurVertSource = require('./generateBlurVertSource'); var generateBlurFragSource = require('./generateBlurFragSource'); @@ -25470,7 +25547,7 @@ } }); -},{"../../core":57,"./generateBlurFragSource":127,"./generateBlurVertSource":128,"./getMaxBlurKernelSize":129}],126:[function(require,module,exports){ +},{"../../core":58,"./generateBlurFragSource":128,"./generateBlurVertSource":129,"./getMaxBlurKernelSize":130}],127:[function(require,module,exports){ var core = require('../../core'); var generateBlurVertSource = require('./generateBlurVertSource'); var generateBlurFragSource = require('./generateBlurFragSource'); @@ -25568,7 +25645,7 @@ } }); -},{"../../core":57,"./generateBlurFragSource":127,"./generateBlurVertSource":128,"./getMaxBlurKernelSize":129}],127:[function(require,module,exports){ +},{"../../core":58,"./generateBlurFragSource":128,"./generateBlurVertSource":129,"./getMaxBlurKernelSize":130}],128:[function(require,module,exports){ var GAUSSIAN_VALUES = { 5:[0.153388, 0.221461, 0.250301], 7:[0.071303, 0.131514, 0.189879, 0.214607], @@ -25579,9 +25656,6 @@ }; var fragTemplate = [ - - 'precision mediump float;', - 'varying vec2 vBlurTexCoords[%size%];', 'uniform sampler2D uSampler;', @@ -25633,7 +25707,7 @@ module.exports = generateFragBlurSource; -},{}],128:[function(require,module,exports){ +},{}],129:[function(require,module,exports){ var vertTemplate = [ 'attribute vec2 aVertexPosition;', @@ -25699,7 +25773,7 @@ module.exports = generateVertBlurSource; -},{}],129:[function(require,module,exports){ +},{}],130:[function(require,module,exports){ var getMaxKernelSize = function(gl) @@ -25717,7 +25791,7 @@ module.exports = getMaxKernelSize; -},{}],130:[function(require,module,exports){ +},{}],131:[function(require,module,exports){ var core = require('../../core'); // @see https://github.com/substack/brfs/issues/25 @@ -25741,9 +25815,9 @@ { core.Filter.call(this, // vertex shader - "precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nvarying vec2 vTextureCoord;\n\nvoid main(void){\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}", + "#define GLSLIFY 1\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nvarying vec2 vTextureCoord;\n\nvoid main(void){\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}\n", // fragment shader - "precision mediump float;\n#define GLSLIFY 1\n\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform float m[20];\n\nvoid main(void)\n{\n\n vec4 c = texture2D(uSampler, vTextureCoord);\n\n gl_FragColor.r = (m[0] * c.r);\n gl_FragColor.r += (m[1] * c.g);\n gl_FragColor.r += (m[2] * c.b);\n gl_FragColor.r += (m[3] * c.a);\n gl_FragColor.r += m[4] * c.a;\n\n gl_FragColor.g = (m[5] * c.r);\n gl_FragColor.g += (m[6] * c.g);\n gl_FragColor.g += (m[7] * c.b);\n gl_FragColor.g += (m[8] * c.a);\n gl_FragColor.g += m[9] * c.a;\n\n gl_FragColor.b = (m[10] * c.r);\n gl_FragColor.b += (m[11] * c.g);\n gl_FragColor.b += (m[12] * c.b);\n gl_FragColor.b += (m[13] * c.a);\n gl_FragColor.b += m[14] * c.a;\n\n gl_FragColor.a = (m[15] * c.r);\n gl_FragColor.a += (m[16] * c.g);\n gl_FragColor.a += (m[17] * c.b);\n gl_FragColor.a += (m[18] * c.a);\n gl_FragColor.a += m[19] * c.a;\n\n// gl_FragColor = vec4(m[0]);\n}\n" + "#define GLSLIFY 1\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform float m[20];\n\nvoid main(void)\n{\n\n vec4 c = texture2D(uSampler, vTextureCoord);\n\n gl_FragColor.r = (m[0] * c.r);\n gl_FragColor.r += (m[1] * c.g);\n gl_FragColor.r += (m[2] * c.b);\n gl_FragColor.r += (m[3] * c.a);\n gl_FragColor.r += m[4] * c.a;\n\n gl_FragColor.g = (m[5] * c.r);\n gl_FragColor.g += (m[6] * c.g);\n gl_FragColor.g += (m[7] * c.b);\n gl_FragColor.g += (m[8] * c.a);\n gl_FragColor.g += m[9] * c.a;\n\n gl_FragColor.b = (m[10] * c.r);\n gl_FragColor.b += (m[11] * c.g);\n gl_FragColor.b += (m[12] * c.b);\n gl_FragColor.b += (m[13] * c.a);\n gl_FragColor.b += m[14] * c.a;\n\n gl_FragColor.a = (m[15] * c.r);\n gl_FragColor.a += (m[16] * c.g);\n gl_FragColor.a += (m[17] * c.b);\n gl_FragColor.a += (m[18] * c.a);\n gl_FragColor.a += m[19] * c.a;\n\n// gl_FragColor = vec4(m[0]);\n}\n" ); this.uniforms.m = [ @@ -26250,7 +26324,7 @@ } }); -},{"../../core":57}],131:[function(require,module,exports){ +},{"../../core":58}],132:[function(require,module,exports){ var core = require('../../core'); @@ -26274,7 +26348,7 @@ // vertex shader "#define GLSLIFY 1\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec4 aColor;\n\nuniform mat3 projectionMatrix;\nuniform mat3 otherMatrix;\n\nvarying vec2 vMapCoord;\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n vMapCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy;\n vColor = vec4(aColor.rgb * aColor.a, aColor.a);\n}\n", // fragment shader - "precision mediump float;\n#define GLSLIFY 1\n\nvarying vec2 vMapCoord;\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nuniform vec2 scale;\n\nuniform sampler2D uSampler;\nuniform sampler2D mapSampler;\n\nvoid main(void)\n{\n vec4 map = texture2D(mapSampler, vMapCoord);\n\n map -= 0.5;\n map.xy *= scale;\n\n gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y));\n}\n" + "#define GLSLIFY 1\nvarying vec2 vMapCoord;\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nuniform vec2 scale;\n\nuniform sampler2D uSampler;\nuniform sampler2D mapSampler;\n\nvoid main(void)\n{\n vec4 map = texture2D(mapSampler, vMapCoord);\n\n map -= 0.5;\n map.xy *= scale;\n\n gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y));\n}\n" ); @@ -26330,7 +26404,7 @@ } }); -},{"../../core":57}],132:[function(require,module,exports){ +},{"../../core":58}],133:[function(require,module,exports){ var core = require('../../core'); @@ -26348,7 +26422,7 @@ "#define GLSLIFY 1\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}\n\n", // fragment shader - "precision mediump float;\n#define GLSLIFY 1\n\nvarying vec2 vTextureCoord;\nuniform float exposure;\nuniform float decay;\nuniform float density;\nuniform float weight;\nuniform vec2 lightPositionOnScreen;\nuniform sampler2D uSampler;\n\nconst int NUM_SAMPLES = 100;\n\nvoid main()\n{\n vec2 deltaTextCoord = vec2( vTextureCoord - lightPositionOnScreen.xy );\n vec2 textCoo = vTextureCoord;\n deltaTextCoord *= 1.0 / float(NUM_SAMPLES) * density;\n float illuminationDecay = 1.0;\n \n for(int i=0; i < NUM_SAMPLES ; i++)\n {\n textCoo -= deltaTextCoord;\n vec4 sample = texture2D(uSampler, textCoo );\n\n sample *= illuminationDecay * weight;\n\n gl_FragColor += sample;\n\n illuminationDecay *= decay;\n }\n \n gl_FragColor *= exposure;\n}" + "#define GLSLIFY 1\nvarying vec2 vTextureCoord;\nuniform float exposure;\nuniform float decay;\nuniform float density;\nuniform float weight;\nuniform vec2 lightPositionOnScreen;\nuniform sampler2D uSampler;\n\nconst int NUM_SAMPLES = 100;\n\nvoid main()\n{\n vec2 deltaTextCoord = vec2( vTextureCoord - lightPositionOnScreen.xy );\n vec2 textCoo = vTextureCoord;\n deltaTextCoord *= 1.0 / float(NUM_SAMPLES) * density;\n float illuminationDecay = 1.0;\n\n for(int i=0; i < NUM_SAMPLES ; i++)\n {\n textCoo -= deltaTextCoord;\n vec4 sample = texture2D(uSampler, textCoo );\n\n sample *= illuminationDecay * weight;\n\n gl_FragColor += sample;\n\n illuminationDecay *= decay;\n }\n\n gl_FragColor *= exposure;\n}\n" ); this.uniforms.exposure = 0.0034; @@ -26423,7 +26497,7 @@ } }); -},{"../../core":57}],133:[function(require,module,exports){ +},{"../../core":58}],134:[function(require,module,exports){ var core = require('../../core'); // @see https://github.com/substack/brfs/issues/25 @@ -26439,9 +26513,9 @@ { core.Filter.call(this, // vertex shader - "precision lowp float;\n#define GLSLIFY 1\n\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nvarying vec2 vTextureCoord;\n\nvoid main(void){\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}", + "#define GLSLIFY 1\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nvarying vec2 vTextureCoord;\n\nvoid main(void){\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}\n", // fragment shader - "precision mediump float;\n#define GLSLIFY 1\n\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float gray;\n\nvoid main(void)\n{\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(0.2126*gl_FragColor.r + 0.7152*gl_FragColor.g + 0.0722*gl_FragColor.b), gray);\n}\n" + "#define GLSLIFY 1\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float gray;\n\nvoid main(void)\n{\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(0.2126*gl_FragColor.r + 0.7152*gl_FragColor.g + 0.0722*gl_FragColor.b), gray);\n}\n" ); this.uniforms.gray = 1; @@ -26472,7 +26546,7 @@ } }); -},{"../../core":57}],134:[function(require,module,exports){ +},{"../../core":58}],135:[function(require,module,exports){ /** * @file Main export of the PIXI filters library * @author Mat Groves @@ -26513,7 +26587,7 @@ GodrayFilter: require('./godray/GodrayFilter') }; -},{"./blur/BlurFilter":124,"./blur/BlurXFilter":125,"./blur/BlurYFilter":126,"./colormatrix/ColorMatrixFilter":130,"./displacement/DisplacementFilter":131,"./godray/GodrayFilter":132,"./gray/GrayFilter":133,"./twist/TwistFilter":135}],135:[function(require,module,exports){ +},{"./blur/BlurFilter":125,"./blur/BlurXFilter":126,"./blur/BlurYFilter":127,"./colormatrix/ColorMatrixFilter":131,"./displacement/DisplacementFilter":132,"./godray/GodrayFilter":133,"./gray/GrayFilter":134,"./twist/TwistFilter":136}],136:[function(require,module,exports){ var core = require('../../core'); @@ -26531,7 +26605,7 @@ "#define GLSLIFY 1\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}\n\n", // fragment shader - "precision mediump float;\n#define GLSLIFY 1\n\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float radius;\nuniform float angle;\nuniform vec2 offset;\nuniform vec4 filterArea;\n\nvec2 mapCoord( vec2 coord )\n{\n coord *= filterArea.xy;\n coord += filterArea.zw;\n\n return coord;\n}\n\nvec2 unmapCoord( vec2 coord )\n{\n coord -= filterArea.zw;\n coord /= filterArea.xy;\n\n return coord;\n}\n\nvec2 twist(vec2 coord)\n{\n coord -= offset;\n\n float dist = length(coord);\n\n if (dist < radius)\n {\n float ratioDist = (radius - dist) / radius;\n float angleMod = ratioDist * ratioDist * angle;\n float s = sin(angleMod);\n float c = cos(angleMod);\n coord = vec2(coord.x * c - coord.y * s, coord.x * s + coord.y * c);\n }\n\n coord += offset;\n\n return coord;\n}\n\nvoid main(void)\n{\n\n vec2 coord = mapCoord(vTextureCoord);\n\n coord = twist(coord);\n\n coord = unmapCoord(coord);\n\n gl_FragColor = texture2D(uSampler, coord );\n\n}\n" + "#define GLSLIFY 1\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float radius;\nuniform float angle;\nuniform vec2 offset;\nuniform vec4 filterArea;\n\nvec2 mapCoord( vec2 coord )\n{\n coord *= filterArea.xy;\n coord += filterArea.zw;\n\n return coord;\n}\n\nvec2 unmapCoord( vec2 coord )\n{\n coord -= filterArea.zw;\n coord /= filterArea.xy;\n\n return coord;\n}\n\nvec2 twist(vec2 coord)\n{\n coord -= offset;\n\n float dist = length(coord);\n\n if (dist < radius)\n {\n float ratioDist = (radius - dist) / radius;\n float angleMod = ratioDist * ratioDist * angle;\n float s = sin(angleMod);\n float c = cos(angleMod);\n coord = vec2(coord.x * c - coord.y * s, coord.x * s + coord.y * c);\n }\n\n coord += offset;\n\n return coord;\n}\n\nvoid main(void)\n{\n\n vec2 coord = mapCoord(vTextureCoord);\n\n coord = twist(coord);\n\n coord = unmapCoord(coord);\n\n gl_FragColor = texture2D(uSampler, coord );\n\n}\n" ); this.uniforms.radius = 400; @@ -26611,7 +26685,7 @@ } }); -},{"../../core":57}],136:[function(require,module,exports){ +},{"../../core":58}],137:[function(require,module,exports){ (function (global){ // run the polyfills require('./polyfill'); @@ -26645,7 +26719,7 @@ global.PIXI = core; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./accessibility":38,"./core":57,"./deprecation":112,"./extract":114,"./extras":122,"./filters":134,"./interaction":139,"./loaders":142,"./mesh":149,"./particles":152,"./polyfill":158}],137:[function(require,module,exports){ +},{"./accessibility":38,"./core":58,"./deprecation":113,"./extract":115,"./extras":123,"./filters":135,"./interaction":140,"./loaders":143,"./mesh":150,"./particles":153,"./polyfill":159}],138:[function(require,module,exports){ var core = require('../core'); /** @@ -26694,7 +26768,7 @@ return displayObject.worldTransform.applyInverse(globalPos || this.global, point); }; -},{"../core":57}],138:[function(require,module,exports){ +},{"../core":58}],139:[function(require,module,exports){ var core = require('../core'), InteractionData = require('./InteractionData'); @@ -27162,7 +27236,6 @@ { displayObject.worldTransform.applyInverse(point, this._tempPoint); hit = displayObject.hitArea.contains( this._tempPoint.x, this._tempPoint.y ); - } else if(displayObject.containsPoint) { @@ -27635,7 +27708,7 @@ core.WebGLRenderer.registerPlugin('interaction', InteractionManager); core.CanvasRenderer.registerPlugin('interaction', InteractionManager); -},{"../core":57,"./InteractionData":137,"./interactiveTarget":140}],139:[function(require,module,exports){ +},{"../core":58,"./InteractionData":138,"./interactiveTarget":141}],140:[function(require,module,exports){ /** * @file Main export of the PIXI interactions library * @author Mat Groves @@ -27652,7 +27725,7 @@ interactiveTarget: require('./interactiveTarget') }; -},{"./InteractionData":137,"./InteractionManager":138,"./interactiveTarget":140}],140:[function(require,module,exports){ +},{"./InteractionData":138,"./InteractionManager":139,"./interactiveTarget":141}],141:[function(require,module,exports){ /** * Default property values of interactive objects * Used by {@link PIXI.interaction.InteractionManager} to automatically give all DisplayObjects these properties @@ -27741,7 +27814,7 @@ module.exports = interactiveTarget; -},{}],141:[function(require,module,exports){ +},{}],142:[function(require,module,exports){ var Resource = require('resource-loader').Resource, core = require('../core'), extras = require('../extras'), @@ -27865,7 +27938,7 @@ }; }; -},{"../core":57,"../extras":122,"path":18,"resource-loader":33}],142:[function(require,module,exports){ +},{"../core":58,"../extras":123,"path":18,"resource-loader":33}],143:[function(require,module,exports){ /** * @file Main export of the PIXI loaders library * @author Mat Groves @@ -27886,7 +27959,7 @@ Resource: require('resource-loader').Resource }; -},{"./bitmapFontParser":141,"./loader":143,"./spritesheetParser":144,"./textureParser":145,"resource-loader":33}],143:[function(require,module,exports){ +},{"./bitmapFontParser":142,"./loader":144,"./spritesheetParser":145,"./textureParser":146,"resource-loader":33}],144:[function(require,module,exports){ var ResourceLoader = require('resource-loader'), textureParser = require('./textureParser'), spritesheetParser = require('./spritesheetParser'), @@ -27948,7 +28021,7 @@ Resource.setExtensionXhrType('fnt', Resource.XHR_RESPONSE_TYPE.DOCUMENT); -},{"./bitmapFontParser":141,"./spritesheetParser":144,"./textureParser":145,"resource-loader":33}],144:[function(require,module,exports){ +},{"./bitmapFontParser":142,"./spritesheetParser":145,"./textureParser":146,"resource-loader":33}],145:[function(require,module,exports){ var Resource = require('resource-loader').Resource, path = require('path'), core = require('../core'), @@ -28065,7 +28138,7 @@ }; }; -},{"../core":57,"async":16,"path":18,"resource-loader":33}],145:[function(require,module,exports){ +},{"../core":58,"async":16,"path":18,"resource-loader":33}],146:[function(require,module,exports){ var core = require('../core'); module.exports = function () @@ -28087,7 +28160,7 @@ }; }; -},{"../core":57}],146:[function(require,module,exports){ +},{"../core":58}],147:[function(require,module,exports){ var core = require('../core'), glCore = require('pixi-gl-core'), Shader = require('./webgl/MeshShader'), @@ -28624,7 +28697,7 @@ TRIANGLES: 1 }; -},{"../core":57,"./webgl/MeshShader":150,"pixi-gl-core":1}],147:[function(require,module,exports){ +},{"../core":58,"./webgl/MeshShader":151,"pixi-gl-core":1}],148:[function(require,module,exports){ var Mesh = require('./Mesh'); /** @@ -28749,7 +28822,7 @@ } }; -},{"./Mesh":146}],148:[function(require,module,exports){ +},{"./Mesh":147}],149:[function(require,module,exports){ var Mesh = require('./Mesh'); var core = require('../core'); @@ -28964,7 +29037,7 @@ this.containerUpdateTransform(); }; -},{"../core":57,"./Mesh":146}],149:[function(require,module,exports){ +},{"../core":58,"./Mesh":147}],150:[function(require,module,exports){ /** * @file Main export of the PIXI extras library * @author Mat Groves @@ -28982,8 +29055,8 @@ MeshShader: require('./webgl/MeshShader') }; -},{"./Mesh":146,"./Plane":147,"./Rope":148,"./webgl/MeshShader":150}],150:[function(require,module,exports){ -var Shader = require('pixi-gl-core').GLShader; +},{"./Mesh":147,"./Plane":148,"./Rope":149,"./webgl/MeshShader":151}],151:[function(require,module,exports){ +var Shader = require('../../core/Shader'); /** * @class @@ -28997,7 +29070,6 @@ gl, // vertex shader [ - 'precision lowp float;', 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -29012,8 +29084,6 @@ '}' ].join('\n'), [ - 'precision lowp float;', - 'varying vec2 vTextureCoord;', 'uniform float alpha;', @@ -29032,7 +29102,7 @@ module.exports = MeshShader; -},{"pixi-gl-core":1}],151:[function(require,module,exports){ +},{"../../core/Shader":39}],152:[function(require,module,exports){ var core = require('../core'); /** @@ -29364,7 +29434,7 @@ this._buffers = null; }; -},{"../core":57}],152:[function(require,module,exports){ +},{"../core":58}],153:[function(require,module,exports){ /** * @file Main export of the PIXI extras library * @author Mat Groves @@ -29380,7 +29450,7 @@ ParticleRenderer: require('./webgl/ParticleRenderer') }; -},{"./ParticleContainer":151,"./webgl/ParticleRenderer":154}],153:[function(require,module,exports){ +},{"./ParticleContainer":152,"./webgl/ParticleRenderer":155}],154:[function(require,module,exports){ var glCore = require('pixi-gl-core'), createIndicesForQuads = require('../../core/utils/createIndicesForQuads'); @@ -29601,7 +29671,7 @@ this.staticBuffer.destroy(); }; -},{"../../core/utils/createIndicesForQuads":107,"pixi-gl-core":1}],154:[function(require,module,exports){ +},{"../../core/utils/createIndicesForQuads":108,"pixi-gl-core":1}],155:[function(require,module,exports){ var core = require('../../core'), ParticleShader = require('./ParticleShader'), ParticleBuffer = require('./ParticleBuffer'); @@ -30033,8 +30103,8 @@ this.tempMatrix = null; }; -},{"../../core":57,"./ParticleBuffer":153,"./ParticleShader":155}],155:[function(require,module,exports){ -var Shader = require('pixi-gl-core').GLShader; +},{"../../core":58,"./ParticleBuffer":154,"./ParticleShader":156}],156:[function(require,module,exports){ +var Shader = require('../../core/Shader'); /** * @class @@ -30076,8 +30146,6 @@ ].join('\n'), // hello [ - 'precision lowp float;', - 'varying vec2 vTextureCoord;', 'varying float vColor;', @@ -30101,7 +30169,7 @@ module.exports = ParticleShader; -},{"pixi-gl-core":1}],156:[function(require,module,exports){ +},{"../../core/Shader":39}],157:[function(require,module,exports){ // References: // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign @@ -30117,7 +30185,7 @@ }; } -},{}],157:[function(require,module,exports){ +},{}],158:[function(require,module,exports){ // References: // https://github.com/sindresorhus/object-assign // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign @@ -30127,7 +30195,7 @@ Object.assign = require('object-assign'); } -},{"object-assign":28}],158:[function(require,module,exports){ +},{"object-assign":28}],159:[function(require,module,exports){ require('./Object.assign'); require('./requestAnimationFrame'); require('./Math.sign'); @@ -30145,7 +30213,7 @@ window.Uint16Array = Array; } -},{"./Math.sign":156,"./Object.assign":157,"./requestAnimationFrame":159}],159:[function(require,module,exports){ +},{"./Math.sign":157,"./Object.assign":158,"./requestAnimationFrame":160}],160:[function(require,module,exports){ (function (global){ // References: // http://paulirish.com/2011/requestanimationframe-for-smart-animating/ @@ -30215,6 +30283,6 @@ } }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}]},{},[136])(136) +},{}]},{},[137])(137) }); //# sourceMappingURL=pixi.js.map diff --git a/bin/pixi.js.map b/bin/pixi.js.map index d916c18..7c3bf99 100644 --- a/bin/pixi.js.map +++ b/bin/pixi.js.map @@ -1 +1 @@ -{"version":3,"names":[],"mappings":"","sources":["pixi.js"],"sourcesContent":["(function(f){if(typeof exports===\"object\"&&typeof module!==\"undefined\"){module.exports=f()}else if(typeof define===\"function\"&&define.amd){define([],f)}else{var g;if(typeof window!==\"undefined\"){g=window}else if(typeof global!==\"undefined\"){g=global}else if(typeof self!==\"undefined\"){g=self}else{g=this}g.PIXI = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o= data.byteLength)\n\t{\n\t\tgl.bufferSubData(this.type, offset, data);\n\t}\n\telse\n\t{\n\t\tgl.bufferData(this.type, data, this.drawType);\n\t}\n\n\tthis.data = data;\n}\n/**\n * Binds the buffer\n *\n */\nBuffer.prototype.bind = function()\n{\n\tvar gl = this.gl;\n\tgl.bindBuffer(this.type, this.buffer);\n}\n\nBuffer.createVertexBuffer = function(gl, data, drawType)\n{\n\treturn new Buffer(gl, gl.ARRAY_BUFFER, data, drawType);\n}\n\nBuffer.createIndexBuffer = function(gl, data, drawType)\n{\n\treturn new Buffer(gl, gl.ELEMENT_ARRAY_BUFFER, data, drawType);\n}\n\nBuffer.create = function(gl, type, data, drawType)\n{\n\treturn new Buffer(gl, type, drawType);\n}\n\n/**\n * Destroys the buffer\n *\n */\nBuffer.prototype.destroy = function(){\n\tthis.gl.deleteBuffer(this.buffer);\n}\n\nmodule.exports = Buffer;\n\n},{}],3:[function(require,module,exports){\n\nvar Texture = require('./GLTexture');\n\n/**\n * Helper class to create a webGL Framebuffer\n *\n * @class\n * @memberof pixi.gl\n * @param gl {WebGLRenderingContext} The current WebGL rendering context\n * @param width {Number} the width of the drawing area of the frame buffer\n * @param height {Number} the height of the drawing area of the frame buffer\n */\nvar Framebuffer = function(gl, width, height)\n{\n\t/**\n * The current WebGL rendering context\n *\n * @member {WebGLRenderingContext}\n */\n\tthis.gl = gl;\n\n\t/**\n * The frame buffer\n *\n * @member {WebGLFramebuffer}\n */\n\tthis.framebuffer = gl.createFramebuffer();\n\n\t/**\n * The stencil buffer\n *\n * @member {WebGLRenderbuffer}\n */\n\tthis.stencil = null;\n\n\t/**\n * The stencil buffer\n *\n * @member {GLTexture}\n */\n\tthis.texture = null;\n\n\t/**\n * The width of the drawing area of the buffer\n *\n * @member {Number}\n */\n\tthis.width = width || 100;\n\t/**\n * The height of the drawing area of the buffer\n *\n * @member {Number}\n */\n\tthis.height = height || 100;\n}\n\n/**\n * Adds a texture to the frame buffer\n * @param texture {GLTexture}\n */\nFramebuffer.prototype.enableTexture = function(texture)\n{\n\tvar gl = this.gl;\n\n\tthis.texture = texture || new Texture(gl);\n\n\tthis.texture.bind();\n\n\t//gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this.width, this.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);\n\n\tthis.bind();\n\n\tgl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture.texture, 0);\n}\n\n/**\n * Initialises the stencil buffer\n * @mat maybe you can come up with a better explaination\n */\nFramebuffer.prototype.enableStencil = function()\n{\n\tif(this.stencil)return;\n\n\tvar gl = this.gl;\n\n\tthis.stencil = gl.createRenderbuffer();\n\n gl.bindRenderbuffer(gl.RENDERBUFFER, this.stencil);\n\n // TODO.. this is depth AND stencil?\n gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, this.stencil);\n gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, this.width , this.height );\n}\n\n/**\n * Erases the drawing area and fills it with a colour\n * @param r {Number} the red value of the clearing colour\n * @param g {Number} the green value of the clearing colour\n * @param b {Number} the blue value of the clearing colour\n * @param a {Number} the alpha value of the clearing colour\n */\nFramebuffer.prototype.clear = function( r, g, b, a )\n{\n\tthis.bind();\n\n\tvar gl = this.gl;\n\n gl.clearColor(r, g, b, a);\n gl.clear(gl.COLOR_BUFFER_BIT);\n}\n\n/**\n * Binds the frame buffer to the WebGL context\n */\nFramebuffer.prototype.bind = function()\n{\n\tvar gl = this.gl;\n\n\tif(this.texture)\n\t{\n\t\tthis.texture.unbind();\n\t}\n\n\tgl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer );\n}\n\n/**\n * Unbinds the frame buffer to the WebGL context\n */\nFramebuffer.prototype.unbind = function()\n{\n\tvar gl = this.gl;\n\tgl.bindFramebuffer(gl.FRAMEBUFFER, null );\t\n}\n/**\n * Resizes the drawing area of the buffer to the given width and height\n * @param width {Number} the new width\n * @param height {Number} the new height\n */\nFramebuffer.prototype.resize = function(width, height)\n{\n\tvar gl = this.gl;\n\n\tthis.width = width;\n\tthis.height = height;\n\n\tif ( this.texture )\n {\n \tthis.texture.uploadData(null, width, height);\n\t}\n\n\tif ( this.stencil )\n {\n // update the stencil buffer width and height\n gl.bindRenderbuffer(gl.RENDERBUFFER, this.stencil);\n gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);\n }\n}\n\n/**\n * Destroys this buffer\n */\nFramebuffer.prototype.destroy = function()\n{\n\tvar gl = this.gl;\n\n\t//TODO\n\tif(this.texture)\n\t{\n\t\tthis.texture.destroy();\n\t}\n\n\tgl.deleteFramebuffer(this.framebuffer);\n\n\tthis.gl = null;\n\n\tthis.stencil = null;\n\tthis.texture = null;\n}\n\n/**\n * Creates a frame buffer with a texture containing the given data\n * @mat can you confirm ? :)\n * @static\n * @param gl {WebGLRenderingContext} The current WebGL rendering context\n * @param width {Number} the width of the drawing area of the frame buffer\n * @param height {Number} the height of the drawing area of the frame buffer\n * @param data {ArrayBuffer| SharedArrayBuffer|ArrayBufferView} an array of data\n */\nFramebuffer.createRGBA = function(gl, width, height, data)\n{\n\tvar texture = Texture.fromData(gl, null, width, height);\n\ttexture.enableNearestScaling();\n texture.enableWrapClamp();\n\n //now create the framebuffer object and attach the texture to it.\n var fbo = new Framebuffer(gl, width, height);\n fbo.enableTexture(texture);\n\n fbo.unbind();\n\n return fbo;\n}\n\n/**\n * Creates a frame buffer with a texture containing the given data\n * @mat not sure what the difference is with the method above ?\n * @static\n * @param gl {WebGLRenderingContext} The current WebGL rendering context\n * @param width {Number} the width of the drawing area of the frame buffer\n * @param height {Number} the height of the drawing area of the frame buffer\n * @param data {ArrayBuffer| SharedArrayBuffer|ArrayBufferView} an array of data\n */\nFramebuffer.createFloat32 = function(gl, width, height, data)\n{\n\t// create a new texture..\n var texture = new Texture.fromData(gl, data, width, height);\n texture.enableNearestScaling();\n texture.enableWrapClamp();\n\n //now create the framebuffer object and attach the texture to it.\n var fbo = new Framebuffer(gl, width, height);\n fbo.enableTexture(texture)\n\n fbo.unbind();\n\n return fbo;\n}\n\nmodule.exports = Framebuffer;\n\n},{\"./GLTexture\":5}],4:[function(require,module,exports){\n\nvar compileProgram = require('./shader/compileProgram'),\n\textractAttributes = require('./shader/extractAttributes'),\n\textractUniforms = require('./shader/extractUniforms'),\n\tgenerateUniformAccessObject = require('./shader/generateUniformAccessObject');\n\n/**\n * Helper class to create a webGL Shader\n *\n * @class\n * @memberof pixi.gl\n * @param gl {WebGLRenderingContext}\n * @param vertexSrc {string|string[]} The vertex shader source as an array of strings.\n * @param fragmentSrc {string|string[]} The fragment shader source as an array of strings.\n */\nvar Shader = function(gl, vertexSrc, fragmentSrc)\n{\n\t/**\n\t * The current WebGL rendering context\n\t *\n\t * @member {WebGLRenderingContext}\n\t */\n\tthis.gl = gl;\n\n\t/**\n\t * The shader program\n\t *\n\t * @member {WebGLProgram}\n\t */\n\t// First compile the program..\n\tthis.program = compileProgram(gl, vertexSrc, fragmentSrc);\n\n\t/**\n\t * The attributes of the shader as an object containing the following properties\n\t * {\n\t * \ttype,\n\t * \tsize,\n\t * \tlocation,\n\t * \tpointer\n\t * }\n\t * @member {Object}\n\t */\n\t// next extract the attributes\n\tthis.attributes = extractAttributes(gl, this.program);\n\n var uniformData = extractUniforms(gl, this.program);\n\n\t/**\n\t * The uniforms of the shader as an object containing the following properties\n\t * {\n\t * \tgl,\n\t * \tdata\n\t * }\n\t * @member {Object}\n\t */\n this.uniforms = generateUniformAccessObject( gl, uniformData );\n}\n/**\n * Uses this shader\n */\nShader.prototype.bind = function()\n{\n\tthis.gl.useProgram(this.program);\n}\n\n/**\n * Destroys this shader\n * TODO\n */\nShader.prototype.destroy = function()\n{\n\tvar gl = this.gl;\n}\n\nmodule.exports = Shader;\n\n},{\"./shader/compileProgram\":9,\"./shader/extractAttributes\":11,\"./shader/extractUniforms\":12,\"./shader/generateUniformAccessObject\":13}],5:[function(require,module,exports){\n\n/**\n * Helper class to create a WebGL Texture\n *\n * @class\n * @memberof pixi.gl\n * @param gl {WebGLRenderingContext} The current WebGL context\n * @param width {number} the width of the texture\n * @param height {number} the height of the texture\n * @param format {number} the pixel format of the texture. defaults to gl.RGBA\n * @param type {number} the gl type of the texture. defaults to gl.UNSIGNED_BYTE\n */\nvar Texture = function(gl, width, height, format, type)\n{\n\t/**\n\t * The current WebGL rendering context\n\t *\n\t * @member {WebGLRenderingContext}\n\t */\n\tthis.gl = gl;\n\n\n\t/**\n\t * The WebGL texture\n\t *\n\t * @member {WebGLTexture}\n\t */\n\tthis.texture = gl.createTexture();\n\n\t/**\n\t * If mipmapping was used for this texture, enable and disable with enableMipmap()\n\t *\n\t * @member {Boolean}\n\t */\n\t// some settings..\n\tthis.mipmap = false;\n\n\n\t/**\n\t * Set to true to enable pre-multiplied alpha\n\t *\n\t * @member {Boolean}\n\t */\n\tthis.premultiplyAlpha = false;\n\n\t/**\n\t * The width of texture\n\t *\n\t * @member {Number}\n\t */\n\tthis.width = width || 0;\n\t/**\n\t * The height of texture\n\t *\n\t * @member {Number}\n\t */\n\tthis.height = height || 0;\n\n\t/**\n\t * The pixel format of the texture. defaults to gl.RGBA\n\t *\n\t * @member {Number}\n\t */\n\tthis.format = format || gl.RGBA;\n\n\t/**\n\t * The gl type of the texture. defaults to gl.UNSIGNED_BYTE\n\t *\n\t * @member {Number}\n\t */\n\tthis.type = type || gl.UNSIGNED_BYTE;\n\n\n}\n\n/**\n * Uploads this texture to the GPU\n * @param source {HTMLImageElement|ImageData|HTMLVideoElement} the source image of the texture\n */\nTexture.prototype.upload = function(source)\n{\n\tthis.bind();\n\n\tvar gl = this.gl;\n\n\t// if the source is a video, we need to use the videoWidth / videoHeight properties as width / height will be incorrect.\n\tthis.width = source.videoWidth || source.width;\n\tthis.height = source.videoHeight || source.height;\n\n\tgl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.premultiplyAlpha);\n gl.texImage2D(gl.TEXTURE_2D, 0, this.format, this.format, this.type, source);\n}\n\nvar FLOATING_POINT_AVAILABLE = false;\n\n/**\n * Use a data source and uploads this texture to the GPU\n * @param data {TypedArray} the data to upload to the texture\n * @param width {number} the new width of the texture\n * @param height {number} the new height of the texture\n */\nTexture.prototype.uploadData = function(data, width, height)\n{\n\tthis.bind();\n\n\tvar gl = this.gl;\n\n\tthis.width = width || this.width;\n\tthis.height = height || this.height;\n\n\tif(data instanceof Float32Array)\n\t{\n\t\tif(!FLOATING_POINT_AVAILABLE)\n\t\t{\n\t\t\tvar ext = gl.getExtension(\"OES_texture_float\");\n\n\t\t\tif(ext)\n\t\t\t{\n\t\t\t\tFLOATING_POINT_AVAILABLE = true;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tthrow new Error('floating point textures not available');\n\t\t\t}\n\t\t}\n\n\t\tthis.type = gl.FLOAT;\n\t}\n\telse\n\t{\n\t\t// TODO support for other types\n\t\tthis.type = gl.UNSIGNED_BYTE;\n\t}\n\n\n\n\t// what type of data?\n\tgl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.premultiplyAlpha);\n\tgl.texImage2D(gl.TEXTURE_2D, 0, this.format, this.width, this.height, 0, this.format, this.type, data || null);\n\n}\n\n/**\n * Binds the texture\n * @param location {@mat}\n */\nTexture.prototype.bind = function(location)\n{\n\tvar gl = this.gl;\n\n\tif(location !== undefined)\n\t{\n\t\tgl.activeTexture(gl.TEXTURE0 + location);\n\t}\n\n\tgl.bindTexture(gl.TEXTURE_2D, this.texture);\n}\n\n/**\n * Unbinds the texture\n */\nTexture.prototype.unbind = function()\n{\n\tvar gl = this.gl;\n\tgl.bindTexture(gl.TEXTURE_2D, null);\n}\n\n/**\n * @mat\n * @param linear {Boolean} if we want to use linear filtering or nearest neighbour interpolation\n */\nTexture.prototype.minFilter = function( linear )\n{\n\tvar gl = this.gl;\n\n\tthis.bind();\n\n\tif(this.mipmap)\n\t{\n\t\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, linear ? gl.LINEAR_MIPMAP_LINEAR : gl.NEAREST_MIPMAP_NEAREST);\n\t}\n\telse\n\t{\n\t\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, linear ? gl.LINEAR : gl.NEAREST);\n\t}\n}\n\n/**\n * @mat\n * @param linear {Boolean} if we want to use linear filtering or nearest neighbour interpolation\n */\nTexture.prototype.magFilter = function( linear )\n{\n\tvar gl = this.gl;\n\n\tthis.bind();\n\n\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, linear ? gl.LINEAR : gl.NEAREST);\n}\n\n/**\n * Enables mipmapping\n */\nTexture.prototype.enableMipmap = function()\n{\n\tvar gl = this.gl;\n\n\tthis.bind();\n\n\tthis.mipmap = true;\n\n\tgl.generateMipmap(gl.TEXTURE_2D);\n}\n\n/**\n * Enables linear filtering\n */\nTexture.prototype.enableLinearScaling = function()\n{\n\tthis.minFilter(true);\n\tthis.magFilter(true);\n}\n\n/**\n * Enables nearest neighbour interpolation\n */\nTexture.prototype.enableNearestScaling = function()\n{\n\tthis.minFilter(false);\n\tthis.magFilter(false);\n}\n\n/**\n * Enables clamping on the texture so WebGL will not repeat it\n */\nTexture.prototype.enableWrapClamp = function()\n{\n\tvar gl = this.gl;\n\n\tthis.bind();\n\n\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n}\n\n/**\n * Enable tiling on the texture\n */\nTexture.prototype.enableWrapRepeat = function()\n{\n\tvar gl = this.gl;\n\n\tthis.bind();\n\n\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);\n}\n\n/**\n * @mat\n */\nTexture.prototype.enableWrapMirrorRepeat = function()\n{\n\tvar gl = this.gl;\n\n\tthis.bind();\n\n\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.MIRRORED_REPEAT);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.MIRRORED_REPEAT);\n}\n\n\n/**\n * Destroys this texture\n */\nTexture.prototype.destroy = function()\n{\n\tvar gl = this.gl;\n\t//TODO\n\tgl.deleteTexture(this.texture);\n}\n\n/**\n * @static\n * @param gl {WebGLRenderingContext} The current WebGL context\n * @param source {HTMLImageElement|ImageData} the source image of the texture\n * @param premultiplyAlpha {Boolean} If we want to use pre-multiplied alpha\n */\nTexture.fromSource = function(gl, source, premultiplyAlpha)\n{\n\tvar texture = new Texture(gl);\n\ttexture.premultiplyAlpha = premultiplyAlpha || false;\n\ttexture.upload(source);\n\n\treturn texture;\n}\n\n/**\n * @static\n * @param gl {WebGLRenderingContext} The current WebGL context\n * @param data {TypedArray} the data to upload to the texture\n * @param width {number} the new width of the texture\n * @param height {number} the new height of the texture\n */\nTexture.fromData = function(gl, data, width, height)\n{\n\t//console.log(data, width, height);\n\tvar texture = new Texture(gl);\n\ttexture.uploadData(data, width, height);\n\n\treturn texture;\n}\n\n\nmodule.exports = Texture;\n\n},{}],6:[function(require,module,exports){\n\n// state object//\nvar setVertexAttribArrays = require( './setVertexAttribArrays' );\n\n/**\n * Helper class to work with WebGL VertexArrayObjects (vaos)\n * Only works if WebGL extensions are enabled (they usually are)\n *\n * @class\n * @memberof pixi.gl\n * @param gl {WebGLRenderingContext} The current WebGL rendering context\n */\nfunction VertexArrayObject(gl, state)\n{\n\n\tthis.nativeVaoExtension = (\n gl.getExtension('OES_vertex_array_object') ||\n gl.getExtension('MOZ_OES_vertex_array_object') ||\n gl.getExtension('WEBKIT_OES_vertex_array_object')\n );\n\n\tthis.nativeState = state;\n\n\tif(this.nativeVaoExtension)\n\t{\n\t\tthis.nativeVao = this.nativeVaoExtension.createVertexArrayOES();\n\t\t\n\t\tvar maxAttribs = gl.getParameter(gl.MAX_VERTEX_ATTRIBS);\n\t\t\n\t\t// VAO - overwrite the state..\n\t\tthis.nativeState = {tempAttribState:new Array(maxAttribs)\n\t\t\t\t\t\t\t,attribState:new Array(maxAttribs)};\n\t}\n\n\t/**\n\t * The current WebGL rendering context\n\t *\n\t * @member {WebGLRenderingContext}\n\t */\n\tthis.gl = gl;\n\n\t/**\n\t * An array of attributes ? @mat\n\t *\n\t * @member {Array}\n\t */\n\tthis.attributes = [];\n\n\t/**\n\t * @mat\n\t *\n\t * @member {Array}\n\t */\n\tthis.indexBuffer = null;\n\n\t/**\n\t * A boolean flag\n\t *\n\t * @member {Boolean}\n\t */\n\tthis.dirty = false;\n}\n\nVertexArrayObject.prototype.constructor = VertexArrayObject;\nmodule.exports = VertexArrayObject;\n\n\n/**\n * Binds the buffer\n */\nVertexArrayObject.prototype.bind = function()\n{\n\tif(this.nativeVao)\n\t{\n\t\tthis.nativeVaoExtension.bindVertexArrayOES(this.nativeVao);\n\n\t\tif(this.dirty)\n\t\t{\n\t\t\tthis.dirty = false;\n\t\t\tthis.activate();\n\t\t}\n\t}\n\telse\n\t{\n\t\t\n\t\tthis.activate();\n\t}\n\n\treturn this;\n}\n\n/**\n * Unbinds the buffer\n */\nVertexArrayObject.prototype.unbind = function()\n{\n\tif(this.nativeVao)\n\t{\n\t\tthis.nativeVaoExtension.bindVertexArrayOES(null);\n\t}\n\n\treturn this;\n}\n\n/**\n * Uses this vao\n */\nVertexArrayObject.prototype.activate = function()\n{\n\t\n\tvar gl = this.gl;\n\tvar lastBuffer = null;\n\n\tfor (var i = 0; i < this.attributes.length; i++)\n\t{\n\t\tvar attrib = this.attributes[i];\n\n\t\tif(lastBuffer !== attrib.buffer)\n\t\t{\n\t\t\tattrib.buffer.bind();\n\t\t\tlastBuffer = attrib.buffer;\n\t\t}\n\n\t\t//attrib.attribute.pointer(attrib.type, attrib.normalized, attrib.stride, attrib.start);\n\t\tgl.vertexAttribPointer(attrib.attribute.location,\n\t\t\t\t\t\t\t attrib.attribute.size, attrib.type || gl.FLOAT,\n\t\t\t\t\t\t\t attrib.normalized || false,\n\t\t\t\t\t\t\t attrib.stride || 0,\n\t\t\t\t\t\t\t attrib.start || 0);\n\n\n\t};\n\n\tsetVertexAttribArrays(gl, this.attributes, this.nativeState);\n\t\n\tthis.indexBuffer.bind();\n\n\treturn this;\n}\n\n/**\n *\n * @param buffer {WebGLBuffer}\n * @param attribute {[type]}\n * @param type {[type]}\n * @param normalized {[type]}\n * @param stride {Number}\n * @param start {Number}\n */\nVertexArrayObject.prototype.addAttribute = function(buffer, attribute, type, normalized, stride, start)\n{\n this.attributes.push({\n \tbuffer: \tbuffer,\n \tattribute: \tattribute,\n\n \tlocation: \tattribute.location,\n\t \ttype: \t\ttype || this.gl.FLOAT,\n\t \tnormalized: normalized || false,\n\t \tstride: \tstride || 0,\n\t \tstart: \t\tstart || 0\n\t})\n\n\tthis.dirty = true;\n\n\treturn this;\n}\n\n/**\n *\n * @param buffer {WebGLBuffer}\n * @param options {Object}\n */\nVertexArrayObject.prototype.addIndex = function(buffer, options)\n{\n this.indexBuffer = buffer;\n\n this.dirty = true;\n\n return this;\n}\n\n/**\n * Unbinds this vao and disables it\n */\nVertexArrayObject.prototype.clear = function()\n{\n\tvar gl = this.gl;\n\n\t// TODO - should this function unbind after clear?\n\t// for now, no but lets see what happens in the real world!\n\tif(this.nativeVao)\n\t{\n\t\tthis.nativeVaoExtension.bindVertexArrayOES(this.nativeVao);\n\t}\n\n\tthis.attributes.length = 0;\n\tthis.indexBuffer = null;\n\n\treturn this;\n}\n\n/**\n * @mat\n * @param type {Number}\n * @param size {Number}\n * @param start {Number}\n */\nVertexArrayObject.prototype.draw = function(type, size, start)\n{\n\tvar gl = this.gl;\n\tgl.drawElements(type, size, gl.UNSIGNED_SHORT, start || 0);\n\n\treturn this;\n}\n\n},{\"./setVertexAttribArrays\":8}],7:[function(require,module,exports){\n\n/**\n * Helper class to create a webGL Context\n *\n * @class\n * @memberof pixi.gl\n * @param canvas {HTMLCanvasElement} the canvas element that we will get the context from\n * @param options {Object} An options object that gets passed in to the canvas element containing the context attributes,\n * see https://developer.mozilla.org/en/docs/Web/API/HTMLCanvasElement/getContext for the options available\n * @return {WebGLRenderingContext} the WebGL context\n */\nvar createContext = function(canvas, options)\n{\n var gl = canvas.getContext('webgl', options) || \n \t canvas.getContext('experimental-webgl', options);\n\n if (!gl)\n {\n // fail, not able to get a context\n throw new Error('This browser does not support webGL. Try using the canvas renderer');\n }\n\n return gl;\n}\n\nmodule.exports = createContext;\n\n},{}],8:[function(require,module,exports){\nvar GL_MAP = {};\n\n/**\n * @mat\n * @param gl {WebGLRenderingContext} The current WebGL context\n * @param attribs {[type]}\n */\nvar setVertexAttribArrays = function (gl, attribs, state)\n{\n\n if(state)\n {\n\n var i,\n tempAttribState = state.tempAttribState,\n attribState = state.attribState;\n\n for (i = 0; i < tempAttribState.length; i++)\n {\n tempAttribState[i] = false;\n }\n\n // set the new attribs\n for (i in attribs)\n {\n tempAttribState[attribs[i].attribute.location] = true;\n }\n\n for (i = 0; i < attribState.length; i++)\n {\n if (attribState[i] !== tempAttribState[i])\n {\n attribState[i] = tempAttribState[i];\n\n if (state.attribState[i])\n {\n gl.enableVertexAttribArray(i);\n }\n else\n {\n gl.disableVertexAttribArray(i);\n }\n }\n }\n\n }\n else\n {\n for (var i = 0; i < attribs.length; i++)\n {\n var attrib = attribs[i];\n gl.enableVertexAttribArray(attrib.attribute.location);\n }\n }\n};\n\nmodule.exports = setVertexAttribArrays;\n\n},{}],9:[function(require,module,exports){\n\n/**\n *\n * @param gl {WebGLRenderingContext} The current WebGL context {WebGLProgram}\n * @param vertexSrc {string|string[]} The vertex shader source as an array of strings.\n * @param fragmentSrc {string|string[]} The fragment shader source as an array of strings.\n * @return {WebGLProgram} the shader program\n */\ncompileProgram = function(gl, vertexSrc, fragmentSrc)\n{\n var glVertShader = compileShader(gl, gl.VERTEX_SHADER, vertexSrc);\n var glFragShader = compileShader(gl, gl.FRAGMENT_SHADER, fragmentSrc);\n\n var program = gl.createProgram();\n\n gl.attachShader(program, glVertShader);\n gl.attachShader(program, glFragShader);\n gl.linkProgram(program);\n\n // if linking fails, then log and cleanup\n if (!gl.getProgramParameter(program, gl.LINK_STATUS))\n {\n console.error('Pixi.js Error: Could not initialize shader.');\n console.error('gl.VALIDATE_STATUS', gl.getProgramParameter(program, gl.VALIDATE_STATUS));\n console.error('gl.getError()', gl.getError());\n\n // if there is a program info log, log it\n if (gl.getProgramInfoLog(program) !== '')\n {\n console.warn('Pixi.js Warning: gl.getProgramInfoLog()', gl.getProgramInfoLog(program));\n }\n\n gl.deleteProgram(program);\n program = null;\n }\n\n // clean up some shaders\n gl.deleteShader(glVertShader);\n gl.deleteShader(glFragShader);\n\n return program;\n}\n\n/**\n *\n * @param gl {WebGLRenderingContext} The current WebGL context {WebGLProgram}\n * @param type {Number} the type, can be either VERTEX_SHADER or FRAGMENT_SHADER\n * @param vertexSrc {string|string[]} The vertex shader source as an array of strings.\n * @return {WebGLShader} the shader\n */\nvar compileShader = function (gl, type, src)\n{\n var shader = gl.createShader(type);\n\n gl.shaderSource(shader, src);\n gl.compileShader(shader);\n\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS))\n {\n console.log(gl.getShaderInfoLog(shader));\n return null;\n }\n\n return shader;\n};\n\nmodule.exports = compileProgram;\n\n},{}],10:[function(require,module,exports){\n\n\nvar defaultValue = function(type, size) \n{\n switch (type)\n {\n case 'float':\n return 0;\n\n case 'vec2': \n return new Float32Array(2 * size);\n\n case 'vec3':\n return new Float32Array(3 * size);\n\n case 'vec4': \n return new Float32Array(4 * size);\n \n case 'int':\n case 'sampler2D':\n return 0;\n\n case 'ivec2': \n return new Int32Array(2 * size);\n\n case 'ivec3':\n return new Int32Array(3 * size);\n\n case 'ivec4': \n return new Int32Array(4 * size);\n\n case 'bool': \n return false;\n\n case 'bvec2':\n\n return booleanArray( 2 * size);\n\n case 'bvec3':\n return booleanArray(3 * size);\n\n case 'bvec4':\n return booleanArray(4 * size);\n\n case 'mat2':\n return new Float32Array([1, 0\n ,0, 1]);\n\n case 'mat3': \n return new Float32Array([1, 0, 0\n ,0, 1, 0\n ,0, 0, 1]);\n\n case 'mat4':\n return new Float32Array([1, 0, 0, 0\n ,0, 1, 0, 0\n ,0, 0, 1, 0\n ,0, 0, 0, 1]);\n }\n}\n\nvar booleanArray = function(size)\n{\n var array = new Array(size);\n\n for (var i = 0; i < array.length; i++) \n {\n array[i] = false;\n };\n\n return array;\n}\n\nmodule.exports = defaultValue;\n\n},{}],11:[function(require,module,exports){\n\nvar mapType = require('./mapType');\nvar mapSize = require('./mapSize');\n\n/**\n * Extracts the attributes\n * @param gl {WebGLRenderingContext} The current WebGL rendering context\n * @param program {WebGLProgram} The shader program to get the attributes from\n * @return attributes {Object}\n */\nvar extractAttributes = function(gl, program)\n{\n var attributes = {};\n\n var totalAttributes = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES)\n\n for (var i = 0; i < totalAttributes; i++)\n {\n var attribData = gl.getActiveAttrib(program, i);\n var type = mapType(gl, attribData.type);\n\n attributes[attribData.name] = {\n type:type,\n size:mapSize(type),\n location:gl.getAttribLocation(program, attribData.name),\n //TODO - make an attribute object\n pointer:function(type, normalized, stride, start){\n\n // console.log(this.location)\n gl.vertexAttribPointer(this.location,this.size, type || gl.FLOAT, normalized || false, stride || 0, start || 0);\n\n }\n }\n };\n\n return attributes;\n}\n\nmodule.exports = extractAttributes;\n\n},{\"./mapSize\":14,\"./mapType\":15}],12:[function(require,module,exports){\nvar mapType = require('./mapType');\nvar defaultValue = require('./defaultValue');\n\n/**\n * Extracts the uniforms\n * @param gl {WebGLRenderingContext} The current WebGL rendering context\n * @param program {WebGLProgram} The shader program to get the uniforms from\n * @return uniforms {Object}\n */\nvar extractUniforms = function(gl, program)\n{\n\tvar uniforms = {};\n\n var totalUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS)\n\n for (var i = 0; i < totalUniforms; i++)\n {\n \tvar uniformData = gl.getActiveUniform(program, i);\n \tvar name = uniformData.name.replace(/\\[.*?\\]/, \"\");\n var type = mapType(gl, uniformData.type );\n\n \tuniforms[name] = {\n \t\ttype:type,\n \t\tsize:uniformData.size,\n \t\tlocation:gl.getUniformLocation(program, name),\n \t\tvalue:defaultValue(type, uniformData.size)\n \t}\n };\n\n\treturn uniforms;\n}\n\nmodule.exports = extractUniforms;\n\n},{\"./defaultValue\":10,\"./mapType\":15}],13:[function(require,module,exports){\n/**\n * Extracts the attributes\n * @param gl {WebGLRenderingContext} The current WebGL rendering context\n * @param uniforms {Array} @mat ?\n * @return attributes {Object}\n */\nvar generateUniformAccessObject = function(gl, uniformData)\n{\n // this is the object we will be sending back.\n // an object hierachy will be created for structs\n var uniforms = {data:{}};\n\n uniforms.gl = gl;\n\n var uniformKeys= Object.keys(uniformData);\n\n for (var i = 0; i < uniformKeys.length; i++)\n {\n var fullName = uniformKeys[i]\n\n var nameTokens = fullName.split('.');\n var name = nameTokens[nameTokens.length - 1];\n\n var uniformGroup = getUniformGroup(nameTokens, uniforms);\n\n var uniform = uniformData[fullName];\n uniformGroup.data[name] = uniform;\n\n uniformGroup.gl = gl;\n\n Object.defineProperty(uniformGroup, name, {\n get: generateGetter(name),\n set: generateSetter(name, uniform)\n })\n };\n\n return uniforms;\n}\n\nvar generateGetter = function(name)\n{\n\tvar template = getterTemplate.replace('%%', name);\n\treturn new Function(template);\n}\n\nvar generateSetter = function(name, uniform)\n{\n var template = setterTemplate.replace(/%%/g, name);\n var setTemplate\n\n if(uniform.size === 1)\n {\n setTemplate = GLSL_TO_SINGLE_SETTERS[uniform.type];\n }\n else\n {\n setTemplate = GLSL_TO_ARRAY_SETTERS[uniform.type];\n }\n\n if(setTemplate)\n {\n template += \"\\nthis.gl.\" + setTemplate + \";\";\n }\n\n \treturn new Function('value', template);\n}\n\nvar getUniformGroup = function(nameTokens, uniform)\n{\n var cur = uniform;\n\n for (var i = 0; i < nameTokens.length - 1; i++)\n {\n var o = cur[nameTokens[i]] || {data:{}};\n cur[nameTokens[i]] = o;\n cur = o;\n };\n\n return cur\n}\n\nvar getterTemplate = [\n 'return this.data.%%.value;',\n].join('\\n');\n\nvar setterTemplate = [\n 'this.data.%%.value = value;',\n 'var location = this.data.%%.location;'\n].join('\\n');\n\n\nvar GLSL_TO_SINGLE_SETTERS = {\n\n 'float': 'uniform1f(location, value)',\n\n 'vec2': 'uniform2f(location, value[0], value[1])',\n 'vec3': 'uniform3f(location, value[0], value[1], value[2])',\n 'vec4': 'uniform4f(location, value[0], value[1], value[2], value[3])',\n\n 'int': 'uniform1i(location, value)',\n 'ivec2': 'uniform2i(location, value[0], value[1])',\n 'ivec3': 'uniform3i(location, value[0], value[1], value[2])',\n 'ivec4': 'uniform4i(location, value[0], value[1], value[2], value[3])',\n\n 'bool': 'uniform1i(location, value)',\n 'bvec2': 'uniform2i(location, value[0], value[1])',\n 'bvec3': 'uniform3i(location, value[0], value[1], value[2])',\n 'bvec4': 'uniform4i(location, value[0], value[1], value[2], value[3])',\n\n 'mat2': 'uniformMatrix2fv(location, false, value)',\n 'mat3': 'uniformMatrix3fv(location, false, value)',\n 'mat4': 'uniformMatrix4fv(location, false, value)',\n\n 'sampler2D':'uniform1i(location, value)'\n}\n\nvar GLSL_TO_ARRAY_SETTERS = {\n\n 'float': 'uniform1fv(location, value)',\n\n 'vec2': 'uniform2fv(location, value)',\n 'vec3': 'uniform3fv(location, value)',\n 'vec4': 'uniform4fv(location, value)',\n\n 'int': 'uniform1iv(location, value)',\n 'ivec2': 'uniform2iv(location, value)',\n 'ivec3': 'uniform3iv(location, value)',\n 'ivec4': 'uniform4iv(location, value)',\n\n 'bool': 'uniform1iv(location, value)',\n 'bvec2': 'uniform2iv(location, value)',\n 'bvec3': 'uniform3iv(location, value)',\n 'bvec4': 'uniform4iv(location, value)',\n\n 'sampler2D':'uniform1iv(location, value)'\n}\n\nmodule.exports = generateUniformAccessObject;\n\n},{}],14:[function(require,module,exports){\n\n\nvar mapSize = function(type) \n{ \n return GLSL_TO_SIZE[type];\n}\n\n\nvar GLSL_TO_SIZE = {\n 'float': 1,\n 'vec2': 2,\n 'vec3': 3,\n 'vec4': 4,\n\n 'int': 1,\n 'ivec2': 2,\n 'ivec3': 3,\n 'ivec4': 4,\n\n 'bool': 1,\n 'bvec2': 2,\n 'bvec3': 3,\n 'bvec4': 4,\n\n 'mat2': 4,\n 'mat3': 9,\n 'mat4': 16,\n\n 'sampler2D': 1\n}\n\nmodule.exports = mapSize;\n\n},{}],15:[function(require,module,exports){\n\n\nvar mapSize = function(gl, type) \n{\n if(!GL_TABLE) \n {\n var typeNames = Object.keys(GL_TO_GLSL_TYPES);\n\n GL_TABLE = {};\n\n for(var i = 0; i < typeNames.length; ++i) \n {\n var tn = typeNames[i];\n GL_TABLE[ gl[tn] ] = GL_TO_GLSL_TYPES[tn];\n }\n }\n\n return GL_TABLE[type];\n}\n\nvar GL_TABLE = null;\n\nvar GL_TO_GLSL_TYPES = {\n 'FLOAT': 'float',\n 'FLOAT_VEC2': 'vec2',\n 'FLOAT_VEC3': 'vec3',\n 'FLOAT_VEC4': 'vec4',\n\n 'INT': 'int',\n 'INT_VEC2': 'ivec2',\n 'INT_VEC3': 'ivec3',\n 'INT_VEC4': 'ivec4',\n \n 'BOOL': 'bool',\n 'BOOL_VEC2': 'bvec2',\n 'BOOL_VEC3': 'bvec3',\n 'BOOL_VEC4': 'bvec4',\n \n 'FLOAT_MAT2': 'mat2',\n 'FLOAT_MAT3': 'mat3',\n 'FLOAT_MAT4': 'mat4',\n \n 'SAMPLER_2D': 'sampler2D' \n}\n\nmodule.exports = mapSize;\n\n},{}],16:[function(require,module,exports){\n(function (process,global){\n/*!\n * async\n * https://github.com/caolan/async\n *\n * Copyright 2010-2014 Caolan McMahon\n * Released under the MIT license\n */\n(function () {\n\n var async = {};\n function noop() {}\n function identity(v) {\n return v;\n }\n function toBool(v) {\n return !!v;\n }\n function notId(v) {\n return !v;\n }\n\n // global on the server, window in the browser\n var previous_async;\n\n // Establish the root object, `window` (`self`) in the browser, `global`\n // on the server, or `this` in some virtual machines. We use `self`\n // instead of `window` for `WebWorker` support.\n var root = typeof self === 'object' && self.self === self && self ||\n typeof global === 'object' && global.global === global && global ||\n this;\n\n if (root != null) {\n previous_async = root.async;\n }\n\n async.noConflict = function () {\n root.async = previous_async;\n return async;\n };\n\n function only_once(fn) {\n return function() {\n if (fn === null) throw new Error(\"Callback was already called.\");\n fn.apply(this, arguments);\n fn = null;\n };\n }\n\n function _once(fn) {\n return function() {\n if (fn === null) return;\n fn.apply(this, arguments);\n fn = null;\n };\n }\n\n //// cross-browser compatiblity functions ////\n\n var _toString = Object.prototype.toString;\n\n var _isArray = Array.isArray || function (obj) {\n return _toString.call(obj) === '[object Array]';\n };\n\n // Ported from underscore.js isObject\n var _isObject = function(obj) {\n var type = typeof obj;\n return type === 'function' || type === 'object' && !!obj;\n };\n\n function _isArrayLike(arr) {\n return _isArray(arr) || (\n // has a positive integer length property\n typeof arr.length === \"number\" &&\n arr.length >= 0 &&\n arr.length % 1 === 0\n );\n }\n\n function _arrayEach(arr, iterator) {\n var index = -1,\n length = arr.length;\n\n while (++index < length) {\n iterator(arr[index], index, arr);\n }\n }\n\n function _map(arr, iterator) {\n var index = -1,\n length = arr.length,\n result = Array(length);\n\n while (++index < length) {\n result[index] = iterator(arr[index], index, arr);\n }\n return result;\n }\n\n function _range(count) {\n return _map(Array(count), function (v, i) { return i; });\n }\n\n function _reduce(arr, iterator, memo) {\n _arrayEach(arr, function (x, i, a) {\n memo = iterator(memo, x, i, a);\n });\n return memo;\n }\n\n function _forEachOf(object, iterator) {\n _arrayEach(_keys(object), function (key) {\n iterator(object[key], key);\n });\n }\n\n function _indexOf(arr, item) {\n for (var i = 0; i < arr.length; i++) {\n if (arr[i] === item) return i;\n }\n return -1;\n }\n\n var _keys = Object.keys || function (obj) {\n var keys = [];\n for (var k in obj) {\n if (obj.hasOwnProperty(k)) {\n keys.push(k);\n }\n }\n return keys;\n };\n\n function _keyIterator(coll) {\n var i = -1;\n var len;\n var keys;\n if (_isArrayLike(coll)) {\n len = coll.length;\n return function next() {\n i++;\n return i < len ? i : null;\n };\n } else {\n keys = _keys(coll);\n len = keys.length;\n return function next() {\n i++;\n return i < len ? keys[i] : null;\n };\n }\n }\n\n // Similar to ES6's rest param (http://ariya.ofilabs.com/2013/03/es6-and-rest-parameter.html)\n // This accumulates the arguments passed into an array, after a given index.\n // From underscore.js (https://github.com/jashkenas/underscore/pull/2140).\n function _restParam(func, startIndex) {\n startIndex = startIndex == null ? func.length - 1 : +startIndex;\n return function() {\n var length = Math.max(arguments.length - startIndex, 0);\n var rest = Array(length);\n for (var index = 0; index < length; index++) {\n rest[index] = arguments[index + startIndex];\n }\n switch (startIndex) {\n case 0: return func.call(this, rest);\n case 1: return func.call(this, arguments[0], rest);\n }\n // Currently unused but handle cases outside of the switch statement:\n // var args = Array(startIndex + 1);\n // for (index = 0; index < startIndex; index++) {\n // args[index] = arguments[index];\n // }\n // args[startIndex] = rest;\n // return func.apply(this, args);\n };\n }\n\n function _withoutIndex(iterator) {\n return function (value, index, callback) {\n return iterator(value, callback);\n };\n }\n\n //// exported async module functions ////\n\n //// nextTick implementation with browser-compatible fallback ////\n\n // capture the global reference to guard against fakeTimer mocks\n var _setImmediate = typeof setImmediate === 'function' && setImmediate;\n\n var _delay = _setImmediate ? function(fn) {\n // not a direct alias for IE10 compatibility\n _setImmediate(fn);\n } : function(fn) {\n setTimeout(fn, 0);\n };\n\n if (typeof process === 'object' && typeof process.nextTick === 'function') {\n async.nextTick = process.nextTick;\n } else {\n async.nextTick = _delay;\n }\n async.setImmediate = _setImmediate ? _delay : async.nextTick;\n\n\n async.forEach =\n async.each = function (arr, iterator, callback) {\n return async.eachOf(arr, _withoutIndex(iterator), callback);\n };\n\n async.forEachSeries =\n async.eachSeries = function (arr, iterator, callback) {\n return async.eachOfSeries(arr, _withoutIndex(iterator), callback);\n };\n\n\n async.forEachLimit =\n async.eachLimit = function (arr, limit, iterator, callback) {\n return _eachOfLimit(limit)(arr, _withoutIndex(iterator), callback);\n };\n\n async.forEachOf =\n async.eachOf = function (object, iterator, callback) {\n callback = _once(callback || noop);\n object = object || [];\n\n var iter = _keyIterator(object);\n var key, completed = 0;\n\n while ((key = iter()) != null) {\n completed += 1;\n iterator(object[key], key, only_once(done));\n }\n\n if (completed === 0) callback(null);\n\n function done(err) {\n completed--;\n if (err) {\n callback(err);\n }\n // Check key is null in case iterator isn't exhausted\n // and done resolved synchronously.\n else if (key === null && completed <= 0) {\n callback(null);\n }\n }\n };\n\n async.forEachOfSeries =\n async.eachOfSeries = function (obj, iterator, callback) {\n callback = _once(callback || noop);\n obj = obj || [];\n var nextKey = _keyIterator(obj);\n var key = nextKey();\n function iterate() {\n var sync = true;\n if (key === null) {\n return callback(null);\n }\n iterator(obj[key], key, only_once(function (err) {\n if (err) {\n callback(err);\n }\n else {\n key = nextKey();\n if (key === null) {\n return callback(null);\n } else {\n if (sync) {\n async.setImmediate(iterate);\n } else {\n iterate();\n }\n }\n }\n }));\n sync = false;\n }\n iterate();\n };\n\n\n\n async.forEachOfLimit =\n async.eachOfLimit = function (obj, limit, iterator, callback) {\n _eachOfLimit(limit)(obj, iterator, callback);\n };\n\n function _eachOfLimit(limit) {\n\n return function (obj, iterator, callback) {\n callback = _once(callback || noop);\n obj = obj || [];\n var nextKey = _keyIterator(obj);\n if (limit <= 0) {\n return callback(null);\n }\n var done = false;\n var running = 0;\n var errored = false;\n\n (function replenish () {\n if (done && running <= 0) {\n return callback(null);\n }\n\n while (running < limit && !errored) {\n var key = nextKey();\n if (key === null) {\n done = true;\n if (running <= 0) {\n callback(null);\n }\n return;\n }\n running += 1;\n iterator(obj[key], key, only_once(function (err) {\n running -= 1;\n if (err) {\n callback(err);\n errored = true;\n }\n else {\n replenish();\n }\n }));\n }\n })();\n };\n }\n\n\n function doParallel(fn) {\n return function (obj, iterator, callback) {\n return fn(async.eachOf, obj, iterator, callback);\n };\n }\n function doParallelLimit(fn) {\n return function (obj, limit, iterator, callback) {\n return fn(_eachOfLimit(limit), obj, iterator, callback);\n };\n }\n function doSeries(fn) {\n return function (obj, iterator, callback) {\n return fn(async.eachOfSeries, obj, iterator, callback);\n };\n }\n\n function _asyncMap(eachfn, arr, iterator, callback) {\n callback = _once(callback || noop);\n arr = arr || [];\n var results = _isArrayLike(arr) ? [] : {};\n eachfn(arr, function (value, index, callback) {\n iterator(value, function (err, v) {\n results[index] = v;\n callback(err);\n });\n }, function (err) {\n callback(err, results);\n });\n }\n\n async.map = doParallel(_asyncMap);\n async.mapSeries = doSeries(_asyncMap);\n async.mapLimit = doParallelLimit(_asyncMap);\n\n // reduce only has a series version, as doing reduce in parallel won't\n // work in many situations.\n async.inject =\n async.foldl =\n async.reduce = function (arr, memo, iterator, callback) {\n async.eachOfSeries(arr, function (x, i, callback) {\n iterator(memo, x, function (err, v) {\n memo = v;\n callback(err);\n });\n }, function (err) {\n callback(err, memo);\n });\n };\n\n async.foldr =\n async.reduceRight = function (arr, memo, iterator, callback) {\n var reversed = _map(arr, identity).reverse();\n async.reduce(reversed, memo, iterator, callback);\n };\n\n async.transform = function (arr, memo, iterator, callback) {\n if (arguments.length === 3) {\n callback = iterator;\n iterator = memo;\n memo = _isArray(arr) ? [] : {};\n }\n\n async.eachOf(arr, function(v, k, cb) {\n iterator(memo, v, k, cb);\n }, function(err) {\n callback(err, memo);\n });\n };\n\n function _filter(eachfn, arr, iterator, callback) {\n var results = [];\n eachfn(arr, function (x, index, callback) {\n iterator(x, function (v) {\n if (v) {\n results.push({index: index, value: x});\n }\n callback();\n });\n }, function () {\n callback(_map(results.sort(function (a, b) {\n return a.index - b.index;\n }), function (x) {\n return x.value;\n }));\n });\n }\n\n async.select =\n async.filter = doParallel(_filter);\n\n async.selectLimit =\n async.filterLimit = doParallelLimit(_filter);\n\n async.selectSeries =\n async.filterSeries = doSeries(_filter);\n\n function _reject(eachfn, arr, iterator, callback) {\n _filter(eachfn, arr, function(value, cb) {\n iterator(value, function(v) {\n cb(!v);\n });\n }, callback);\n }\n async.reject = doParallel(_reject);\n async.rejectLimit = doParallelLimit(_reject);\n async.rejectSeries = doSeries(_reject);\n\n function _createTester(eachfn, check, getResult) {\n return function(arr, limit, iterator, cb) {\n function done() {\n if (cb) cb(getResult(false, void 0));\n }\n function iteratee(x, _, callback) {\n if (!cb) return callback();\n iterator(x, function (v) {\n if (cb && check(v)) {\n cb(getResult(true, x));\n cb = iterator = false;\n }\n callback();\n });\n }\n if (arguments.length > 3) {\n eachfn(arr, limit, iteratee, done);\n } else {\n cb = iterator;\n iterator = limit;\n eachfn(arr, iteratee, done);\n }\n };\n }\n\n async.any =\n async.some = _createTester(async.eachOf, toBool, identity);\n\n async.someLimit = _createTester(async.eachOfLimit, toBool, identity);\n\n async.all =\n async.every = _createTester(async.eachOf, notId, notId);\n\n async.everyLimit = _createTester(async.eachOfLimit, notId, notId);\n\n function _findGetResult(v, x) {\n return x;\n }\n async.detect = _createTester(async.eachOf, identity, _findGetResult);\n async.detectSeries = _createTester(async.eachOfSeries, identity, _findGetResult);\n async.detectLimit = _createTester(async.eachOfLimit, identity, _findGetResult);\n\n async.sortBy = function (arr, iterator, callback) {\n async.map(arr, function (x, callback) {\n iterator(x, function (err, criteria) {\n if (err) {\n callback(err);\n }\n else {\n callback(null, {value: x, criteria: criteria});\n }\n });\n }, function (err, results) {\n if (err) {\n return callback(err);\n }\n else {\n callback(null, _map(results.sort(comparator), function (x) {\n return x.value;\n }));\n }\n\n });\n\n function comparator(left, right) {\n var a = left.criteria, b = right.criteria;\n return a < b ? -1 : a > b ? 1 : 0;\n }\n };\n\n async.auto = function (tasks, concurrency, callback) {\n if (typeof arguments[1] === 'function') {\n // concurrency is optional, shift the args.\n callback = concurrency;\n concurrency = null;\n }\n callback = _once(callback || noop);\n var keys = _keys(tasks);\n var remainingTasks = keys.length;\n if (!remainingTasks) {\n return callback(null);\n }\n if (!concurrency) {\n concurrency = remainingTasks;\n }\n\n var results = {};\n var runningTasks = 0;\n\n var hasError = false;\n\n var listeners = [];\n function addListener(fn) {\n listeners.unshift(fn);\n }\n function removeListener(fn) {\n var idx = _indexOf(listeners, fn);\n if (idx >= 0) listeners.splice(idx, 1);\n }\n function taskComplete() {\n remainingTasks--;\n _arrayEach(listeners.slice(0), function (fn) {\n fn();\n });\n }\n\n addListener(function () {\n if (!remainingTasks) {\n callback(null, results);\n }\n });\n\n _arrayEach(keys, function (k) {\n if (hasError) return;\n var task = _isArray(tasks[k]) ? tasks[k]: [tasks[k]];\n var taskCallback = _restParam(function(err, args) {\n runningTasks--;\n if (args.length <= 1) {\n args = args[0];\n }\n if (err) {\n var safeResults = {};\n _forEachOf(results, function(val, rkey) {\n safeResults[rkey] = val;\n });\n safeResults[k] = args;\n hasError = true;\n\n callback(err, safeResults);\n }\n else {\n results[k] = args;\n async.setImmediate(taskComplete);\n }\n });\n var requires = task.slice(0, task.length - 1);\n // prevent dead-locks\n var len = requires.length;\n var dep;\n while (len--) {\n if (!(dep = tasks[requires[len]])) {\n throw new Error('Has nonexistent dependency in ' + requires.join(', '));\n }\n if (_isArray(dep) && _indexOf(dep, k) >= 0) {\n throw new Error('Has cyclic dependencies');\n }\n }\n function ready() {\n return runningTasks < concurrency && _reduce(requires, function (a, x) {\n return (a && results.hasOwnProperty(x));\n }, true) && !results.hasOwnProperty(k);\n }\n if (ready()) {\n runningTasks++;\n task[task.length - 1](taskCallback, results);\n }\n else {\n addListener(listener);\n }\n function listener() {\n if (ready()) {\n runningTasks++;\n removeListener(listener);\n task[task.length - 1](taskCallback, results);\n }\n }\n });\n };\n\n\n\n async.retry = function(times, task, callback) {\n var DEFAULT_TIMES = 5;\n var DEFAULT_INTERVAL = 0;\n\n var attempts = [];\n\n var opts = {\n times: DEFAULT_TIMES,\n interval: DEFAULT_INTERVAL\n };\n\n function parseTimes(acc, t){\n if(typeof t === 'number'){\n acc.times = parseInt(t, 10) || DEFAULT_TIMES;\n } else if(typeof t === 'object'){\n acc.times = parseInt(t.times, 10) || DEFAULT_TIMES;\n acc.interval = parseInt(t.interval, 10) || DEFAULT_INTERVAL;\n } else {\n throw new Error('Unsupported argument type for \\'times\\': ' + typeof t);\n }\n }\n\n var length = arguments.length;\n if (length < 1 || length > 3) {\n throw new Error('Invalid arguments - must be either (task), (task, callback), (times, task) or (times, task, callback)');\n } else if (length <= 2 && typeof times === 'function') {\n callback = task;\n task = times;\n }\n if (typeof times !== 'function') {\n parseTimes(opts, times);\n }\n opts.callback = callback;\n opts.task = task;\n\n function wrappedTask(wrappedCallback, wrappedResults) {\n function retryAttempt(task, finalAttempt) {\n return function(seriesCallback) {\n task(function(err, result){\n seriesCallback(!err || finalAttempt, {err: err, result: result});\n }, wrappedResults);\n };\n }\n\n function retryInterval(interval){\n return function(seriesCallback){\n setTimeout(function(){\n seriesCallback(null);\n }, interval);\n };\n }\n\n while (opts.times) {\n\n var finalAttempt = !(opts.times-=1);\n attempts.push(retryAttempt(opts.task, finalAttempt));\n if(!finalAttempt && opts.interval > 0){\n attempts.push(retryInterval(opts.interval));\n }\n }\n\n async.series(attempts, function(done, data){\n data = data[data.length - 1];\n (wrappedCallback || opts.callback)(data.err, data.result);\n });\n }\n\n // If a callback is passed, run this as a controll flow\n return opts.callback ? wrappedTask() : wrappedTask;\n };\n\n async.waterfall = function (tasks, callback) {\n callback = _once(callback || noop);\n if (!_isArray(tasks)) {\n var err = new Error('First argument to waterfall must be an array of functions');\n return callback(err);\n }\n if (!tasks.length) {\n return callback();\n }\n function wrapIterator(iterator) {\n return _restParam(function (err, args) {\n if (err) {\n callback.apply(null, [err].concat(args));\n }\n else {\n var next = iterator.next();\n if (next) {\n args.push(wrapIterator(next));\n }\n else {\n args.push(callback);\n }\n ensureAsync(iterator).apply(null, args);\n }\n });\n }\n wrapIterator(async.iterator(tasks))();\n };\n\n function _parallel(eachfn, tasks, callback) {\n callback = callback || noop;\n var results = _isArrayLike(tasks) ? [] : {};\n\n eachfn(tasks, function (task, key, callback) {\n task(_restParam(function (err, args) {\n if (args.length <= 1) {\n args = args[0];\n }\n results[key] = args;\n callback(err);\n }));\n }, function (err) {\n callback(err, results);\n });\n }\n\n async.parallel = function (tasks, callback) {\n _parallel(async.eachOf, tasks, callback);\n };\n\n async.parallelLimit = function(tasks, limit, callback) {\n _parallel(_eachOfLimit(limit), tasks, callback);\n };\n\n async.series = function(tasks, callback) {\n _parallel(async.eachOfSeries, tasks, callback);\n };\n\n async.iterator = function (tasks) {\n function makeCallback(index) {\n function fn() {\n if (tasks.length) {\n tasks[index].apply(null, arguments);\n }\n return fn.next();\n }\n fn.next = function () {\n return (index < tasks.length - 1) ? makeCallback(index + 1): null;\n };\n return fn;\n }\n return makeCallback(0);\n };\n\n async.apply = _restParam(function (fn, args) {\n return _restParam(function (callArgs) {\n return fn.apply(\n null, args.concat(callArgs)\n );\n });\n });\n\n function _concat(eachfn, arr, fn, callback) {\n var result = [];\n eachfn(arr, function (x, index, cb) {\n fn(x, function (err, y) {\n result = result.concat(y || []);\n cb(err);\n });\n }, function (err) {\n callback(err, result);\n });\n }\n async.concat = doParallel(_concat);\n async.concatSeries = doSeries(_concat);\n\n async.whilst = function (test, iterator, callback) {\n callback = callback || noop;\n if (test()) {\n var next = _restParam(function(err, args) {\n if (err) {\n callback(err);\n } else if (test.apply(this, args)) {\n iterator(next);\n } else {\n callback.apply(null, [null].concat(args));\n }\n });\n iterator(next);\n } else {\n callback(null);\n }\n };\n\n async.doWhilst = function (iterator, test, callback) {\n var calls = 0;\n return async.whilst(function() {\n return ++calls <= 1 || test.apply(this, arguments);\n }, iterator, callback);\n };\n\n async.until = function (test, iterator, callback) {\n return async.whilst(function() {\n return !test.apply(this, arguments);\n }, iterator, callback);\n };\n\n async.doUntil = function (iterator, test, callback) {\n return async.doWhilst(iterator, function() {\n return !test.apply(this, arguments);\n }, callback);\n };\n\n async.during = function (test, iterator, callback) {\n callback = callback || noop;\n\n var next = _restParam(function(err, args) {\n if (err) {\n callback(err);\n } else {\n args.push(check);\n test.apply(this, args);\n }\n });\n\n var check = function(err, truth) {\n if (err) {\n callback(err);\n } else if (truth) {\n iterator(next);\n } else {\n callback(null);\n }\n };\n\n test(check);\n };\n\n async.doDuring = function (iterator, test, callback) {\n var calls = 0;\n async.during(function(next) {\n if (calls++ < 1) {\n next(null, true);\n } else {\n test.apply(this, arguments);\n }\n }, iterator, callback);\n };\n\n function _queue(worker, concurrency, payload) {\n if (concurrency == null) {\n concurrency = 1;\n }\n else if(concurrency === 0) {\n throw new Error('Concurrency must not be zero');\n }\n function _insert(q, data, pos, callback) {\n if (callback != null && typeof callback !== \"function\") {\n throw new Error(\"task callback must be a function\");\n }\n q.started = true;\n if (!_isArray(data)) {\n data = [data];\n }\n if(data.length === 0 && q.idle()) {\n // call drain immediately if there are no tasks\n return async.setImmediate(function() {\n q.drain();\n });\n }\n _arrayEach(data, function(task) {\n var item = {\n data: task,\n callback: callback || noop\n };\n\n if (pos) {\n q.tasks.unshift(item);\n } else {\n q.tasks.push(item);\n }\n\n if (q.tasks.length === q.concurrency) {\n q.saturated();\n }\n });\n async.setImmediate(q.process);\n }\n function _next(q, tasks) {\n return function(){\n workers -= 1;\n\n var removed = false;\n var args = arguments;\n _arrayEach(tasks, function (task) {\n _arrayEach(workersList, function (worker, index) {\n if (worker === task && !removed) {\n workersList.splice(index, 1);\n removed = true;\n }\n });\n\n task.callback.apply(task, args);\n });\n if (q.tasks.length + workers === 0) {\n q.drain();\n }\n q.process();\n };\n }\n\n var workers = 0;\n var workersList = [];\n var q = {\n tasks: [],\n concurrency: concurrency,\n payload: payload,\n saturated: noop,\n empty: noop,\n drain: noop,\n started: false,\n paused: false,\n push: function (data, callback) {\n _insert(q, data, false, callback);\n },\n kill: function () {\n q.drain = noop;\n q.tasks = [];\n },\n unshift: function (data, callback) {\n _insert(q, data, true, callback);\n },\n process: function () {\n while(!q.paused && workers < q.concurrency && q.tasks.length){\n\n var tasks = q.payload ?\n q.tasks.splice(0, q.payload) :\n q.tasks.splice(0, q.tasks.length);\n\n var data = _map(tasks, function (task) {\n return task.data;\n });\n\n if (q.tasks.length === 0) {\n q.empty();\n }\n workers += 1;\n workersList.push(tasks[0]);\n var cb = only_once(_next(q, tasks));\n worker(data, cb);\n }\n },\n length: function () {\n return q.tasks.length;\n },\n running: function () {\n return workers;\n },\n workersList: function () {\n return workersList;\n },\n idle: function() {\n return q.tasks.length + workers === 0;\n },\n pause: function () {\n q.paused = true;\n },\n resume: function () {\n if (q.paused === false) { return; }\n q.paused = false;\n var resumeCount = Math.min(q.concurrency, q.tasks.length);\n // Need to call q.process once per concurrent\n // worker to preserve full concurrency after pause\n for (var w = 1; w <= resumeCount; w++) {\n async.setImmediate(q.process);\n }\n }\n };\n return q;\n }\n\n async.queue = function (worker, concurrency) {\n var q = _queue(function (items, cb) {\n worker(items[0], cb);\n }, concurrency, 1);\n\n return q;\n };\n\n async.priorityQueue = function (worker, concurrency) {\n\n function _compareTasks(a, b){\n return a.priority - b.priority;\n }\n\n function _binarySearch(sequence, item, compare) {\n var beg = -1,\n end = sequence.length - 1;\n while (beg < end) {\n var mid = beg + ((end - beg + 1) >>> 1);\n if (compare(item, sequence[mid]) >= 0) {\n beg = mid;\n } else {\n end = mid - 1;\n }\n }\n return beg;\n }\n\n function _insert(q, data, priority, callback) {\n if (callback != null && typeof callback !== \"function\") {\n throw new Error(\"task callback must be a function\");\n }\n q.started = true;\n if (!_isArray(data)) {\n data = [data];\n }\n if(data.length === 0) {\n // call drain immediately if there are no tasks\n return async.setImmediate(function() {\n q.drain();\n });\n }\n _arrayEach(data, function(task) {\n var item = {\n data: task,\n priority: priority,\n callback: typeof callback === 'function' ? callback : noop\n };\n\n q.tasks.splice(_binarySearch(q.tasks, item, _compareTasks) + 1, 0, item);\n\n if (q.tasks.length === q.concurrency) {\n q.saturated();\n }\n async.setImmediate(q.process);\n });\n }\n\n // Start with a normal queue\n var q = async.queue(worker, concurrency);\n\n // Override push to accept second parameter representing priority\n q.push = function (data, priority, callback) {\n _insert(q, data, priority, callback);\n };\n\n // Remove unshift function\n delete q.unshift;\n\n return q;\n };\n\n async.cargo = function (worker, payload) {\n return _queue(worker, 1, payload);\n };\n\n function _console_fn(name) {\n return _restParam(function (fn, args) {\n fn.apply(null, args.concat([_restParam(function (err, args) {\n if (typeof console === 'object') {\n if (err) {\n if (console.error) {\n console.error(err);\n }\n }\n else if (console[name]) {\n _arrayEach(args, function (x) {\n console[name](x);\n });\n }\n }\n })]));\n });\n }\n async.log = _console_fn('log');\n async.dir = _console_fn('dir');\n /*async.info = _console_fn('info');\n async.warn = _console_fn('warn');\n async.error = _console_fn('error');*/\n\n async.memoize = function (fn, hasher) {\n var memo = {};\n var queues = {};\n var has = Object.prototype.hasOwnProperty;\n hasher = hasher || identity;\n var memoized = _restParam(function memoized(args) {\n var callback = args.pop();\n var key = hasher.apply(null, args);\n if (has.call(memo, key)) { \n async.setImmediate(function () {\n callback.apply(null, memo[key]);\n });\n }\n else if (has.call(queues, key)) {\n queues[key].push(callback);\n }\n else {\n queues[key] = [callback];\n fn.apply(null, args.concat([_restParam(function (args) {\n memo[key] = args;\n var q = queues[key];\n delete queues[key];\n for (var i = 0, l = q.length; i < l; i++) {\n q[i].apply(null, args);\n }\n })]));\n }\n });\n memoized.memo = memo;\n memoized.unmemoized = fn;\n return memoized;\n };\n\n async.unmemoize = function (fn) {\n return function () {\n return (fn.unmemoized || fn).apply(null, arguments);\n };\n };\n\n function _times(mapper) {\n return function (count, iterator, callback) {\n mapper(_range(count), iterator, callback);\n };\n }\n\n async.times = _times(async.map);\n async.timesSeries = _times(async.mapSeries);\n async.timesLimit = function (count, limit, iterator, callback) {\n return async.mapLimit(_range(count), limit, iterator, callback);\n };\n\n async.seq = function (/* functions... */) {\n var fns = arguments;\n return _restParam(function (args) {\n var that = this;\n\n var callback = args[args.length - 1];\n if (typeof callback == 'function') {\n args.pop();\n } else {\n callback = noop;\n }\n\n async.reduce(fns, args, function (newargs, fn, cb) {\n fn.apply(that, newargs.concat([_restParam(function (err, nextargs) {\n cb(err, nextargs);\n })]));\n },\n function (err, results) {\n callback.apply(that, [err].concat(results));\n });\n });\n };\n\n async.compose = function (/* functions... */) {\n return async.seq.apply(null, Array.prototype.reverse.call(arguments));\n };\n\n\n function _applyEach(eachfn) {\n return _restParam(function(fns, args) {\n var go = _restParam(function(args) {\n var that = this;\n var callback = args.pop();\n return eachfn(fns, function (fn, _, cb) {\n fn.apply(that, args.concat([cb]));\n },\n callback);\n });\n if (args.length) {\n return go.apply(this, args);\n }\n else {\n return go;\n }\n });\n }\n\n async.applyEach = _applyEach(async.eachOf);\n async.applyEachSeries = _applyEach(async.eachOfSeries);\n\n\n async.forever = function (fn, callback) {\n var done = only_once(callback || noop);\n var task = ensureAsync(fn);\n function next(err) {\n if (err) {\n return done(err);\n }\n task(next);\n }\n next();\n };\n\n function ensureAsync(fn) {\n return _restParam(function (args) {\n var callback = args.pop();\n args.push(function () {\n var innerArgs = arguments;\n if (sync) {\n async.setImmediate(function () {\n callback.apply(null, innerArgs);\n });\n } else {\n callback.apply(null, innerArgs);\n }\n });\n var sync = true;\n fn.apply(this, args);\n sync = false;\n });\n }\n\n async.ensureAsync = ensureAsync;\n\n async.constant = _restParam(function(values) {\n var args = [null].concat(values);\n return function (callback) {\n return callback.apply(this, args);\n };\n });\n\n async.wrapSync =\n async.asyncify = function asyncify(func) {\n return _restParam(function (args) {\n var callback = args.pop();\n var result;\n try {\n result = func.apply(this, args);\n } catch (e) {\n return callback(e);\n }\n // if result is Promise object\n if (_isObject(result) && typeof result.then === \"function\") {\n result.then(function(value) {\n callback(null, value);\n })[\"catch\"](function(err) {\n callback(err.message ? err : new Error(err));\n });\n } else {\n callback(null, result);\n }\n });\n };\n\n // Node.js\n if (typeof module === 'object' && module.exports) {\n module.exports = async;\n }\n // AMD / RequireJS\n else if (typeof define === 'function' && define.amd) {\n define([], function () {\n return async;\n });\n }\n // included directly via