Struggling to figure out how to use a button to change the .mtl file associated with my .obj in three.js. Any suggestions on accomplishing this would be greatly appreciated!
Below is the code I've been working with, based on the objmtl loader example from threejs.org. So far, I have only managed to toggle the visibility of the obj using a button. However, I am eager to implement additional buttons that can swap out the .mtl files to showcase different colors and properties.
var mtlLoader = new THREE.MTLLoader();
mtlLoader.setBaseUrl( 'examples/obj/male02/' );
mtlLoader.setPath( 'examples/obj/male02/' );
mtlLoader.load( 'male02_dds.mtl', function( materials ) {
materials.preload();
var objLoader = new THREE.OBJLoader();
objLoader.setMaterials( materials );
objLoader.setPath( 'examples/obj/male02/' );
objLoader.load( 'male02.obj', function ( object ) {
object.position.y = - 95;
dude = object;
scene.add( dude );
info.innerHTML += '<br/><br/><input id=pants2 type="button" onclick="dude.visible = false" value="Dude: OFF"/>';
info.innerHTML += '<input id=pants2 type="button" onclick="dude.visible = true" value="Dude: ON"/>';