Shaders freeze when changing uniforms with react-dat-gui #1080
-
I doubt it is a react-dat-gui specific problem but when using a slider to update a uniform I created called 'frequency' to get more waves on a plane, it freezes the shader animation. I used useMemo for uniforms but that only stops the freezing when I resize the window. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Solved it! Not sure how to close this,but If anyone runs into a similar problem--I passed my props that are manipulated by react-dat-gui straight into the mesh, using a ref, like bruno did instead of changing the uniforms object directly: |
Beta Was this translation helpful? Give feedback.
Solved it! Not sure how to close this,but If anyone runs into a similar problem--I passed my props that are manipulated by react-dat-gui straight into the mesh, using a ref, like bruno did instead of changing the uniforms object directly:
if (shaderMaterialRef.current) { shaderMaterialRef.current.uniforms.uFrequency.value = new THREE.Vector2( props.uFrequencyX, props.uFrequencyY ); }
message me if you this wasnt clear 🙏