I am currently facing an issue while trying to render image texture dynamically. The console is showing an error message: Uncaught TypeError: Cannot read property 'width' of undefined. Some have suggested setting needsUpdate to false, but doing so results in a black patch that I find unpleasing. I need it to be set to true. How can I achieve this? The actual code is quite lengthy, so I am indicating where the problem arises.
var g = new THREE.PlaneGeometry(100,100);
var tx =THREE.ImageUtils.loadTexture(imgUrl,undefined,callback,callbackError);
var m = new THREE.MeshBasicMaterial({
map:tx
});
m.map.needsUpdate = true; //1
tx.needsUpdate = true; //2
////if 1 and 2 is commented then its ok but rendering is not good
var b = THREE.SceneUtils.createMultiMaterialObject(g,[
m
,new THREE.MeshBasicMaterial({wireframeLinewidth:3,color:0x222222,wireframe:true})
]);