pixijs / particle-emitter

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

Bug: PropertyNode.createList leads to errors if there are two points with same value #209

Open CosmoMyzrailGorynych opened 9 months ago

CosmoMyzrailGorynych commented 9 months ago

In this file and this line, https://github.com/pixijs/particle-emitter/blob/master/src/PropertyNode.ts#L104 The PropertyNode bails out forming a complete list if it finds that the only two values in a list have same values. Still, all the behaviors try to interpolate over such lists, leading to errors, and crashing the whole pixi.js app:

изображение изображение

Why am I having timeline points when I have same values instead of having static behaviors? Because I am making a general-use app where users are free to write everything they desire, and handling that behaviors array in emitters' config objects is enough of an attraction for me in definitely typed projects to handle already.

andrewstart commented 9 months ago

I can defend against this by flagging such lists as stepped, but the expectation here was that any editor would check the user's data and use the simpler static behavior for the improved performance since the interpolation of a list is not needed.

CosmoMyzrailGorynych commented 9 months ago

The expectation here was that any editor would check the user's data and use the simpler static behavior for the improved performance since the interpolation of a list is not needed.

This complicates using the particle-emitter library a lot 🤷 In my editor I need interactivity and live preview, including when users make changes — can't do that with switching behavior types. Even so, the editor and its assets need to be definitely typed, which is doable in the end, but it is way too much of a hassle with alternating types and tuples, and you still have to wire up that all in UI. TL;DR upgrading to particle-emitter v5 was a nightmare and I don't want to look into rewriting it again.

Aside from my struggles, I believe a library should not alter the input, at least not without a library user's consent — and there were no warnings in docs or console about using a flat line in property lists. This unauthorized automagic led to long hours of finding out why my emitter tandem editor randomly breaks for my users. And if a library does alter input, failing with errors after this expected behavior is definitely a bug.

A side note, I looked through the sources and did not understand why the simplification of two-point lists was needed. If you have time, could you explain that?