pixi-viewport icon indicating copy to clipboard operation
pixi-viewport copied to clipboard

Mask doesn’t move with interactive viewport

Open ismaserrano opened this issue 4 years ago • 3 comments

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.

ismaserrano avatar Dec 01 '20 21:12 ismaserrano

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.

davidfig avatar Dec 01 '20 22:12 davidfig

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.

Erfa avatar Jan 28 '21 23:01 Erfa

Thanks @Erfa!

TimAstier avatar Dec 25 '22 19:12 TimAstier