Hello,
I am creating a customization software with Three.js. I get .mtl and .obj files from 3d design program. I already set material type from 3D CAD program but when I load obj to canvas with three.js I also have to define like this:
mtlLoader.load( 'yaka2.mtl', function( materials ) {
materials.preload();
objLoader.setMaterials( materials );
objLoader.load( 'yaka2.obj', function ( obj ) {
// texture
texture = textureLoader.load(kumas);
obj.traverse( function ( child ) {
if ( child.isMesh ) child.material = new THREE.MeshStandardMaterial({
metalness: metalValue,
roughness: roughValue,
map: texture,
normalMap: textureNormal,
});
} );
scene.add( obj );
},
// onProgress callback
function ( xhr ) {
console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
},
// onError callback
function ( err ) {
console.log( 'An error happened' );
});
});
SO if you look at above code, I import .mtl file from 3D CAD program then I also define which materila that I will use in THREE.js: “THREE.MeshStandardMaterial” then I also set roughness and metalness ( metalness: metalValue, roughness: roughValue).
Then my question is this: I already define which material will I use (is it shiny, is it leather, is it wool etc) at the 3D CAD program, then I export both material and .obj of the CAD program. Then I i use them in THREE.js.
Then the point is: If I already define these in CAD then WHY should I choose a material, a roughness and metalness AGAIN in THREE.js?
I hope question is clear, I want to understand why should I choose a material and other material feature for THREE.js for objects and materials imported from CAD programs. Because I already determied which material will I use BUT UNFORTUNATELY I have to arrange things again in THREE.js (or shouldn’t I?).
Am I doing wrong? Or is there a way directly using pre-created materials and objects as defined in CAD program?
I will be very glad if anyone can enlight me about the problem.
Thanks