pixi-viewport
pixi-viewport copied to clipboard
Mask doesn’t move with interactive viewport
I’ve searching for several hours with documented issue or similar, but with no success... There is any limitation with masks in the viewport? I’ve created a working mask container with a circle but when I try to interact with the viewport dragging, only plain forms move it, but mask is fixed. The project is created with React and the mask is children of viewport with the other forms.
I don't know of any limitation on viewport working with masks. Is your mask attached at the right hierarchical level? If it's inside the viewport, it should move with it. The viewport is just an extension of a pixi.container and has the same transforms as containers.
I am new to PIXI and had the same issue - turns out it's just like @davidfig is saying, the mask itself actually needs to be added to some container, it's not enough to just assign it as a mask to something.
In other words, this is not enough:
objectToBeMasked.mask = mask
You also need this:
viewport.addChild(mask)
This does not actually render the mask, as I assumed it would. I guess PIXI is smart enough to figure out that it is a mask and is not supposed to be rendered.
Thanks @Erfa!