3 ms·
This post is great. Having helped move a large codebase over to React, I love React's emphasis of one-way data flow which I've seen greatly simplify many things
by AgentME 4y ago
This post is great. Having helped move a large codebase over to React, I love React's emphasis of one-way data flow which I've seen greatly simplify many things and help avoid whole classes of bugs. I've been looking into graphics libraries (including three.js) lately, and the retained-mode style APIs in many that end up encouraging two-way data flow feel like a large step back. I've been wanting for graphics libraries that emphasize a React-style one-way data flow. I had been looking into react-three-fiber, but I've suspected that a wrapper like it doesn't take the fullest advantage of one-way data flow. This post addresses what I've been hoping for while being a good introduction to the issue for others.
>Three.js might seem like a great choice for the job: it has a 3D scene, editing controls and so on. But, my scene is not the source of truth, it's the output of a process. The actual source of truth being live-edited is another tree that sits before it. So I need to solve a two-way synchronization problem between both. This requires careful reasoning about state changes.