steveg
steveg

Reputation: 93

OBJ + MTL loads but doesn't render

If I use the following code to load the .obj and .mtl downloaded from https://poly.google.com/view/9NXf-SDxJny it works fine, I see the star rendered in my scene.

return new Promise((resolve, reject) => 
    {
        let mtlLoader = new THREE.MTLLoader();
        mtlLoader.crossOrigin = true;
        mtlLoader.setPath(ASSETS_PATH);
        mtlLoader.load(filename + '.mtl', (materials) => 
        {           
            materials.preload();
            let objLoader = new THREE.OBJLoader();
                objLoader.setPath(ASSETS_PATH);

                objLoader.setMaterials(materials);
                objLoader.load(filename + '.obj', (obj) => 
                {   
                    this.obj = obj; 
                    resolve(true);
                });
        });
    });

But when I use the same code to load the obj and mtl from https://poly.google.com/view/4-OZNPuTqFq it doesn't show. I don't get any errors. If I remove the line objLoader.setMaterials(materials); then i see the cake but with no material. So it appears to be a material issue.

I have a codepen with the full code here https://codepen.io/steveg3003/pen/6f0d8c4a17ed12bea49b3391a6d80ce3?editors=0010

Thanks

Upvotes: 2

Views: 627

Answers (2)

phreakhead
phreakhead

Reputation: 15259

Something similar happened to me, except the model was all black. I had to open up the .mtl file and change the "Kd 0.00 0.00 0.00" to "Kd 1.00 1.00 1.00"

Upvotes: 1

steveg
steveg

Reputation: 93

So the solution for me was to manually change the 'd' value inside the material file (.mtl) from 0.00000 to 1.00000

Upvotes: 1

Related Questions