3
votes

I'm trying to load a fairly complex .obj file into three.js. Here's the code:

    // Load obj file
    var loader = new THREE.OBJMTLLoader();
    loader.load('MQ-9.obj', 'MQ-9.mtl', function(object) {
            scene.add(object);
    });

The MQ-9.mtl file refers to three images that are used on various places of the object (which is an MQ-9 Predator drone). I can load the object fine but its all black. The images don't appear to be loading. What am I doing wrong?

1
Do you have console errors? Do you have lights in the scene? Are you sure you are rendering after all assets load? Can you provide a link to a live example?WestLangley
Thanks for the reply. No console errors. I think I have lights. The other elements are visible. Its just the object that is not getting a texture. I'm definitely rendering, other things are showing up. All the other elements were created using base shapes, not loaded. I'll try to upload the code to a live server...Frank Miller
I wish there was a way to add a screenshotFrank Miller
Your suggestion about lights worked. I inserted an ambient and the surface images appeared. Thx!Frank Miller

1 Answers

1
votes

If you load a model and it renders black, there can be several possible causes, some of which include problems with your model. Make sure you have no console errors.

Other than that, the two most common causes are:

  1. a lack of lights in the scene

  2. rendering the scene before all assets load

three.js r.67