three.js加载obj / mtl呈现黑色 [英] three.js load obj/mtl renders black

查看:1616
本文介绍了three.js加载obj / mtl呈现黑色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将相当复杂的.obj文件加载到three.js中。代码如下:

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);
    });

MQ-9.mtl文件引用在对象的各个位置使用的三个图像(这是MQ-9 Predator无人机)。我可以很好地加载对象,但是它全都是黑色的。图片似乎未加载。我在做什么错?

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?

推荐答案

如果加载模型并呈现黑色,则可能有多种可能的原因,其中一些其中包括模型问题。确保没有控制台错误。

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. 场景中没有灯光

  1. a lack of lights in the scene

在所有资产加载之前渲染场景

rendering the scene before all assets load

three.js r.67

three.js r.67

这篇关于three.js加载obj / mtl呈现黑色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆