javascriptthree.jsshader

How do you update a uniform In Three.js?


How do you update a shader uniform in three.js?

Let's say the uniform is defined as

new THREE.ShaderMaterial({
  uniforms: {
    yourUniform: { value: 'Something' }
  }
});

Solution

  • This seems to work:

    yourMesh.material.uniforms.yourUniform.value = whatever;