GLTFLoader fails to load the model when a referenced texture file is missing

Hi Forum,

Since a texture encoding overriding has been added as part of the 3D model loading. In case the texture is missing (null), the script fails, and the loader returns the error without loading the model.

Here is the related code line.

The problem happens when some referenced texture file can’t be loaded.

Could we relax this problem by adding a null check in three.js/GLTFLoader.js at 15b35ad614a23f97343ea348534db8b685cfc535 · mrdoob/three.js · GitHub ?

Happy to send the PR if you think it is worth it, I understand the problem is in the 3D model and not in the loader, but also I think we could load the 3D model without the broken textures and just log a console error if this problem is detected.

What do you think?

There is a line just above this, checking:

if ( ! texture ) return null;

That was added pretty recently, in r147. If you’re not on that release then you may just need to update, otherwise I think we’re open to PRs here. Usually we don’t work around invalid glTF content, but missing textures is common and simple enough case that we do.

2 Likes

I was in r146, now running in r148 without issues.
Thanks @donmccurdy