pixijs / particle-emitter

A particle system for PixiJS
http://pixijs.io/particle-emitter/docs
MIT License
786 stars 124 forks source link

AnimatedParticle makes flickers. #150

Closed novogrammer closed 3 years ago

novogrammer commented 3 years ago

Hi, I found this at frame calculation.

        {
          framerate: 12,
          loop: true,
          textures: [
            "./assets/img/dummy/bunny.png",
            "./assets/img/dummy/bunny.png", //same image
          ],
        },

https://github.com/pixijs/pixi-particles/blob/7d385da292404efb18b0a5d13e6f35ccf06293b5/src/AnimatedParticle.ts#L150-L152 console.log(frame); sometimes frame eq 2.

add a follow line to quick fix this issue.

            frame = Math.min(frame, this.textures.length - 1);
andrewstart commented 3 years ago

Would it also fix it to change if (this.elapsed > this.duration) -> if (this.elapsed >= this.duration) instead?

novogrammer commented 3 years ago

Would it also fix it to change if (this.elapsed > this.duration) -> if (this.elapsed >= this.duration) instead?

No, It was not fixed.

In my case, emitter.update(1/60); may cause this. Rational Number???

Please see my log when frame eq 2.

{
    "frame": 2,
    "delta": 0.016666666666666666,
    "elapsed": 0.16666666666666663,
    "duration": 0.16666666666666666
}

Would it also fix it to change if (this.elapsed > this.duration) -> if (this.elapsed >= this.duration) instead?

In case of emitter.update(1/50); It was fixed.

andrewstart commented 3 years ago

Fixed in version 4.3.1.

JPM87 commented 9 months ago

Hi, I am facing the same flickering issue when I am using 2 different textures....

following setup works fine textures: [ "assets/effect-yellow.png", "assets/effect-yellow.png", ]

but when I am using two different textures it all starts to flicker....

textures: [ "assets/effect-yellow.png", "assets/effect-red.png", ]

I am using
"pixi.js": "^7.3.1" "@pixi/particle-emitter": "^5.0.8",

andrewstart commented 9 months ago

Are you using a ParticleContainer as the parent of your particles?

JPM87 commented 9 months ago

Are you using a ParticleContainer as the parent of your particles?

Yes, exactly. First I thought it could be an autoUpate issue. Then I implemented a ticker which updates the stage and the emitter. But both results were the same.

I am extending a stage which is added to the renderer. The stage than has mutliple containers and a particle container as a child. All particles are rendered on the particle container.

andrewstart commented 9 months ago

ParticleContainer requires that all children use one BaseTexture (either one Texture, or all Textures from one atlas). Additionally, the intended usage for ParticleContainer isn't the same as how this particle library functions, so you'd probably see better performance with the LinkedListContainer from this library.