Skip to content

Commit 9d79605

Browse files
committed
Pixi 2.2.0 merged.
1 parent a51e22a commit 9d79605

8 files changed

Lines changed: 116 additions & 100 deletions

File tree

src/pixi/Pixi.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ PIXI.CANVAS_RENDERER = 1;
3636
* @property {String} VERSION
3737
* @static
3838
*/
39-
PIXI.VERSION = "v2.1.0";
39+
PIXI.VERSION = "v2.2.0";
4040

4141
/**
4242
* Various blend modes supported by pixi.
@@ -105,6 +105,14 @@ if(typeof(Float32Array) != 'undefined')
105105
{
106106
PIXI.Float32Array = Float32Array;
107107
PIXI.Uint16Array = Uint16Array;
108+
109+
// Uint32Array and ArrayBuffer only used by WebGL renderer
110+
// We can suppose that if WebGL is supported then typed arrays are supported too
111+
// as they predate WebGL support for all browsers:
112+
// see typed arrays support: http://caniuse.com/#search=TypedArrays
113+
// see WebGL support: http://caniuse.com/#search=WebGL
114+
PIXI.Uint32Array = Uint32Array;
115+
PIXI.ArrayBuffer = ArrayBuffer;
108116
}
109117
else
110118
{

src/pixi/extras/PIXISpine.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ PIXI.Spine.prototype.createMesh = function (slot, attachment) {
297297

298298
var strip = new PIXI.Strip(texture);
299299
strip.drawMode = PIXI.Strip.DrawModes.TRIANGLES;
300-
strip.padding = 5;
300+
strip.canvasPadding = 1.5;
301301

302302
strip.vertices = new PIXI.Float32Array(attachment.uvs.length);
303303
strip.uvs = attachment.uvs;

src/pixi/extras/Spine.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2423,7 +2423,7 @@ spine.AtlasAttachmentLoader = function (atlas) {
24232423
};
24242424
spine.AtlasAttachmentLoader.prototype = {
24252425
newRegionAttachment: function (skin, name, path) {
2426-
var region = this.atlas.findRegion(name);
2426+
var region = this.atlas.findRegion(path);
24272427
if (!region) throw "Region not found in atlas: " + path + " (region attachment: " + name + ")";
24282428
var attachment = new spine.RegionAttachment(name);
24292429
attachment.rendererObject = region;
@@ -2437,7 +2437,7 @@ spine.AtlasAttachmentLoader.prototype = {
24372437
return attachment;
24382438
},
24392439
newMeshAttachment: function (skin, name, path) {
2440-
var region = this.atlas.findRegion(name);
2440+
var region = this.atlas.findRegion(path);
24412441
if (!region) throw "Region not found in atlas: " + path + " (mesh attachment: " + name + ")";
24422442
var attachment = new spine.MeshAttachment(name);
24432443
attachment.rendererObject = region;
@@ -2455,7 +2455,7 @@ spine.AtlasAttachmentLoader.prototype = {
24552455
return attachment;
24562456
},
24572457
newSkinnedMeshAttachment: function (skin, name, path) {
2458-
var region = this.atlas.findRegion(name);
2458+
var region = this.atlas.findRegion(path);
24592459
if (!region) throw "Region not found in atlas: " + path + " (skinned mesh attachment: " + name + ")";
24602460
var attachment = new spine.SkinnedMeshAttachment(name);
24612461
attachment.rendererObject = region;

src/pixi/extras/Strip.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,12 @@ PIXI.Strip = function(texture)
5858
this.blendMode = PIXI.blendModes.NORMAL;
5959

6060
/**
61-
* if you need a padding, not yet implemented
61+
* Triangles in canvas mode are automatically antialiased, use this value to force triangles to overlap a bit with each other.
6262
*
63-
* @property padding
63+
* @property canvasPadding
6464
* @type Number
6565
*/
66-
this.padding = 0;
67-
// NYI, TODO padding ?
66+
this.canvasPadding = 0;
6867

6968
this.drawMode = PIXI.Strip.DrawModes.TRIANGLE_STRIP;
7069

@@ -278,33 +277,34 @@ PIXI.Strip.prototype._renderCanvasDrawTriangle = function(context, vertices, uvs
278277
var u0 = uvs[index0] * textureWidth, u1 = uvs[index1] * textureWidth, u2 = uvs[index2] * textureWidth;
279278
var v0 = uvs[index0 + 1] * textureHeight, v1 = uvs[index1 + 1] * textureHeight, v2 = uvs[index2 + 1] * textureHeight;
280279

281-
if (this.padding > 0) {
282-
var padding = this.padding;
280+
if (this.canvasPadding > 0) {
281+
var paddingX = this.canvasPadding / this.worldTransform.a;
282+
var paddingY = this.canvasPadding / this.worldTransform.d;
283283
var centerX = (x0 + x1 + x2) / 3;
284284
var centerY = (y0 + y1 + y2) / 3;
285285

286286
var normX = x0 - centerX;
287287
var normY = y0 - centerY;
288288

289289
var dist = Math.sqrt(normX * normX + normY * normY);
290-
x0 = centerX + (normX / dist) * (dist + padding);
291-
y0 = centerY + (normY / dist) * (dist + padding);
290+
x0 = centerX + (normX / dist) * (dist + paddingX);
291+
y0 = centerY + (normY / dist) * (dist + paddingY);
292292

293293
//
294294

295295
normX = x1 - centerX;
296296
normY = y1 - centerY;
297297

298298
dist = Math.sqrt(normX * normX + normY * normY);
299-
x1 = centerX + (normX / dist) * (dist + padding);
300-
y1 = centerY + (normY / dist) * (dist + padding);
299+
x1 = centerX + (normX / dist) * (dist + paddingX);
300+
y1 = centerY + (normY / dist) * (dist + paddingY);
301301

302302
normX = x2 - centerX;
303303
normY = y2 - centerY;
304304

305305
dist = Math.sqrt(normX * normX + normY * normY);
306-
x2 = centerX + (normX / dist) * (dist + padding);
307-
y2 = centerY + (normY / dist) * (dist + padding);
306+
x2 = centerX + (normX / dist) * (dist + paddingX);
307+
y2 = centerY + (normY / dist) * (dist + paddingY);
308308
}
309309

310310
context.save();

src/pixi/extras/TilingSprite.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ PIXI.TilingSprite.prototype._renderCanvas = function(renderSession)
218218
var resolution = renderSession.resolution;
219219

220220
context.setTransform(transform.a * resolution,
221-
transform.c * resolution,
222221
transform.b * resolution,
222+
transform.c * resolution,
223223
transform.d * resolution,
224224
transform.tx * resolution,
225225
transform.ty * resolution);

src/pixi/renderers/webgl/shaders/PixiShader.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ PIXI.PixiShader.prototype.destroy = function()
371371
PIXI.PixiShader.defaultVertexSrc = [
372372
'attribute vec2 aVertexPosition;',
373373
'attribute vec2 aTextureCoord;',
374-
'attribute vec2 aColor;',
374+
'attribute vec4 aColor;',
375375

376376
'uniform vec2 projectionVector;',
377377
'uniform vec2 offsetVector;',
@@ -384,7 +384,6 @@ PIXI.PixiShader.defaultVertexSrc = [
384384
'void main(void) {',
385385
' gl_Position = vec4( ((aVertexPosition + offsetVector) / projectionVector) + center , 0.0, 1.0);',
386386
' vTextureCoord = aTextureCoord;',
387-
' vec3 color = mod(vec3(aColor.y/65536.0, aColor.y/256.0, aColor.y), 256.0) / 256.0;',
388-
' vColor = vec4(color * aColor.x, aColor.x);',
387+
' vColor = aColor;',
389388
'}'
390-
];
389+
];

0 commit comments

Comments
 (0)