Optional onUnmount onMount functions for R3F nodes? #2199
mysterybear
started this conversation in
Ideas
Replies: 1 comment 5 replies
-
Do this work in a Docs for useEffect
Store the materials in a context and use a provider with a hook. Something like this inside your component.
Just an idea |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey
So the Three.js paradigm is lots of mutation... R3F kinda "declarative-ises" that, which is great... But then we still end up having to code Three.js style really (e.g. ref and mutate on materials, all kinds of stuff)
I wonder if an API like this would be possible:
onUnmount
andonMount
are optional props. The default is whatever the current behaviour is now (add/remove to scene via parent). I guess there could also be apreventDefault
like with event handlers?This would all afford the possibility of doing something like
node.traverse
on the root and then setting all the materials tovisible={false}
, avoiding having to re-compile materials etcThoughts? Cheers!
Beta Was this translation helpful? Give feedback.
All reactions