FBX model default material is MeshPhongMaterial , how to change?

I use FBXLoader to load my model in three.js, the game 's fps is slow, so I check it with spector.js and found that the model is using MeshPhongMaterial, see: https://imgur.com/4zgZZ51

The Phong material is maybe too expensive for my game, and model has no shiny surface, so I want to change it to MeshLambertMaterial, is there any approach?

Lambert material is supported by the FBX spec, so it may be possible to specify this in your modelling program. In practice, I have not found any way to do this - every FBX file I’ve tested has always had only Phong materials, no matter what the original settings were pre-export.

However, you can update the materials after you’ve loaded the file:

const loader = new THREE.FBXLoader();
loader.load( 'models/your_model.fbx', function ( object ) {

  object.traverse( function ( child ) {

    if ( child.isMesh ) {

         // switch the material here - you'll need to take the settings from the 
         //original material, or create your own new settings, something like:
        const oldMat = child.material;

        child.material = new THREE.MeshLambertMaterial( {  
           color: oldMat.color,
           map: oldMat.map,
        } );


  } );

  scene.add( object );

} );
1 Like