question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getLocalBounds() causes transform to update, can cause problems in render pass

See original GitHub issue

I have found that calling DisplayObject#getLocalBounds can mess things up if called while the renderer is rendering. This is because this method will cause a transform update after removing the parent.

In many parts of @pixi/core, we use DisplayObject#getBounds(false), which will not update the transform to include the parent’s transform. This is an inherent weakness in PixiJS and should be properly documented.

To solve the problem, you must call update-transform after getting the local bounds.

target.getLocalBounds();
target.updateTransform();

However, code like Container#width (getter) already uses the getLocalBounds() method. This means that trying to access a display-object’s width will result in failure of the renderer.

Maybe we should solve this? @ivanpopelyshev thoughts?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:18 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
ShukantPalcommented, Jan 28, 2020

@bigtimebuddy Sorry for the delay, here is a demo: https://jsfiddle.net/ShukantPal/bjc0te8x/7/.

At line 26, the getLocalBounds() method causes the Sprite to render at 128x128 instead of the scaled up 256x256 (due to 2x scale of stage).

0reactions
stale[bot]commented, Apr 27, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

getLocalBounds() causes transform to update, can ... - GitHub
In my apps I have separate prerender() pass where all filters and caches are measured, and elements re-positioned.
Read more >
PIXI.Container - PixiJS API Documentation
Updates the transform on all children of this container for rendering. _calculateBounds () void protected. Container.ts:535.
Read more >
Mesh3D | Pixi3D - v2.1.0
The material for the mesh. If the material is empty the mesh won't be rendered. ... Local bounds object, swapped with _bounds when...
Read more >
Component Class Reference - JUCE
A focus container type that can be passed to setFocusContainerType(). ... Returns the transform that is currently being applied to this component.
Read more >
pixi.js (v4.4.1) — Pixi.js is a fast lightweight 2D library that works ...
Constructor to create a storage for our EE objects. An Events instance is a plain object whose properties are event names. Returns. Void ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found