三.js 加载 obj/mtl 呈现黑色 [英] three.js load obj/mtl renders black
问题描述
我正在尝试将一个相当复杂的 .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:
场景中缺少灯光
a lack of lights in the scene
在加载所有资源之前渲染场景
rendering the scene before all assets load
three.js r.67
three.js r.67
这篇关于三.js 加载 obj/mtl 呈现黑色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!