PIXI.Float32Array, PIXI.Uint16Array, PIXI.Uint32Array and PIXI.ArrayBuffer have all been removed, and replaced with their own proper native versions. The polyfill now captures any instances where the browser needs to fall back to an Array instead.

This commit is contained in:
Richard Davey 2016-09-28 19:02:59 +01:00
parent 4ca182dd1a
commit 6ce28658f6
10 changed files with 38 additions and 50 deletions

View file

@ -349,6 +349,9 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
* PIXI.Graphics and PIXI.GraphicsData have been removed, and all functionality merged in to Phaser.Graphics, to cut down on the number of internal classes and inheritance going on.
* WebGLGraphics and CanvasGraphics have been updated so that it checks for Phaser Geometry shape types internally.
* PIXI.PI_2 has been removed, because it's available via Phaser.Math.PI2. The only place PI_2 was used has been updated to now use PI2.
* The polyfills.js file now polyfills in for Float32Array, Uint16Array and ArrayBuffer.
* PIXI.Float32Array, PIXI.Uint16Array, PIXI.Uint32Array and PIXI.ArrayBuffer have all been removed, and replaced with their own proper native versions. The polyfill now captures any instances where the browser needs to fall back to an Array instead.
### Bug Fixes
@ -379,6 +382,7 @@ Please note that Phaser uses a custom build of Pixi and always has done. The fol
* PIXI.PI_2, PIXI.RAD_TO_DEG and PIXI.DEG_TO_RAD have all been removed, as they are no longer used internally, and are all available under Phaser.Math.
* PIXI.RETINA_PREFIX has been removed, as it was never used anywhere internally.
* PIXI._UID has been removed, all affected classes now use Phaser._UID.
* PIXI.Float32Array, PIXI.Uint16Array, PIXI.Uint32Array and PIXI.ArrayBuffer have all been removed, and replaced with their own proper native versions.
For changes in previous releases please see the extensive [Version History](https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md).

View file

@ -113,22 +113,22 @@ Phaser.Creature = function (game, x, y, key, mesh, animation) {
var target = this.manager.target_creature;
/**
* @property {PIXI.Float32Array} vertices - The vertices data.
* @property {Float32Array} vertices - The vertices data.
* @protected
*/
this.vertices = new PIXI.Float32Array(target.total_num_pts * 2);
this.vertices = new Float32Array(target.total_num_pts * 2);
/**
* @property {PIXI.Float32Array} uvs - The UV data.
* @property {Float32Array} uvs - The UV data.
* @protected
*/
this.uvs = new PIXI.Float32Array(target.total_num_pts * 2);
this.uvs = new Float32Array(target.total_num_pts * 2);
/**
* @property {PIXI.Uint16Array} indices
* @property {Uint16Array} indices
* @protected
*/
this.indices = new PIXI.Uint16Array(target.global_indices.length);
this.indices = new Uint16Array(target.global_indices.length);
for (var i = 0; i < this.indices.length; i++)
{
@ -136,10 +136,10 @@ Phaser.Creature = function (game, x, y, key, mesh, animation) {
}
/**
* @property {PIXI.Uint16Array} colors - The vertices colors
* @property {Uint16Array} colors - The vertices colors
* @protected
*/
this.colors = new PIXI.Float32Array([1, 1, 1, 1]);
this.colors = new Float32Array([1, 1, 1, 1]);
this.updateRenderData(target.global_pts, target.global_uvs);

View file

@ -65,26 +65,26 @@ Phaser.Rope = function (game, x, y, key, frame, points) {
this.texture = Phaser.Cache.DEFAULT;
// set up the main bits..
this.uvs = new PIXI.Float32Array([0, 1,
this.uvs = new Float32Array([0, 1,
1, 1,
1, 0,
0, 1]);
this.vertices = new PIXI.Float32Array([0, 0,
this.vertices = new Float32Array([0, 0,
100, 0,
100, 100,
0, 100]);
this.colors = new PIXI.Float32Array([1, 1, 1, 1]);
this.colors = new Float32Array([1, 1, 1, 1]);
this.indices = new PIXI.Uint16Array([0, 1, 2, 3]);
this.indices = new Uint16Array([0, 1, 2, 3]);
if (points)
{
this.vertices = new PIXI.Float32Array(points.length * 4);
this.uvs = new PIXI.Float32Array(points.length * 4);
this.colors = new PIXI.Float32Array(points.length * 2);
this.indices = new PIXI.Uint16Array(points.length * 2);
this.vertices = new Float32Array(points.length * 4);
this.uvs = new Float32Array(points.length * 4);
this.colors = new Float32Array(points.length * 2);
this.indices = new Uint16Array(points.length * 2);
}
/**

View file

@ -194,12 +194,12 @@ Phaser.Matrix.prototype = {
*
* @method Phaser.Matrix#toArray
* @param {boolean} [transpose=false] - Whether the values in the array are transposed or not.
* @param {PIXI.Float32Array} [array] - If provided the values will be set into this array, otherwise a new Float32Array is created.
* @return {PIXI.Float32Array} The newly created array which contains the matrix.
* @param {Float32Array} [array] - If provided the values will be set into this array, otherwise a new Float32Array is created.
* @return {Float32Array} The newly created array which contains the matrix.
*/
toArray: function (transpose, array) {
if (array === undefined) { array = new PIXI.Float32Array(9); }
if (array === undefined) { array = new Float32Array(9); }
if (transpose)
{

View file

@ -17,22 +17,3 @@
* @static
*/
var PIXI = PIXI || {};
if (typeof(Float32Array) != 'undefined')
{
PIXI.Float32Array = Float32Array;
PIXI.Uint16Array = Uint16Array;
// Uint32Array and ArrayBuffer only used by WebGL renderer
// We can suppose that if WebGL is supported then typed arrays are supported too
// as they predate WebGL support for all browsers:
// see typed arrays support: http://caniuse.com/#search=TypedArrays
// see WebGL support: http://caniuse.com/#search=WebGL
PIXI.Uint32Array = Uint32Array;
PIXI.ArrayBuffer = ArrayBuffer;
}
else
{
PIXI.Float32Array = Array;
PIXI.Uint16Array = Array;
}

View file

@ -44,14 +44,14 @@ PIXI.WebGLFastSpriteBatch = function(gl)
* @property vertices
* @type Float32Array
*/
this.vertices = new PIXI.Float32Array(numVerts);
this.vertices = new Float32Array(numVerts);
/**
* Index data
* @property indices
* @type Uint16Array
*/
this.indices = new PIXI.Uint16Array(numIndices);
this.indices = new Uint16Array(numIndices);
/**
* @property vertexBuffer

View file

@ -411,7 +411,7 @@ PIXI.WebGLFilterManager.prototype.initShaderBuffers = function()
// bind and upload the vertexs..
// keep a reference to the vertexFloatData..
this.vertexArray = new PIXI.Float32Array([0.0, 0.0,
this.vertexArray = new Float32Array([0.0, 0.0,
1.0, 0.0,
0.0, 1.0,
1.0, 1.0]);
@ -420,7 +420,7 @@ PIXI.WebGLFilterManager.prototype.initShaderBuffers = function()
gl.bufferData(gl.ARRAY_BUFFER, this.vertexArray, gl.STATIC_DRAW);
// bind and upload the uv buffer
this.uvArray = new PIXI.Float32Array([0.0, 0.0,
this.uvArray = new Float32Array([0.0, 0.0,
1.0, 0.0,
0.0, 1.0,
1.0, 1.0]);
@ -428,7 +428,7 @@ PIXI.WebGLFilterManager.prototype.initShaderBuffers = function()
gl.bindBuffer(gl.ARRAY_BUFFER, this.uvBuffer);
gl.bufferData(gl.ARRAY_BUFFER, this.uvArray, gl.STATIC_DRAW);
this.colorArray = new PIXI.Float32Array([1.0, 0xFFFFFF,
this.colorArray = new Float32Array([1.0, 0xFFFFFF,
1.0, 0xFFFFFF,
1.0, 0xFFFFFF,
1.0, 0xFFFFFF]);

View file

@ -888,12 +888,12 @@ PIXI.WebGLGraphicsData.prototype.upload = function()
var gl = this.gl;
// this.lastIndex = graphics.graphicsData.length;
this.glPoints = new PIXI.Float32Array(this.points);
this.glPoints = new Float32Array(this.points);
gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer);
gl.bufferData(gl.ARRAY_BUFFER, this.glPoints, gl.STATIC_DRAW);
this.glIndicies = new PIXI.Uint16Array(this.indices);
this.glIndicies = new Uint16Array(this.indices);
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.glIndicies, gl.STATIC_DRAW);

View file

@ -51,7 +51,7 @@ PIXI.WebGLSpriteBatch = function (game) {
* @property vertices
* @type ArrayBuffer
*/
this.vertices = new PIXI.ArrayBuffer(numVerts);
this.vertices = new ArrayBuffer(numVerts);
/**
* View on the vertices as a Float32Array
@ -59,7 +59,7 @@ PIXI.WebGLSpriteBatch = function (game) {
* @property positions
* @type Float32Array
*/
this.positions = new PIXI.Float32Array(this.vertices);
this.positions = new Float32Array(this.vertices);
/**
* View on the vertices as a Uint32Array
@ -67,7 +67,7 @@ PIXI.WebGLSpriteBatch = function (game) {
* @property colors
* @type Uint32Array
*/
this.colors = new PIXI.Uint32Array(this.vertices);
this.colors = new Uint32Array(this.vertices);
/**
* Holds the indices
@ -75,7 +75,7 @@ PIXI.WebGLSpriteBatch = function (game) {
* @property indices
* @type Uint16Array
*/
this.indices = new PIXI.Uint16Array(numIndices);
this.indices = new Uint16Array(numIndices);
/**
* @property lastIndexCount

View file

@ -138,8 +138,11 @@ if (typeof window.Uint32Array !== "function" && typeof window.Uint32Array !== "o
window[type].constructor = window[type];
};
CheapArray('Float32Array'); // jshint ignore:line
CheapArray('Uint32Array'); // jshint ignore:line
CheapArray('Int16Array'); // jshint ignore:line
CheapArray('Uint16Array'); // jshint ignore:line
CheapArray('Int16Array'); // jshint ignore:line
CheapArray('ArrayBuffer'); // jshint ignore:line
}
/**