I am trying to load a .fbx model in my three.js project which has many texture .png files with it but I am unable to figure out how to load and map the textures correctly.
FBXLoader
should automatically load and apply textures. Assuming the textures are properly defined/referenced in the FBX asset.
/cc
I am not using fbx model from my local. I am using links that provide me texture and fbx model seperately. So when i render the fbx model only, it appears black on the screen. I tried the same with a 3d model that has only one texture file and loaded the file it appeared correctly. So my aim is to load all the textures and apply them to the model.
Here is the code:
const loader = new FBXLoader();
loader.load( 'https//__link for fbx model', function ( object ) {
// mixer = new THREE.AnimationMixer( object );
// const action = mixer.clipAction( object.animations[ 0 ] );
// action.play();
console.log(object)
object.traverse( function ( child ) {
if ( child.isMesh ) {
textureLoader.load( 'http//:___link for texture file', ( texture ) => {
child.material.map = texture;
child.material.needsupdate = true;
console.log(texture)
// render(); // only if there is no render loop
});
console.log( child.geometry.attributes.uv );
child.castShadow = true;
child.receiveShadow = true;
}
} );
object.scale.set(0.01,0.01,0.01)
scene.add( object );
} );
This code only work for fbx model with only one texture file. Can you help me to load the fbx model correctly that is having multiple texture files?
hi bro, Can you slove this pro?
i have the same question
Just point the start and end (count) index of triangles to which need apply textures.