If/else vs state machines in THREE.js

Just curious…
In much of the examples I’ve seen for THREE.js, I’ve rarely seen state machines implemented.
Any reason for this?
Should I avoid using them vs if/else scenarios?
May be simply up to taste, or performance issues.
What do YOU use mostly?

Three doesn’t really limit you in any way in terms of implementation / code style / frameworks. As long as you create / update / dispose everything properly - you’re free to create state machines with Three (technically speaking, any project build with Three + React or react-three-fiber is a state-machine.)

(The examples look one way or another probably because they were built over time by different people - their focus is also mainly on readability, instead of impressive / complex coding.)

1 Like

There are a lot of differing opinions about how to do state management in programming. Game developers often use ECS patterns. Web developers, at least recently, seem to like abstractions like Redux. Or, less commonly, Coroutines. I think it mostly comes down to preference, and whatever helps you to write and debug your code easily.


Thanks for the replies.
Yeah, I’ve been researching and following Vue/Vuex instead of React/Redux as a solution to implementing a more manageable framework for such things.
Haven’t had time to delve into it deeply yet.
Found some Vue-THREE bridging libraries.