GLTF/GLB texture map not loading

This is my model in c4d:

I export it as GLB

Now I try to load it into my scene:

  const bgTexture = new THREE.TextureLoader().load("sunny2.png");
  const bgMaterial = new THREE.MeshBasicMaterial({ map: bgTexture, transparent: true });

  const loaderG = new GLTFLoader();
    function (gltf) {
      let mesh = gltf.scene;
      mesh.material = bgMaterial;
    function (xhr) {
      console.log((xhr.loaded / * 100) + '% loaded');
    function (error) {
      console.log('An error happened');

Model is loading but without the texture:

Texture settings are set like this in c4d:

when I apply the bgMaterial to a box or a plane I see the texture…

I tried the same with .obj and .dae, with same result.

So it seems you don’t get the texture exported from C4D. Since this is not a three.js issue then, it’s probably better to ask a question at the C4D community.

When I export it as .obj, I got also the .mtl file

var mesh = null;
  var mtlLoader = new MTLLoader();
  mtlLoader.setPath( "/export/" );
  mtlLoader.load( 'model.mtl', function( materials ) {
    var objLoader = new OBJLoader();
    objLoader.setMaterials( materials );
    objLoader.setPath( "/export/" );
    objLoader.load( 'model.obj', function ( object ) {
      mesh = object;
      scene.add( mesh );
    } );
  } )

But the texture map is not there… I don’t think this has anything to do with c4d.

The content of the mtl file:

# WaveFront *.mtl file (generated by Cinema 4D)

newmtl default
Ka 1 1 1
Kd 1 1 1
map_Kd -o 0.220 -0.420 -s 1.700 1.700 sunny2.jpg
Ks 1 1 1
Ns 50
illum 7

the sunny2.jpg image is in the same directory.

Do you mind sharing the glb asset in this topic?

Please use OBJ and Collada only to verify this issue. glTF should be your first choice.

I know I had some problems with .glb, try to export in .gltf if possible !

model.gltf (2.1 MB)

I added the gltf model - I see the texture map in gltf is included as base64 in the file itself.

Your asset defines no texture coordinates.

soo it is a c4d thing… no idea where to set this - there is not much to configuire in the export window.

Ok I found the solution. You first have to “bake the texture” before you export it.