tguerin / newton

An Easy To Use Particle Emitter
https://newton.7omtech.fr
MIT License
22 stars 7 forks source link

Support runtime active effects #16

Closed tguerin closed 8 months ago

tguerin commented 9 months ago

This pr aims to improve 3 things:

netlify[bot] commented 9 months ago

Deploy Preview for imaginative-palmier-d7ee2c canceled.

Name Link
Latest commit f1c92d17040d35f26d65cf05702a0f21c2a3379d
Latest deploy log https://app.netlify.com/sites/imaginative-palmier-d7ee2c/deploys/6548066ca34211000886f65f
tguerin commented 9 months ago

@Joshix-1 wdyt? Does it fix your issue? Need to clean the code btw.

Joshix-1 commented 9 months ago

I feel like the solution of only allowing either dynamically added via NewtonState or fixed added via Newton arg is a better solution. Or maybe have two different widgets for each use case. This feels like it's getting too complex

tguerin commented 9 months ago

As i said, i'm totally fine removing the runtime version and stick to the effects passed as parameters. Will remove the runtime support. Thanks for your time!

Joshix-1 commented 9 months ago

that's not what I meant.

My use case is to have an effect on button press. That's not really possible with the effects passed as parameters. But I don't need both in the same widgets. That are two different use-cases that could be split into two widgets or one widget that only supports one of them at the time.

What I do:

I have a globalKey that I set as the key of the Newton widget.

GlobalKey<NewtonState> _newtonKey = GlobalKey();

And on button press / other event I run _newtonState.addEffect(...) that works if the state isn't cleared. The effect gets added only temporary and then gets removed.

tguerin commented 9 months ago

ah got it!

tguerin commented 8 months ago

I reworked the PR and updated the description. I don't think we need 2 different widgets. A Newton widget can accept effects added at runtime howevert they must be removed at runtime (or automatically removed if there is a finite particle count). Still draft cause I need to test it properly.

Joshix-1 commented 8 months ago

Code looks good