Obj material's textures cannot be downloaded

Our server configurration asks for an authorization jwt token for every request. Because of this SceneLoader can load the obj and the mtl file but cannot load the image files for textures. They get an http 401 from server. I have set Custom Request Headers on WebRequest too.
I have seen this. Tried same but with no luck.
How to overcome this?

We need more info:) like a repro for instance!

WebRequest is here to let you completely control the request so you should be able to do what you need

I use SceneLoader.AppendAsync to load my OBJ files, like:

WebRequest.CustomRequestHeaders.Auth = `Bearer ${user.token}`;
await SceneLoader.AppendAsync(

I set my header for authorization. getFileExtension is a function returns ".obj" in this obj file case.
However my textures are missing in the resulting scene. When I check the network pane I see there is and HTTP 401 Unauthorized for the texture file, which is a .png file in this case. Our server protects the resources by checking a jwt in the request headers with bearer scheme. While the other files are successfully downloaded since WebRequest.CustomRequestHeaders set only the image files are not downloaded.

How can I download them? How can I make the requests for image files too have my custom authorization header?

Oh that’s the problem, I understand now. Unfortunately we are on the web and to download and decode the images we use an img tag:

1 Like

You can do something like this:
I mean you have to download yourself the images, I didn’t try with customHeader, but I think it should work.

1 Like

Maybe I can use this and use xhr request’s setRequestHeader method.
But what I wonder in this case is to match the textures with the meshes

I will check if we have the correspondence data as in form of properties in scene meshes, materials or textures.


I have made a progress on this after looking into yesterday again. I have used fetch and set headers to get textures from network. When BJS tool fails it works and loads them. Then set correct one into correct material.
I am gonna share it here and on the repo as soon as possible.