New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the DisplayObject#cacheAsBitmap issue #5784 #5841
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #5841 +/- ##
==========================================
- Coverage 70.55% 70.54% -0.02%
==========================================
Files 205 205
Lines 10400 10402 +2
==========================================
Hits 7338 7338
- Misses 3062 3064 +2
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the demo to help verify. You’re on a roll @mofnire!
OK, i know how to fix that, good catch! The idea is to store That's how we generally bind renderTexture: Third param, destinationFrame, is never actually used in tree-related operations, I'll mark that parameter as I'll do separate PR and use your example to test it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, you are completely right, we need exactly those lines to solve that issue. I dug up another one, but sourceFrame
doesn't save it, so i'll form my PR separate from yours after we merge your fix.
Cursed playground: https://www.pixiplayground.com/#/edit/62HZx5glfSl7R1TJe_5aH
Thank you very much for this, well done! :D |
Description of change
This PR is to fix #5784. There are two problems in
DisplayObject#_initCachedDisplayObject
.renderer._activeRenderTarget
does not hold a current rendering target.https://github.com/pixijs/pixi.js/blob/4d71fa06ea787d81651fc3e624610ccfc3c3f457/packages/mixin-cache-as-bitmap/src/index.js#L185-L189
I replaced it with
const cachedRenderTarget = renderer.renderTexture.current;
.renderer.projection.transform
is not restored after the line 213.I changed the method so that the projection transform is restored.
https://github.com/pixijs/pixi.js/blob/4d71fa06ea787d81651fc3e624610ccfc3c3f457/packages/mixin-cache-as-bitmap/src/index.js#L210-L216
Working example is https://www.pixiplayground.com/#/edit/hk1gjmUM84Nl72GncOii~.
*Please note I could not find the way of writing tests of features like this :( *
Pre-Merge Checklist
npm run lint
)npm run test
)