-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Bug: Can't get updated worldTransform immediately #10433
Comments
I have the same issue. Up to Pixijs version 6 method |
hey both, sorry for the late response - curious what the use case is here? |
Thank you for your reply! I teach computer science, mathematics and physics in a german high school. To help my students learning object oriented programming i developed a browser based java compiler, runtime engine and ide. I used pixi.js as graphic library. You can see it in action here Unfortulately i haven't made an english translation yet. Click on "Login als Testuser", then choose "Mover Game" on the left side and start it (green triangle button on top of the screen) to see pixi.js in action. In my runtime library there are classes for rectangles, circles, sprites, polygons, ..., and groups. Groups can contain other graphical objects (especially other groups) to form a tree-like structure. It is possible to add graphical objects to a group and to detach them from their group without changing their visual appearance, which means: without changing their worldtransform. To achieve this i had to really fight with pixi.js which unfortunately doesn't preserve the worldTransform when detaching children from transformed containers. It was especially hard as setting localTransform of a container doesn't immediately update worldTransform. Another problem was collision detection. To get more acurracy than hitboxes i store a surrounding polygon ("hitPolygon") alongside each PIXI.container. To keep this in sync with container transformations whilst also retaining good performance i store only the 'initial' hitPolygons which correspond to worldTransform == identitiy. Whenever i need a hitPolygon i apply the container's worldTransform to it. This poses the problem that often worldTransforms are not up to date as pixi.js only updates them when it renders it's scene subsequently. My workaround is to always update worldTransforms 'by hand' whenever i move/rotate/scale containers. This costs performance as it has to be done recursively (if a group is transformed) and it is redundant to pixi.js doing the same computations later when rendering the scene. What i would need is a way to make pixi.js update an container's worldTransform matrix (and recursively the world matrices of it's subtree if it has children) whenever needed and to update it's internal dirty-flags so that this work is not done again when pixi.js renders the scene subsequently. Another drawback of pixi.js is it's redundant system of pivot/scale/skew/rotation. I prefer to work with localTransform and it's methods to move/rotate/scale. If i need more complex operations (e.g. rotate around a given center outside the object or scale with a given center outside the object) matrix multiplications feel more comfortable than computing values for pivot/scale/skew/rotation. Unfortunately i always have to call I'd appreciate it if pixi.js would make it easier to use a matrix-based approach. |
Hi - I believe I'm also running into this issue.
which I'm thinking just isn't going to work because there's no way to force an update to world transform anymore? |
Current Behavior
After modifying a container's transform, by setting its scale, position, etc., I'm unable to calculate the new world transform immediately after the operation.
Expected Behavior
I'd expect to be able to retrieve the new world transform of the object after modifying its transform.
Steps to Reproduce
const container = app.stage.addChild(new PIXI.Container())
container.scale.set(0.5)
// TODO: Force a recalculation of the container's world transform. How?
console.log(container.worldTransform) // This currently prints a matrix that doesn't contain the scale
Environment
pixi.js
version: 8.0.5Possible Solution
No response
Additional Information
I understand there's performance implications, but in certain situations it is important to be able to do this. I found multiple notions about calling updateTransform, but that doesn't work, and doesn't seem to behave the same in PixiJS v8.
The text was updated successfully, but these errors were encountered: