diff --git a/bin/pixi.js b/bin/pixi.js index 22c122a..ee10553 100644 --- a/bin/pixi.js +++ b/bin/pixi.js @@ -8980,6 +8980,8 @@ * If set to DEFAULT, the renderer will occasianally check textures usage. If they are not used for a specified period of time they will be removed from the GPU. * They will of corse be uploaded again when they are required. This is a silent behind the scenes process that should ensure that the GPU does not get filled up. * Handy for mobile devices! + * This property only affects WebGL + * Handy for mobile devices! * This property only affects WebGL. * * @static @@ -9087,12 +9089,13 @@ // 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. + 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 }; module.exports = CONST; -},{"./utils/maxRecommendedTextures":109}],40:[function(require,module,exports){ +},{"./utils/maxRecommendedTextures":110}],40:[function(require,module,exports){ var math = require('../math'), utils = require('../utils'), DisplayObject = require('./DisplayObject'); @@ -9720,7 +9723,7 @@ this.children = null; }; -},{"../math":61,"../utils":108,"./DisplayObject":41}],41:[function(require,module,exports){ +},{"../math":61,"../utils":109,"./DisplayObject":41}],41:[function(require,module,exports){ var math = require('../math'), EventEmitter = require('eventemitter3'), Transform = require('./Transform'), @@ -9733,6 +9736,7 @@ * * @class * @extends EventEmitter + * @mixes PIXI.interaction.interactiveTarget * @memberof PIXI */ function DisplayObject() @@ -9796,13 +9800,6 @@ this.filterArea = null; /** - * Interaction shape. Children will be hit first, then this shape will be checked. - * - * @member {PIXI.Rectangle|PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.RoundedRectangle} - */ - this.hitArea = null; - - /** * The original, cached bounds of the object * * @member {PIXI.Rectangle} @@ -11607,6 +11604,30 @@ return texture; }; +Graphics.prototype.closePath = function () +{ + // ok so close path assumes next one is a hole! + var currentPath = this.currentPath; + if (currentPath && currentPath.shape) + { + currentPath.shape.close(); + } + return this; +}; + +Graphics.prototype.addHole = function() +{ + // this is a hole! + var hole = this.graphicsData.pop(); + + this.currentPath = this.graphicsData[this.graphicsData.length-1]; + + this.currentPath.addHole(hole.shape); + this.currentPath = null; + + return this; +}; + /** * Destroys the Graphics object. */ @@ -11633,7 +11654,7 @@ this._localBounds = null; }; -},{"../const":39,"../display/Container":40,"../math":61,"../renderers/canvas/CanvasRenderer":68,"../sprites/Sprite":91,"../textures/RenderTexture":100,"../textures/Texture":101,"./GraphicsData":46,"./utils/bezierCurveTo":48}],46:[function(require,module,exports){ +},{"../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){ /** * A GraphicsData object. * @@ -11687,6 +11708,9 @@ */ this.fill = fill; + + this.holes = []; + /* * @member {PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.Rectangle|PIXI.RoundedRectangle} The shape object to draw. */ @@ -11719,11 +11743,17 @@ ); }; +GraphicsData.prototype.addHole = function (shape) +{ + this.holes.push(shape); +}; + /** * Destroys the Graphics data. */ GraphicsData.prototype.destroy = function () { this.shape = null; + this.holes = null; }; },{}],47:[function(require,module,exports){ @@ -11812,25 +11842,14 @@ { context.beginPath(); - var points = shape.points; + this.renderPolygon(shape.points, shape.closed, context); - context.moveTo(points[0], points[1]); - - for (var j=1; j < points.length/2; j++) + for (var j = 0; j < data.holes.length; j++) { - context.lineTo(points[j * 2], points[j * 2 + 1]); + var hole = data.holes[j]; + this.renderPolygon(hole.points, true, context); } - if (shape.closed) - { - context.lineTo(points[0], points[1]); - } - - // if the first and last point are the same close the path - much neater :) - if (points[0] === points[points.length-2] && points[1] === points[points.length-1]) - { - context.closePath(); - } if (data.fill) { @@ -11996,6 +12015,21 @@ } }; +CanvasGraphicsRenderer.prototype.renderPolygon = function (points, close, context) +{ + context.moveTo(points[0], points[1]); + + for (var j=1; j < points.length/2; j++) + { + context.lineTo(points[j * 2], points[j * 2 + 1]); + } + + if (close) + { + context.closePath(); + } +}; + /* * destroy graphics object * @@ -12274,7 +12308,7 @@ return webGLData; }; -},{"../../const":39,"../../renderers/webgl/WebGLRenderer":75,"../../renderers/webgl/utils/ObjectRenderer":85,"../../utils":108,"./WebGLGraphicsData":50,"./shaders/PrimitiveShader":51,"./utils/buildCircle":52,"./utils/buildPoly":54,"./utils/buildRectangle":55,"./utils/buildRoundedRectangle":56}],50:[function(require,module,exports){ +},{"../../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){ var glCore = require('pixi-gl-core'); @@ -12539,7 +12573,7 @@ module.exports = buildCircle; -},{"../../../const":39,"../../../utils":108,"./buildLine":53}],53:[function(require,module,exports){ +},{"../../../const":39,"../../../utils":109,"./buildLine":53}],53:[function(require,module,exports){ var math = require('../../../math'), utils = require('../../../utils'); @@ -12759,7 +12793,7 @@ }; module.exports = buildLine; -},{"../../../math":61,"../../../utils":108}],54:[function(require,module,exports){ +},{"../../../math":61,"../../../utils":109}],54:[function(require,module,exports){ var buildLine = require('./buildLine'), utils = require('../../../utils'), earcut = require('earcut'); @@ -12777,20 +12811,21 @@ var points = graphicsData.points; - // need to add the points the the graphics object.. - if (graphicsData.shape.closed) - { - // close the poly if the value is true! - if (points[0] !== points[points.length-2] || points[1] !== points[points.length-1]) - { - points.push(points[0], points[1]); - } - } - - if(graphicsData.fill && points.length > 6) { + var holeArray = []; + // Process holes.. + var holes = graphicsData.holes; + + for (var i = 0; i < holes.length; i++) { + var hole = holes[i]; + + holeArray.push(points.length/2); + + points = points.concat(hole.points); + } + // get first and last point.. figure out the middle! var verts = webGLData.points; var indices = webGLData.indices; @@ -12804,7 +12839,7 @@ var g = color[1] * alpha; var b = color[2] * alpha; - var triangles = earcut(points, null, 2); + var triangles = earcut(points, holeArray, 2); if (!triangles) { return; @@ -12839,7 +12874,7 @@ module.exports = buildPoly; -},{"../../../utils":108,"./buildLine":53,"earcut":25}],55:[function(require,module,exports){ +},{"../../../utils":109,"./buildLine":53,"earcut":25}],55:[function(require,module,exports){ var buildLine = require('./buildLine'), utils = require('../../../utils'); @@ -12910,7 +12945,7 @@ }; module.exports = buildRectangle; -},{"../../../utils":108,"./buildLine":53}],56:[function(require,module,exports){ +},{"../../../utils":109,"./buildLine":53}],56:[function(require,module,exports){ var earcut = require('earcut'), buildLine = require('./buildLine'), utils = require('../../../utils'); @@ -13040,7 +13075,7 @@ module.exports = buildRoundedRectangle; -},{"../../../utils":108,"./buildLine":53,"earcut":25}],57:[function(require,module,exports){ +},{"../../../utils":109,"./buildLine":53,"earcut":25}],57:[function(require,module,exports){ /** * @file Main export of the PIXI core library * @author Mat Groves @@ -13071,7 +13106,7 @@ // text Text: require('./text/Text'), - + TextStyle: require('./text/TextStyle'), // primitives Graphics: require('./graphics/Graphics'), GraphicsData: require('./graphics/GraphicsData'), @@ -13136,7 +13171,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,"./textures/BaseRenderTexture":98,"./textures/BaseTexture":99,"./textures/RenderTexture":100,"./textures/Texture":101,"./textures/TextureUvs":102,"./textures/VideoBaseTexture":103,"./ticker":105,"./utils":108,"pixi-gl-core":1}],58:[function(require,module,exports){ +},{"./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){ // 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]; @@ -14090,6 +14125,18 @@ return new Polygon(this.points.slice()); }; + +Polygon.prototype.close = function () +{ + var points = this.points; + + // close the poly if the value is true! + if (points[0] !== points[points.length-2] || points[1] !== points[points.length-1]) + { + points.push(points[0], points[1]); + } +}; + /** * Checks whether the x and y coordinates passed to this function are contained within this polygon * @@ -14674,7 +14721,7 @@ this._lastObjectRendered = null; }; -},{"../const":39,"../display/Container":40,"../math":61,"../textures/RenderTexture":100,"../utils":108,"eventemitter3":26}],68:[function(require,module,exports){ +},{"../const":39,"../display/Container":40,"../math":61,"../textures/RenderTexture":101,"../utils":109,"eventemitter3":26}],68:[function(require,module,exports){ var SystemRenderer = require('../SystemRenderer'), CanvasMaskManager = require('./utils/CanvasMaskManager'), CanvasRenderTarget = require('./utils/CanvasRenderTarget'), @@ -14796,7 +14843,7 @@ if(renderTexture) { renderTexture = renderTexture.baseTexture || renderTexture; - + if(!renderTexture._canvasRenderTarget) { @@ -14855,16 +14902,18 @@ context.clear(); } - if( clear || this.clearBeforeRender) + if(clear !== undefined ? clear : this.clearBeforeRender) { - if (this.transparent) - { - context.clearRect(0, 0, this.width, this.height); - } - else - { - context.fillStyle = this._backgroundColorString; - context.fillRect(0, 0, this.width , this.height); + if (this.renderingToScreen) { + if (this.transparent) { + context.clearRect(0, 0, this.width, this.height); + } + else { + context.fillStyle = this._backgroundColorString; + context.fillRect(0, 0, this.width, this.height); + } + } else { + //TODO: implement background for CanvasRenderTarget or RenderTexture? } } @@ -14929,7 +14978,7 @@ }; -},{"../../const":39,"../../utils":108,"../SystemRenderer":67,"./utils/CanvasMaskManager":69,"./utils/CanvasRenderTarget":70,"./utils/mapCanvasBlendModesToPixi":72}],69:[function(require,module,exports){ +},{"../../const":39,"../../utils":109,"../SystemRenderer":67,"./utils/CanvasMaskManager":69,"./utils/CanvasRenderTarget":70,"./utils/mapCanvasBlendModesToPixi":72}],69:[function(require,module,exports){ var CONST = require('../../../const'); /** * A set of functions used to handle masking. @@ -15612,7 +15661,7 @@ module.exports = TextureManager; -},{"../../const":39,"../../utils":108,"./utils/RenderTarget":87,"pixi-gl-core":1}],75:[function(require,module,exports){ +},{"../../const":39,"../../utils":109,"./utils/RenderTarget":87,"pixi-gl-core":1}],75:[function(require,module,exports){ var SystemRenderer = require('../SystemRenderer'), MaskManager = require('./managers/MaskManager'), StencilManager = require('./managers/StencilManager'), @@ -16167,7 +16216,7 @@ // this = null; }; -},{"../../const":39,"../../utils":108,"../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":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){ var mapWebGLBlendModesToPixi = require('./utils/mapWebGLBlendModesToPixi'); /** @@ -16575,7 +16624,7 @@ '}' ].join('\n'); -},{"../../../utils":108,"./extractUniformsFromSrc":78}],78:[function(require,module,exports){ +},{"../../../utils":109,"./extractUniformsFromSrc":78}],78:[function(require,module,exports){ var defaultValue = require('pixi-gl-core/lib/shader/defaultValue'); var mapSize = require('pixi-gl-core/lib/shader/mapSize'); @@ -17702,7 +17751,7 @@ module.exports = Quad; -},{"../../../utils/createIndicesForQuads":106,"pixi-gl-core":1}],87:[function(require,module,exports){ +},{"../../../utils/createIndicesForQuads":107,"pixi-gl-core":1}],87:[function(require,module,exports){ var math = require('../../../math'), CONST = require('../../../const'), GLFramebuffer = require('pixi-gl-core').GLFramebuffer; @@ -18372,7 +18421,7 @@ } }; -Sprite.prototype.caclulateVertices = function () +Sprite.prototype.calculateVertices = function () { var texture = this._texture, wt = this.transform.worldTransform, @@ -18431,7 +18480,7 @@ { this.textureDirty = false; // set the vertex data - this.caclulateVertices(); + this.calculateVertices(); } renderer.setObjectRenderer(renderer.plugins.sprite); @@ -18465,7 +18514,7 @@ this.vertexDirty = false; // set the vertex data - this.caclulateVertices(); + this.calculateVertices(); } @@ -18650,7 +18699,7 @@ return new Sprite(Texture.fromImage(imageId, crossorigin, scaleMode)); }; -},{"../const":39,"../display/Container":40,"../math":61,"../textures/Texture":101,"../utils":108}],92:[function(require,module,exports){ +},{"../const":39,"../display/Container":40,"../math":61,"../textures/Texture":102,"../utils":109}],92:[function(require,module,exports){ var CanvasRenderer = require('../../renderers/canvas/CanvasRenderer'), CONST = require('../../const'), math = require('../../math'), @@ -19049,7 +19098,7 @@ */ CanvasTinter.tintMethod = CanvasTinter.canUseMultiply ? CanvasTinter.tintWithMultiply : CanvasTinter.tintWithPerPixel; -},{"../../renderers/canvas/utils/canUseNewCanvasBlendModes":71,"../../utils":108}],94:[function(require,module,exports){ +},{"../../renderers/canvas/utils/canUseNewCanvasBlendModes":71,"../../utils":109}],94:[function(require,module,exports){ var Buffer = function(size) @@ -19430,32 +19479,33 @@ */ SpriteRenderer.prototype.destroy = function () { - for (var i = 0; i < this.vaoMax; i++) { + for (var i = 0; i < this.vertexCount; i++) { this.vertexBuffers[i].destroy(); this.vaos[i].destroy(); } this.indexBuffer.destroy(); + this.renderer.off('prerender', this.onPrerender, this); ObjectRenderer.prototype.destroy.call(this); this.shader.destroy(); - this.renderer = null; - - this.vertexBuffer = null; + this.vertexBuffers = null; + this.vaos = null; this.indexBuffer = null; + this.indices = null; this.sprites = null; this.shader = null; for (i = 0; i < this.buffers.length; i++) { - this.buffers[i].destroy(); + this.buffers[i].destroy(); } }; -},{"../../const":39,"../../renderers/webgl/WebGLRenderer":75,"../../renderers/webgl/utils/ObjectRenderer":85,"../../renderers/webgl/utils/checkMaxIfStatmentsInShader":88,"../../utils/createIndicesForQuads":106,"./BatchBuffer":94,"./generateMultiTextureShader":96,"bit-twiddle":17,"pixi-gl-core":1}],96:[function(require,module,exports){ +},{"../../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; var fragTemplate = [ @@ -20229,7 +20279,343 @@ this._texture.destroy(destroyBaseTexture === undefined ? true : destroyBaseTexture); }; -},{"../const":39,"../math":61,"../sprites/Sprite":91,"../textures/Texture":101,"../utils":108}],98:[function(require,module,exports){ +},{"../const":39,"../math":61,"../sprites/Sprite":91,"../textures/Texture":102,"../utils":109}],98:[function(require,module,exports){ +var EventEmitter = require('eventemitter3'), + CONST = require('../const'), + utils = require('../utils'); + +/** + * A TextStyle Object decorates a Text Object. It acts as an event emitter, and can be shared between + * multiple Text objects. + * + * @class + * @extends EventEmitter + * @memberof PIXI + * @param [style] {object} The style parameters + * @param [style.font='bold 20pt Arial'] {string} The style and size of the font + * @param [style.fill='black'] {string|number} A canvas fillstyle that will be used on the text e.g 'red', '#00FF00' + * @param [style.align='left'] {string} Alignment for multiline text ('left', 'center' or 'right'), does not affect single line text + * @param [style.stroke='black'] {string|number} A canvas fillstyle that will be used on the text stroke e.g 'blue', '#FCFF00' + * @param [style.strokeThickness=0] {number} A number that represents the thickness of the stroke. Default is 0 (no stroke) + * @param [style.wordWrap=false] {boolean} Indicates if word wrap should be used + * @param [style.wordWrapWidth=100] {number} The width at which text will wrap, it needs wordWrap to be set to true + * @param [style.lineHeight] {number} The line height, a number that represents the vertical space that a letter uses + * @param [style.dropShadow=false] {boolean} Set a drop shadow for the text + * @param [style.dropShadowColor='#000000'] {string} A fill style to be used on the dropshadow e.g 'red', '#00FF00' + * @param [style.dropShadowAngle=Math.PI/6] {number} Set a angle of the drop shadow + * @param [style.dropShadowDistance=5] {number} Set a distance of the drop shadow + * @param [style.dropShadowBlur=0] {number} Set a shadow blur radius + * @param [style.padding=0] {number} Occasionally some fonts are cropped on top or bottom. Adding some padding will + * prevent this from happening by adding padding to the top and bottom of text height. + * @param [style.textBaseline='alphabetic'] {string} The baseline of the text that is rendered. + * @param [style.lineJoin='miter'] {string} The lineJoin property sets the type of corner created, it can resolve + * spiked text issues. Default is 'miter' (creates a sharp corner). + * @param [style.miterLimit=10] {number} The miter limit to use when using the 'miter' lineJoin mode. This can reduce + * or increase the spikiness of rendered text. + */ +function TextStyle(style) +{ + EventEmitter.call(this); + Object.assign(this, this._defaults, style); +} + +TextStyle.prototype = Object.create(EventEmitter.prototype); +TextStyle.prototype.constructor = TextStyle; +module.exports = TextStyle; + +// Default settings. Explained in the constructor. +TextStyle.prototype._defaults = { + align: 'left', + dropShadow: false, + dropShadowAngle: Math.PI / 6, + dropShadowBlur: 0, + dropShadowColor: '#000000', + dropShadowDistance: 5, + lineHeight: null, + lineJoin: 'miter', + fill: 'black', + font: 'bold 20pt Arial', + miterLimit: 10, + padding: 0, + stroke: 'black', + strokeThickness: 0, + textBaseline: 'alphabetic', + wordWrap: false, + wordWrapWidth: 100 +}; + +/** + * Creates a new TextStyle object with the same values as this one. + * Note that the only the properties of the object are cloned, not its event emitter. + * + * @return {PIXI.TextStyle} + */ +TextStyle.prototype.clone = function () +{ + var clonedProperties = {}; + for (var key in this._defaults) + { + clonedProperties[key] = this[key]; + } + return new TextStyle(clonedProperties); +}; + +/** + * Resets all properties to the defaults specified in TextStyle.prototype._default + */ +TextStyle.prototype.reset = function () +{ + Object.assign(this, this._defaults); +}; + +/** + * Create setters and getters for each of the style properties. Converts colors where necessary. + * Any set operation will emit a styleChanged event. + */ +Object.defineProperties(TextStyle.prototype, { + font: { + get: function () + { + return this._font; + }, set: function (font) + { + if (this._font !== font) + { + this._font = font; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + fill: { + get: function () + { + return this._fill; + }, set: function (fill) + { + var outputColor = getColor(fill); + if (this._fill !== outputColor) + { + this._fill = outputColor; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + align: { + get: function () + { + return this._align; + }, set: function (align) + { + if (this._align !== align) + { + this._align = align; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + stroke: { + get: function () + { + return this._stroke; + }, set: function (stroke) + { + var outputColor = getColor(stroke); + if (this._stroke !== outputColor) + { + this._stroke = outputColor; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + strokeThickness: { + get: function () + { + return this._strokeThickness; + }, set: function (strokeThickness) + { + if (this._strokeThickness !== strokeThickness) + { + this._strokeThickness = strokeThickness; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + wordWrap: { + get: function () + { + return this._wordWrap; + }, set: function (wordWrap) + { + if (this._wordWrap !== wordWrap) + { + this._wordWrap = wordWrap; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + wordWrapWidth: { + get: function () + { + return this._wordWrapWidth; + }, set: function (wordWrapWidth) + { + if (this._wordWrapWidth !== wordWrapWidth) + { + this._wordWrapWidth = wordWrapWidth; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + dropShadow: { + get: function () + { + return this._dropShadow; + }, set: function (dropShadow) + { + if (this._dropShadow !== dropShadow) + { + this._dropShadow = dropShadow; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + dropShadowColor: { + get: function () + { + return this._dropShadowColor; + }, set: function (dropShadowColor) + { + var outputColor = getColor(dropShadowColor); + if (this._dropShadowColor !== outputColor) + { + this._dropShadowColor = outputColor; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + dropShadowAngle: { + get: function () + { + return this._dropShadowAngle; + }, set: function (dropShadowAngle) + { + if (this._dropShadowAngle !== dropShadowAngle) + { + this._dropShadowAngle = dropShadowAngle; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + dropShadowDistance: { + get: function () + { + return this._dropShadowDistance; + }, set: function (dropShadowDistance) + { + if (this._dropShadowDistance !== dropShadowDistance) + { + this._dropShadowDistance = dropShadowDistance; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + dropShadowBlur: { + get: function () + { + return this._dropShadowBlur; + }, set: function (dropShadowBlur) + { + if (this._dropShadowBlur !== dropShadowBlur) + { + this._dropShadowBlur = dropShadowBlur; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + padding: { + get: function () + { + return this._padding; + }, set: function (padding) + { + if (this._padding !== padding) + { + this._padding = padding; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + textBaseline: { + get: function () + { + return this._textBaseline; + }, set: function (textBaseline) + { + if (this._textBaseline !== textBaseline) + { + this._textBaseline = textBaseline; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + lineJoin: { + get: function () + { + return this._lineJoin; + }, set: function (lineJoin) + { + if (this._lineJoin !== lineJoin) + { + this._lineJoin = lineJoin; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + lineHeight: { + get: function () + { + return this._lineHeight; + }, set: function (lineHeight) + { + if (this._lineHeight !== lineHeight) + { + this._lineHeight = lineHeight; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + miterLimit: { + get: function () + { + return this._miterLimit; + }, set: function (miterLimit) + { + if (this._miterLimit !== miterLimit) + { + this._miterLimit = miterLimit; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + } +}); + +/** + * Utility function to convert hexadecimal colors to strings, and simply return the color if it's a string. + * + * @return {string} The color as a string. + */ +function getColor(color) +{ + if (typeof color === 'number') + { + return utils.hex2string(color); + } else + { + return color; + } +} + +},{"../const":39,"../utils":109,"eventemitter3":26}],99:[function(require,module,exports){ var BaseTexture = require('./BaseTexture'), CONST = require('../const'); @@ -20367,7 +20753,7 @@ }; -},{"../const":39,"./BaseTexture":99}],99:[function(require,module,exports){ +},{"../const":39,"./BaseTexture":100}],100:[function(require,module,exports){ var utils = require('../utils'), CONST = require('../const'), EventEmitter = require('eventemitter3'), @@ -20816,7 +21202,7 @@ return baseTexture; }; -},{"../const":39,"../utils":108,"../utils/determineCrossOrigin":107,"bit-twiddle":17,"eventemitter3":26}],100:[function(require,module,exports){ +},{"../const":39,"../utils":109,"../utils/determineCrossOrigin":108,"bit-twiddle":17,"eventemitter3":26}],101:[function(require,module,exports){ var BaseRenderTexture = require('./BaseRenderTexture'), Texture = require('./Texture'); @@ -20937,7 +21323,7 @@ return new RenderTexture(new BaseRenderTexture(width, height, scaleMode, resolution)); }; -},{"./BaseRenderTexture":98,"./Texture":101}],101:[function(require,module,exports){ +},{"./BaseRenderTexture":99,"./Texture":102}],102:[function(require,module,exports){ var BaseTexture = require('./BaseTexture'), VideoBaseTexture = require('./VideoBaseTexture'), TextureUvs = require('./TextureUvs'), @@ -21426,13 +21812,19 @@ /** * An empty texture, used often to not have to create multiple empty textures. + * Can not be destroyed. * * @static * @constant */ Texture.EMPTY = new Texture(new BaseTexture()); +Texture.EMPTY.destroy = function() {} +Texture.EMPTY.on = function() {}; +Texture.EMPTY.once = function() {}; +Texture.EMPTY.emit = function() {}; -},{"../math":61,"../utils":108,"./BaseTexture":99,"./TextureUvs":102,"./VideoBaseTexture":103,"eventemitter3":26}],102:[function(require,module,exports){ + +},{"../math":61,"../utils":109,"./BaseTexture":100,"./TextureUvs":103,"./VideoBaseTexture":104,"eventemitter3":26}],103:[function(require,module,exports){ /** * A standard object to store the Uvs of a texture @@ -21517,7 +21909,7 @@ this.uvsUint32[3] = (((this.y3 * 65535) & 0xFFFF) << 16) | ((this.x3 * 65535) & 0xFFFF); }; -},{"../math/GroupD8":58}],103:[function(require,module,exports){ +},{"../math/GroupD8":58}],104:[function(require,module,exports){ var BaseTexture = require('./BaseTexture'), utils = require('../utils'); @@ -21754,7 +22146,7 @@ return source; } -},{"../utils":108,"./BaseTexture":99}],104:[function(require,module,exports){ +},{"../utils":109,"./BaseTexture":100}],105:[function(require,module,exports){ var CONST = require('../const'), EventEmitter = require('eventemitter3'), // Internal event used by composed emitter @@ -22091,7 +22483,7 @@ // Allow calling update directly with default currentTime. currentTime = currentTime || performance.now(); // Save uncapped elapsedMS for measurement - elapsedMS = this.elapsedMS = currentTime - this.lastTime; + Math.max(0, elapsedMS = this.elapsedMS = currentTime - this.lastTime); // cap the milliseconds elapsed used for deltaTime if (elapsedMS > this._maxElapsedMS) @@ -22109,7 +22501,7 @@ module.exports = Ticker; -},{"../const":39,"eventemitter3":26}],105:[function(require,module,exports){ +},{"../const":39,"eventemitter3":26}],106:[function(require,module,exports){ var Ticker = require('./Ticker'); /** @@ -22165,7 +22557,7 @@ Ticker: Ticker }; -},{"./Ticker":104}],106:[function(require,module,exports){ +},{"./Ticker":105}],107:[function(require,module,exports){ /** * Generic Mask Stack data structure * @class @@ -22196,7 +22588,7 @@ module.exports = createIndicesForQuads; -},{}],107:[function(require,module,exports){ +},{}],108:[function(require,module,exports){ var tempAnchor; var _url = require('url'); @@ -22240,7 +22632,7 @@ }; module.exports = determineCrossOrigin; -},{"url":24}],108:[function(require,module,exports){ +},{"url":24}],109:[function(require,module,exports){ var CONST = require('../const'); /** @@ -22386,7 +22778,14 @@ var canvas = document.createElement('canvas'), gl = canvas.getContext('webgl', contextOptions) || canvas.getContext('experimental-webgl', contextOptions); - return !!(gl && gl.getContextAttributes().stencil); + var success = !!(gl && gl.getContextAttributes().stencil); + if (gl) + { + gl.getExtension('WEBGL_lose_context').loseContext(); + } + gl = null; + + return success; } catch (e) { @@ -22443,7 +22842,7 @@ BaseTextureCache: {} }; -},{"../const":39,"./pluginTarget":110,"eventemitter3":26}],109:[function(require,module,exports){ +},{"../const":39,"./pluginTarget":111,"eventemitter3":26}],110:[function(require,module,exports){ var Device = require('ismobilejs'); @@ -22464,7 +22863,7 @@ }; module.exports = maxRecommendedTextures; -},{"ismobilejs":27}],110:[function(require,module,exports){ +},{"ismobilejs":27}],111:[function(require,module,exports){ /** * Mixins functionality to make an object have "plugins". * @@ -22534,7 +22933,7 @@ } }; -},{}],111:[function(require,module,exports){ +},{}],112:[function(require,module,exports){ /*global console */ var core = require('./core'), mesh = require('./mesh'), @@ -22834,9 +23233,9 @@ return this.generateCanvasTexture(scaleMode, resolution); }; -core.RenderTexture.prototype.render = function(displayObject) +core.RenderTexture.prototype.render = function(displayObject, matrix, clear, updateTransform) { - this.legacyRenderer.render(displayObject, this); + this.legacyRenderer.render(displayObject, this, clear, matrix, !updateTransform); warn('RenderTexture.render is now deprecated, please use renderer.render(displayObject, renderTexture)'); }; @@ -22995,7 +23394,7 @@ }; -},{"./core":57,"./extras":121,"./filters":133,"./mesh":148,"./particles":151}],112:[function(require,module,exports){ +},{"./core":57,"./extras":122,"./filters":134,"./mesh":149,"./particles":152}],113:[function(require,module,exports){ var core = require('../../core'), tempRect = new core.Rectangle(); @@ -23134,13 +23533,13 @@ core.CanvasRenderer.registerPlugin('extract', WebGLExtract); -},{"../../core":57}],113:[function(require,module,exports){ +},{"../../core":57}],114:[function(require,module,exports){ module.exports = { webGL: require('./webgl/WebGLExtract'), canvas: require('./canvas/CanvasExtract') }; -},{"./canvas/CanvasExtract":112,"./webgl/WebGLExtract":114}],114:[function(require,module,exports){ +},{"./canvas/CanvasExtract":113,"./webgl/WebGLExtract":115}],115:[function(require,module,exports){ var core = require('../../core'), tempRect = new core.Rectangle(); @@ -23324,7 +23723,7 @@ core.WebGLRenderer.registerPlugin('extract', Extract); -},{"../../core":57}],115:[function(require,module,exports){ +},{"../../core":57}],116:[function(require,module,exports){ var core = require('../core'); /** @@ -23712,7 +24111,7 @@ BitmapText.fonts = {}; -},{"../core":57}],116:[function(require,module,exports){ +},{"../core":57}],117:[function(require,module,exports){ var core = require('../core'); /** @@ -24032,7 +24431,7 @@ return new MovieClip(textures); }; -},{"../core":57}],117:[function(require,module,exports){ +},{"../core":57}],118:[function(require,module,exports){ var core = require('../core'), tempPoint = new core.Point(), CanvasTinter = require('../core/sprites/canvas/CanvasTinter'), @@ -24463,7 +24862,7 @@ return new TilingSprite(core.Texture.fromImage(imageId, crossorigin, scaleMode),width,height); }; -},{"../core":57,"../core/sprites/canvas/CanvasTinter":93,"./webgl/TilingShader":122}],118:[function(require,module,exports){ +},{"../core":57,"../core/sprites/canvas/CanvasTinter":93,"./webgl/TilingShader":123}],119:[function(require,module,exports){ var core = require('../core'), DisplayObject = core.DisplayObject, _tempMatrix = new core.Matrix(); @@ -24739,7 +25138,7 @@ this._originalDestroy(); }; -},{"../core":57}],119:[function(require,module,exports){ +},{"../core":57}],120:[function(require,module,exports){ var core = require('../core'); /** @@ -24769,7 +25168,7 @@ return null; }; -},{"../core":57}],120:[function(require,module,exports){ +},{"../core":57}],121:[function(require,module,exports){ var core = require('../core'); /** @@ -24799,7 +25198,7 @@ return point; }; -},{"../core":57}],121:[function(require,module,exports){ +},{"../core":57}],122:[function(require,module,exports){ /** * @file Main export of the PIXI extras library * @author Mat Groves @@ -24820,7 +25219,7 @@ BitmapText: require('./BitmapText') }; -},{"./BitmapText":115,"./MovieClip":116,"./TilingSprite":117,"./cacheAsBitmap":118,"./getChildByName":119,"./getGlobalPosition":120}],122:[function(require,module,exports){ +},{"./BitmapText":116,"./MovieClip":117,"./TilingSprite":118,"./cacheAsBitmap":119,"./getChildByName":120,"./getGlobalPosition":121}],123:[function(require,module,exports){ var Shader = require('pixi-gl-core').GLShader; @@ -24844,7 +25243,7 @@ module.exports = TilingShader; -},{"pixi-gl-core":1}],123:[function(require,module,exports){ +},{"pixi-gl-core":1}],124:[function(require,module,exports){ var core = require('../../core'), BlurXFilter = require('./BlurXFilter'), BlurYFilter = require('./BlurYFilter'); @@ -24964,7 +25363,7 @@ } }); -},{"../../core":57,"./BlurXFilter":124,"./BlurYFilter":125}],124:[function(require,module,exports){ +},{"../../core":57,"./BlurXFilter":125,"./BlurYFilter":126}],125:[function(require,module,exports){ var core = require('../../core'); var generateBlurVertSource = require('./generateBlurVertSource'); var generateBlurFragSource = require('./generateBlurFragSource'); @@ -25072,7 +25471,7 @@ } }); -},{"../../core":57,"./generateBlurFragSource":126,"./generateBlurVertSource":127,"./getMaxBlurKernelSize":128}],125:[function(require,module,exports){ +},{"../../core":57,"./generateBlurFragSource":127,"./generateBlurVertSource":128,"./getMaxBlurKernelSize":129}],126:[function(require,module,exports){ var core = require('../../core'); var generateBlurVertSource = require('./generateBlurVertSource'); var generateBlurFragSource = require('./generateBlurFragSource'); @@ -25170,7 +25569,7 @@ } }); -},{"../../core":57,"./generateBlurFragSource":126,"./generateBlurVertSource":127,"./getMaxBlurKernelSize":128}],126:[function(require,module,exports){ +},{"../../core":57,"./generateBlurFragSource":127,"./generateBlurVertSource":128,"./getMaxBlurKernelSize":129}],127:[function(require,module,exports){ var GAUSSIAN_VALUES = { 5:[0.153388, 0.221461, 0.250301], 7:[0.071303, 0.131514, 0.189879, 0.214607], @@ -25235,7 +25634,7 @@ module.exports = generateFragBlurSource; -},{}],127:[function(require,module,exports){ +},{}],128:[function(require,module,exports){ var vertTemplate = [ 'attribute vec2 aVertexPosition;', @@ -25265,11 +25664,11 @@ if(x) { - template = 'vBlurTexCoords[%index%] = aTextureCoord + vec2(%samlpeIndex% * strength, 0.0);'; + template = 'vBlurTexCoords[%index%] = aTextureCoord + vec2(%sampleIndex% * strength, 0.0);'; } else { - template = 'vBlurTexCoords[%index%] = aTextureCoord + vec2(0.0, %samlpeIndex% * strength);'; + template = 'vBlurTexCoords[%index%] = aTextureCoord + vec2(0.0, %sampleIndex% * strength);'; } @@ -25285,7 +25684,7 @@ value = kernelSize - i - 1; } - blur = blur.replace('%samlpeIndex%', (i - (halfLength-1)) + '.0'); + blur = blur.replace('%sampleIndex%', (i - (halfLength-1)) + '.0'); blurLoop += blur; blurLoop += '\n'; @@ -25301,7 +25700,7 @@ module.exports = generateVertBlurSource; -},{}],128:[function(require,module,exports){ +},{}],129:[function(require,module,exports){ var getMaxKernelSize = function(gl) @@ -25319,7 +25718,7 @@ module.exports = getMaxKernelSize; -},{}],129:[function(require,module,exports){ +},{}],130:[function(require,module,exports){ var core = require('../../core'); // @see https://github.com/substack/brfs/issues/25 @@ -25853,7 +26252,7 @@ } }); -},{"../../core":57}],130:[function(require,module,exports){ +},{"../../core":57}],131:[function(require,module,exports){ var core = require('../../core'); @@ -25932,7 +26331,7 @@ } }); -},{"../../core":57}],131:[function(require,module,exports){ +},{"../../core":57}],132:[function(require,module,exports){ var core = require('../../core'); @@ -26025,7 +26424,7 @@ } }); -},{"../../core":57}],132:[function(require,module,exports){ +},{"../../core":57}],133:[function(require,module,exports){ var core = require('../../core'); // @see https://github.com/substack/brfs/issues/25 @@ -26074,7 +26473,7 @@ } }); -},{"../../core":57}],133:[function(require,module,exports){ +},{"../../core":57}],134:[function(require,module,exports){ /** * @file Main export of the PIXI filters library * @author Mat Groves @@ -26115,7 +26514,7 @@ GodrayFilter: require('./godray/GodrayFilter') }; -},{"./blur/BlurFilter":123,"./blur/BlurXFilter":124,"./blur/BlurYFilter":125,"./colormatrix/ColorMatrixFilter":129,"./displacement/DisplacementFilter":130,"./godray/GodrayFilter":131,"./gray/GrayFilter":132,"./twist/TwistFilter":134}],134:[function(require,module,exports){ +},{"./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){ var core = require('../../core'); @@ -26213,7 +26612,7 @@ } }); -},{"../../core":57}],135:[function(require,module,exports){ +},{"../../core":57}],136:[function(require,module,exports){ (function (global){ // run the polyfills require('./polyfill'); @@ -26247,7 +26646,7 @@ global.PIXI = core; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./accessibility":38,"./core":57,"./deprecation":111,"./extract":113,"./extras":121,"./filters":133,"./interaction":138,"./loaders":141,"./mesh":148,"./particles":151,"./polyfill":157}],136:[function(require,module,exports){ +},{"./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){ var core = require('../core'); /** @@ -26296,7 +26695,7 @@ return displayObject.worldTransform.applyInverse(globalPos || this.global, point); }; -},{"../core":57}],137:[function(require,module,exports){ +},{"../core":57}],138:[function(require,module,exports){ var core = require('../core'), InteractionData = require('./InteractionData'); @@ -27235,7 +27634,7 @@ core.WebGLRenderer.registerPlugin('interaction', InteractionManager); core.CanvasRenderer.registerPlugin('interaction', InteractionManager); -},{"../core":57,"./InteractionData":136,"./interactiveTarget":139}],138:[function(require,module,exports){ +},{"../core":57,"./InteractionData":137,"./interactiveTarget":140}],139:[function(require,module,exports){ /** * @file Main export of the PIXI interactions library * @author Mat Groves @@ -27252,10 +27651,10 @@ interactiveTarget: require('./interactiveTarget') }; -},{"./InteractionData":136,"./InteractionManager":137,"./interactiveTarget":139}],139:[function(require,module,exports){ +},{"./InteractionData":137,"./InteractionManager":138,"./interactiveTarget":140}],140:[function(require,module,exports){ /** * Default property values of interactive objects - * used by {@link PIXI.interaction.InteractionManager}. + * Used by {@link PIXI.interaction.InteractionManager} to automatically give all DisplayObjects these properties * * @mixin * @memberof PIXI.interaction @@ -27269,39 +27668,79 @@ */ var interactiveTarget = { /** - * @todo Needs docs. + * Determines if the displayObject be clicked/touched + * + * @inner {boolean} */ interactive: false, + /** - * @todo Needs docs. - */ - buttonMode: false, - /** - * @todo Needs docs. + * Determines if the children to the displayObject can be clicked/touched + * Setting this to false allows pixi to bypass a recursive hitTest function + * + * @inner {boolean} */ interactiveChildren: true, + /** - * @todo Needs docs. + * Interaction shape. Children will be hit first, then this shape will be checked. + * + * @inner {PIXI.Rectangle|PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.RoundedRectangle} + */ + hitArea: null, + + /** + * If enabled, the mouse cursor will change when hovered over the displayObject if it is interactive + * + * @inner {boolean} + */ + buttonMode: false, + + /** + * If buttonMode is enabled, this defines what CSS cursor property is used when the mouse cursor is hovered over the displayObject + * https://developer.mozilla.org/en/docs/Web/CSS/cursor + * + * @inner {string} */ defaultCursor: 'pointer', // some internal checks.. - /** - * @todo Needs docs. + * Internal check to detect if the mouse cursor is hovered over the displayObject + * + * @inner {boolean} * @private */ _over: false, + /** - * @todo Needs docs. + * Internal check to detect if the left mouse button is pressed on the displayObject + * + * @inner {boolean} + * @private + */ + _isLeftDown: false, + + /** + * Internal check to detect if the right mouse button is pressed on the displayObject + * + * @inner {boolean} + * @private + */ + _isRightDown: false, + + /** + * Internal check to detect if a user has touched the displayObject + * + * @inner {boolean} * @private */ _touchDown: false -}; + }; module.exports = interactiveTarget; -},{}],140:[function(require,module,exports){ +},{}],141:[function(require,module,exports){ var Resource = require('resource-loader').Resource, core = require('../core'), extras = require('../extras'), @@ -27425,7 +27864,7 @@ }; }; -},{"../core":57,"../extras":121,"path":18,"resource-loader":33}],141:[function(require,module,exports){ +},{"../core":57,"../extras":122,"path":18,"resource-loader":33}],142:[function(require,module,exports){ /** * @file Main export of the PIXI loaders library * @author Mat Groves @@ -27446,7 +27885,7 @@ Resource: require('resource-loader').Resource }; -},{"./bitmapFontParser":140,"./loader":142,"./spritesheetParser":143,"./textureParser":144,"resource-loader":33}],142:[function(require,module,exports){ +},{"./bitmapFontParser":141,"./loader":143,"./spritesheetParser":144,"./textureParser":145,"resource-loader":33}],143:[function(require,module,exports){ var ResourceLoader = require('resource-loader'), textureParser = require('./textureParser'), spritesheetParser = require('./spritesheetParser'), @@ -27508,7 +27947,7 @@ Resource.setExtensionXhrType('fnt', Resource.XHR_RESPONSE_TYPE.DOCUMENT); -},{"./bitmapFontParser":140,"./spritesheetParser":143,"./textureParser":144,"resource-loader":33}],143:[function(require,module,exports){ +},{"./bitmapFontParser":141,"./spritesheetParser":144,"./textureParser":145,"resource-loader":33}],144:[function(require,module,exports){ var Resource = require('resource-loader').Resource, path = require('path'), core = require('../core'), @@ -27625,7 +28064,7 @@ }; }; -},{"../core":57,"async":16,"path":18,"resource-loader":33}],144:[function(require,module,exports){ +},{"../core":57,"async":16,"path":18,"resource-loader":33}],145:[function(require,module,exports){ var core = require('../core'); module.exports = function () @@ -27647,7 +28086,7 @@ }; }; -},{"../core":57}],145:[function(require,module,exports){ +},{"../core":57}],146:[function(require,module,exports){ var core = require('../core'), glCore = require('pixi-gl-core'), Shader = require('./webgl/MeshShader'), @@ -28185,7 +28624,7 @@ TRIANGLES: 1 }; -},{"../core":57,"./webgl/MeshShader":149,"pixi-gl-core":1}],146:[function(require,module,exports){ +},{"../core":57,"./webgl/MeshShader":150,"pixi-gl-core":1}],147:[function(require,module,exports){ var Mesh = require('./Mesh'); /** @@ -28310,7 +28749,7 @@ } }; -},{"./Mesh":145}],147:[function(require,module,exports){ +},{"./Mesh":146}],148:[function(require,module,exports){ var Mesh = require('./Mesh'); var core = require('../core'); @@ -28525,7 +28964,7 @@ this.containerUpdateTransform(); }; -},{"../core":57,"./Mesh":145}],148:[function(require,module,exports){ +},{"../core":57,"./Mesh":146}],149:[function(require,module,exports){ /** * @file Main export of the PIXI extras library * @author Mat Groves @@ -28543,7 +28982,7 @@ MeshShader: require('./webgl/MeshShader') }; -},{"./Mesh":145,"./Plane":146,"./Rope":147,"./webgl/MeshShader":149}],149:[function(require,module,exports){ +},{"./Mesh":146,"./Plane":147,"./Rope":148,"./webgl/MeshShader":150}],150:[function(require,module,exports){ var Shader = require('pixi-gl-core').GLShader; /** @@ -28593,7 +29032,7 @@ module.exports = MeshShader; -},{"pixi-gl-core":1}],150:[function(require,module,exports){ +},{"pixi-gl-core":1}],151:[function(require,module,exports){ var core = require('../core'); /** @@ -28926,7 +29365,7 @@ this._buffers = null; }; -},{"../core":57}],151:[function(require,module,exports){ +},{"../core":57}],152:[function(require,module,exports){ /** * @file Main export of the PIXI extras library * @author Mat Groves @@ -28942,7 +29381,7 @@ ParticleRenderer: require('./webgl/ParticleRenderer') }; -},{"./ParticleContainer":150,"./webgl/ParticleRenderer":153}],152:[function(require,module,exports){ +},{"./ParticleContainer":151,"./webgl/ParticleRenderer":154}],153:[function(require,module,exports){ var glCore = require('pixi-gl-core'), createIndicesForQuads = require('../../core/utils/createIndicesForQuads'); @@ -29163,7 +29602,7 @@ this.staticBuffer.destroy(); }; -},{"../../core/utils/createIndicesForQuads":106,"pixi-gl-core":1}],153:[function(require,module,exports){ +},{"../../core/utils/createIndicesForQuads":107,"pixi-gl-core":1}],154:[function(require,module,exports){ var core = require('../../core'), ParticleShader = require('./ParticleShader'), ParticleBuffer = require('./ParticleBuffer'); @@ -29595,7 +30034,7 @@ this.tempMatrix = null; }; -},{"../../core":57,"./ParticleBuffer":152,"./ParticleShader":154}],154:[function(require,module,exports){ +},{"../../core":57,"./ParticleBuffer":153,"./ParticleShader":155}],155:[function(require,module,exports){ var Shader = require('pixi-gl-core').GLShader; /** @@ -29663,7 +30102,7 @@ module.exports = ParticleShader; -},{"pixi-gl-core":1}],155:[function(require,module,exports){ +},{"pixi-gl-core":1}],156:[function(require,module,exports){ // References: // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign @@ -29679,7 +30118,7 @@ }; } -},{}],156:[function(require,module,exports){ +},{}],157:[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 @@ -29689,7 +30128,7 @@ Object.assign = require('object-assign'); } -},{"object-assign":28}],157:[function(require,module,exports){ +},{"object-assign":28}],158:[function(require,module,exports){ require('./Object.assign'); require('./requestAnimationFrame'); require('./Math.sign'); @@ -29707,7 +30146,7 @@ window.Uint16Array = Array; } -},{"./Math.sign":155,"./Object.assign":156,"./requestAnimationFrame":158}],158:[function(require,module,exports){ +},{"./Math.sign":156,"./Object.assign":157,"./requestAnimationFrame":159}],159:[function(require,module,exports){ (function (global){ // References: // http://paulirish.com/2011/requestanimationframe-for-smart-animating/ @@ -29777,6 +30216,6 @@ } }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}]},{},[135])(135) +},{}]},{},[136])(136) }); //# sourceMappingURL=pixi.js.map diff --git a/bin/pixi.js b/bin/pixi.js index 22c122a..ee10553 100644 --- a/bin/pixi.js +++ b/bin/pixi.js @@ -8980,6 +8980,8 @@ * If set to DEFAULT, the renderer will occasianally check textures usage. If they are not used for a specified period of time they will be removed from the GPU. * They will of corse be uploaded again when they are required. This is a silent behind the scenes process that should ensure that the GPU does not get filled up. * Handy for mobile devices! + * This property only affects WebGL + * Handy for mobile devices! * This property only affects WebGL. * * @static @@ -9087,12 +9089,13 @@ // 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. + 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 }; module.exports = CONST; -},{"./utils/maxRecommendedTextures":109}],40:[function(require,module,exports){ +},{"./utils/maxRecommendedTextures":110}],40:[function(require,module,exports){ var math = require('../math'), utils = require('../utils'), DisplayObject = require('./DisplayObject'); @@ -9720,7 +9723,7 @@ this.children = null; }; -},{"../math":61,"../utils":108,"./DisplayObject":41}],41:[function(require,module,exports){ +},{"../math":61,"../utils":109,"./DisplayObject":41}],41:[function(require,module,exports){ var math = require('../math'), EventEmitter = require('eventemitter3'), Transform = require('./Transform'), @@ -9733,6 +9736,7 @@ * * @class * @extends EventEmitter + * @mixes PIXI.interaction.interactiveTarget * @memberof PIXI */ function DisplayObject() @@ -9796,13 +9800,6 @@ this.filterArea = null; /** - * Interaction shape. Children will be hit first, then this shape will be checked. - * - * @member {PIXI.Rectangle|PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.RoundedRectangle} - */ - this.hitArea = null; - - /** * The original, cached bounds of the object * * @member {PIXI.Rectangle} @@ -11607,6 +11604,30 @@ return texture; }; +Graphics.prototype.closePath = function () +{ + // ok so close path assumes next one is a hole! + var currentPath = this.currentPath; + if (currentPath && currentPath.shape) + { + currentPath.shape.close(); + } + return this; +}; + +Graphics.prototype.addHole = function() +{ + // this is a hole! + var hole = this.graphicsData.pop(); + + this.currentPath = this.graphicsData[this.graphicsData.length-1]; + + this.currentPath.addHole(hole.shape); + this.currentPath = null; + + return this; +}; + /** * Destroys the Graphics object. */ @@ -11633,7 +11654,7 @@ this._localBounds = null; }; -},{"../const":39,"../display/Container":40,"../math":61,"../renderers/canvas/CanvasRenderer":68,"../sprites/Sprite":91,"../textures/RenderTexture":100,"../textures/Texture":101,"./GraphicsData":46,"./utils/bezierCurveTo":48}],46:[function(require,module,exports){ +},{"../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){ /** * A GraphicsData object. * @@ -11687,6 +11708,9 @@ */ this.fill = fill; + + this.holes = []; + /* * @member {PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.Rectangle|PIXI.RoundedRectangle} The shape object to draw. */ @@ -11719,11 +11743,17 @@ ); }; +GraphicsData.prototype.addHole = function (shape) +{ + this.holes.push(shape); +}; + /** * Destroys the Graphics data. */ GraphicsData.prototype.destroy = function () { this.shape = null; + this.holes = null; }; },{}],47:[function(require,module,exports){ @@ -11812,25 +11842,14 @@ { context.beginPath(); - var points = shape.points; + this.renderPolygon(shape.points, shape.closed, context); - context.moveTo(points[0], points[1]); - - for (var j=1; j < points.length/2; j++) + for (var j = 0; j < data.holes.length; j++) { - context.lineTo(points[j * 2], points[j * 2 + 1]); + var hole = data.holes[j]; + this.renderPolygon(hole.points, true, context); } - if (shape.closed) - { - context.lineTo(points[0], points[1]); - } - - // if the first and last point are the same close the path - much neater :) - if (points[0] === points[points.length-2] && points[1] === points[points.length-1]) - { - context.closePath(); - } if (data.fill) { @@ -11996,6 +12015,21 @@ } }; +CanvasGraphicsRenderer.prototype.renderPolygon = function (points, close, context) +{ + context.moveTo(points[0], points[1]); + + for (var j=1; j < points.length/2; j++) + { + context.lineTo(points[j * 2], points[j * 2 + 1]); + } + + if (close) + { + context.closePath(); + } +}; + /* * destroy graphics object * @@ -12274,7 +12308,7 @@ return webGLData; }; -},{"../../const":39,"../../renderers/webgl/WebGLRenderer":75,"../../renderers/webgl/utils/ObjectRenderer":85,"../../utils":108,"./WebGLGraphicsData":50,"./shaders/PrimitiveShader":51,"./utils/buildCircle":52,"./utils/buildPoly":54,"./utils/buildRectangle":55,"./utils/buildRoundedRectangle":56}],50:[function(require,module,exports){ +},{"../../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){ var glCore = require('pixi-gl-core'); @@ -12539,7 +12573,7 @@ module.exports = buildCircle; -},{"../../../const":39,"../../../utils":108,"./buildLine":53}],53:[function(require,module,exports){ +},{"../../../const":39,"../../../utils":109,"./buildLine":53}],53:[function(require,module,exports){ var math = require('../../../math'), utils = require('../../../utils'); @@ -12759,7 +12793,7 @@ }; module.exports = buildLine; -},{"../../../math":61,"../../../utils":108}],54:[function(require,module,exports){ +},{"../../../math":61,"../../../utils":109}],54:[function(require,module,exports){ var buildLine = require('./buildLine'), utils = require('../../../utils'), earcut = require('earcut'); @@ -12777,20 +12811,21 @@ var points = graphicsData.points; - // need to add the points the the graphics object.. - if (graphicsData.shape.closed) - { - // close the poly if the value is true! - if (points[0] !== points[points.length-2] || points[1] !== points[points.length-1]) - { - points.push(points[0], points[1]); - } - } - - if(graphicsData.fill && points.length > 6) { + var holeArray = []; + // Process holes.. + var holes = graphicsData.holes; + + for (var i = 0; i < holes.length; i++) { + var hole = holes[i]; + + holeArray.push(points.length/2); + + points = points.concat(hole.points); + } + // get first and last point.. figure out the middle! var verts = webGLData.points; var indices = webGLData.indices; @@ -12804,7 +12839,7 @@ var g = color[1] * alpha; var b = color[2] * alpha; - var triangles = earcut(points, null, 2); + var triangles = earcut(points, holeArray, 2); if (!triangles) { return; @@ -12839,7 +12874,7 @@ module.exports = buildPoly; -},{"../../../utils":108,"./buildLine":53,"earcut":25}],55:[function(require,module,exports){ +},{"../../../utils":109,"./buildLine":53,"earcut":25}],55:[function(require,module,exports){ var buildLine = require('./buildLine'), utils = require('../../../utils'); @@ -12910,7 +12945,7 @@ }; module.exports = buildRectangle; -},{"../../../utils":108,"./buildLine":53}],56:[function(require,module,exports){ +},{"../../../utils":109,"./buildLine":53}],56:[function(require,module,exports){ var earcut = require('earcut'), buildLine = require('./buildLine'), utils = require('../../../utils'); @@ -13040,7 +13075,7 @@ module.exports = buildRoundedRectangle; -},{"../../../utils":108,"./buildLine":53,"earcut":25}],57:[function(require,module,exports){ +},{"../../../utils":109,"./buildLine":53,"earcut":25}],57:[function(require,module,exports){ /** * @file Main export of the PIXI core library * @author Mat Groves @@ -13071,7 +13106,7 @@ // text Text: require('./text/Text'), - + TextStyle: require('./text/TextStyle'), // primitives Graphics: require('./graphics/Graphics'), GraphicsData: require('./graphics/GraphicsData'), @@ -13136,7 +13171,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,"./textures/BaseRenderTexture":98,"./textures/BaseTexture":99,"./textures/RenderTexture":100,"./textures/Texture":101,"./textures/TextureUvs":102,"./textures/VideoBaseTexture":103,"./ticker":105,"./utils":108,"pixi-gl-core":1}],58:[function(require,module,exports){ +},{"./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){ // 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]; @@ -14090,6 +14125,18 @@ return new Polygon(this.points.slice()); }; + +Polygon.prototype.close = function () +{ + var points = this.points; + + // close the poly if the value is true! + if (points[0] !== points[points.length-2] || points[1] !== points[points.length-1]) + { + points.push(points[0], points[1]); + } +}; + /** * Checks whether the x and y coordinates passed to this function are contained within this polygon * @@ -14674,7 +14721,7 @@ this._lastObjectRendered = null; }; -},{"../const":39,"../display/Container":40,"../math":61,"../textures/RenderTexture":100,"../utils":108,"eventemitter3":26}],68:[function(require,module,exports){ +},{"../const":39,"../display/Container":40,"../math":61,"../textures/RenderTexture":101,"../utils":109,"eventemitter3":26}],68:[function(require,module,exports){ var SystemRenderer = require('../SystemRenderer'), CanvasMaskManager = require('./utils/CanvasMaskManager'), CanvasRenderTarget = require('./utils/CanvasRenderTarget'), @@ -14796,7 +14843,7 @@ if(renderTexture) { renderTexture = renderTexture.baseTexture || renderTexture; - + if(!renderTexture._canvasRenderTarget) { @@ -14855,16 +14902,18 @@ context.clear(); } - if( clear || this.clearBeforeRender) + if(clear !== undefined ? clear : this.clearBeforeRender) { - if (this.transparent) - { - context.clearRect(0, 0, this.width, this.height); - } - else - { - context.fillStyle = this._backgroundColorString; - context.fillRect(0, 0, this.width , this.height); + if (this.renderingToScreen) { + if (this.transparent) { + context.clearRect(0, 0, this.width, this.height); + } + else { + context.fillStyle = this._backgroundColorString; + context.fillRect(0, 0, this.width, this.height); + } + } else { + //TODO: implement background for CanvasRenderTarget or RenderTexture? } } @@ -14929,7 +14978,7 @@ }; -},{"../../const":39,"../../utils":108,"../SystemRenderer":67,"./utils/CanvasMaskManager":69,"./utils/CanvasRenderTarget":70,"./utils/mapCanvasBlendModesToPixi":72}],69:[function(require,module,exports){ +},{"../../const":39,"../../utils":109,"../SystemRenderer":67,"./utils/CanvasMaskManager":69,"./utils/CanvasRenderTarget":70,"./utils/mapCanvasBlendModesToPixi":72}],69:[function(require,module,exports){ var CONST = require('../../../const'); /** * A set of functions used to handle masking. @@ -15612,7 +15661,7 @@ module.exports = TextureManager; -},{"../../const":39,"../../utils":108,"./utils/RenderTarget":87,"pixi-gl-core":1}],75:[function(require,module,exports){ +},{"../../const":39,"../../utils":109,"./utils/RenderTarget":87,"pixi-gl-core":1}],75:[function(require,module,exports){ var SystemRenderer = require('../SystemRenderer'), MaskManager = require('./managers/MaskManager'), StencilManager = require('./managers/StencilManager'), @@ -16167,7 +16216,7 @@ // this = null; }; -},{"../../const":39,"../../utils":108,"../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":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){ var mapWebGLBlendModesToPixi = require('./utils/mapWebGLBlendModesToPixi'); /** @@ -16575,7 +16624,7 @@ '}' ].join('\n'); -},{"../../../utils":108,"./extractUniformsFromSrc":78}],78:[function(require,module,exports){ +},{"../../../utils":109,"./extractUniformsFromSrc":78}],78:[function(require,module,exports){ var defaultValue = require('pixi-gl-core/lib/shader/defaultValue'); var mapSize = require('pixi-gl-core/lib/shader/mapSize'); @@ -17702,7 +17751,7 @@ module.exports = Quad; -},{"../../../utils/createIndicesForQuads":106,"pixi-gl-core":1}],87:[function(require,module,exports){ +},{"../../../utils/createIndicesForQuads":107,"pixi-gl-core":1}],87:[function(require,module,exports){ var math = require('../../../math'), CONST = require('../../../const'), GLFramebuffer = require('pixi-gl-core').GLFramebuffer; @@ -18372,7 +18421,7 @@ } }; -Sprite.prototype.caclulateVertices = function () +Sprite.prototype.calculateVertices = function () { var texture = this._texture, wt = this.transform.worldTransform, @@ -18431,7 +18480,7 @@ { this.textureDirty = false; // set the vertex data - this.caclulateVertices(); + this.calculateVertices(); } renderer.setObjectRenderer(renderer.plugins.sprite); @@ -18465,7 +18514,7 @@ this.vertexDirty = false; // set the vertex data - this.caclulateVertices(); + this.calculateVertices(); } @@ -18650,7 +18699,7 @@ return new Sprite(Texture.fromImage(imageId, crossorigin, scaleMode)); }; -},{"../const":39,"../display/Container":40,"../math":61,"../textures/Texture":101,"../utils":108}],92:[function(require,module,exports){ +},{"../const":39,"../display/Container":40,"../math":61,"../textures/Texture":102,"../utils":109}],92:[function(require,module,exports){ var CanvasRenderer = require('../../renderers/canvas/CanvasRenderer'), CONST = require('../../const'), math = require('../../math'), @@ -19049,7 +19098,7 @@ */ CanvasTinter.tintMethod = CanvasTinter.canUseMultiply ? CanvasTinter.tintWithMultiply : CanvasTinter.tintWithPerPixel; -},{"../../renderers/canvas/utils/canUseNewCanvasBlendModes":71,"../../utils":108}],94:[function(require,module,exports){ +},{"../../renderers/canvas/utils/canUseNewCanvasBlendModes":71,"../../utils":109}],94:[function(require,module,exports){ var Buffer = function(size) @@ -19430,32 +19479,33 @@ */ SpriteRenderer.prototype.destroy = function () { - for (var i = 0; i < this.vaoMax; i++) { + for (var i = 0; i < this.vertexCount; i++) { this.vertexBuffers[i].destroy(); this.vaos[i].destroy(); } this.indexBuffer.destroy(); + this.renderer.off('prerender', this.onPrerender, this); ObjectRenderer.prototype.destroy.call(this); this.shader.destroy(); - this.renderer = null; - - this.vertexBuffer = null; + this.vertexBuffers = null; + this.vaos = null; this.indexBuffer = null; + this.indices = null; this.sprites = null; this.shader = null; for (i = 0; i < this.buffers.length; i++) { - this.buffers[i].destroy(); + this.buffers[i].destroy(); } }; -},{"../../const":39,"../../renderers/webgl/WebGLRenderer":75,"../../renderers/webgl/utils/ObjectRenderer":85,"../../renderers/webgl/utils/checkMaxIfStatmentsInShader":88,"../../utils/createIndicesForQuads":106,"./BatchBuffer":94,"./generateMultiTextureShader":96,"bit-twiddle":17,"pixi-gl-core":1}],96:[function(require,module,exports){ +},{"../../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; var fragTemplate = [ @@ -20229,7 +20279,343 @@ this._texture.destroy(destroyBaseTexture === undefined ? true : destroyBaseTexture); }; -},{"../const":39,"../math":61,"../sprites/Sprite":91,"../textures/Texture":101,"../utils":108}],98:[function(require,module,exports){ +},{"../const":39,"../math":61,"../sprites/Sprite":91,"../textures/Texture":102,"../utils":109}],98:[function(require,module,exports){ +var EventEmitter = require('eventemitter3'), + CONST = require('../const'), + utils = require('../utils'); + +/** + * A TextStyle Object decorates a Text Object. It acts as an event emitter, and can be shared between + * multiple Text objects. + * + * @class + * @extends EventEmitter + * @memberof PIXI + * @param [style] {object} The style parameters + * @param [style.font='bold 20pt Arial'] {string} The style and size of the font + * @param [style.fill='black'] {string|number} A canvas fillstyle that will be used on the text e.g 'red', '#00FF00' + * @param [style.align='left'] {string} Alignment for multiline text ('left', 'center' or 'right'), does not affect single line text + * @param [style.stroke='black'] {string|number} A canvas fillstyle that will be used on the text stroke e.g 'blue', '#FCFF00' + * @param [style.strokeThickness=0] {number} A number that represents the thickness of the stroke. Default is 0 (no stroke) + * @param [style.wordWrap=false] {boolean} Indicates if word wrap should be used + * @param [style.wordWrapWidth=100] {number} The width at which text will wrap, it needs wordWrap to be set to true + * @param [style.lineHeight] {number} The line height, a number that represents the vertical space that a letter uses + * @param [style.dropShadow=false] {boolean} Set a drop shadow for the text + * @param [style.dropShadowColor='#000000'] {string} A fill style to be used on the dropshadow e.g 'red', '#00FF00' + * @param [style.dropShadowAngle=Math.PI/6] {number} Set a angle of the drop shadow + * @param [style.dropShadowDistance=5] {number} Set a distance of the drop shadow + * @param [style.dropShadowBlur=0] {number} Set a shadow blur radius + * @param [style.padding=0] {number} Occasionally some fonts are cropped on top or bottom. Adding some padding will + * prevent this from happening by adding padding to the top and bottom of text height. + * @param [style.textBaseline='alphabetic'] {string} The baseline of the text that is rendered. + * @param [style.lineJoin='miter'] {string} The lineJoin property sets the type of corner created, it can resolve + * spiked text issues. Default is 'miter' (creates a sharp corner). + * @param [style.miterLimit=10] {number} The miter limit to use when using the 'miter' lineJoin mode. This can reduce + * or increase the spikiness of rendered text. + */ +function TextStyle(style) +{ + EventEmitter.call(this); + Object.assign(this, this._defaults, style); +} + +TextStyle.prototype = Object.create(EventEmitter.prototype); +TextStyle.prototype.constructor = TextStyle; +module.exports = TextStyle; + +// Default settings. Explained in the constructor. +TextStyle.prototype._defaults = { + align: 'left', + dropShadow: false, + dropShadowAngle: Math.PI / 6, + dropShadowBlur: 0, + dropShadowColor: '#000000', + dropShadowDistance: 5, + lineHeight: null, + lineJoin: 'miter', + fill: 'black', + font: 'bold 20pt Arial', + miterLimit: 10, + padding: 0, + stroke: 'black', + strokeThickness: 0, + textBaseline: 'alphabetic', + wordWrap: false, + wordWrapWidth: 100 +}; + +/** + * Creates a new TextStyle object with the same values as this one. + * Note that the only the properties of the object are cloned, not its event emitter. + * + * @return {PIXI.TextStyle} + */ +TextStyle.prototype.clone = function () +{ + var clonedProperties = {}; + for (var key in this._defaults) + { + clonedProperties[key] = this[key]; + } + return new TextStyle(clonedProperties); +}; + +/** + * Resets all properties to the defaults specified in TextStyle.prototype._default + */ +TextStyle.prototype.reset = function () +{ + Object.assign(this, this._defaults); +}; + +/** + * Create setters and getters for each of the style properties. Converts colors where necessary. + * Any set operation will emit a styleChanged event. + */ +Object.defineProperties(TextStyle.prototype, { + font: { + get: function () + { + return this._font; + }, set: function (font) + { + if (this._font !== font) + { + this._font = font; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + fill: { + get: function () + { + return this._fill; + }, set: function (fill) + { + var outputColor = getColor(fill); + if (this._fill !== outputColor) + { + this._fill = outputColor; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + align: { + get: function () + { + return this._align; + }, set: function (align) + { + if (this._align !== align) + { + this._align = align; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + stroke: { + get: function () + { + return this._stroke; + }, set: function (stroke) + { + var outputColor = getColor(stroke); + if (this._stroke !== outputColor) + { + this._stroke = outputColor; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + strokeThickness: { + get: function () + { + return this._strokeThickness; + }, set: function (strokeThickness) + { + if (this._strokeThickness !== strokeThickness) + { + this._strokeThickness = strokeThickness; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + wordWrap: { + get: function () + { + return this._wordWrap; + }, set: function (wordWrap) + { + if (this._wordWrap !== wordWrap) + { + this._wordWrap = wordWrap; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + wordWrapWidth: { + get: function () + { + return this._wordWrapWidth; + }, set: function (wordWrapWidth) + { + if (this._wordWrapWidth !== wordWrapWidth) + { + this._wordWrapWidth = wordWrapWidth; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + dropShadow: { + get: function () + { + return this._dropShadow; + }, set: function (dropShadow) + { + if (this._dropShadow !== dropShadow) + { + this._dropShadow = dropShadow; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + dropShadowColor: { + get: function () + { + return this._dropShadowColor; + }, set: function (dropShadowColor) + { + var outputColor = getColor(dropShadowColor); + if (this._dropShadowColor !== outputColor) + { + this._dropShadowColor = outputColor; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + dropShadowAngle: { + get: function () + { + return this._dropShadowAngle; + }, set: function (dropShadowAngle) + { + if (this._dropShadowAngle !== dropShadowAngle) + { + this._dropShadowAngle = dropShadowAngle; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + dropShadowDistance: { + get: function () + { + return this._dropShadowDistance; + }, set: function (dropShadowDistance) + { + if (this._dropShadowDistance !== dropShadowDistance) + { + this._dropShadowDistance = dropShadowDistance; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + dropShadowBlur: { + get: function () + { + return this._dropShadowBlur; + }, set: function (dropShadowBlur) + { + if (this._dropShadowBlur !== dropShadowBlur) + { + this._dropShadowBlur = dropShadowBlur; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + padding: { + get: function () + { + return this._padding; + }, set: function (padding) + { + if (this._padding !== padding) + { + this._padding = padding; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + textBaseline: { + get: function () + { + return this._textBaseline; + }, set: function (textBaseline) + { + if (this._textBaseline !== textBaseline) + { + this._textBaseline = textBaseline; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + lineJoin: { + get: function () + { + return this._lineJoin; + }, set: function (lineJoin) + { + if (this._lineJoin !== lineJoin) + { + this._lineJoin = lineJoin; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + lineHeight: { + get: function () + { + return this._lineHeight; + }, set: function (lineHeight) + { + if (this._lineHeight !== lineHeight) + { + this._lineHeight = lineHeight; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + }, + miterLimit: { + get: function () + { + return this._miterLimit; + }, set: function (miterLimit) + { + if (this._miterLimit !== miterLimit) + { + this._miterLimit = miterLimit; + this.emit(CONST.TEXT_STYLE_CHANGED); + } + } + } +}); + +/** + * Utility function to convert hexadecimal colors to strings, and simply return the color if it's a string. + * + * @return {string} The color as a string. + */ +function getColor(color) +{ + if (typeof color === 'number') + { + return utils.hex2string(color); + } else + { + return color; + } +} + +},{"../const":39,"../utils":109,"eventemitter3":26}],99:[function(require,module,exports){ var BaseTexture = require('./BaseTexture'), CONST = require('../const'); @@ -20367,7 +20753,7 @@ }; -},{"../const":39,"./BaseTexture":99}],99:[function(require,module,exports){ +},{"../const":39,"./BaseTexture":100}],100:[function(require,module,exports){ var utils = require('../utils'), CONST = require('../const'), EventEmitter = require('eventemitter3'), @@ -20816,7 +21202,7 @@ return baseTexture; }; -},{"../const":39,"../utils":108,"../utils/determineCrossOrigin":107,"bit-twiddle":17,"eventemitter3":26}],100:[function(require,module,exports){ +},{"../const":39,"../utils":109,"../utils/determineCrossOrigin":108,"bit-twiddle":17,"eventemitter3":26}],101:[function(require,module,exports){ var BaseRenderTexture = require('./BaseRenderTexture'), Texture = require('./Texture'); @@ -20937,7 +21323,7 @@ return new RenderTexture(new BaseRenderTexture(width, height, scaleMode, resolution)); }; -},{"./BaseRenderTexture":98,"./Texture":101}],101:[function(require,module,exports){ +},{"./BaseRenderTexture":99,"./Texture":102}],102:[function(require,module,exports){ var BaseTexture = require('./BaseTexture'), VideoBaseTexture = require('./VideoBaseTexture'), TextureUvs = require('./TextureUvs'), @@ -21426,13 +21812,19 @@ /** * An empty texture, used often to not have to create multiple empty textures. + * Can not be destroyed. * * @static * @constant */ Texture.EMPTY = new Texture(new BaseTexture()); +Texture.EMPTY.destroy = function() {} +Texture.EMPTY.on = function() {}; +Texture.EMPTY.once = function() {}; +Texture.EMPTY.emit = function() {}; -},{"../math":61,"../utils":108,"./BaseTexture":99,"./TextureUvs":102,"./VideoBaseTexture":103,"eventemitter3":26}],102:[function(require,module,exports){ + +},{"../math":61,"../utils":109,"./BaseTexture":100,"./TextureUvs":103,"./VideoBaseTexture":104,"eventemitter3":26}],103:[function(require,module,exports){ /** * A standard object to store the Uvs of a texture @@ -21517,7 +21909,7 @@ this.uvsUint32[3] = (((this.y3 * 65535) & 0xFFFF) << 16) | ((this.x3 * 65535) & 0xFFFF); }; -},{"../math/GroupD8":58}],103:[function(require,module,exports){ +},{"../math/GroupD8":58}],104:[function(require,module,exports){ var BaseTexture = require('./BaseTexture'), utils = require('../utils'); @@ -21754,7 +22146,7 @@ return source; } -},{"../utils":108,"./BaseTexture":99}],104:[function(require,module,exports){ +},{"../utils":109,"./BaseTexture":100}],105:[function(require,module,exports){ var CONST = require('../const'), EventEmitter = require('eventemitter3'), // Internal event used by composed emitter @@ -22091,7 +22483,7 @@ // Allow calling update directly with default currentTime. currentTime = currentTime || performance.now(); // Save uncapped elapsedMS for measurement - elapsedMS = this.elapsedMS = currentTime - this.lastTime; + Math.max(0, elapsedMS = this.elapsedMS = currentTime - this.lastTime); // cap the milliseconds elapsed used for deltaTime if (elapsedMS > this._maxElapsedMS) @@ -22109,7 +22501,7 @@ module.exports = Ticker; -},{"../const":39,"eventemitter3":26}],105:[function(require,module,exports){ +},{"../const":39,"eventemitter3":26}],106:[function(require,module,exports){ var Ticker = require('./Ticker'); /** @@ -22165,7 +22557,7 @@ Ticker: Ticker }; -},{"./Ticker":104}],106:[function(require,module,exports){ +},{"./Ticker":105}],107:[function(require,module,exports){ /** * Generic Mask Stack data structure * @class @@ -22196,7 +22588,7 @@ module.exports = createIndicesForQuads; -},{}],107:[function(require,module,exports){ +},{}],108:[function(require,module,exports){ var tempAnchor; var _url = require('url'); @@ -22240,7 +22632,7 @@ }; module.exports = determineCrossOrigin; -},{"url":24}],108:[function(require,module,exports){ +},{"url":24}],109:[function(require,module,exports){ var CONST = require('../const'); /** @@ -22386,7 +22778,14 @@ var canvas = document.createElement('canvas'), gl = canvas.getContext('webgl', contextOptions) || canvas.getContext('experimental-webgl', contextOptions); - return !!(gl && gl.getContextAttributes().stencil); + var success = !!(gl && gl.getContextAttributes().stencil); + if (gl) + { + gl.getExtension('WEBGL_lose_context').loseContext(); + } + gl = null; + + return success; } catch (e) { @@ -22443,7 +22842,7 @@ BaseTextureCache: {} }; -},{"../const":39,"./pluginTarget":110,"eventemitter3":26}],109:[function(require,module,exports){ +},{"../const":39,"./pluginTarget":111,"eventemitter3":26}],110:[function(require,module,exports){ var Device = require('ismobilejs'); @@ -22464,7 +22863,7 @@ }; module.exports = maxRecommendedTextures; -},{"ismobilejs":27}],110:[function(require,module,exports){ +},{"ismobilejs":27}],111:[function(require,module,exports){ /** * Mixins functionality to make an object have "plugins". * @@ -22534,7 +22933,7 @@ } }; -},{}],111:[function(require,module,exports){ +},{}],112:[function(require,module,exports){ /*global console */ var core = require('./core'), mesh = require('./mesh'), @@ -22834,9 +23233,9 @@ return this.generateCanvasTexture(scaleMode, resolution); }; -core.RenderTexture.prototype.render = function(displayObject) +core.RenderTexture.prototype.render = function(displayObject, matrix, clear, updateTransform) { - this.legacyRenderer.render(displayObject, this); + this.legacyRenderer.render(displayObject, this, clear, matrix, !updateTransform); warn('RenderTexture.render is now deprecated, please use renderer.render(displayObject, renderTexture)'); }; @@ -22995,7 +23394,7 @@ }; -},{"./core":57,"./extras":121,"./filters":133,"./mesh":148,"./particles":151}],112:[function(require,module,exports){ +},{"./core":57,"./extras":122,"./filters":134,"./mesh":149,"./particles":152}],113:[function(require,module,exports){ var core = require('../../core'), tempRect = new core.Rectangle(); @@ -23134,13 +23533,13 @@ core.CanvasRenderer.registerPlugin('extract', WebGLExtract); -},{"../../core":57}],113:[function(require,module,exports){ +},{"../../core":57}],114:[function(require,module,exports){ module.exports = { webGL: require('./webgl/WebGLExtract'), canvas: require('./canvas/CanvasExtract') }; -},{"./canvas/CanvasExtract":112,"./webgl/WebGLExtract":114}],114:[function(require,module,exports){ +},{"./canvas/CanvasExtract":113,"./webgl/WebGLExtract":115}],115:[function(require,module,exports){ var core = require('../../core'), tempRect = new core.Rectangle(); @@ -23324,7 +23723,7 @@ core.WebGLRenderer.registerPlugin('extract', Extract); -},{"../../core":57}],115:[function(require,module,exports){ +},{"../../core":57}],116:[function(require,module,exports){ var core = require('../core'); /** @@ -23712,7 +24111,7 @@ BitmapText.fonts = {}; -},{"../core":57}],116:[function(require,module,exports){ +},{"../core":57}],117:[function(require,module,exports){ var core = require('../core'); /** @@ -24032,7 +24431,7 @@ return new MovieClip(textures); }; -},{"../core":57}],117:[function(require,module,exports){ +},{"../core":57}],118:[function(require,module,exports){ var core = require('../core'), tempPoint = new core.Point(), CanvasTinter = require('../core/sprites/canvas/CanvasTinter'), @@ -24463,7 +24862,7 @@ return new TilingSprite(core.Texture.fromImage(imageId, crossorigin, scaleMode),width,height); }; -},{"../core":57,"../core/sprites/canvas/CanvasTinter":93,"./webgl/TilingShader":122}],118:[function(require,module,exports){ +},{"../core":57,"../core/sprites/canvas/CanvasTinter":93,"./webgl/TilingShader":123}],119:[function(require,module,exports){ var core = require('../core'), DisplayObject = core.DisplayObject, _tempMatrix = new core.Matrix(); @@ -24739,7 +25138,7 @@ this._originalDestroy(); }; -},{"../core":57}],119:[function(require,module,exports){ +},{"../core":57}],120:[function(require,module,exports){ var core = require('../core'); /** @@ -24769,7 +25168,7 @@ return null; }; -},{"../core":57}],120:[function(require,module,exports){ +},{"../core":57}],121:[function(require,module,exports){ var core = require('../core'); /** @@ -24799,7 +25198,7 @@ return point; }; -},{"../core":57}],121:[function(require,module,exports){ +},{"../core":57}],122:[function(require,module,exports){ /** * @file Main export of the PIXI extras library * @author Mat Groves @@ -24820,7 +25219,7 @@ BitmapText: require('./BitmapText') }; -},{"./BitmapText":115,"./MovieClip":116,"./TilingSprite":117,"./cacheAsBitmap":118,"./getChildByName":119,"./getGlobalPosition":120}],122:[function(require,module,exports){ +},{"./BitmapText":116,"./MovieClip":117,"./TilingSprite":118,"./cacheAsBitmap":119,"./getChildByName":120,"./getGlobalPosition":121}],123:[function(require,module,exports){ var Shader = require('pixi-gl-core').GLShader; @@ -24844,7 +25243,7 @@ module.exports = TilingShader; -},{"pixi-gl-core":1}],123:[function(require,module,exports){ +},{"pixi-gl-core":1}],124:[function(require,module,exports){ var core = require('../../core'), BlurXFilter = require('./BlurXFilter'), BlurYFilter = require('./BlurYFilter'); @@ -24964,7 +25363,7 @@ } }); -},{"../../core":57,"./BlurXFilter":124,"./BlurYFilter":125}],124:[function(require,module,exports){ +},{"../../core":57,"./BlurXFilter":125,"./BlurYFilter":126}],125:[function(require,module,exports){ var core = require('../../core'); var generateBlurVertSource = require('./generateBlurVertSource'); var generateBlurFragSource = require('./generateBlurFragSource'); @@ -25072,7 +25471,7 @@ } }); -},{"../../core":57,"./generateBlurFragSource":126,"./generateBlurVertSource":127,"./getMaxBlurKernelSize":128}],125:[function(require,module,exports){ +},{"../../core":57,"./generateBlurFragSource":127,"./generateBlurVertSource":128,"./getMaxBlurKernelSize":129}],126:[function(require,module,exports){ var core = require('../../core'); var generateBlurVertSource = require('./generateBlurVertSource'); var generateBlurFragSource = require('./generateBlurFragSource'); @@ -25170,7 +25569,7 @@ } }); -},{"../../core":57,"./generateBlurFragSource":126,"./generateBlurVertSource":127,"./getMaxBlurKernelSize":128}],126:[function(require,module,exports){ +},{"../../core":57,"./generateBlurFragSource":127,"./generateBlurVertSource":128,"./getMaxBlurKernelSize":129}],127:[function(require,module,exports){ var GAUSSIAN_VALUES = { 5:[0.153388, 0.221461, 0.250301], 7:[0.071303, 0.131514, 0.189879, 0.214607], @@ -25235,7 +25634,7 @@ module.exports = generateFragBlurSource; -},{}],127:[function(require,module,exports){ +},{}],128:[function(require,module,exports){ var vertTemplate = [ 'attribute vec2 aVertexPosition;', @@ -25265,11 +25664,11 @@ if(x) { - template = 'vBlurTexCoords[%index%] = aTextureCoord + vec2(%samlpeIndex% * strength, 0.0);'; + template = 'vBlurTexCoords[%index%] = aTextureCoord + vec2(%sampleIndex% * strength, 0.0);'; } else { - template = 'vBlurTexCoords[%index%] = aTextureCoord + vec2(0.0, %samlpeIndex% * strength);'; + template = 'vBlurTexCoords[%index%] = aTextureCoord + vec2(0.0, %sampleIndex% * strength);'; } @@ -25285,7 +25684,7 @@ value = kernelSize - i - 1; } - blur = blur.replace('%samlpeIndex%', (i - (halfLength-1)) + '.0'); + blur = blur.replace('%sampleIndex%', (i - (halfLength-1)) + '.0'); blurLoop += blur; blurLoop += '\n'; @@ -25301,7 +25700,7 @@ module.exports = generateVertBlurSource; -},{}],128:[function(require,module,exports){ +},{}],129:[function(require,module,exports){ var getMaxKernelSize = function(gl) @@ -25319,7 +25718,7 @@ module.exports = getMaxKernelSize; -},{}],129:[function(require,module,exports){ +},{}],130:[function(require,module,exports){ var core = require('../../core'); // @see https://github.com/substack/brfs/issues/25 @@ -25853,7 +26252,7 @@ } }); -},{"../../core":57}],130:[function(require,module,exports){ +},{"../../core":57}],131:[function(require,module,exports){ var core = require('../../core'); @@ -25932,7 +26331,7 @@ } }); -},{"../../core":57}],131:[function(require,module,exports){ +},{"../../core":57}],132:[function(require,module,exports){ var core = require('../../core'); @@ -26025,7 +26424,7 @@ } }); -},{"../../core":57}],132:[function(require,module,exports){ +},{"../../core":57}],133:[function(require,module,exports){ var core = require('../../core'); // @see https://github.com/substack/brfs/issues/25 @@ -26074,7 +26473,7 @@ } }); -},{"../../core":57}],133:[function(require,module,exports){ +},{"../../core":57}],134:[function(require,module,exports){ /** * @file Main export of the PIXI filters library * @author Mat Groves @@ -26115,7 +26514,7 @@ GodrayFilter: require('./godray/GodrayFilter') }; -},{"./blur/BlurFilter":123,"./blur/BlurXFilter":124,"./blur/BlurYFilter":125,"./colormatrix/ColorMatrixFilter":129,"./displacement/DisplacementFilter":130,"./godray/GodrayFilter":131,"./gray/GrayFilter":132,"./twist/TwistFilter":134}],134:[function(require,module,exports){ +},{"./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){ var core = require('../../core'); @@ -26213,7 +26612,7 @@ } }); -},{"../../core":57}],135:[function(require,module,exports){ +},{"../../core":57}],136:[function(require,module,exports){ (function (global){ // run the polyfills require('./polyfill'); @@ -26247,7 +26646,7 @@ global.PIXI = core; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./accessibility":38,"./core":57,"./deprecation":111,"./extract":113,"./extras":121,"./filters":133,"./interaction":138,"./loaders":141,"./mesh":148,"./particles":151,"./polyfill":157}],136:[function(require,module,exports){ +},{"./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){ var core = require('../core'); /** @@ -26296,7 +26695,7 @@ return displayObject.worldTransform.applyInverse(globalPos || this.global, point); }; -},{"../core":57}],137:[function(require,module,exports){ +},{"../core":57}],138:[function(require,module,exports){ var core = require('../core'), InteractionData = require('./InteractionData'); @@ -27235,7 +27634,7 @@ core.WebGLRenderer.registerPlugin('interaction', InteractionManager); core.CanvasRenderer.registerPlugin('interaction', InteractionManager); -},{"../core":57,"./InteractionData":136,"./interactiveTarget":139}],138:[function(require,module,exports){ +},{"../core":57,"./InteractionData":137,"./interactiveTarget":140}],139:[function(require,module,exports){ /** * @file Main export of the PIXI interactions library * @author Mat Groves @@ -27252,10 +27651,10 @@ interactiveTarget: require('./interactiveTarget') }; -},{"./InteractionData":136,"./InteractionManager":137,"./interactiveTarget":139}],139:[function(require,module,exports){ +},{"./InteractionData":137,"./InteractionManager":138,"./interactiveTarget":140}],140:[function(require,module,exports){ /** * Default property values of interactive objects - * used by {@link PIXI.interaction.InteractionManager}. + * Used by {@link PIXI.interaction.InteractionManager} to automatically give all DisplayObjects these properties * * @mixin * @memberof PIXI.interaction @@ -27269,39 +27668,79 @@ */ var interactiveTarget = { /** - * @todo Needs docs. + * Determines if the displayObject be clicked/touched + * + * @inner {boolean} */ interactive: false, + /** - * @todo Needs docs. - */ - buttonMode: false, - /** - * @todo Needs docs. + * Determines if the children to the displayObject can be clicked/touched + * Setting this to false allows pixi to bypass a recursive hitTest function + * + * @inner {boolean} */ interactiveChildren: true, + /** - * @todo Needs docs. + * Interaction shape. Children will be hit first, then this shape will be checked. + * + * @inner {PIXI.Rectangle|PIXI.Circle|PIXI.Ellipse|PIXI.Polygon|PIXI.RoundedRectangle} + */ + hitArea: null, + + /** + * If enabled, the mouse cursor will change when hovered over the displayObject if it is interactive + * + * @inner {boolean} + */ + buttonMode: false, + + /** + * If buttonMode is enabled, this defines what CSS cursor property is used when the mouse cursor is hovered over the displayObject + * https://developer.mozilla.org/en/docs/Web/CSS/cursor + * + * @inner {string} */ defaultCursor: 'pointer', // some internal checks.. - /** - * @todo Needs docs. + * Internal check to detect if the mouse cursor is hovered over the displayObject + * + * @inner {boolean} * @private */ _over: false, + /** - * @todo Needs docs. + * Internal check to detect if the left mouse button is pressed on the displayObject + * + * @inner {boolean} + * @private + */ + _isLeftDown: false, + + /** + * Internal check to detect if the right mouse button is pressed on the displayObject + * + * @inner {boolean} + * @private + */ + _isRightDown: false, + + /** + * Internal check to detect if a user has touched the displayObject + * + * @inner {boolean} * @private */ _touchDown: false -}; + }; module.exports = interactiveTarget; -},{}],140:[function(require,module,exports){ +},{}],141:[function(require,module,exports){ var Resource = require('resource-loader').Resource, core = require('../core'), extras = require('../extras'), @@ -27425,7 +27864,7 @@ }; }; -},{"../core":57,"../extras":121,"path":18,"resource-loader":33}],141:[function(require,module,exports){ +},{"../core":57,"../extras":122,"path":18,"resource-loader":33}],142:[function(require,module,exports){ /** * @file Main export of the PIXI loaders library * @author Mat Groves @@ -27446,7 +27885,7 @@ Resource: require('resource-loader').Resource }; -},{"./bitmapFontParser":140,"./loader":142,"./spritesheetParser":143,"./textureParser":144,"resource-loader":33}],142:[function(require,module,exports){ +},{"./bitmapFontParser":141,"./loader":143,"./spritesheetParser":144,"./textureParser":145,"resource-loader":33}],143:[function(require,module,exports){ var ResourceLoader = require('resource-loader'), textureParser = require('./textureParser'), spritesheetParser = require('./spritesheetParser'), @@ -27508,7 +27947,7 @@ Resource.setExtensionXhrType('fnt', Resource.XHR_RESPONSE_TYPE.DOCUMENT); -},{"./bitmapFontParser":140,"./spritesheetParser":143,"./textureParser":144,"resource-loader":33}],143:[function(require,module,exports){ +},{"./bitmapFontParser":141,"./spritesheetParser":144,"./textureParser":145,"resource-loader":33}],144:[function(require,module,exports){ var Resource = require('resource-loader').Resource, path = require('path'), core = require('../core'), @@ -27625,7 +28064,7 @@ }; }; -},{"../core":57,"async":16,"path":18,"resource-loader":33}],144:[function(require,module,exports){ +},{"../core":57,"async":16,"path":18,"resource-loader":33}],145:[function(require,module,exports){ var core = require('../core'); module.exports = function () @@ -27647,7 +28086,7 @@ }; }; -},{"../core":57}],145:[function(require,module,exports){ +},{"../core":57}],146:[function(require,module,exports){ var core = require('../core'), glCore = require('pixi-gl-core'), Shader = require('./webgl/MeshShader'), @@ -28185,7 +28624,7 @@ TRIANGLES: 1 }; -},{"../core":57,"./webgl/MeshShader":149,"pixi-gl-core":1}],146:[function(require,module,exports){ +},{"../core":57,"./webgl/MeshShader":150,"pixi-gl-core":1}],147:[function(require,module,exports){ var Mesh = require('./Mesh'); /** @@ -28310,7 +28749,7 @@ } }; -},{"./Mesh":145}],147:[function(require,module,exports){ +},{"./Mesh":146}],148:[function(require,module,exports){ var Mesh = require('./Mesh'); var core = require('../core'); @@ -28525,7 +28964,7 @@ this.containerUpdateTransform(); }; -},{"../core":57,"./Mesh":145}],148:[function(require,module,exports){ +},{"../core":57,"./Mesh":146}],149:[function(require,module,exports){ /** * @file Main export of the PIXI extras library * @author Mat Groves @@ -28543,7 +28982,7 @@ MeshShader: require('./webgl/MeshShader') }; -},{"./Mesh":145,"./Plane":146,"./Rope":147,"./webgl/MeshShader":149}],149:[function(require,module,exports){ +},{"./Mesh":146,"./Plane":147,"./Rope":148,"./webgl/MeshShader":150}],150:[function(require,module,exports){ var Shader = require('pixi-gl-core').GLShader; /** @@ -28593,7 +29032,7 @@ module.exports = MeshShader; -},{"pixi-gl-core":1}],150:[function(require,module,exports){ +},{"pixi-gl-core":1}],151:[function(require,module,exports){ var core = require('../core'); /** @@ -28926,7 +29365,7 @@ this._buffers = null; }; -},{"../core":57}],151:[function(require,module,exports){ +},{"../core":57}],152:[function(require,module,exports){ /** * @file Main export of the PIXI extras library * @author Mat Groves @@ -28942,7 +29381,7 @@ ParticleRenderer: require('./webgl/ParticleRenderer') }; -},{"./ParticleContainer":150,"./webgl/ParticleRenderer":153}],152:[function(require,module,exports){ +},{"./ParticleContainer":151,"./webgl/ParticleRenderer":154}],153:[function(require,module,exports){ var glCore = require('pixi-gl-core'), createIndicesForQuads = require('../../core/utils/createIndicesForQuads'); @@ -29163,7 +29602,7 @@ this.staticBuffer.destroy(); }; -},{"../../core/utils/createIndicesForQuads":106,"pixi-gl-core":1}],153:[function(require,module,exports){ +},{"../../core/utils/createIndicesForQuads":107,"pixi-gl-core":1}],154:[function(require,module,exports){ var core = require('../../core'), ParticleShader = require('./ParticleShader'), ParticleBuffer = require('./ParticleBuffer'); @@ -29595,7 +30034,7 @@ this.tempMatrix = null; }; -},{"../../core":57,"./ParticleBuffer":152,"./ParticleShader":154}],154:[function(require,module,exports){ +},{"../../core":57,"./ParticleBuffer":153,"./ParticleShader":155}],155:[function(require,module,exports){ var Shader = require('pixi-gl-core').GLShader; /** @@ -29663,7 +30102,7 @@ module.exports = ParticleShader; -},{"pixi-gl-core":1}],155:[function(require,module,exports){ +},{"pixi-gl-core":1}],156:[function(require,module,exports){ // References: // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign @@ -29679,7 +30118,7 @@ }; } -},{}],156:[function(require,module,exports){ +},{}],157:[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 @@ -29689,7 +30128,7 @@ Object.assign = require('object-assign'); } -},{"object-assign":28}],157:[function(require,module,exports){ +},{"object-assign":28}],158:[function(require,module,exports){ require('./Object.assign'); require('./requestAnimationFrame'); require('./Math.sign'); @@ -29707,7 +30146,7 @@ window.Uint16Array = Array; } -},{"./Math.sign":155,"./Object.assign":156,"./requestAnimationFrame":158}],158:[function(require,module,exports){ +},{"./Math.sign":156,"./Object.assign":157,"./requestAnimationFrame":159}],159:[function(require,module,exports){ (function (global){ // References: // http://paulirish.com/2011/requestanimationframe-for-smart-animating/ @@ -29777,6 +30216,6 @@ } }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}]},{},[135])(135) +},{}]},{},[136])(136) }); //# sourceMappingURL=pixi.js.map diff --git a/bin/pixi.js.map b/bin/pixi.js.map index 2288100..24d39c6 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