Skip to content
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

EmitterConfigV3 spawnShape has no effect on setting the radius #217

Open
Auler opened this issue Jul 31, 2024 · 15 comments
Open

EmitterConfigV3 spawnShape has no effect on setting the radius #217

Auler opened this issue Jul 31, 2024 · 15 comments

Comments

@Auler
Copy link

Auler commented Jul 31, 2024

In the behaviors of EmitteConfigV3, type: "spawnShape" and type: "torus" have no effect when setting radius or innerRadius.
Even if the radius is set to 0, it can still be displayed normally.

{
          type: 'spawnShape',
          config: {
              type: 'torus',
              data: {
                  x: 0,
                  y: 0,
                  radius: 0,
                  innerRadius: 0,
                  affectRotation: true
              }
          }
      },
@andrewstart
Copy link
Collaborator

It seems to be working fine in https://pixijs.io/particle-emitter/examples/explosionRing.html, and emitting as a single point with a radius of 0 is normal behavior. Do you have a example you can show where it isn't working?

@Auler
Copy link
Author

Auler commented Aug 1, 2024

The example in the following code shows that the page still maintains its original size.
explosion3
Reference https://pixijs.io/particle-emitter/examples/explosion3.html
emitter = new PIXI.particles.Emitter( particleContainer, { "lifetime": { "min": 0.5, "max": 1 }, "ease": [ { "s": 0, "cp": 0.329, "e": 0.548 }, { "s": 0.548, "cp": 0.767, "e": 0.876 }, { "s": 0.876, "cp": 0.985, "e": 1 } ], "frequency": 0.001, "emitterLifetime": 0.1, "maxParticles": 100, "addAtBack": true, "pos": { "x": 0, "y": 0 }, "behaviors": [ { "type": "alpha", "config": { "alpha": { "list": [ { "time": 0, "value": 0.74 }, { "time": 1, "value": 0 } ] } } }, { "type": "moveSpeed", "config": { "speed": { "list": [ { "time": 0, "value": 700 }, { "time": 1, "value": 0 } ] } } }, { "type": "scale", "config": { "scale": { "list": [ { "time": 0, "value": 5 }, { "time": 1, "value": 1.2 } ] }, "minMult": 1 } }, { "type": "color", "config": { "color": { "list": [ { "time": 0, "value": "ffdfa0" }, { "time": 1, "value": "100f0c" } ] } } }, { "type": "rotation", "config": { "accel": 0, "minSpeed": 0, "maxSpeed": 200, "minStart": 0, "maxStart": 360 } }, { type: 'spawnShape', config: { type: 'torus', data: { x: 0, y: 0, radius: 0, innerRadius: 0, affectRotation: true } } }, { "type": "textureSingle", "config": { "texture": texture } }, ] } );

@andrewstart
Copy link
Collaborator

When you say "maintains its original size", are you removing the old emitter and hooking up the new one to the update loop?

@Auler
Copy link
Author

Auler commented Aug 2, 2024

I'm not quite sure what you mean by removing the old launcher and creating a new one.
I initially set the radius and then emitted particles. The initial and final effects of the particles far exceeded the radius setting.
Even if the radius is initially set to 0, it does not affect the radius at creation and final dissipation.

@Auler
Copy link
Author

Auler commented Aug 2, 2024

Create a particle, set the radius, and then emit it once. But from the beginning to the end, the radius did not take effect.

@andrewstart
Copy link
Collaborator

In the current example that uses the torus shape, when I open up the console and modify the emitter with

emitter.getBehavior("spawnShape").shape.radius = 0;
emitter.getBehavior("spawnShape").shape.innerRadius = 0;

the initial position of the particles as they are emitted is correct - they are emitted from a single point. Note that all spawning behaviors only affect the initial position - the particles are not restricted to the torus shape after they are created.

Since what I have works correctly, I need to see more of your setup in order to diagnose what is going wrong. If you can create a minimum repository that shows the issue, that would be helpful.

@Auler
Copy link
Author

Auler commented Aug 4, 2024

[(http://pixi.auler.xin/index.html)]
You can input the following code into the console.
emitter.getBehavior("spawnShape").shape.radius = 0;
emitter.getBehavior("spawnShape").shape.innerRadius = 0;
This is the example I tested. If you have time, you can help take a look. thank you.

@andrewstart
Copy link
Collaborator

Ah, I see. The issue isn't the torus spawning, but that the high particle speed and random starting rotation tend to override the initial direction and placement (magnified by the large particle size). The torus places particles randomly in its configured ring, and unless told not to it rotates them to be pointing away from the center of the torus. After that, the rotation behavior is giving each particle a completely random starting rotation, and finally the speed movement moves in the direction of that starting rotation. As a result, the particles are spawning in a torus but then going all over the place very quickly, and expanding so much that they cover up what is going on.

@Auler
Copy link
Author

Auler commented Aug 5, 2024

So may I ask how to handle size through configuration or other means.
I use the sprite.scale property for scaling here. I don't know if there is a better way.

@andrewstart
Copy link
Collaborator

The scaling isn't really the issue - if you want to have particles spawn in a recognizable ring, then don't use the rotation behavior, because the torus spawning will take care of sending particles away from the center. The Explosion 3 example uses the fully random rotation because it emits from a single point with no rotation, instead of using the torus/circle spawning.

@Auler
Copy link
Author

Auler commented Aug 5, 2024

`

// {
// "type": "rotation",
// "config": {
// "accel": 0,
// "minSpeed": 0,
// "maxSpeed": 200,
// "minStart": 0,
// "maxStart": 360
// }
// },
`
Do you mean removing the behavior rotation from the configuration?
But I deleted this configuration and it still hasn't affected.
Can you provide a possible example?

@andrewstart
Copy link
Collaborator

You'll also need to change the radius/innerRadius of your shape to not be 0 anymore.

@Auler
Copy link
Author

Auler commented Aug 9, 2024

Okay, I have a rough idea of what the situation is. This should be a parameter for spawning particles, but the radius of outward emit after spawning is not affected. But if the emit speed is changed, the effect will be very poor.

`

{
"type": "moveSpeed",
"config": {
"speed": {
"list": [
{
"time": 0,
"value": 700
},
{
"time": 1,
"value": 0
}
]
}
}
},
`

@andrewstart
Copy link
Collaborator

What type of effect are you trying to create, exactly?

@Auler
Copy link
Author

Auler commented Aug 31, 2024

Probably using effects of size sprite.scale. set (0.25, 0.25). If there is no other better way, this implementation can also be used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants