Open oveddan opened 8 years ago
The problem here is that things like ShaderMaterial
and Geometry
are not instances of Object3D
and the underlying scene graph is built using Object3D
nodes. I mean it's certainly possible but would require a lot of work and/or hackery. Especially problematic is that the behavior is undefined when people do odd things like have multiple Geometry
child or other strange things.
I usually recommend doing something like you've shown above - write a component to do all the nasty work and then use that component everywhere. #34 lists a few other components I wanted to write that would be similar.
Also you might want to look at react-three-renderer which takes a different approach and betters supports embedding geometry/material as React components.
Per the example using shaders: https://github.com/oveddan/react-three/blob/three-shader-example/examples/shader/shader.jsx#L22
It would be great if there was a react component for a
THREE.ShaderMaterial
Currently this is done like:
It would be great if there was some way to have a ShaderMaterial as a child element of the mesh, and there was an easy way to pass new values to the uniforms.