In the gltf
file there is a node buffers
that contains a URI to the bin
files. Is there any way to intercept the moment when the loader will try to download the bin
files?
Usually these files are located at the same level, but in my case I would like to store the bin
files in a different path.
Is this achievable without modifying the gltf
file?
You can try to create and instance of LoadingManager
and then use the setURLModifier() method which allows you to modify URLs of the asset’s resources. Don’t forget to pass the loading manager to the loader’s constructor.
I think setResourcePath
can also be used for this, if the .bin
file is in the same directory as any textures.
I played with this and I made it work. Thanks for letting me know. I have one suggestion that you might consider or not. I asked a question on SO about this.
I have the gltf
and bin
files in a cloud service. When retrieving them, I’m using some query parameters that authorize me (that’s the way sadly, no Authorization header). What happens is that if I pass the URL to the gltf
file as it needs to be (i.e. host/pathToGltfFile?<someQueryParams>
) the download goes through and it is successful. But when the parser gets to the buffers
node it gets the path to the bin
from there but for some reason it drops all query params, basically turning the URL to host/pathToBin
which is invalid in my case.
I do not have enough insight to see the reasoning behind this, but IMO it should only tweak the pathname
from the url and leave the rest as it is.
It’s resolving the URL in the same way web browser would resolve CSS or image files from an HTML page – relative to the page’s path, but not copying query or hash params. I think setURLModifier
would be the way to go for more control of that.