Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

three.js load obj/mtl renders black

Tags:

three.js

3d

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?

like image 270
Frank Miller Avatar asked Apr 15 '26 08:04

Frank Miller


1 Answers

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

like image 71
WestLangley Avatar answered Apr 19 '26 02:04

WestLangley



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!