Joshua Foxworth
Joshua Foxworth

Reputation: 1397

How to load mtl files with gltf in react-three-fiber

I have downloaded a set of files from a site and exported the glb, gltf, and mtl files in blender. I can get the glb or gltf file to display in the react-three-fiber scene, but I am not sure how to get the textures to display properly. I have come across a couple of demos but they seem old and what would not work.

Here is how I load the file.

import desk from '../../assets/desk.gltf'; // or .glb file

const [gltf, set] = useState();
useMemo(() => new GLTFLoader().load(desk, set), []);
return gltf ? <primitive object={gltf.scene} scale={[0.05, 0.05, 0.05]} position={[0,0,1]} 
rotation={[Math.PI/2,Math.PI,0]}/> : null

Upvotes: 2

Views: 910

Answers (1)

Mugen87
Mugen87

Reputation: 31026

I'm afraid you are mixing two topics. MTL files are relate to the OBJ format. Meaning the visual aspects of the assets's geometry are stored in one or more external MTL files.

glTF does not have separate files for that. Material definitions are directly defined in the glTF JSON manifest. So loading the actual glTF asset is sufficient for loading material definitions.

Upvotes: 2

Related Questions