How to use needs update property with MTL Loader

Hello,
Is there a way to clear the catch images by MTL loader? As when I dynamically update the material (as well as obj) file having the same image names (in MTL), and after removing and re-adding the mesh, it’s texture map gets destroyed. Attached below:

But when I refresh the page everything comes to perfect position.

As with the texture we have needsUpdate is there such alternative for the MTL Material?
thank you in advance.

so far I have done:


mtlLoader.load("file://" + mtl_file, function(materials) {

	//materials.needsUpdate = true; //error
					
       materials.preload();
				    
	var update_material = Object.keys(materials.materials);
				   
	for(var i=0; i < update_material.length; i++){
		materials.materials[update_material[i]].needsUpdate = true;
	}

	materials.options.needsUpdate = true;

       contd...

I’m not sure your shared code snippet make sense. There is no point to set needsUpdate to true unless certain properties are changed.

Do you mind explaining in more detail what you mean by that? I’m afraid your problem is not yet clear.

@Mugen87 Thank you for the response.
Actually I have the MTL file along with the respective Images. When i initially open that file (in the same session) everything is perfect. While the session is still on the file gets modified both mtl and obj. So i remove the mesh from the scene. and re-add those in order to load up the new updated files. But there are existing images which are being catch by the browser. In order to update those I have to reload the entire page. Is there a way it can be done without reloading the entire page?