ObjLoader , mtlLoader and meshPhysicalMaterial

Hello guys , please i have a problem that a dont found the solution . I want to put a physicalmaterial into a geometrie that i loaded with the objLoader and mtlLoader , i need to add a roughness and metalness value to the geometrie . this is the Js code and mtl code : ( I think i need to keep the mtlLoader for good Uv )

var pmaterial = new THREE.MeshPhysicalMaterial({
      color: 0x0000ff,
      metalness: 0.2,
      roughness: 0.4,
      roughnessMap: new THREE.TextureLoader().load('obj/rough.jpg'),

var mtlLoader1 = new THREE.MTLLoader();
      mtlLoader1.load('geo.mtl', function(materials) {
          var objLoader1 = new THREE.OBJLoader();
          objLoader1.load('geo.obj', function(object1) {

and the .mtl code :

newmtl Mat
Ka 1 1 1
Kd 0.80000001192093 0.80000001192093 0.80000001192093
map_Kd diffuse.jpg
Ks 1 1 1
Ns 50
illum 7

Thanks !

You may need markdown https://guides.github.com/features/mastering-markdown/

1 Like

No, texture coordinates are defined in OBJ not MTL. Try to load your file just with OBJLoader and then overwrite the default material of the mesh with MeshPhysicalMaterial.

1 Like

Thanks , i find the solution in the other site :

objLoader = new THREE.OBJLoader();
objLoader.load('sub03.obj', function(object) {
  object.traverse(function(child) {
    if (child instanceof THREE.Mesh) {
      child.material = lambert1;