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.

Nested masked objects break when going outside viewport (in certain conditions)

See original GitHub issue

The included playground demo explains it best, but to sum it up, when the following conditions are true, the mask on container C will be disabled when it moves out of the viewport:

  • scissor masking is enabled
  • masked container © is a child of a masked object (P)
  • the parent container (P) contains at least one other object

This feels somewhat similar to #5974 (which was fixed a long time ago) but is obviously not exactly the same case.

Expected Behavior

Mask will never disable

Current Behavior

Mask disables when object leaves viewport

Possible Solution

Disable scissor masking

Steps to Reproduce

https://www.pixiplayground.com/#/edit/2qJVNoyRHDVPMtaTJ4hCY

Environment

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:33 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
ivanpopelyshevcommented, Oct 19, 2021

yes, that’s the difference. double-destroy works in v4.5 but not in v4.8

Suppose you called sprite.destroy() (important: NO PARAMS) , two times. v4.5 works fine, v4.8 breaks because of this line: https://github.com/pixijs/pixijs/blob/fc2248c5df12cf2273ddafdccbe6eb19c33b73eb/src/core/sprites/Sprite.js#L441

v6 should break same way. I advice you to override destroy, because that’s completely different topic of discussion and will take long time to negotiate with others (whether this behaviour is ok)

let containerDestroy = PIXI.Container.prototype.destroy;
PIXI.Sprite.prototype.destroy = function(options) {
        containerDestroy.call(this, options);

        this.shader = null;
        this._anchor = null;
        
        if (!this._texture) {
            return;
        }

        this._texture.off('update', this._onTextureUpdate, this);

        const destroyTexture = typeof options === 'boolean' ? options : options && options.texture;

        if (destroyTexture)
        {
            const destroyBaseTexture = typeof options === 'boolean' ? options : options && options.baseTexture;

            this._texture.destroy(!!destroyBaseTexture);
        }
        this._texture = null;
    }
1reaction
ivanpopelyshevcommented, Oct 19, 2021

so its something like double-destroy, that worked in 4.5.3 but not working in 4.8.9, let me try

Read more comments on GitHub >

github_iconTop Results From Across the Web

Masking works in viewport and preview, not in export.
I got this background line that is masked so it doesn't intersect with the foreground object ('Reveal all' on the group, then 'Subtract'...
Read more >
Nested Viewports - Autodesk Community - AutoCAD
Does anyone know how to mask objects in nested viewports? The back viewport objects show through the front viewport. Thanks!
Read more >
The stacking context - CSS: Cascading Style Sheets | MDN
The stacking context is a three-dimensional conceptualization of HTML elements along an imaginary z-axis relative to the user, who is assumed ...
Read more >
Nested div masked off by circular container div - css
In my experience, you can't get it to do this with straight css. Things "spill out" of the border-radius. ... Do you have...
Read more >
Trim objects in the Timeline in Motion - Apple Support
In Motion, trim an object's timebar when you want to shorten or lengthen its duration. ... Timeline showing an object being trimmed, revealing...
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