如何在three.js中使用GLTF Loader?纹理和材质显示为黑色 [英] How to use GLTF Loader in three.js? Texture and material displaying as black
问题描述
我在加载 gltf 时遇到问题.该模型能够成功加载,但所有纹理和材料(已嵌入 .gltf 中)都是完全黑色的.当我在 gltfviewer 中查看它时,所有纹理和材料都正确显示.我是 Three.js 的新手,所以如果有人能指导我使用 GLTF 加载器,我将不胜感激!
I'm having issues loading a gltf. The model is able to load successfully but all the textures and materials (already embedded in the .gltf) are completely black. When I view it in the gltfviewer, all the textures and materials show up correctly. I'm new to three.js so if anyone can walk me through using the GLTF loader, I would greatly appreciate it!!
推荐答案
这个问题本质上和如何将 AmbientLight 与 MeshStandardMaterial 结合使用? — 您的模型具有 100% 金属材料,纯金属不会反射漫射(环境光和半球)光.
This issue is essentially the same as How to use AmbientLight in combination with MeshStandardMaterial? — your model has a 100% metallic material, and pure metals do not reflect diffuse (ambient and hemisphere) lights.
理想情况下,始终向 PBR 模型添加环境贴图.另一种解决方案是添加非漫射/直接光,例如 PointLight 或 DirectionalLight 实例.如果您能够编辑模型,降低其金属度也将起作用.
Ideally, always add an environment map to PBR models. Another solution is to add non-diffuse/direct lights, such as PointLight or DirectionalLight instances. If you are able to edit the model, reducing its metalness would also work.
更多详情,请参见https://github.com/mrdoob/three.js/issues/9228.
这篇关于如何在three.js中使用GLTF Loader?纹理和材质显示为黑色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!