New build files for testing.

This commit is contained in:
photonstorm 2014-08-29 18:13:33 +01:00
parent 410cfd2d71
commit da5a9482f6
11 changed files with 2663 additions and 1046 deletions

View file

@ -14383,12 +14383,19 @@ Phaser.Physics.P2.prototype = {
* Adds a Spring to the world.
*
* @method Phaser.Physics.P2#addSpring
* @param {Phaser.Physics.P2.Spring} spring - The Spring to add to the World.
* @param {Phaser.Physics.P2.Spring|p2.LinearSpring|p2.RotationalSpring} spring - The Spring to add to the World.
* @return {Phaser.Physics.P2.Spring} The Spring that was added.
*/
addSpring: function (spring) {
this.world.addSpring(spring);
if (spring instanceof Phaser.Physics.P2.Spring || spring instanceof Phaser.Physics.P2.RotationalSpring)
{
this.world.addSpring(spring.data);
}
else
{
this.world.addSpring(spring);
}
this.onSpringAdded.dispatch(spring);
@ -14405,7 +14412,14 @@ Phaser.Physics.P2.prototype = {
*/
removeSpring: function (spring) {
this.world.removeSpring(spring);
if (spring instanceof Phaser.Physics.P2.Spring || spring instanceof Phaser.Physics.P2.RotationalSpring)
{
this.world.removeSpring(spring.data);
}
else
{
this.world.removeSpring(spring);
}
this.onSpringRemoved.dispatch(spring);
@ -15740,13 +15754,13 @@ Phaser.Physics.P2.PointProxy.prototype.constructor = Phaser.Physics.P2.PointProx
/**
* @name Phaser.Physics.P2.PointProxy#x
* @property {number} x - The x property of this PointProxy.
* @property {number} x - The x property of this PointProxy get and set in pixels.
*/
Object.defineProperty(Phaser.Physics.P2.PointProxy.prototype, "x", {
get: function () {
return this.destination[0];
return this.world.mpx(this.destination[0]);
},
@ -15760,10 +15774,50 @@ Object.defineProperty(Phaser.Physics.P2.PointProxy.prototype, "x", {
/**
* @name Phaser.Physics.P2.PointProxy#y
* @property {number} y - The y property of this PointProxy.
* @property {number} y - The y property of this PointProxy get and set in pixels.
*/
Object.defineProperty(Phaser.Physics.P2.PointProxy.prototype, "y", {
get: function () {
return this.world.mpx(this.destination[1]);
},
set: function (value) {
this.destination[1] = this.world.pxm(value);
}
});
/**
* @name Phaser.Physics.P2.PointProxy#mx
* @property {number} mx - The x property of this PointProxy get and set in meters.
*/
Object.defineProperty(Phaser.Physics.P2.PointProxy.prototype, "mx", {
get: function () {
return this.destination[0];
},
set: function (value) {
this.destination[0] = value;
}
});
/**
* @name Phaser.Physics.P2.PointProxy#my
* @property {number} my - The x property of this PointProxy get and set in meters.
*/
Object.defineProperty(Phaser.Physics.P2.PointProxy.prototype, "my", {
get: function () {
return this.destination[1];
@ -15772,7 +15826,7 @@ Object.defineProperty(Phaser.Physics.P2.PointProxy.prototype, "y", {
set: function (value) {
this.destination[1] = this.world.pxm(value);
this.destination[1] = value;
}
@ -15804,10 +15858,50 @@ Phaser.Physics.P2.InversePointProxy.prototype.constructor = Phaser.Physics.P2.In
/**
* @name Phaser.Physics.P2.InversePointProxy#x
* @property {number} x - The x property of this InversePointProxy.
* @property {number} x - The x property of this InversePointProxy get and set in pixels.
*/
Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "x", {
get: function () {
return this.world.mpxi(this.destination[0]);
},
set: function (value) {
this.destination[0] = this.world.pxmi(value);
}
});
/**
* @name Phaser.Physics.P2.InversePointProxy#y
* @property {number} y - The y property of this InversePointProxy get and set in pixels.
*/
Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "y", {
get: function () {
return this.world.mpxi(this.destination[1]);
},
set: function (value) {
this.destination[1] = this.world.pxmi(value);
}
});
/**
* @name Phaser.Physics.P2.InversePointProxy#mx
* @property {number} mx - The x property of this InversePointProxy get and set in meters.
*/
Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "mx", {
get: function () {
return this.destination[0];
@ -15816,17 +15910,17 @@ Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "x", {
set: function (value) {
this.destination[0] = this.world.pxm(-value);
this.destination[0] = -value;
}
});
/**
* @name Phaser.Physics.P2.InversePointProxy#y
* @property {number} y - The y property of this InversePointProxy.
* @name Phaser.Physics.P2.InversePointProxy#my
* @property {number} my - The y property of this InversePointProxy get and set in meters.
*/
Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "y", {
Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "my", {
get: function () {
@ -15836,7 +15930,7 @@ Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "y", {
set: function (value) {
this.destination[1] = this.world.pxm(-value);
this.destination[1] = -value;
}
@ -17588,6 +17682,8 @@ Object.defineProperty(Phaser.Physics.P2.Body.prototype, "debug", {
/**
* A Body can be set to collide against the World bounds automatically if this is set to true. Otherwise it will leave the World.
* Note that this only applies if your World has bounds! The response to the collision should be managed via CollisionMaterials.
* Also note that when you set this it will only effect Body shapes that already exist. If you then add further shapes to your Body
* after setting this it will *not* proactively set them to collide with the bounds.
*
* @name Phaser.Physics.P2.Body#collideWorldBounds
* @property {boolean} collideWorldBounds - Should the Body collide with the World bounds?
@ -18112,11 +18208,13 @@ Phaser.Physics.P2.Spring = function (world, bodyA, bodyB, restLength, stiffness,
options.localAnchorB = [ world.pxm(localB[0]), world.pxm(localB[1]) ];
}
p2.LinearSpring.call(this, bodyA, bodyB, options);
/**
* @property {p2.LinearSpring} data - The actual p2 spring object.
*/
this.data = new p2.LinearSpring(bodyA, bodyB, options);
};
Phaser.Physics.P2.Spring.prototype = Object.create(p2.LinearSpring.prototype);
Phaser.Physics.P2.Spring.prototype.constructor = Phaser.Physics.P2.Spring;
/**
@ -18165,11 +18263,13 @@ Phaser.Physics.P2.RotationalSpring = function (world, bodyA, bodyB, restAngle, s
damping: damping
};
p2.RotationalSpring.call(this, bodyA, bodyB, options);
/**
* @property {p2.RotationalSpring} data - The actual p2 spring object.
*/
this.data = new p2.RotationalSpring(bodyA, bodyB, options);
};
Phaser.Physics.P2.Spring.prototype = Object.create(p2.RotationalSpring.prototype);
Phaser.Physics.P2.Spring.prototype.constructor = Phaser.Physics.P2.Spring;
/**

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -190,6 +190,45 @@ PIXI.Matrix.prototype.toArray = function(transpose)
return array;
};
/**
* Get a new position with the current transormation applied.
* Can be used to go from a child's coordinate space to the world coordinate space. (e.g. rendering)
*
* @method apply
* @param pos {Point} The origin
* @param [newPos] {Point} The point that the new position is assigned to (allowed to be same as input)
* @return {Point} The new point, transformed trough this matrix
*/
PIXI.Matrix.prototype.apply = function(pos, newPos)
{
newPos = newPos || new PIXI.Point();
newPos.x = this.a * pos.x + this.b * pos.y + this.tx;
newPos.y = this.c * pos.x + this.d * pos.y + this.ty;
return newPos;
};
/**
* Get a new position with the inverse of the current transormation applied.
* Can be used to go from the world coordinate space to a child's coordinate space. (e.g. input)
*
* @method apply
* @param pos {Point} The origin
* @param [newPos] {Point} The point that the new position is assigned to (allowed to be same as input)
* @return {Point} The new point, inverse-transformed trough this matrix
*/
PIXI.Matrix.prototype.applyInverse = function(pos, newPos)
{
newPos = newPos || new PIXI.Point();
var id = 1 / (this.a * this.d + this.b * -this.c);
newPos.x = this.d * id * pos.x - this.b * id * pos.y + (this.ty * this.b - this.tx * this.d) * id;
newPos.y = this.a * id * pos.y - this.c * id * pos.x + (this.tx * this.c - this.ty * this.a) * id;
return newPos;
};
PIXI.identityMatrix = new PIXI.Matrix();
PIXI.determineMatrixArrayType = function() {
@ -210,7 +249,7 @@ PIXI.Matrix2 = PIXI.determineMatrixArrayType();
*/
/**
* The base class for all objects that are rendered on the screen.
* The base class for all objects that are rendered on the screen.
* This is an abstract class and should not be used on its own rather it should be extended.
*
* @class DisplayObject
@ -330,7 +369,7 @@ PIXI.DisplayObject = function()
/**
* This is the cursor that will be used when the mouse is over this object. To enable this the element must have interaction = true and buttonMode = true
*
*
* @property defaultCursor
* @type String
*
@ -410,33 +449,7 @@ PIXI.DisplayObject = function()
/*
* MOUSE Callbacks
*/
/**
* A callback that is used when the users clicks on the displayObject with their mouse
* @method click
* @param interactionData {InteractionData}
*/
/**
* A callback that is used when the user clicks the mouse down over the sprite
* @method mousedown
* @param interactionData {InteractionData}
*/
/**
* A callback that is used when the user releases the mouse that was over the displayObject
* for this callback to be fired the mouse must have been pressed down over the displayObject
* @method mouseup
* @param interactionData {InteractionData}
*/
/**
* A callback that is used when the user releases the mouse that was over the displayObject but is no longer over the displayObject
* for this callback to be fired, The touch must have started over the displayObject
* @method mouseupoutside
* @param interactionData {InteractionData}
*/
/**
* A callback that is used when the users mouse rolls over the displayObject
* @method mouseover
@ -449,6 +462,59 @@ PIXI.DisplayObject = function()
* @param interactionData {InteractionData}
*/
//Left button
/**
* A callback that is used when the users clicks on the displayObject with their mouse's left button
* @method click
* @param interactionData {InteractionData}
*/
/**
* A callback that is used when the user clicks the mouse's left button down over the sprite
* @method mousedown
* @param interactionData {InteractionData}
*/
/**
* A callback that is used when the user releases the mouse's left button that was over the displayObject
* for this callback to be fired, the mouse's left button must have been pressed down over the displayObject
* @method mouseup
* @param interactionData {InteractionData}
*/
/**
* A callback that is used when the user releases the mouse's left button that was over the displayObject but is no longer over the displayObject
* for this callback to be fired, the mouse's left button must have been pressed down over the displayObject
* @method mouseupoutside
* @param interactionData {InteractionData}
*/
//Right button
/**
* A callback that is used when the users clicks on the displayObject with their mouse's right button
* @method rightclick
* @param interactionData {InteractionData}
*/
/**
* A callback that is used when the user clicks the mouse's right button down over the sprite
* @method rightdown
* @param interactionData {InteractionData}
*/
/**
* A callback that is used when the user releases the mouse's right button that was over the displayObject
* for this callback to be fired the mouse's right button must have been pressed down over the displayObject
* @method rightup
* @param interactionData {InteractionData}
*/
/**
* A callback that is used when the user releases the mouse's right button that was over the displayObject but is no longer over the displayObject
* for this callback to be fired, the mouse's right button must have been pressed down over the displayObject
* @method rightupoutside
* @param interactionData {InteractionData}
*/
/*
* TOUCH Callbacks
@ -688,7 +754,6 @@ PIXI.DisplayObject.prototype.getLocalBounds = function()
return this.getBounds(PIXI.identityMatrix);///PIXI.EmptyRectangle();
};
/**
* Sets the object's stage reference, the stage this object is connected to
*
@ -716,10 +781,41 @@ PIXI.DisplayObject.prototype.updateCache = function()
this._generateCachedSprite();
};
/**
* Calculates the global position of the display object
*
* @method toGlobal
* @param position {Point} The world origin to calculate from
* @return {Point} A point object representing the position of this object
*/
PIXI.DisplayObject.prototype.toGlobal = function(pos)
{
this.updateTransform();
return this.worldTransform.apply(pos);
};
/**
* Calculates the local position of the display object relative to another point
*
* @method toGlobal
* @param position {Point} The world origin to calculate from
* @param [from] {DisplayObject} The DisplayObject to calculate the global position from
* @return {Point} A point object representing the position of this object
*/
PIXI.DisplayObject.prototype.toLocal = function(pos, from)
{
if (from)
{
pos = from.toGlobal(pos);
}
this.updateTransform();
return this.worldTransform.applyInverse(pos);
};
PIXI.DisplayObject.prototype._renderCachedSprite = function(renderSession)
{
this._cachedSprite.worldAlpha = this.worldAlpha;
if(renderSession.gl)
{
PIXI.Sprite.prototype._renderWebGL.call(this._cachedSprite, renderSession);
@ -734,11 +830,11 @@ PIXI.DisplayObject.prototype._generateCachedSprite = function()//renderSession)
{
this._cacheAsBitmap = false;
var bounds = this.getLocalBounds();
if(!this._cachedSprite)
{
var renderTexture = new PIXI.RenderTexture(bounds.width | 0, bounds.height | 0);//, renderSession.renderer);
this._cachedSprite = new PIXI.Sprite(renderTexture);
this._cachedSprite.worldTransform = this.worldTransform;
}
@ -766,7 +862,7 @@ PIXI.DisplayObject.prototype._generateCachedSprite = function()//renderSession)
* Renders the object using the WebGL renderer
*
* @method _renderWebGL
* @param renderSession {RenderSession}
* @param renderSession {RenderSession}
* @private
*/
PIXI.DisplayObject.prototype._destroyCachedSprite = function()
@ -792,7 +888,7 @@ PIXI.DisplayObject.prototype._renderWebGL = function(renderSession)
* Renders the object using the Canvas renderer
*
* @method _renderCanvas
* @param renderSession {RenderSession}
* @param renderSession {RenderSession}
* @private
*/
PIXI.DisplayObject.prototype._renderCanvas = function(renderSession)
@ -1060,6 +1156,10 @@ PIXI.DisplayObjectContainer.prototype.removeChildren = function(beginIndex, endI
}
return removed;
}
else if (range === 0 && this.children.length === 0)
{
return [];
}
else
{
throw new Error( 'Range Error, numeric values are outside the acceptable range' );
@ -1614,7 +1714,7 @@ PIXI.Sprite.prototype._renderWebGL = function(renderSession)
PIXI.Sprite.prototype._renderCanvas = function(renderSession)
{
// If the sprite is not visible or the alpha is 0 then no need to render this element
if (this.visible === false || this.alpha === 0) return;
if (this.visible === false || this.alpha === 0 || this.texture.crop.width <= 0 || this.texture.crop.height <= 0) return;
if (this.blendMode !== renderSession.currentBlendMode)
{
@ -2112,7 +2212,6 @@ PIXI.Text.prototype.setStyle = function(style)
style.strokeThickness = style.strokeThickness || 0;
style.wordWrap = style.wordWrap || false;
style.wordWrapWidth = style.wordWrapWidth || 100;
style.wordWrapWidth = style.wordWrapWidth || 100;
style.dropShadow = style.dropShadow || false;
style.dropShadowAngle = style.dropShadowAngle || Math.PI / 6;
@ -2760,32 +2859,34 @@ PIXI.Stage.prototype.getMousePosition = function()
*
* @method cancelAnimationFrame
*/
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] ||
window[vendors[x] + 'CancelRequestAnimationFrame'];
}
(function(window) {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] ||
window[vendors[x] + 'CancelRequestAnimationFrame'];
}
if (!window.requestAnimationFrame) {
window.requestAnimationFrame = function(callback) {
var currTime = new Date().getTime();
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
timeToCall);
lastTime = currTime + timeToCall;
return id;
};
}
if (!window.requestAnimationFrame) {
window.requestAnimationFrame = function(callback) {
var currTime = new Date().getTime();
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
timeToCall);
lastTime = currTime + timeToCall;
return id;
};
}
if (!window.cancelAnimationFrame) {
window.cancelAnimationFrame = function(id) {
clearTimeout(id);
};
}
if (!window.cancelAnimationFrame) {
window.cancelAnimationFrame = function(id) {
clearTimeout(id);
};
}
window.requestAnimFrame = window.requestAnimationFrame;
window.requestAnimFrame = window.requestAnimationFrame;
})(this);
/**
* Converts a hex color number to an [R, G, B] array
@ -2814,14 +2915,20 @@ PIXI.rgb2hex = function(rgb) {
*/
if (typeof Function.prototype.bind !== 'function') {
Function.prototype.bind = (function () {
var slice = Array.prototype.slice;
return function (thisArg) {
var target = this, boundArgs = slice.call(arguments, 1);
var target = this, i = arguments.length - 1, boundArgs = [];
if (i > 0)
{
boundArgs.length = i;
while (i--) boundArgs[i] = arguments[i + 1];
}
if (typeof target !== 'function') throw new TypeError();
function bound() {
var args = boundArgs.concat(slice.call(arguments));
var i = arguments.length, args = new Array(i);
while (i--) args[i] = arguments[i];
args = boundArgs.concat(args);
target.apply(this instanceof bound ? this : thisArg, args);
}
@ -2903,6 +3010,7 @@ PIXI.unpackColorRGB = function(r, g, b)//r, g, b, a)
*/
PIXI.canUseNewCanvasBlendModes = function()
{
if (typeof document === 'undefined') return false;
var canvas = document.createElement('canvas');
canvas.width = 1;
canvas.height = 1;
@ -3856,6 +3964,20 @@ PIXI.StripShader.prototype.init = function()
this.program = program;
};
/**
* Destroys the shader
* @method destroy
*
*/
PIXI.StripShader.prototype.destroy = function()
{
this.gl.deleteProgram( this.program );
this.uniforms = null;
this.gl = null;
this.attribute = null;
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -3960,7 +4082,7 @@ PIXI.PrimitiveShader.prototype.destroy = function()
this.uniforms = null;
this.gl = null;
this.attribute = null;
this.attributes = null;
};
/**
@ -4130,8 +4252,6 @@ PIXI.WebGLGraphics.renderGraphics = function(graphics, renderSession)//projectio
gl.drawElements(gl.TRIANGLE_FAN, 4, gl.UNSIGNED_SHORT, ( webGLData.indices.length - 4 ) * 2 );
renderSession.stencilManager.popStencil(graphics, webGLData, renderSession);
this.last = webGLData.mode;
}
else
{
@ -4994,14 +5114,14 @@ PIXI.WebGLRenderer = function(width, height, view, transparent, antialias, prese
// deal with losing context..
this.contextLost = this.handleContextLost.bind(this);
this.contextRestoredLost = this.handleContextRestored.bind(this);
this.view.addEventListener('webglcontextlost', this.contextLost, false);
this.view.addEventListener('webglcontextrestored', this.contextRestoredLost, false);
this.options = {
alpha: this.transparent,
antialias:!!antialias, // SPEED UP??
premultipliedAlpha:!!transparent,
premultipliedAlpha:!!transparent && transparent !== 'notMultiplied',
stencil:true,
preserveDrawingBuffer: preserveDrawingBuffer
};
@ -5130,7 +5250,7 @@ PIXI.WebGLRenderer.prototype.render = function(stage)
stage.interactionManager.setTarget(this);
}
}
var gl = this.gl;
// -- Does this need to be set every frame? -- //
@ -5201,7 +5321,7 @@ PIXI.WebGLRenderer.prototype.render = function(stage)
* @method renderDIsplayObject
* @param displayObject {DisplayObject} The DisplayObject to render
* @param projection {Point} The projection
* @param buffer {Array} a standard WebGL buffer
* @param buffer {Array} a standard WebGL buffer
*/
PIXI.WebGLRenderer.prototype.renderDisplayObject = function(displayObject, projection, buffer)
{
@ -5396,7 +5516,7 @@ PIXI.updateWebGLTexture = function(texture, gl)
texture._dirty[gl.id] = false;
}
};
/**
@ -5435,15 +5555,19 @@ PIXI.WebGLRenderer.prototype.handleContextRestored = function()
}
}
PIXI.glContexts[this.glContextId] = null;
var gl = this.gl;
gl.id = PIXI.WebGLRenderer.glContextId ++;
this.glContextId = gl.id = PIXI.WebGLRenderer.glContextId++;
PIXI.glContexts[this.glContextId] = gl;
// need to set the context...
this.shaderManager.setContext(gl);
this.spriteBatch.setContext(gl);
this.primitiveBatch.setContext(gl);
// this.primitiveBatch.setContext(gl);
this.maskManager.setContext(gl);
this.filterManager.setContext(gl);
@ -5465,7 +5589,7 @@ PIXI.WebGLRenderer.prototype.handleContextRestored = function()
}
/**
* Whether the context was lost
* Whether the context was lost
* @property contextLost
* @type Boolean
*/
@ -5482,7 +5606,7 @@ PIXI.WebGLRenderer.prototype.destroy = function()
{
// deal with losing context..
// remove listeners
this.view.removeEventListener('webglcontextlost', this.contextLost);
this.view.removeEventListener('webglcontextrestored', this.contextRestoredLost);
@ -5495,7 +5619,7 @@ PIXI.WebGLRenderer.prototype.destroy = function()
// time to create the render managers! each one focuses on managine a state in webGL
this.shaderManager.destroy();
this.spriteBatch.destroy();
this.primitiveBatch.destroy();
// this.primitiveBatch.destroy();
this.maskManager.destroy();
this.filterManager.destroy();
@ -5503,7 +5627,7 @@ PIXI.WebGLRenderer.prototype.destroy = function()
this.spriteBatch = null;
this.maskManager = null;
this.filterManager = null;
this.gl = null;
//
this.renderSession = null;
@ -5562,13 +5686,7 @@ PIXI.WebGLBlendModeManager.prototype.destroy = function()
*/
PIXI.WebGLMaskManager = function(gl)
{
this.maskStack = [];
this.maskPosition = 0;
this.setContext(gl);
this.reverse = false;
this.count = 0;
};
/**
@ -5620,9 +5738,9 @@ PIXI.WebGLMaskManager.prototype.popMask = function(maskData, renderSession)
*/
PIXI.WebGLMaskManager.prototype.destroy = function()
{
this.maskStack = null;
this.gl = null;
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -5763,7 +5881,7 @@ PIXI.WebGLStencilManager.prototype.bindGraphics = function(graphics, webGLData,
if(webGLData.mode === 1)
{
shader = renderSession.shaderManager.complexPrimativeShader;
shader = renderSession.shaderManager.complexPrimitiveShader;
renderSession.shaderManager.setShader( shader );
@ -5908,9 +6026,10 @@ PIXI.WebGLStencilManager.prototype.popStencil = function(graphics, webGLData, re
*/
PIXI.WebGLStencilManager.prototype.destroy = function()
{
this.maskStack = null;
this.stencilStack = null;
this.gl = null;
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -5927,7 +6046,6 @@ PIXI.WebGLShaderManager = function(gl)
this.maxAttibs = 10;
this.attribState = [];
this.tempAttribState = [];
this.shaderMap = [];
for (var i = 0; i < this.maxAttibs; i++) {
this.attribState[i] = false;
@ -5952,7 +6070,7 @@ PIXI.WebGLShaderManager.prototype.setContext = function(gl)
this.primitiveShader = new PIXI.PrimitiveShader(gl);
// the next one is used for rendering triangle strips
this.complexPrimativeShader = new PIXI.ComplexPrimitiveShader(gl);
this.complexPrimitiveShader = new PIXI.ComplexPrimitiveShader(gl);
// this shader is used for the default sprite rendering
this.defaultShader = new PIXI.PixiShader(gl);
@ -6035,6 +6153,8 @@ PIXI.WebGLShaderManager.prototype.destroy = function()
this.primitiveShader.destroy();
this.complexPrimitiveShader.destroy();
this.defaultShader.destroy();
this.fastShader.destroy();
@ -7394,7 +7514,7 @@ PIXI.FilterTexture = function(gl, width, height, scaleMode)
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, scaleMode === PIXI.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer );
gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer );
gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer );
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0);
@ -8896,7 +9016,7 @@ PIXI.Graphics.prototype.drawPath = function(path)
{
if (!this.currentPath.points.length) this.graphicsData.pop();
this.currentPath = this.currentPath = {lineWidth:this.lineWidth, lineColor:this.lineColor, lineAlpha:this.lineAlpha,
this.currentPath = {lineWidth:this.lineWidth, lineColor:this.lineColor, lineAlpha:this.lineAlpha,
fillColor:this.fillColor, fillAlpha:this.fillAlpha, fill:this.filling, points:[], type:PIXI.Graphics.POLY};
this.graphicsData.push(this.currentPath);
@ -9403,6 +9523,13 @@ PIXI.Strip = function(texture)
{
PIXI.DisplayObjectContainer.call( this );
/**
* The texture of the strip
*
* @property texture
* @type Texture
*/
this.texture = texture;
// set up the main bits..
@ -9420,8 +9547,24 @@ PIXI.Strip = function(texture)
this.indices = new PIXI.Uint16Array([0, 1, 2, 3]);
/**
* Whether the strip is dirty or not
*
* @property dirty
* @type Boolean
*/
this.dirty = true;
/**
* if you need a padding, not yet implemented
*
* @property padding
* @type Number
*/
this.padding = 0;
// NYI, TODO padding ?
};
// constructor
@ -9571,7 +9714,7 @@ PIXI.Strip.prototype._renderCanvas = function(renderSession)
var x0 = verticies[index], x1 = verticies[index+2], x2 = verticies[index+4];
var y0 = verticies[index+1], y1 = verticies[index+3], y2 = verticies[index+5];
if(true)
if(this.padding === 0)
{
//expand();
@ -9677,6 +9820,7 @@ PIXI.Strip.prototype.onTextureUpdate = function()
*
* @class Rope
* @constructor
* @extends Strip
* @param texture {Texture} The texture to use
* @param points {Array}
*
@ -10030,7 +10174,7 @@ PIXI.TilingSprite.prototype._renderWebGL = function(renderSession)
renderSession.spriteBatch.stop();
if (this._filters) renderSession.filterManager.popFilter();
if (this._mask) renderSession.maskManager.popMask(renderSession);
if (this._mask) renderSession.maskManager.popMask(this._mask, renderSession);
renderSession.spriteBatch.start();
};
@ -10297,6 +10441,7 @@ PIXI.TilingSprite.prototype.generateTilingTexture = function(forcePowerOfTwo)
this.refreshTexture = false;
this.tilingTexture.baseTexture._powerOf2 = true;
};
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
@ -10377,10 +10522,10 @@ PIXI.BaseTexture = function(source, scaleMode)
// used for webGL
this._glTextures = [];
// used for webGL teture updateing...
this._dirty = [];
if(!source)return;
if((this.source.complete || this.source.getContext) && this.source.width && this.source.height)
@ -10417,7 +10562,7 @@ PIXI.BaseTexture = function(source, scaleMode)
this.imageUrl = null;
this._powerOf2 = false;
};
@ -10465,14 +10610,14 @@ PIXI.BaseTexture.prototype.updateSourceImage = function(newSrc)
* @static
* @method fromImage
* @param imageUrl {String} The image url of the texture
* @param crossorigin {Boolean}
* @param crossorigin {Boolean}
* @param scaleMode {Number} Should be one of the PIXI.scaleMode consts
* @return BaseTexture
*/
PIXI.BaseTexture.fromImage = function(imageUrl, crossorigin, scaleMode)
{
var baseTexture = PIXI.BaseTextureCache[imageUrl];
if(crossorigin === undefined && imageUrl.indexOf('data:') === -1) crossorigin = true;
if(!baseTexture)
@ -10588,7 +10733,7 @@ PIXI.Texture = function(baseTexture, frame)
* @type Rectangle
*/
this.trim = null;
/**
* This will let the renderer know if the texture is valid. If its not then it cannot be rendered.
*
@ -10597,14 +10742,6 @@ PIXI.Texture = function(baseTexture, frame)
*/
this.valid = false;
/**
* The context scope under which events are run.
*
* @property scope
* @type Object
*/
this.scope = this;
/**
* The WebGL UV data cache.
*
@ -10613,7 +10750,7 @@ PIXI.Texture = function(baseTexture, frame)
* @type Object
*/
this._uvs = null;
/**
* The width of the Texture in pixels.
*
@ -10646,8 +10783,7 @@ PIXI.Texture = function(baseTexture, frame)
}
else
{
var scope = this;
baseTexture.addEventListener('loaded', function(){ scope.onBaseTextureLoaded(); });
baseTexture.addEventListener('loaded', this.onBaseTextureLoaded.bind(this));
}
};
@ -10666,10 +10802,10 @@ PIXI.Texture.prototype.onBaseTextureLoaded = function()
baseTexture.removeEventListener('loaded', this.onLoaded);
if (this.noFrame) this.frame = new PIXI.Rectangle(0, 0, baseTexture.width, baseTexture.height);
this.setFrame(this.frame);
this.scope.dispatchEvent( { type: 'update', content: this } );
this.dispatchEvent( { type: 'update', content: this } );
};
/**
@ -10896,6 +11032,7 @@ PIXI.RenderTexture = function(width, height, renderer, scaleMode)
{
PIXI.EventTarget.call( this );
/**
* The with of the render texture
*
@ -10987,6 +11124,9 @@ PIXI.RenderTexture.prototype.resize = function(width, height, updateBase)
return;
}
this.valid = (width > 0 && height > 0);
this.width = this.frame.width = this.crop.width = width;
this.height = this.frame.height = this.crop.height = height;
@ -11002,7 +11142,9 @@ PIXI.RenderTexture.prototype.resize = function(width, height, updateBase)
this.projection.y = -this.height / 2;
}
if(!this.valid)return;
this.textureBuffer.resize(this.width, this.height);
};
/**
@ -11012,6 +11154,8 @@ PIXI.RenderTexture.prototype.resize = function(width, height, updateBase)
*/
PIXI.RenderTexture.prototype.clear = function()
{
if(!this.valid)return;
if (this.renderer.type === PIXI.WEBGL_RENDERER)
{
this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER, this.textureBuffer.frameBuffer);
@ -11030,6 +11174,7 @@ PIXI.RenderTexture.prototype.clear = function()
*/
PIXI.RenderTexture.prototype.renderWebGL = function(displayObject, position, clear)
{
if(!this.valid)return;
//TOOD replace position with matrix..
var gl = this.renderer.gl;
@ -11086,6 +11231,8 @@ PIXI.RenderTexture.prototype.renderWebGL = function(displayObject, position, cle
*/
PIXI.RenderTexture.prototype.renderCanvas = function(displayObject, position, clear)
{
if(!this.valid)return;
var children = displayObject.children;
var originalWorldTransform = displayObject.worldTransform;
@ -11119,6 +11266,65 @@ PIXI.RenderTexture.prototype.renderCanvas = function(displayObject, position, cl
displayObject.worldTransform = originalWorldTransform;
};
/**
* Will return a HTML Image of the texture
*
* @method getImage
*/
PIXI.RenderTexture.prototype.getImage = function()
{
var image = new Image();
image.src = this.getBase64();
return image;
};
/**
* Will return a a base64 string of the texture
*
* @method getImage
*/
PIXI.RenderTexture.prototype.getBase64 = function()
{
return this.getCanvas().toDataURL();
};
PIXI.RenderTexture.prototype.getCanvas = function()
{
if (this.renderer.type === PIXI.WEBGL_RENDERER)
{
var gl = this.renderer.gl;
var width = this.textureBuffer.width;
var height = this.textureBuffer.height;
var webGLPixels = new Uint8Array(4 * width * height);
gl.bindFramebuffer(gl.FRAMEBUFFER, this.textureBuffer.frameBuffer);
gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, webGLPixels);
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
var tempCanvas = new PIXI.CanvasBuffer(width, height);
var canvasData = tempCanvas.context.getImageData(0, 0, width, height);
var canvasPixels = canvasData.data;
for (var i = 0; i < webGLPixels.length; i+=4)
{
var alpha = webGLPixels[i+3];
canvasPixels[i] = webGLPixels[i] * alpha;
canvasPixels[i+1] = webGLPixels[i+1] * alpha;
canvasPixels[i+2] = webGLPixels[i+2] * alpha;
canvasPixels[i+3] = alpha;
}
tempCanvas.context.putImageData(canvasData, 0, 0);
return tempCanvas.canvas;
}
else
{
return this.textureBuffer.canvas;
}
};
PIXI.RenderTexture.tempMatrix = new PIXI.Matrix();

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

43
build/phaser.min.js vendored

File diff suppressed because one or more lines are too long