Coder Social home page Coder Social logo

Comments (4)

bigtimebuddy avatar bigtimebuddy commented on April 27, 2024

Here's the code reference for v8 filters assignment:

set filters(value: Filter | Filter[] | null | undefined)

Because assigning filters to [] means that internally hasFilters is false in that function. So this is called:

this.removeEffect(this._filters.effect);
returnFilterEffect(this._filters.effect);
this._filters.effect = null;

Then when you obj.filters.push(filter) later, the effect is never getting set.

@GoodBoyDigital thoughts? Should the filters array be a Proxy object instead?

from pixijs.

GoodBoyDigital avatar GoodBoyDigital commented on April 27, 2024

this is a bit of a tricky one as generally! We want to not have to cause filters to break batching, so we check at the time of assignment if there are actually any filters. this is done to not have to check the whole scene graph for filter changes each frame.

this means currently the following:

container.filters = [] // no filters - s oskipped
container.filters.push(filter) // this is not watched, so still thinks there are no filters

this best way is to always assign the filters directly:

container.filters = [] // no filters
container.filters = [filter] // will add a filter

i know its a bit weird but, perf wise i know devs use this container.filters = [] syntax to null out filters.

from pixijs.

GoodBoyDigital avatar GoodBoyDigital commented on April 27, 2024

to add to that :)

container.filters = [filter] // will add a filter
container.filters.pop() // will not render filters, but still break the batches

from pixijs.

bigtimebuddy avatar bigtimebuddy commented on April 27, 2024

Two ideas how we could enforce this:

  • Have filters getter type as readonly Filters[] type
  • Do Object.freeze on the setter input to keep users from manipulating the array at runtime

from pixijs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.