pixijs/layers

Adding viewport to layers

TytiX opened this issue · 4 comments

TytiX commented

Hi,

I tried to put pixi-layers in a viewport (with pixi-viewport).

I have achivied a render but interactions are not working...

  • when panning -> light move (it's supposed to be attach to the red dot...)
  • ambiant light is only defined on the initial viewport (zoom out and there is a gray square)

see source sample : https://stackblitz.com/edit/rxjs-xupagq

oddly when commenting the line 74 (lighting not working) -> interactions are working again

Hello!

Thanks for sharing the demo. yes, there was a report that lighting + viewport = broken interaction.

I can look at it next week.

Are you sure that your layers themselves aren't controlled by viewport, only world is?

TytiX commented

nailed it!

the lighting layer was attached to viewport and not app stage...
app.stage.addChild(lightingSprite);
thx

app.stage.addChild(lightingSprite);

yeah, because that texture is already taken from the screen coords, and you dont need to scroll/scale it :) I think someone had that problem already ...

I ran into this also haha. Don't be like me and try to open up pixi-viewport and make the Viewport class inherit from Stage instead of Container and just adding your lighting directly to that thinking you will solve this problem (you wont). It will actually render everything properly but it will not pan the lighting layer properly when you move the viewport and you arent any closer to solving it.

Solve it the way OP solved it in their working example https://stackblitz.com/edit/rxjs-xupagq