I’m struggling with referencing texture images from a .GLB file using either relative or absolute URIs.
Given glTF content of:
...
images: [
{
name: 'copper_wires',
mimeType: 'image/jpeg',
uri: '../textures/copper_wires.jpg'
},
]
...
I receive the console error
Unable to load from /3D/assemblies/5/optimized_model.glb: /images/0/uri: '../textures/copper_wires.jpg' is invalid
In this case the library doesn’t even attempt to fetch the file.
If instead I attempt an absolute URL:
...
images: [
{
name: 'copper_wires',
mimeType: 'image/jpeg',
uri: "https://server.com/3D/textures/copper_wires.jpg"
},
]
...
Then the SceneLoader tries to fetch /3D/assemblies/5/https://server.com/3D/textures/copper_wires.jpg
and fails.
It looks like the loader tries to just append the uri to the base path of the current .GLB file.
I found this forum post where @Deltakosh advises against using relative URLs.
If I want to put image files somewhere other than below the GLB directory, what options do I have?
By way of background - I’d like to pull out textures from models and store them in a single /textures directory so that they can be cached between model loads. I’m already using a material library for comment textures across ALL models, but this will handle a situation where there’s a texture that’s only used in a handful.