I searched for a solution but I havent found anything.
I have a problem regarding loading objects.
My project requires a small babylon previewer for the newly uploaded objects.
We support obj with mtl, textures,
gltf either with embedded textures or not
The user can either provide a URL for the object which works as expected, or he can provide a local object with its textures
I dont have access neither to the original object, nor to the uploader.
I get the resulted files data which I can create a new blob from.
The problem is that when I try to load an obj with mtl, the loader reads obj without an issue but then it tries to load the mtl using its original name and not the blob.
Do you have any ideas?
The only thing that comes to mind and I want to avoid is editing the loaded obj or gltf to change the uri of the rest of the objects.
The OBJ file contains the line that references the .mtl file (the URL to load). You will need to change the content of this file with the new (blobl) URL instead of the URL referenced there.
But maybe someone else had a better solution?
Thank you Raanan for the fast answer.
That is what I try to avoid. I will wait if someone else has a better idea
You can try to override the
FileTools.RequestFile function to intercept the request for the mtl file:
You can use Tools.PreprocessUrl instead of overriding FileTools.RequestFile. All url requests should go through that function. That should be a bit cleaner.
This function is typically used when you need to pass authentication tokens as parameters to the URL, but in this case you can use it to redirect to blobs.
thank you all for your answers. I will try them and gine feedback