ColladaLoader: Malformed urls
See original GitHub issueI’m loading dae via http url, the dae and all of its textures are accessed like wise:
http://<baseurl>/<relative path>/name.dae
http://<baseurl>/<relative path>/TextureResource1.png
http://<baseurl>/<relative path>/TextureResource2.png
All textures in the dae are references like:
<image id = "TextureResource1img">
<init_from>./TextureResource1.jpg</init_from>
</image>
<image id = "TextureResource2img">
<init_from>./TextureResource2.jpg</init_from>
I use ColladaLoader to load dae with relative url like "/<relative path>/name.dae"
-
When I pass this line:
var path = (scope.path === '') ? core_js_libs_threejs1_three_module_js__WEBPACK_IMPORTED_MODULE_0__["LoaderUtils"].extractUrlBase(url) : scope.path;
path is set to
"/<relative path>/"
-
Then in ColladaLoader.parse you create a texture loader and set it’s path to
"/<relative path>/"
textureLoader.setPath(this.resourcePath || path).setCrossOrigin(this.crossOrigin);
-
In the process of loading the textures you are calling loatTextureForUniform, there
var image = getImage(surface.init_from);
is set to "./TextureResource1.jpg"
since I have path set to "/<relative path>/"
, I get in the if
if (path) {
var parts = path.split('/');
parts.pop();
let baseUrl = (parts.length < 1 ? '.' : parts.join('/')) + '/';
url = baseUrl + image;
}
as a result I get url set to "/<relative path>/./TextureResource1.jpg"
Which btw is still fine by the browser since If you call it like this, the browser resolves the relative path to absolute by itself, but you do not stop here!
- While makeing this call:
var texture = getTextureLoader(url).load(url);
I end up in ImageLoader.load with url "/<relative path>/./TextureResource1.jpg"
and this.path = "/<relative path>/"
and this IF kills it:
if ( this.path !== undefined ) url = this.path + url;
The result is url "/<relative path>//<relative path>/./TextureResource1.jpg"
?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top GitHub Comments
Closing due to lack of feedback.
Please share a working demo (e.g. as a live example or a GitHub repo) that demonstrates the issue.
Can you please explain once more why this URL is given to
ImageLoader
? When reading the code inColladaLoader
, it looks like the loader directly passes the image name to theload()
method (without modification).BTW: Instead of copy/paste code, you can also link to source files like I did in my post before.