jnsmalm / pixi3d

The 3D renderer for PixiJS. Seamless integration with 2D applications.
https://pixi3d.org
MIT License
759 stars 44 forks source link

Remove the PostProcessingSprite handler from the shared ticker #68

Closed amauryt closed 2 years ago

amauryt commented 2 years ago

Thank you for this great library. I am using it in the context of a Single Page Application (SPA), in which I need to create and destroy several PIXI apps within the lifecycle of the SPA. I noticed that the handler added by a PostProcessingSprite instance on this line is an anonymous function, which makes it pretty much impossible to remove from the PIXI shared ticker. This causes an error when destroying PIXI apps with PostProcessingSprite instances and creating other PIXI apps within the SPA.

When I encountered the error the first time I initially expected that by destroying the PostProcessingSprite instance the handler would be removed. Perhaps this could be a good solution without introducing breaking changes? That is, having the anonymous function to be a named function, which on destroying the sprite could now be removed from the shared ticker. Or perhaps there is another solution?

Thanks in advance!

jnsmalm commented 2 years ago

Hi and thank you for feedback, I'll create a fix for this!

jnsmalm commented 2 years ago

Might have found a fix for this. If you want to help out, you can get latest version from develop branch.

npm install
npm run build

You will find pixi3d.js in dist folder. Please let me know if this fixes your issues.

amauryt commented 2 years ago

That was quick! I just tested the develop branch directly on my app and it works: destroying the sprite removes the handler and I no longer see the error. Thank you!

jnsmalm commented 2 years ago

Fixed in v1.1.1