jagenjo / litegraph.js

A graph node engine and editor written in Javascript similar to PD or UDK Blueprints, comes with its own editor in HTML5 Canvas2D. The engine can run client side or server side using Node. It allows to export graphs as JSONs to be included in applications independently.
MIT License
5.33k stars 602 forks source link

Maybe it is an issue #424

Closed byte911 closed 6 months ago

byte911 commented 6 months ago

image

I think it's an issue, then I will view code to verify it.

jagenjo commented 6 months ago

is the graph running? if it is not running the data is not being feed to the branch node.

atlasan commented 6 months ago

@jagenjo @byte911 Tested. It works when play is on, as said.

image

Anuyway a more complex example could eventually not work, as we still need to implement the logic to update values along the graph when an event occurs..

The actual behavior does not read the value updated in the same "frame".

2023-10-31 09_46_29-LiteGraph — Mozilla Firefox

So just be careful when using events while checking values depending on that or other events: they are usually updated at the previous last frame instead of the current one (extra "frame" caused by the event).

jagenjo commented 6 months ago

yes, thats a huge problem currently. Not sure how to handle it. The only solution I can think of is to execute the whole graph once an event is triggered, but that would be slow. The optiomal solution implies some analysis of the graph to see which nodes are affected by the event and execute only those.

atlasan commented 6 months ago

Yes, the second approach was the one I chose when I tried to implement that. The solution seemed working to me with some exhaustive tests. Unlucky the changes are many and are mixed with others in that Draft PR I had. Maybe in a spare night and a couple of beers (or tea?) together we could merge the interesting part of it.

2023-10-31 09_46_16-LiteGraph — Mozilla Firefox
byte911 commented 6 months ago

@atlasan @jagenjo thanks, I got it.