Merge branch 'dev' of https://github.com/GoodBoyDigital/pixi.js into dev
This commit is contained in:
commit
e78a82fa34
20 changed files with 183 additions and 926 deletions
|
@ -5,7 +5,6 @@ module.exports = function(grunt) {
|
||||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||||
grunt.loadNpmTasks('grunt-contrib-connect');
|
grunt.loadNpmTasks('grunt-contrib-connect');
|
||||||
grunt.loadNpmTasks('grunt-contrib-yuidoc');
|
grunt.loadNpmTasks('grunt-contrib-yuidoc');
|
||||||
grunt.loadNpmTasks('grunt-contrib-watch');
|
|
||||||
|
|
||||||
grunt.loadTasks('tasks');
|
grunt.loadTasks('tasks');
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Pixi Renderer [](https://travis-ci.org/GoodBoyDigital/pixi.js)
|
Pixi Renderer
|
||||||
=============
|
=============
|
||||||
|
|
||||||

|

|
||||||
|
|
536
bin/pixi.dev.js
536
bin/pixi.dev.js
File diff suppressed because it is too large
Load diff
26
bin/pixi.js
26
bin/pixi.js
File diff suppressed because one or more lines are too long
|
@ -39,7 +39,6 @@ PIXI.InteractionManager = function(stage)
|
||||||
|
|
||||||
// helpers
|
// helpers
|
||||||
this.tempPoint = new PIXI.Point();
|
this.tempPoint = new PIXI.Point();
|
||||||
//this.tempMatrix = mat3.create();
|
|
||||||
|
|
||||||
this.mouseoverEnabled = true;
|
this.mouseoverEnabled = true;
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* @class Matrix
|
* @class Matrix
|
||||||
* The Matrix class will choose the best type of array to use between
|
* The Matrix class will choose the best type of array to use between
|
||||||
* a regular javascript Array and a Float32Array if the latter is available
|
* a regular javascript Array and a Float32Array if the latter is available
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
PIXI.determineMatrixArrayType = function() {
|
PIXI.determineMatrixArrayType = function() {
|
||||||
return (typeof Float32Array !== 'undefined') ? Float32Array : Array;
|
return (typeof Float32Array !== 'undefined') ? Float32Array : Array;
|
||||||
|
@ -14,343 +14,6 @@ PIXI.determineMatrixArrayType = function() {
|
||||||
|
|
||||||
PIXI.Matrix2 = PIXI.determineMatrixArrayType();
|
PIXI.Matrix2 = PIXI.determineMatrixArrayType();
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A lighter version of the rad gl-matrix created by Brandon Jones, Colin MacKenzie IV
|
|
||||||
* you both rock!
|
|
||||||
*
|
|
||||||
* @class mat3
|
|
||||||
* @static
|
|
||||||
*/
|
|
||||||
|
|
||||||
PIXI.mat3 = {};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Creates a mat3 object
|
|
||||||
*
|
|
||||||
* @method mat3.create
|
|
||||||
* @static
|
|
||||||
*/
|
|
||||||
PIXI.mat3.create = function()
|
|
||||||
{
|
|
||||||
var matrix = new PIXI.Matrix2(9);
|
|
||||||
|
|
||||||
matrix[0] = 1;
|
|
||||||
matrix[1] = 0;
|
|
||||||
matrix[2] = 0;
|
|
||||||
matrix[3] = 0;
|
|
||||||
matrix[4] = 1;
|
|
||||||
matrix[5] = 0;
|
|
||||||
matrix[6] = 0;
|
|
||||||
matrix[7] = 0;
|
|
||||||
matrix[8] = 1;
|
|
||||||
|
|
||||||
return matrix;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Creates a mat3 identity matrix
|
|
||||||
*
|
|
||||||
* @method mat3.indentity
|
|
||||||
* @static
|
|
||||||
* @param matrix {Array|Float32Array}
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
PIXI.mat3.identity = function(matrix)
|
|
||||||
{
|
|
||||||
matrix[0] = 1;
|
|
||||||
matrix[1] = 0;
|
|
||||||
matrix[2] = 0;
|
|
||||||
matrix[3] = 0;
|
|
||||||
matrix[4] = 1;
|
|
||||||
matrix[5] = 0;
|
|
||||||
matrix[6] = 0;
|
|
||||||
matrix[7] = 0;
|
|
||||||
matrix[8] = 1;
|
|
||||||
|
|
||||||
return matrix;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Multiplies the matrices given as parameters by themselves
|
|
||||||
*
|
|
||||||
* @method mat3.multiply
|
|
||||||
* @static
|
|
||||||
* @param mat {Array|Float32Array} the first operand (matrix)
|
|
||||||
* @param mat2 {Array|Float32Array} the second operand (matrix)
|
|
||||||
* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix
|
|
||||||
*/
|
|
||||||
PIXI.mat3.multiply = function (mat, mat2, dest)
|
|
||||||
{
|
|
||||||
if (!dest) { dest = mat; }
|
|
||||||
|
|
||||||
// Cache the matrix values (makes for huge speed increases!)
|
|
||||||
var a00 = mat[0], a01 = mat[1], a02 = mat[2],
|
|
||||||
a10 = mat[3], a11 = mat[4], a12 = mat[5],
|
|
||||||
a20 = mat[6], a21 = mat[7], a22 = mat[8],
|
|
||||||
|
|
||||||
b00 = mat2[0], b01 = mat2[1], b02 = mat2[2],
|
|
||||||
b10 = mat2[3], b11 = mat2[4], b12 = mat2[5],
|
|
||||||
b20 = mat2[6], b21 = mat2[7], b22 = mat2[8];
|
|
||||||
|
|
||||||
dest[0] = b00 * a00 + b01 * a10 + b02 * a20;
|
|
||||||
dest[1] = b00 * a01 + b01 * a11 + b02 * a21;
|
|
||||||
dest[2] = b00 * a02 + b01 * a12 + b02 * a22;
|
|
||||||
|
|
||||||
dest[3] = b10 * a00 + b11 * a10 + b12 * a20;
|
|
||||||
dest[4] = b10 * a01 + b11 * a11 + b12 * a21;
|
|
||||||
dest[5] = b10 * a02 + b11 * a12 + b12 * a22;
|
|
||||||
|
|
||||||
dest[6] = b20 * a00 + b21 * a10 + b22 * a20;
|
|
||||||
dest[7] = b20 * a01 + b21 * a11 + b22 * a21;
|
|
||||||
dest[8] = b20 * a02 + b21 * a12 + b22 * a22;
|
|
||||||
|
|
||||||
return dest;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Makes a copy of the matrix given in parameter
|
|
||||||
*
|
|
||||||
* @method mat3.clone
|
|
||||||
* @static
|
|
||||||
* @param mat {Array|Float32Array}
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
PIXI.mat3.clone = function(mat)
|
|
||||||
{
|
|
||||||
var matrix = new PIXI.Matrix2(9);
|
|
||||||
|
|
||||||
matrix[0] = mat[0];
|
|
||||||
matrix[1] = mat[1];
|
|
||||||
matrix[2] = mat[2];
|
|
||||||
matrix[3] = mat[3];
|
|
||||||
matrix[4] = mat[4];
|
|
||||||
matrix[5] = mat[5];
|
|
||||||
matrix[6] = mat[6];
|
|
||||||
matrix[7] = mat[7];
|
|
||||||
matrix[8] = mat[8];
|
|
||||||
|
|
||||||
return matrix;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Re-arranges the matrix
|
|
||||||
*
|
|
||||||
* @method mat3.transpose
|
|
||||||
* @static
|
|
||||||
* @param mat {Array|Float32Array}
|
|
||||||
* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix
|
|
||||||
*/
|
|
||||||
PIXI.mat3.transpose = function (mat, dest)
|
|
||||||
{
|
|
||||||
// If we are transposing ourselves we can skip a few steps but have to cache some values
|
|
||||||
if (!dest || mat === dest) {
|
|
||||||
var a01 = mat[1], a02 = mat[2],
|
|
||||||
a12 = mat[5];
|
|
||||||
|
|
||||||
mat[1] = mat[3];
|
|
||||||
mat[2] = mat[6];
|
|
||||||
mat[3] = a01;
|
|
||||||
mat[5] = mat[7];
|
|
||||||
mat[6] = a02;
|
|
||||||
mat[7] = a12;
|
|
||||||
return mat;
|
|
||||||
}
|
|
||||||
|
|
||||||
dest[0] = mat[0];
|
|
||||||
dest[1] = mat[3];
|
|
||||||
dest[2] = mat[6];
|
|
||||||
dest[3] = mat[1];
|
|
||||||
dest[4] = mat[4];
|
|
||||||
dest[5] = mat[7];
|
|
||||||
dest[6] = mat[2];
|
|
||||||
dest[7] = mat[5];
|
|
||||||
dest[8] = mat[8];
|
|
||||||
return dest;
|
|
||||||
};
|
|
||||||
|
|
||||||
PIXI.mat4 = {};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Appends the mat3 into a mat4, therefore making it a regular mat4 object
|
|
||||||
*
|
|
||||||
* @method mat3.toMat4
|
|
||||||
* @static
|
|
||||||
* @param mat {Array|Float32Array}
|
|
||||||
* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
PIXI.mat3.toMat4 = function (mat, dest)
|
|
||||||
{
|
|
||||||
if (!dest) { dest = PIXI.mat4.create(); }
|
|
||||||
|
|
||||||
dest[15] = 1;
|
|
||||||
dest[14] = 0;
|
|
||||||
dest[13] = 0;
|
|
||||||
dest[12] = 0;
|
|
||||||
|
|
||||||
dest[11] = 0;
|
|
||||||
dest[10] = mat[8];
|
|
||||||
dest[9] = mat[7];
|
|
||||||
dest[8] = mat[6];
|
|
||||||
|
|
||||||
dest[7] = 0;
|
|
||||||
dest[6] = mat[5];
|
|
||||||
dest[5] = mat[4];
|
|
||||||
dest[4] = mat[3];
|
|
||||||
|
|
||||||
dest[3] = 0;
|
|
||||||
dest[2] = mat[2];
|
|
||||||
dest[1] = mat[1];
|
|
||||||
dest[0] = mat[0];
|
|
||||||
|
|
||||||
return dest;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Creates a new mat4 matrix
|
|
||||||
*
|
|
||||||
* @method mat4.create
|
|
||||||
* @static
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
PIXI.mat4.create = function()
|
|
||||||
{
|
|
||||||
var matrix = new PIXI.Matrix2(16);
|
|
||||||
|
|
||||||
matrix[0] = 1;
|
|
||||||
matrix[1] = 0;
|
|
||||||
matrix[2] = 0;
|
|
||||||
matrix[3] = 0;
|
|
||||||
matrix[4] = 0;
|
|
||||||
matrix[5] = 1;
|
|
||||||
matrix[6] = 0;
|
|
||||||
matrix[7] = 0;
|
|
||||||
matrix[8] = 0;
|
|
||||||
matrix[9] = 0;
|
|
||||||
matrix[10] = 1;
|
|
||||||
matrix[11] = 0;
|
|
||||||
matrix[12] = 0;
|
|
||||||
matrix[13] = 0;
|
|
||||||
matrix[14] = 0;
|
|
||||||
matrix[15] = 1;
|
|
||||||
|
|
||||||
return matrix;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Re-arranges the matrix
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @method mat4.transpose
|
|
||||||
* @static
|
|
||||||
* @param mat {Array|Float32Array}
|
|
||||||
* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
PIXI.mat4.transpose = function (mat, dest)
|
|
||||||
{
|
|
||||||
// If we are transposing ourselves we can skip a few steps but have to cache some values
|
|
||||||
if (!dest || mat === dest)
|
|
||||||
{
|
|
||||||
var a01 = mat[1], a02 = mat[2], a03 = mat[3],
|
|
||||||
a12 = mat[6], a13 = mat[7],
|
|
||||||
a23 = mat[11];
|
|
||||||
|
|
||||||
mat[1] = mat[4];
|
|
||||||
mat[2] = mat[8];
|
|
||||||
mat[3] = mat[12];
|
|
||||||
mat[4] = a01;
|
|
||||||
mat[6] = mat[9];
|
|
||||||
mat[7] = mat[13];
|
|
||||||
mat[8] = a02;
|
|
||||||
mat[9] = a12;
|
|
||||||
mat[11] = mat[14];
|
|
||||||
mat[12] = a03;
|
|
||||||
mat[13] = a13;
|
|
||||||
mat[14] = a23;
|
|
||||||
return mat;
|
|
||||||
}
|
|
||||||
|
|
||||||
dest[0] = mat[0];
|
|
||||||
dest[1] = mat[4];
|
|
||||||
dest[2] = mat[8];
|
|
||||||
dest[3] = mat[12];
|
|
||||||
dest[4] = mat[1];
|
|
||||||
dest[5] = mat[5];
|
|
||||||
dest[6] = mat[9];
|
|
||||||
dest[7] = mat[13];
|
|
||||||
dest[8] = mat[2];
|
|
||||||
dest[9] = mat[6];
|
|
||||||
dest[10] = mat[10];
|
|
||||||
dest[11] = mat[14];
|
|
||||||
dest[12] = mat[3];
|
|
||||||
dest[13] = mat[7];
|
|
||||||
dest[14] = mat[11];
|
|
||||||
dest[15] = mat[15];
|
|
||||||
return dest;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Multiplies the matrices given as parameters by themselves
|
|
||||||
*
|
|
||||||
* @method mat4.multiply
|
|
||||||
* @static
|
|
||||||
* @param mat {Array|Float32Array} the first operand (matrix)
|
|
||||||
* @param mat2 {Array|Float32Array} the second operand (matrix)
|
|
||||||
* @param [dest] {Array|Float32Array} the matrix which will hold the resulting matrix
|
|
||||||
*/
|
|
||||||
PIXI.mat4.multiply = function (mat, mat2, dest)
|
|
||||||
{
|
|
||||||
if (!dest) { dest = mat; }
|
|
||||||
|
|
||||||
// Cache the matrix values (makes for huge speed increases!)
|
|
||||||
var a00 = mat[ 0], a01 = mat[ 1], a02 = mat[ 2], a03 = mat[3];
|
|
||||||
var a10 = mat[ 4], a11 = mat[ 5], a12 = mat[ 6], a13 = mat[7];
|
|
||||||
var a20 = mat[ 8], a21 = mat[ 9], a22 = mat[10], a23 = mat[11];
|
|
||||||
var a30 = mat[12], a31 = mat[13], a32 = mat[14], a33 = mat[15];
|
|
||||||
|
|
||||||
// Cache only the current line of the second matrix
|
|
||||||
var b0 = mat2[0], b1 = mat2[1], b2 = mat2[2], b3 = mat2[3];
|
|
||||||
dest[0] = b0*a00 + b1*a10 + b2*a20 + b3*a30;
|
|
||||||
dest[1] = b0*a01 + b1*a11 + b2*a21 + b3*a31;
|
|
||||||
dest[2] = b0*a02 + b1*a12 + b2*a22 + b3*a32;
|
|
||||||
dest[3] = b0*a03 + b1*a13 + b2*a23 + b3*a33;
|
|
||||||
|
|
||||||
b0 = mat2[4];
|
|
||||||
b1 = mat2[5];
|
|
||||||
b2 = mat2[6];
|
|
||||||
b3 = mat2[7];
|
|
||||||
dest[4] = b0*a00 + b1*a10 + b2*a20 + b3*a30;
|
|
||||||
dest[5] = b0*a01 + b1*a11 + b2*a21 + b3*a31;
|
|
||||||
dest[6] = b0*a02 + b1*a12 + b2*a22 + b3*a32;
|
|
||||||
dest[7] = b0*a03 + b1*a13 + b2*a23 + b3*a33;
|
|
||||||
|
|
||||||
b0 = mat2[8];
|
|
||||||
b1 = mat2[9];
|
|
||||||
b2 = mat2[10];
|
|
||||||
b3 = mat2[11];
|
|
||||||
dest[8] = b0*a00 + b1*a10 + b2*a20 + b3*a30;
|
|
||||||
dest[9] = b0*a01 + b1*a11 + b2*a21 + b3*a31;
|
|
||||||
dest[10] = b0*a02 + b1*a12 + b2*a22 + b3*a32;
|
|
||||||
dest[11] = b0*a03 + b1*a13 + b2*a23 + b3*a33;
|
|
||||||
|
|
||||||
b0 = mat2[12];
|
|
||||||
b1 = mat2[13];
|
|
||||||
b2 = mat2[14];
|
|
||||||
b3 = mat2[15];
|
|
||||||
dest[12] = b0*a00 + b1*a10 + b2*a20 + b3*a30;
|
|
||||||
dest[13] = b0*a01 + b1*a11 + b2*a21 + b3*a31;
|
|
||||||
dest[14] = b0*a02 + b1*a12 + b2*a22 + b3*a32;
|
|
||||||
dest[15] = b0*a03 + b1*a13 + b2*a23 + b3*a33;
|
|
||||||
|
|
||||||
return dest;
|
|
||||||
};
|
|
||||||
|
|
||||||
PIXI.identityMatrix = PIXI.mat3.create();
|
|
||||||
PIXI.tempMatrix = PIXI.mat3.create();
|
|
||||||
|
|
||||||
PIXI.Matrix = function()
|
PIXI.Matrix = function()
|
||||||
{
|
{
|
||||||
this.a = 1;
|
this.a = 1;
|
||||||
|
@ -359,25 +22,21 @@ PIXI.Matrix = function()
|
||||||
this.d = 1;
|
this.d = 1;
|
||||||
this.tx = 0;
|
this.tx = 0;
|
||||||
this.ty = 0;
|
this.ty = 0;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
PIXI.Matrix.prototype.fromArray = function(array)
|
PIXI.Matrix.prototype.fromArray = function(array)
|
||||||
{
|
{
|
||||||
|
|
||||||
this.a = array[0];
|
this.a = array[0];
|
||||||
this.b = array[1];
|
this.b = array[1];
|
||||||
this.c = array[3];
|
this.c = array[3];
|
||||||
this.d = array[4];
|
this.d = array[4];
|
||||||
this.tx = array[2];
|
this.tx = array[2];
|
||||||
this.ty = array[5];
|
this.ty = array[5];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
PIXI.Matrix.prototype.toArray = function(transpose)
|
PIXI.Matrix.prototype.toArray = function(transpose)
|
||||||
{
|
{
|
||||||
if(!this.array)this.array = new Float32Array(9);
|
if(!this.array) this.array = new Float32Array(9);
|
||||||
var array = this.array;
|
var array = this.array;
|
||||||
|
|
||||||
if(transpose)
|
if(transpose)
|
||||||
|
@ -404,6 +63,8 @@ PIXI.Matrix.prototype.toArray = function(transpose)
|
||||||
this.array[7] = 0;
|
this.array[7] = 0;
|
||||||
this.array[8] = 1;
|
this.array[8] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return array;//[this.a, this.b, this.tx, this.c, this.d, this.ty, 0, 0, 1];
|
return array;//[this.a, this.b, this.tx, this.c, this.d, this.ty, 0, 0, 1];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PIXI.identityMatrix = new PIXI.Matrix();
|
|
@ -139,17 +139,7 @@ PIXI.DisplayObject = function()
|
||||||
* @readOnly
|
* @readOnly
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.worldTransform = new PIXI.Matrix();//PIXI.mat3.create(); //mat3.identity();
|
this.worldTransform = new PIXI.Matrix();
|
||||||
|
|
||||||
/**
|
|
||||||
* [read-only] Current transform of the object locally
|
|
||||||
*
|
|
||||||
* @property localTransform
|
|
||||||
* @type Mat3
|
|
||||||
* @readOnly
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
// this.localTransform = new PIXI.Matrix()//PIXI.mat3.create(); //mat3.identity();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [NYI] Unknown
|
* [NYI] Unknown
|
||||||
|
@ -402,6 +392,9 @@ PIXI.DisplayObject.prototype.updateTransform = function()
|
||||||
// TODO OPTIMIZE THIS!! with dirty
|
// TODO OPTIMIZE THIS!! with dirty
|
||||||
if(this.rotation !== this.rotationCache)
|
if(this.rotation !== this.rotationCache)
|
||||||
{
|
{
|
||||||
|
if(isNaN(parseFloat(this.rotation)))
|
||||||
|
throw new Error('DisplayObject rotation values must be numeric.');
|
||||||
|
|
||||||
this.rotationCache = this.rotation;
|
this.rotationCache = this.rotation;
|
||||||
this._sr = Math.sin(this.rotation);
|
this._sr = Math.sin(this.rotation);
|
||||||
this._cr = Math.cos(this.rotation);
|
this._cr = Math.cos(this.rotation);
|
||||||
|
@ -534,4 +527,4 @@ Object.defineProperty(PIXI.DisplayObject.prototype, 'y', {
|
||||||
set: function(value) {
|
set: function(value) {
|
||||||
this.position.y = value;
|
this.position.y = value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -30,7 +30,7 @@ PIXI.Stage = function(backgroundColor)
|
||||||
* @readOnly
|
* @readOnly
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.worldTransform = new PIXI.Matrix();//PIXI.mat3.create();
|
this.worldTransform = new PIXI.Matrix();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not the stage is interactive
|
* Whether or not the stage is interactive
|
||||||
|
|
|
@ -223,6 +223,10 @@ PIXI.TilingSprite.prototype._renderCanvas = function(renderSession)
|
||||||
|
|
||||||
var tilePosition = this.tilePosition;
|
var tilePosition = this.tilePosition;
|
||||||
var tileScale = this.tileScale;
|
var tileScale = this.tileScale;
|
||||||
|
|
||||||
|
tilePosition.x %= this.tilingTexture.baseTexture.width;
|
||||||
|
tilePosition.y %= this.tilingTexture.baseTexture.height;
|
||||||
|
|
||||||
// console.log(tileScale.x)
|
// console.log(tileScale.x)
|
||||||
// offset
|
// offset
|
||||||
context.scale(tileScale.x,tileScale.y);
|
context.scale(tileScale.x,tileScale.y);
|
||||||
|
|
|
@ -371,9 +371,9 @@ PIXI.Graphics.prototype._renderWebGL = function(renderSession)
|
||||||
// check blend mode
|
// check blend mode
|
||||||
if(this.blendMode !== renderSession.spriteBatch.currentBlendMode)
|
if(this.blendMode !== renderSession.spriteBatch.currentBlendMode)
|
||||||
{
|
{
|
||||||
this.spriteBatch.currentBlendMode = this.blendMode;
|
renderSession.spriteBatch.currentBlendMode = this.blendMode;
|
||||||
var blendModeWebGL = PIXI.blendModesWebGL[renderSession.spriteBatch.currentBlendMode];
|
var blendModeWebGL = PIXI.blendModesWebGL[renderSession.spriteBatch.currentBlendMode];
|
||||||
this.spriteBatch.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]);
|
renderSession.spriteBatch.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
PIXI.WebGLGraphics.renderGraphics(this, renderSession);
|
PIXI.WebGLGraphics.renderGraphics(this, renderSession);
|
||||||
|
|
|
@ -82,8 +82,6 @@ PIXI.WebGLFastSpriteBatch.prototype.begin = function(spriteBatch, renderSession)
|
||||||
{
|
{
|
||||||
this.renderSession = renderSession;
|
this.renderSession = renderSession;
|
||||||
this.shader = this.renderSession.shaderManager.fastShader;
|
this.shader = this.renderSession.shaderManager.fastShader;
|
||||||
|
|
||||||
// PIXI.mat3.transpose(spriteBatch.worldTransform.toArray(), this.tempMatrix);
|
|
||||||
|
|
||||||
this.matrix = spriteBatch.worldTransform.toArray(true);
|
this.matrix = spriteBatch.worldTransform.toArray(true);
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,6 @@ PIXI.WebGLGraphics.renderGraphics = function(graphics, renderSession)//projectio
|
||||||
renderSession.shaderManager.activatePrimitiveShader();
|
renderSession.shaderManager.activatePrimitiveShader();
|
||||||
|
|
||||||
// This could be speeded up for sure!
|
// This could be speeded up for sure!
|
||||||
// var m = PIXI.mat3.clone(graphics.worldTransform);
|
|
||||||
|
|
||||||
// set the matrix transform
|
// set the matrix transform
|
||||||
gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
|
gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
|
@ -278,6 +278,9 @@ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite)
|
||||||
|
|
||||||
var uvs = tilingSprite._uvs;
|
var uvs = tilingSprite._uvs;
|
||||||
|
|
||||||
|
tilingSprite.tilePosition.x %= texture.baseTexture.width;
|
||||||
|
tilingSprite.tilePosition.y %= texture.baseTexture.height;
|
||||||
|
|
||||||
var offsetX = tilingSprite.tilePosition.x/texture.baseTexture.width;
|
var offsetX = tilingSprite.tilePosition.x/texture.baseTexture.width;
|
||||||
var offsetY = tilingSprite.tilePosition.y/texture.baseTexture.height;
|
var offsetY = tilingSprite.tilePosition.y/texture.baseTexture.height;
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,8 @@ PIXI.BitmapText = function(text, style)
|
||||||
{
|
{
|
||||||
PIXI.DisplayObjectContainer.call(this);
|
PIXI.DisplayObjectContainer.call(this);
|
||||||
|
|
||||||
|
this._pool = [];
|
||||||
|
|
||||||
this.setText(text);
|
this.setText(text);
|
||||||
this.setStyle(style);
|
this.setStyle(style);
|
||||||
this.updateText();
|
this.updateText();
|
||||||
|
@ -125,13 +127,28 @@ PIXI.BitmapText.prototype.updateText = function()
|
||||||
lineAlignOffsets.push(alignOffset);
|
lineAlignOffsets.push(alignOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < chars.length; i++)
|
var lenChildren = this.children.length;
|
||||||
|
var lenChars = chars.length;
|
||||||
|
for(i = 0; i < lenChars; i++)
|
||||||
{
|
{
|
||||||
var c = new PIXI.Sprite(chars[i].texture); //PIXI.Sprite.fromFrame(chars[i].charCode);
|
var c = i < lenChildren ? this.children[i] : this._pool.pop(); // get old child if have. if not - take from pool.
|
||||||
|
|
||||||
|
if (c) c.setTexture(chars[i].texture); // check if got one before.
|
||||||
|
else c = new PIXI.Sprite(chars[i].texture); // if no create new one.
|
||||||
|
|
||||||
c.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
c.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
||||||
c.position.y = chars[i].position.y * scale;
|
c.position.y = chars[i].position.y * scale;
|
||||||
c.scale.x = c.scale.y = scale;
|
c.scale.x = c.scale.y = scale;
|
||||||
this.addChild(c);
|
if (!c.parent) this.addChild(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove unnecessary children.
|
||||||
|
// and put their into the pool.
|
||||||
|
while(this.children.length > lenChars)
|
||||||
|
{
|
||||||
|
var child = this.getChildAt(this.children.length - 1);
|
||||||
|
this._pool.push(child);
|
||||||
|
this.removeChild(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.width = maxLineWidth * scale;
|
this.width = maxLineWidth * scale;
|
||||||
|
@ -148,12 +165,7 @@ PIXI.BitmapText.prototype.updateTransform = function()
|
||||||
{
|
{
|
||||||
if(this.dirty)
|
if(this.dirty)
|
||||||
{
|
{
|
||||||
while(this.children.length > 0)
|
|
||||||
{
|
|
||||||
this.removeChild(this.getChildAt(0));
|
|
||||||
}
|
|
||||||
this.updateText();
|
this.updateText();
|
||||||
|
|
||||||
this.dirty = false;
|
this.dirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,34 +66,7 @@ PIXI.BaseTexture = function(source, scaleMode)
|
||||||
|
|
||||||
if(!source)return;
|
if(!source)return;
|
||||||
|
|
||||||
if(this.source instanceof Image || this.source instanceof HTMLImageElement)
|
if(this.source.complete || this.source.getContext)
|
||||||
{
|
|
||||||
if(this.source.complete)
|
|
||||||
{
|
|
||||||
this.hasLoaded = true;
|
|
||||||
this.width = this.source.width;
|
|
||||||
this.height = this.source.height;
|
|
||||||
|
|
||||||
PIXI.texturesToUpdate.push(this);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
var scope = this;
|
|
||||||
this.source.onload = function() {
|
|
||||||
|
|
||||||
scope.hasLoaded = true;
|
|
||||||
scope.width = scope.source.width;
|
|
||||||
scope.height = scope.source.height;
|
|
||||||
|
|
||||||
// add it to somewhere...
|
|
||||||
PIXI.texturesToUpdate.push(scope);
|
|
||||||
scope.dispatchEvent( { type: 'loaded', content: scope } );
|
|
||||||
};
|
|
||||||
//this.image.src = imageUrl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
this.hasLoaded = true;
|
this.hasLoaded = true;
|
||||||
this.width = this.source.width;
|
this.width = this.source.width;
|
||||||
|
@ -101,6 +74,22 @@ PIXI.BaseTexture = function(source, scaleMode)
|
||||||
|
|
||||||
PIXI.texturesToUpdate.push(this);
|
PIXI.texturesToUpdate.push(this);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
var scope = this;
|
||||||
|
this.source.onload = function() {
|
||||||
|
|
||||||
|
scope.hasLoaded = true;
|
||||||
|
scope.width = scope.source.width;
|
||||||
|
scope.height = scope.source.height;
|
||||||
|
|
||||||
|
// add it to somewhere...
|
||||||
|
PIXI.texturesToUpdate.push(scope);
|
||||||
|
scope.dispatchEvent( { type: 'loaded', content: scope } );
|
||||||
|
};
|
||||||
|
//this.image.src = imageUrl;
|
||||||
|
}
|
||||||
|
|
||||||
this.imageUrl = null;
|
this.imageUrl = null;
|
||||||
this._powerOf2 = false;
|
this._powerOf2 = false;
|
||||||
|
@ -122,10 +111,9 @@ PIXI.BaseTexture.prototype.constructor = PIXI.BaseTexture;
|
||||||
*/
|
*/
|
||||||
PIXI.BaseTexture.prototype.destroy = function()
|
PIXI.BaseTexture.prototype.destroy = function()
|
||||||
{
|
{
|
||||||
if(this.source instanceof Image)
|
if(this.imageUrl)
|
||||||
{
|
{
|
||||||
if (this.imageUrl in PIXI.BaseTextureCache)
|
delete PIXI.BaseTextureCache[this.imageUrl];
|
||||||
delete PIXI.BaseTextureCache[this.imageUrl];
|
|
||||||
this.imageUrl = null;
|
this.imageUrl = null;
|
||||||
this.source.src = null;
|
this.source.src = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,6 @@ PIXI.RenderTexture = function(width, height, renderer)
|
||||||
this.width = width || 100;
|
this.width = width || 100;
|
||||||
this.height = height || 100;
|
this.height = height || 100;
|
||||||
|
|
||||||
this.identityMatrix = PIXI.mat3.create();
|
|
||||||
|
|
||||||
this.frame = new PIXI.Rectangle(0, 0, this.width, this.height);
|
this.frame = new PIXI.Rectangle(0, 0, this.width, this.height);
|
||||||
|
|
||||||
this.baseTexture = new PIXI.BaseTexture();
|
this.baseTexture = new PIXI.BaseTexture();
|
||||||
|
@ -47,7 +45,7 @@ PIXI.RenderTexture = function(width, height, renderer)
|
||||||
this.baseTexture._glTextures = [];
|
this.baseTexture._glTextures = [];
|
||||||
|
|
||||||
this.baseTexture.hasLoaded = true;
|
this.baseTexture.hasLoaded = true;
|
||||||
|
|
||||||
// each render texture can only belong to one renderer at the moment if its webGL
|
// each render texture can only belong to one renderer at the moment if its webGL
|
||||||
this.renderer = renderer || PIXI.defaultRenderer;
|
this.renderer = renderer || PIXI.defaultRenderer;
|
||||||
|
|
||||||
|
|
|
@ -1,40 +1,13 @@
|
||||||
|
function pixi_core_Matrix_confirmNewMatrix(matrix) {
|
||||||
function pixi_core_Matrix_confirmNewMat3(matrix) {
|
|
||||||
var expect = chai.expect;
|
var expect = chai.expect;
|
||||||
|
|
||||||
expect(matrix).to.be.an.instanceof(PIXI.Matrix);
|
expect(matrix).to.be.an.instanceof(PIXI.Matrix);
|
||||||
expect(matrix).to.not.be.empty;
|
expect(matrix).to.not.be.empty;
|
||||||
|
|
||||||
expect(matrix[1]).to.equal(0);
|
expect(matrix.a).to.equal(1);
|
||||||
expect(matrix[2]).to.equal(0);
|
expect(matrix.b).to.equal(0);
|
||||||
expect(matrix[3]).to.equal(0);
|
expect(matrix.c).to.equal(0);
|
||||||
expect(matrix[4]).to.equal(1);
|
expect(matrix.d).to.equal(1);
|
||||||
expect(matrix[5]).to.equal(0);
|
expect(matrix.tx).to.equal(0);
|
||||||
expect(matrix[6]).to.equal(0);
|
expect(matrix.ty).to.equal(0);
|
||||||
expect(matrix[7]).to.equal(0);
|
}
|
||||||
expect(matrix[8]).to.equal(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
function pixi_core_Matrix_confirmNewMat4(matrix) {
|
|
||||||
var expect = chai.expect;
|
|
||||||
|
|
||||||
expect(matrix).to.be.an.instanceof(PIXI.Matrix);
|
|
||||||
expect(matrix).to.not.be.empty;
|
|
||||||
|
|
||||||
expect(matrix[0]).to.equal(1);
|
|
||||||
expect(matrix[1]).to.equal(0);
|
|
||||||
expect(matrix[2]).to.equal(0);
|
|
||||||
expect(matrix[3]).to.equal(0);
|
|
||||||
expect(matrix[4]).to.equal(0);
|
|
||||||
expect(matrix[5]).to.equal(1);
|
|
||||||
expect(matrix[6]).to.equal(0);
|
|
||||||
expect(matrix[7]).to.equal(0);
|
|
||||||
expect(matrix[8]).to.equal(0);
|
|
||||||
expect(matrix[9]).to.equal(0);
|
|
||||||
expect(matrix[10]).to.equal(1);
|
|
||||||
expect(matrix[11]).to.equal(0);
|
|
||||||
expect(matrix[12]).to.equal(0);
|
|
||||||
expect(matrix[13]).to.equal(0);
|
|
||||||
expect(matrix[14]).to.equal(0);
|
|
||||||
expect(matrix[15]).to.equal(1);
|
|
||||||
}
|
|
|
@ -33,10 +33,8 @@ function pixi_display_DisplayObject_confirmNew(obj) {
|
||||||
expect(obj).to.have.property('renderable');
|
expect(obj).to.have.property('renderable');
|
||||||
expect(obj).to.have.property('stage');
|
expect(obj).to.have.property('stage');
|
||||||
|
|
||||||
expect(obj).to.have.deep.property('worldTransform.length', 9);
|
expect(obj).to.have.deep.property('worldTransform');
|
||||||
pixi_core_Matrix_confirmNewMat3(obj.worldTransform);
|
pixi_core_Matrix_confirmNewMatrix(obj.worldTransform);
|
||||||
expect(obj).to.have.deep.property('localTransform.length', 9);
|
|
||||||
pixi_core_Matrix_confirmNewMat3(obj.localTransform);
|
|
||||||
|
|
||||||
expect(obj).to.have.deep.property('color.length', 0);
|
expect(obj).to.have.deep.property('color.length', 0);
|
||||||
expect(obj).to.have.property('dynamic', true);
|
expect(obj).to.have.property('dynamic', true);
|
||||||
|
|
|
@ -2,29 +2,17 @@ describe('pixi/core/Matrix', function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var expect = chai.expect;
|
var expect = chai.expect;
|
||||||
var mat3 = PIXI.mat3;
|
|
||||||
var mat4 = PIXI.mat4;
|
it('Ensure determineMatrixArrayType exists', function () {
|
||||||
var Matrix = PIXI.Matrix;
|
expect(PIXI.determineMatrixArrayType).to.be.a('function');
|
||||||
/*
|
|
||||||
it('Ensure determineMatrixArrayType works', function () {
|
|
||||||
expect(Matrix).to.be.a('function');
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
it('mat3 exists', function () {
|
|
||||||
expect(mat3).to.be.an('object');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Confirm new mat3 matrix', function () {
|
it('Matrix exists', function () {
|
||||||
var matrix = new mat3.create();
|
expect(PIXI.Matrix).to.be.an('function');
|
||||||
pixi_core_Matrix_confirmNewMat3(matrix);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('mat3 exists', function () {
|
it('Confirm new Matrix', function () {
|
||||||
expect(mat4).to.be.an('object');
|
var matrix = new PIXI.Matrix();
|
||||||
});
|
pixi_core_Matrix_confirmNewMatrix(matrix);
|
||||||
|
|
||||||
it('Confirm new mat4 matrix', function () {
|
|
||||||
var matrix = new mat4.create();
|
|
||||||
pixi_core_Matrix_confirmNewMat4(matrix);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,7 +20,7 @@ describe('pixi/display/Stage', function () {
|
||||||
expect(obj).to.respondTo('setBackgroundColor');
|
expect(obj).to.respondTo('setBackgroundColor');
|
||||||
expect(obj).to.respondTo('getMousePosition');
|
expect(obj).to.respondTo('getMousePosition');
|
||||||
// FIXME: duplicate member in DisplayObject
|
// FIXME: duplicate member in DisplayObject
|
||||||
pixi_core_Matrix_confirmNewMat3(obj.worldTransform);
|
pixi_core_Matrix_confirmNewMatrix(obj.worldTransform);
|
||||||
// FIXME: convert arg to bool in constructor
|
// FIXME: convert arg to bool in constructor
|
||||||
expect(obj).to.have.property('interactive', true);
|
expect(obj).to.have.property('interactive', true);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue