diff --git a/package.json b/package.json index cb892c1..14eff63 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "README.md" ], "dependencies": { + "babel-plugin-add-module-exports": "^0.2.1", "bit-twiddle": "^1.0.2", "earcut": "^2.0.7", "eventemitter3": "^2.0.0", diff --git a/package.json b/package.json index cb892c1..14eff63 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "README.md" ], "dependencies": { + "babel-plugin-add-module-exports": "^0.2.1", "bit-twiddle": "^1.0.2", "earcut": "^2.0.7", "eventemitter3": "^2.0.0", diff --git a/src/core/textures/BaseRenderTexture.js b/src/core/textures/BaseRenderTexture.js index 9951fa1..c18d1dd 100644 --- a/src/core/textures/BaseRenderTexture.js +++ b/src/core/textures/BaseRenderTexture.js @@ -73,9 +73,10 @@ this.clearColor = [0, 0, 0, 0]; this.frameBuffer = new FrameBuffer(width, height) - .addColorTexture(0, this); - - // TODO - could this be added the systems? + .addColorTexture(0, this) + // TODO this shoul dreally only be enabled if its required + // at the point of a mask being rendered. + .enableStencil(); /** * The data structure for the stencil masks diff --git a/package.json b/package.json index cb892c1..14eff63 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "README.md" ], "dependencies": { + "babel-plugin-add-module-exports": "^0.2.1", "bit-twiddle": "^1.0.2", "earcut": "^2.0.7", "eventemitter3": "^2.0.0", diff --git a/src/core/textures/BaseRenderTexture.js b/src/core/textures/BaseRenderTexture.js index 9951fa1..c18d1dd 100644 --- a/src/core/textures/BaseRenderTexture.js +++ b/src/core/textures/BaseRenderTexture.js @@ -73,9 +73,10 @@ this.clearColor = [0, 0, 0, 0]; this.frameBuffer = new FrameBuffer(width, height) - .addColorTexture(0, this); - - // TODO - could this be added the systems? + .addColorTexture(0, this) + // TODO this shoul dreally only be enabled if its required + // at the point of a mask being rendered. + .enableStencil(); /** * The data structure for the stencil masks diff --git a/src/extras/cacheAsBitmap.js b/src/extras/cacheAsBitmap.js index 4a165a3..6a0b9ac 100644 --- a/src/extras/cacheAsBitmap.js +++ b/src/extras/cacheAsBitmap.js @@ -163,7 +163,7 @@ this.alpha = 1; // first we flush anything left in the renderer (otherwise it would get rendered to the cached texture) - renderer.currentRenderer.flush(); + renderer.batch.flush(); // this.filters= []; // next we find the dimensions of the untransformed object @@ -184,7 +184,7 @@ // this could be more elegent.. const cachedRenderTarget = renderer._activeRenderTarget; // We also store the filter stack - I will definitely look to change how this works a little later down the line. - const stack = renderer.filterManager.filterStack; + //const stack = renderer.filterManager.filterStack; // this renderTexture will be used to store the cached DisplayObject @@ -212,9 +212,9 @@ renderer.render(this, renderTexture, true, m, true); // now restore the state be setting the new properties - renderer.bindRenderTarget(cachedRenderTarget); + renderer.renderTexture.bind(cachedRenderTarget); - renderer.filterManager.filterStack = stack; + //renderer.filterManager.filterStack = stack; this.renderWebGL = this._renderCachedWebGL; this.updateTransform = this.displayObjectUpdateTransform; diff --git a/package.json b/package.json index cb892c1..14eff63 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "README.md" ], "dependencies": { + "babel-plugin-add-module-exports": "^0.2.1", "bit-twiddle": "^1.0.2", "earcut": "^2.0.7", "eventemitter3": "^2.0.0", diff --git a/src/core/textures/BaseRenderTexture.js b/src/core/textures/BaseRenderTexture.js index 9951fa1..c18d1dd 100644 --- a/src/core/textures/BaseRenderTexture.js +++ b/src/core/textures/BaseRenderTexture.js @@ -73,9 +73,10 @@ this.clearColor = [0, 0, 0, 0]; this.frameBuffer = new FrameBuffer(width, height) - .addColorTexture(0, this); - - // TODO - could this be added the systems? + .addColorTexture(0, this) + // TODO this shoul dreally only be enabled if its required + // at the point of a mask being rendered. + .enableStencil(); /** * The data structure for the stencil masks diff --git a/src/extras/cacheAsBitmap.js b/src/extras/cacheAsBitmap.js index 4a165a3..6a0b9ac 100644 --- a/src/extras/cacheAsBitmap.js +++ b/src/extras/cacheAsBitmap.js @@ -163,7 +163,7 @@ this.alpha = 1; // first we flush anything left in the renderer (otherwise it would get rendered to the cached texture) - renderer.currentRenderer.flush(); + renderer.batch.flush(); // this.filters= []; // next we find the dimensions of the untransformed object @@ -184,7 +184,7 @@ // this could be more elegent.. const cachedRenderTarget = renderer._activeRenderTarget; // We also store the filter stack - I will definitely look to change how this works a little later down the line. - const stack = renderer.filterManager.filterStack; + //const stack = renderer.filterManager.filterStack; // this renderTexture will be used to store the cached DisplayObject @@ -212,9 +212,9 @@ renderer.render(this, renderTexture, true, m, true); // now restore the state be setting the new properties - renderer.bindRenderTarget(cachedRenderTarget); + renderer.renderTexture.bind(cachedRenderTarget); - renderer.filterManager.filterStack = stack; + //renderer.filterManager.filterStack = stack; this.renderWebGL = this._renderCachedWebGL; this.updateTransform = this.displayObjectUpdateTransform; diff --git a/test/loaders/bitmapFontParser.js b/test/loaders/bitmapFontParser.js index 70703fc..76dc2e3 100644 --- a/test/loaders/bitmapFontParser.js +++ b/test/loaders/bitmapFontParser.js @@ -119,7 +119,7 @@ const charA = font.chars['A'.charCodeAt(0) || 65]; expect(charA).to.exist; - expect(charA.texture.baseTexture.source).to.equal(this.fontImage); + expect(charA.texture.baseTexture.resource.source).to.equal(this.fontImage); expect(charA.texture.frame.x).to.equal(2); expect(charA.texture.frame.y).to.equal(2); expect(charA.texture.frame.width).to.equal(19); @@ -127,7 +127,7 @@ const charB = font.chars['B'.charCodeAt(0) || 66]; expect(charB).to.exist; - expect(charB.texture.baseTexture.source).to.equal(this.fontImage); + expect(charB.texture.baseTexture.resource.source).to.equal(this.fontImage); expect(charB.texture.frame.x).to.equal(2); expect(charB.texture.frame.y).to.equal(24); expect(charB.texture.frame.width).to.equal(15); @@ -135,7 +135,7 @@ const charC = font.chars['C'.charCodeAt(0) || 67]; expect(charC).to.exist; - expect(charC.texture.baseTexture.source).to.equal(this.fontImage); + expect(charC.texture.baseTexture.resource.source).to.equal(this.fontImage); expect(charC.texture.frame.x).to.equal(23); expect(charC.texture.frame.y).to.equal(2); expect(charC.texture.frame.width).to.equal(18); @@ -143,7 +143,7 @@ const charD = font.chars['D'.charCodeAt(0) || 68]; expect(charD).to.exist; - expect(charD.texture.baseTexture.source).to.equal(this.fontImage); + expect(charD.texture.baseTexture.resource.source).to.equal(this.fontImage); expect(charD.texture.frame.x).to.equal(19); expect(charD.texture.frame.y).to.equal(24); expect(charD.texture.frame.width).to.equal(17); @@ -165,7 +165,7 @@ const charA = font.chars['A'.charCodeAt(0) || 65]; expect(charA).to.exist; - expect(charA.texture.baseTexture.source).to.equal(this.fontScaledImage); + expect(charA.texture.baseTexture.resource.source).to.equal(this.fontScaledImage); expect(charA.texture.frame.x).to.equal(4); // 2 / 0.5 expect(charA.texture.frame.y).to.equal(4); // 2 / 0.5 expect(charA.texture.frame.width).to.equal(38); // 19 / 0.5 @@ -173,7 +173,7 @@ const charB = font.chars['B'.charCodeAt(0) || 66]; expect(charB).to.exist; - expect(charB.texture.baseTexture.source).to.equal(this.fontScaledImage); + expect(charB.texture.baseTexture.resource.source).to.equal(this.fontScaledImage); expect(charB.texture.frame.x).to.equal(4); // 2 / 0.5 expect(charB.texture.frame.y).to.equal(48); // 24 / 0.5 expect(charB.texture.frame.width).to.equal(30); // 15 / 0.5 @@ -181,7 +181,7 @@ const charC = font.chars['C'.charCodeAt(0) || 67]; expect(charC).to.exist; - expect(charC.texture.baseTexture.source).to.equal(this.fontScaledImage); + expect(charC.texture.baseTexture.resource.source).to.equal(this.fontScaledImage); expect(charC.texture.frame.x).to.equal(46); // 23 / 0.5 expect(charC.texture.frame.y).to.equal(4); // 2 / 0.5 expect(charC.texture.frame.width).to.equal(36); // 18 / 0.5 @@ -189,7 +189,7 @@ const charD = font.chars['D'.charCodeAt(0) || 68]; expect(charD).to.exist; - expect(charD.texture.baseTexture.source).to.equal(this.fontScaledImage); + expect(charD.texture.baseTexture.resource.source).to.equal(this.fontScaledImage); expect(charD.texture.frame.x).to.equal(38); // 19 / 0.5 expect(charD.texture.frame.y).to.equal(48); // 24 / 0.5 expect(charD.texture.frame.width).to.equal(34); // 17 / 0.5 @@ -218,7 +218,7 @@ const charA = font.chars['A'.charCodeAt(0) || 65]; expect(charA).to.exist; - expect(charA.texture.baseTexture.source).to.equal(this.atlasImage); + expect(charA.texture.baseTexture.resource.source).to.equal(this.atlasImage); expect(charA.texture.frame.x).to.equal(fontX + 2); expect(charA.texture.frame.y).to.equal(fontY + 2); expect(charA.texture.frame.width).to.equal(19); @@ -226,7 +226,7 @@ const charB = font.chars['B'.charCodeAt(0) || 66]; expect(charB).to.exist; - expect(charB.texture.baseTexture.source).to.equal(this.atlasImage); + expect(charB.texture.baseTexture.resource.source).to.equal(this.atlasImage); expect(charB.texture.frame.x).to.equal(fontX + 2); expect(charB.texture.frame.y).to.equal(fontY + 24); expect(charB.texture.frame.width).to.equal(15); @@ -234,7 +234,7 @@ const charC = font.chars['C'.charCodeAt(0) || 67]; expect(charC).to.exist; - expect(charC.texture.baseTexture.source).to.equal(this.atlasImage); + expect(charC.texture.baseTexture.resource.source).to.equal(this.atlasImage); expect(charC.texture.frame.x).to.equal(fontX + 23); expect(charC.texture.frame.y).to.equal(fontY + 2); expect(charC.texture.frame.width).to.equal(18); @@ -242,7 +242,7 @@ const charD = font.chars['D'.charCodeAt(0) || 68]; expect(charD).to.exist; - expect(charD.texture.baseTexture.source).to.equal(this.atlasImage); + expect(charD.texture.baseTexture.resource.source).to.equal(this.atlasImage); expect(charD.texture.frame.x).to.equal(fontX + 19); expect(charD.texture.frame.y).to.equal(fontY + 24); expect(charD.texture.frame.width).to.equal(17); @@ -256,9 +256,12 @@ it('should properly register bitmap font NESTED into SCALED spritesheet', function (done) { - const baseTexture = new PIXI.BaseTexture(this.atlasScaledImage, null, 1); + const baseTexture = new PIXI.BaseTexture(this.atlasScaledImage, null, 0.5); + const spritesheet = new PIXI.Spritesheet(baseTexture, this.atlasScaledJSON); + // console.log(this.atlasScaledImage); + spritesheet.parse(() => { const fontTexture = PIXI.Texture.fromFrame('resources/font.png'); @@ -272,15 +275,19 @@ const charA = font.chars['A'.charCodeAt(0) || 65]; expect(charA).to.exist; - expect(charA.texture.baseTexture.source).to.equal(this.atlasScaledImage); + expect(charA.texture.baseTexture.resource.source).to.equal(this.atlasScaledImage); + + //console.log('>' + charA.texture.frame.x, fontX + 2) + expect(charA.texture.frame.x).to.equal(fontX + 2); expect(charA.texture.frame.y).to.equal(fontY + 2); expect(charA.texture.frame.width).to.equal(19); expect(charA.texture.frame.height).to.equal(20); const charB = font.chars['B'.charCodeAt(0) || 66]; + expect(charB).to.exist; - expect(charB.texture.baseTexture.source).to.equal(this.atlasScaledImage); + expect(charB.texture.baseTexture.resource.source).to.equal(this.atlasScaledImage); expect(charB.texture.frame.x).to.equal(fontX + 2); expect(charB.texture.frame.y).to.equal(fontY + 24); expect(charB.texture.frame.width).to.equal(15); @@ -288,7 +295,7 @@ const charC = font.chars['C'.charCodeAt(0) || 67]; expect(charC).to.exist; - expect(charC.texture.baseTexture.source).to.equal(this.atlasScaledImage); + expect(charC.texture.baseTexture.resource.source).to.equal(this.atlasScaledImage); expect(charC.texture.frame.x).to.equal(fontX + 23); expect(charC.texture.frame.y).to.equal(fontY + 2); expect(charC.texture.frame.width).to.equal(18); @@ -296,7 +303,7 @@ const charD = font.chars['D'.charCodeAt(0) || 68]; expect(charD).to.exist; - expect(charD.texture.baseTexture.source).to.equal(this.atlasScaledImage); + expect(charD.texture.baseTexture.resource.source).to.equal(this.atlasScaledImage); expect(charD.texture.frame.x).to.equal(fontX + 19); expect(charD.texture.frame.y).to.equal(fontY + 24); expect(charD.texture.frame.width).to.equal(17);