Changing material(s) of a mesh in runtime

It seems your code snippets are not sufficient in order to understand the issue. Replacing a material is actually easy, even setting Material.needsUpdate to true is not required, see:

Consider to demonstrate your issue with a live example.

2 Likes