0

I can't load my object. The screen is blank. The code to load is:

        var mtlLoader = new THREE.MTLLoader();
        mtlLoader.setBaseUrl('assets/');
        mtlLoader.setPath('assets/');
        mtlLoader.load('Gita.mtl', function (materials) {

            materials.preload();

            materials.materials.default.map.magFilter = THREE.NearestFilter;
            materials.materials.default.map.minFilter = THREE.LinearFilter;

            var objLoader = new THREE.OBJLoader();
            objLoader.setMaterials(materials);
            objLoader.setPath('assets/');
            objLoader.load('Gita.obj', function (object) {

                scene.add(object);

            });

        });

this is my object: https://drive.google.com/drive/folders/0B71ivPfsz82mYzVxYU1TZkt5ekk?usp=sharing

Hope you can help me. Thanks for your attention.

  • You are trying to load a tga texture from a drive and there are spaces in the name. try putting the texture at the same location where your mtl file is. – gaitat Apr 25 '17 at 21:28
  • Also make sure that it's the object that's not being loaded. You could have the object but no proper material/textures or even lights/normals. – pailhead Apr 25 '17 at 23:11

1 Answers1

0

here is my code to load a Obj file. I tried your Object in my code and it worked, maybe it works for you, too.

                var manager = new THREE.LoadingManager();
                var loader = new THREE.OBJLoader(manager);     
                var fileloader = new THREE.FileLoader();
                fileloader.load('Gita.obj', function(data){

                    var object = loader.parse(data);
                    object.scale.set(0.5, 0.5, 0.5);
                    scene.add(object);
                },
                    function (xhr) {

                        console.log((xhr.loaded / xhr.total * 100) + '% loaded');
                    },
                      //if download fails
                    function (xhr) {

                        //console.error('An error happened : ' + xhr);
                    }
                );
ahmetkilinc
  • 674
  • 7
  • 19