I am trying to load and render a gLTF model that contains some metallic surfaces and after rendering they appear dark (black, but glossy). I tried all the recommendations from other topics, but nothing works. Here is the code I was able to come up with.
Make sure that the envMap is actually loading. Check Network panel in Chrome devtools and see if the request for the environment map texture has the correct texture in its response.
Also since it looks like you’re loading just a simple flat texture (not an hdri), in the texture loader callback be sure to add a proper mapping:
You can load them using RGBELoader. Then you just set the texture as scene.environment.
Keep in mind that HDRI textures produce not only reflections but also light - and they will make other lights in the scene useless. HDRIs are effectively light data saved to a texture - thanks to that it’s possible to achieve very realistic lighting and reflections in 3D, based on just photographs.
See the code above (ie. this) - it’s a bit different from loading just a texture.
Load the HDRI, set .mapping, and set texture as scene.environment - that’s it. No more, no less, no models or generators involved, three will do the calculations for you on all models where it’s needed.
scene.environment applies light and reflections to all models and textures in your scene. You wouldn’t need to set it manually anywhere - when using HDRIs you can ignore the existence of material.envMap.
If you’d like each submesh of your model to have different reflections (although it’s kinda hard to imagine a scenario in which you’d like that? ) - consider using just non-HDRI textures instead.
It is awesome! I tried to apply it to the whole scene and it seems that even non-metallic surfaces look fine. Thank you very much! Appreciate your help!