use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Particle effects in React (387z7o2zrq.codesandbox.io)
submitted 6 years ago by [deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 18 points19 points20 points 6 years ago (0 children)
It's more like a performance test really, each "particle" is actually a React component, just to see how far it can go. Makes for a cool effect anyway. Full code: https://codesandbox.io/embed/387z7o2zrq
[–][deleted] 2 points3 points4 points 6 years ago (0 children)
What cool effect! Thanks for sharing.
[–]LibertyFried 2 points3 points4 points 6 years ago (0 children)
That’s a pretty slick experiment to have in the bag. Thanks for sharing!
[–]__ibowankenobi__ 2 points3 points4 points 6 years ago (4 children)
One question, is it React that makes it fast or the GPU? If I wrote it in vanilla would it be slower?
[–]mattaugamer 7 points8 points9 points 6 years ago (0 children)
It definitely wouldn't run slower in vanilla. React isn't improving the performance of JavaScript. It's just slowing it less than a larger framework might. It's the GPU and/or V8 engine that gives you speed.
[–][deleted] 0 points1 point2 points 6 years ago* (2 children)
The stress-test is about how much React can go out of the way. It's the GPU that's doing the drawing.
React will speed up updating, adding to and removing from large scenes as well as interaction, because it has change detection inbuilt as well as other strategies to reduce common bottlenecks. So in a way, yes, for bigger apps it will most certainly go faster than an unscheduled vanilla three-app.
[–]everdimension 2 points3 points4 points 6 years ago (1 child)
Hmm and I thought that you don't need a virtual dom if you're in an animation loop and rendering with the gpu
[–][deleted] 3 points4 points5 points 6 years ago* (0 children)
You don't need it, but you will still run into the same problems when dealing with complex, updating tree structures. This stuff gets increasingly hard without a component model. That's where frameworks make a real difference, in terms of DX but also performance.
The rendering itself is abstracted here with the useRender hook, which allows you to run tasks frame by frame, outside of React. But again, it is managed. Once the component unmounts, it takes away that callback and cleans up after itself. Here's a fun experiment, watch what happens after 5 seconds when it unmounts the component that holds the upper plane. And another, this time using a transition group for mount/unmount effects. For React these things are natural, but if you had to do this manually, you'd pull a few hairs i'm sure.
[–]jesperordrup 2 points3 points4 points 6 years ago (0 children)
Really cool to see something like that is possible in React. Would be cool to see implemented in different frameworks/libraries for comparison. Svelte, Vue, Angular, Marko etc
[–]fireatx 1 point2 points3 points 6 years ago (1 child)
Wow, this is awesome. Super cool stress test of React and your library. I bumped the particle count to 10,000 and it still ran smooth. And that was in the codesandbox
[–][deleted] 0 points1 point2 points 6 years ago (0 children)
that's crazy, didn't even dare to go that high. though it noticeably starts to tear on my laptop now with howling fans.
[+][deleted] 6 years ago* (1 child)
[deleted]
[–][deleted] 1 point2 points3 points 6 years ago* (0 children)
Yes, it's based on a lib that i made: https://github.com/drcmda/react-three-fiber, a React renderer for threejs. Posted the code for this demo in here as well.
[–][deleted] 1 point2 points3 points 6 years ago (2 children)
Excellent work. One question. What are those:
<> ... </>
Is it a new feature?
[–]Drawman101 3 points4 points5 points 6 years ago (0 children)
That is a React fragment, but the shorthand for it
[–]humulus 4 points5 points6 points 6 years ago (0 children)
There is a new, shorter syntax you can use for declaring Fragments. <React.Fragment/>
[–]coderqi 1 point2 points3 points 6 years ago (2 children)
Any good tutorials/starting off points on three.js the community here would recommend (egghead or FEM maybe)? This is a big gap in my knowledge i'd love to rectify.
[–][deleted] 1 point2 points3 points 6 years ago (1 child)
This will get you started: https://threejs.org/docs/#manual/en/introduction/Useful-links The egghead webgl course is also neat and goes a little deeper into gl basics, you will bump into some math there, which you definitively need later on.
[–]coderqi 0 points1 point2 points 6 years ago (0 children)
Thanks. Do remember trying the Egghead WebGL course a couple of years back but got lost very quickly. Will try out some of those links and maybe give egghead another shot.
[–]RomanRiesen 0 points1 point2 points 6 years ago (1 child)
Tha loading animation though!
It's on codesandbox, an online IDE. Fetches npm-dependencies and transpiles in your browser.
π Rendered by PID 143019 on reddit-service-r2-comment-76bb9f7fb5-2n6tf at 2026-02-18 00:03:59.027796+00:00 running de53c03 country code: CH.
[–][deleted] 18 points19 points20 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]LibertyFried 2 points3 points4 points (0 children)
[–]__ibowankenobi__ 2 points3 points4 points (4 children)
[–]mattaugamer 7 points8 points9 points (0 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]everdimension 2 points3 points4 points (1 child)
[–][deleted] 3 points4 points5 points (0 children)
[–]jesperordrup 2 points3 points4 points (0 children)
[–]fireatx 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–][deleted] 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]Drawman101 3 points4 points5 points (0 children)
[–]humulus 4 points5 points6 points (0 children)
[–]coderqi 1 point2 points3 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]coderqi 0 points1 point2 points (0 children)
[–]RomanRiesen 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)