Okay so I have total access to a material, I can change it's colour at runtime, however trying to change the map texture gives an error.
For example
var materials = mesh.material.materials;
materials[index].color.setHex(0xb60430);
materials[index].needsUpdate = true;
scene.render();
this works totally fine, however in the same situation
var materials = mesh.material.materials;
var texture = new THREE.Texture(myPreloadedImageObject);
materials[index].map = texture;
materials[index].needsUpdate = true;
scene.render();
This throws an error (excuse if it's a bit weird I can't copy paste from the node-webkit console)
[.WebGLRenderingContext]GL ERROR :GL_INVALID_OPERATION : glDrawElements: attempt to access out of range vertices in attribute 1
Note that I can also remove the material like this
materials[index] = 0;
scene.render();
And it also does not throw the error.
s9k from the github issues section suggested
geometry.buffersNeedUpdate = true;
geometry.uvsNeedUpdate = true;
Which I did and now it doesn't throw an error, but it just doesn't do anything...the material remains unchanged. Again if I try to set the colour, it works, but if I try to set the colour and the material, nothing happens.
If I log the material after render, it does indeed have a map set as the texture, but for some reason it isn't being rendered I guess
Any ideas? Is this a bug?