In other words, you write declarative code, and it does the hard imperative work of adding/removing/disposing/updating things for you.
Just like how it helps you sync your data model to underlying stateful DOM nodes; the idea can be applied on top of any stateful system.
cjonas · 47m ago
Just to clarify, you'd write the bottom code (declarative) and the library translates it to the above (imperative) code?
MortyWaves · 45m ago
That’s right
cjonas · 39m ago
Are there any guides on using the "react style" framework (JSX / State) to generate outputs other than DOM? I've been interested in the idea of doing something similar for JSON or markdown document generation.
cwackerfuss · 28m ago
I don't have a good guide for you, but this is the lib you use to create custom React renderers:
R3F is great but almost all the code sandbox demos have been broken for years at this point
tlarkworthy · 1h ago
note three.js [1] has nothing to do with React out of the box though, this page highlights an atypical way of using three.js through a popular React binding.
You might be getting downvoted for saying it's an "atypical" way of using three.js. the pmnd.rs community (for example) is quite large.
I understand why people like the declarative nature of react three fiber, but it's quite unfortunate that it requires something like code sandbox to allow modification / working with it on the web- but that's by nature due to being react.
Vanilla three.js can be written surprisingly similarly, if you are disciplined about breaking things up into functions/components. And no react necessary / can embed a code editor and allow direct modification.
Since they bring their own reconcile(a, b, diff) function to React, these libs can turn:
Into: In other words, you write declarative code, and it does the hard imperative work of adding/removing/disposing/updating things for you.Just like how it helps you sync your data model to underlying stateful DOM nodes; the idea can be applied on top of any stateful system.
https://www.npmjs.com/package/react-reconciler
https://r3f.docs.pmnd.rs/getting-started/examples
The examples here
https://threejs.org/examples/#webgl_animation_keyframes
seem to work great on my phone...
[1] https://threejs.org/
I understand why people like the declarative nature of react three fiber, but it's quite unfortunate that it requires something like code sandbox to allow modification / working with it on the web- but that's by nature due to being react.
Vanilla three.js can be written surprisingly similarly, if you are disciplined about breaking things up into functions/components. And no react necessary / can embed a code editor and allow direct modification.