At the root of my scene is a PIXI.Container object. When I change its scale, all items inside it scale with the exception of masks. All masks retain their original size, causing more clipping than intended.
Is this intended, or is this a bug in the way masks are displayed? Do I need to walk my whole scene graph searching for masks and manually scale them in proportion each time the Container changes scale?
Is this intended, or is this a bug in the way masks are displayed
A bug, mask transforms are not updated which will cause this issue.
Hello! This is intended behaviour :)
Its a cool feature that means a mask does not need to be tied to the thing it is masking. To solve your issue you would simply need to add the mask to the object you are masking.
Forcing the mask to respect the transform of the object it is masking is quite restrictive. The current model is based on how flash does it - it is much more robust :)
Hello all of you enthusiasts and pros :),
I would also like to take part in the discussion.
I had the same question.
Can we add a new property that determines single mask's behavior?
And of course the default should be the flash-like one.
I'm confused how is the mask not acting with the parent transform more robust? It seems like it violates the principle of least suprise. I would expect a mask to act just like the parent unless I tell it not to.
_Edit_: Makes a lot more sense after I read this comment: https://github.com/pixijs/pixi.js/commit/c8244ed05ccf789608dba3ce92a8d93c5e5dc43a#commitcomment-12490060. Masks aren't restricted to a single object, they can be anywhere. I'll revert this.
I got a little bit confused too, so probably an example will be the best to illustrate what I mean.
I can open a new issue if you say.
Like @GoodBoyDigital mentioned, if you want it to scale and such with the object it is applied to, just also add it as as child:
sprite.mask = maskObject;
sprite.addChild(maskObject);
Does that not accomplish what you want?
I'll confirm when I get a moment. It's not very intuitive though, so adding this to the docs somewhere would be helpful.
Nice! Guys it would be nice if you put this non-intuitive idea to docs :).
PR welcome to add a note about this
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Like @GoodBoyDigital mentioned, if you want it to scale and such with the object it is applied to, just also add it as as child:
Does that not accomplish what you want?