pixijs / pixi-projection

MIT License
191 stars 34 forks source link

SpriteMaskFilter2d method has an error #61

Closed HongSiyuan closed 4 years ago

HongSiyuan commented 4 years ago

Hi, I'm using pixi-projection @0.36 in PIXI @5.2.0 recently. However, I found an error in the browser's console. image

I saw the source code in the line 2014:

        SpriteMaskFilter2d.prototype.apply = function (filterManager, input, output, clear) {
            var maskSprite = this.maskSprite;
            var tex = this.maskSprite.texture; // !! here the maskSprite.texture is undefined 
            if (!tex.valid) {
                return;
            }
            if (!tex.uvMatrix) {
                tex.uvMatrix = new PIXI.TextureMatrix(tex, 0.0);
            }
            tex.uvMatrix.update();
            this.uniforms.mask = maskSprite.texture;
            this.uniforms.otherMatrix = SpriteMaskFilter2d.calculateSpriteMatrix(input, this.maskMatrix, maskSprite)
                .prepend(tex.uvMatrix.mapCoord);
            this.uniforms.alpha = maskSprite.worldAlpha;
            this.uniforms.maskClamp = tex.uvMatrix.uClampFrame;
            filterManager.applyFilter(this, input, output, clear);
        };

I tried to change the code to

            var maskSprite = this.maskSprite.maskObject;
            var tex = maskSprite.texture;

It seems to work out, so I am confused whether it's a bug.

ivanpopelyshev commented 4 years ago

Good one! Yes, its extension of changes in 5.2.0 - MaskData object, i forgot to change that in pixi-projection. I will release new pixi-projection soon :)

HongSiyuan commented 4 years ago

Thanks a lot! :D

HongSiyuan commented 4 years ago

@ivanpopelyshev Hi,PIXI.Container doesn't support PIXI.Sprite as mask after changing the code to the above. could you help release new pixi-projection please. Thanks! :D

ivanpopelyshev commented 4 years ago

@HongSiyuan I published new version, can you please check it ? 0.3.7 npm or in dist folder of this repo. I'm sorry I couldn't just fix it after your cry for help because, well, I support like 10 pixi plugins and I have huge tasks in main pixi repo.

HongSiyuan commented 4 years ago

@HongSiyuan I published new version, can you please check it ? 0.3.7 npm or in dist folder of this repo. I'm sorry I couldn't just fix it after your cry for help because, well, I support like 10 pixi plugins and I have huge tasks in main pixi repo.

It still dose not support PIXI.Sprite as mask after importing pixi-projection@0.3.7. If i change mask's attribute isSprite to false, it works somehow, which, however, will causes another bugs.

ivanpopelyshev commented 4 years ago

:( ok, i did that without testing. need to actually test that thing