BaseUrl applied twice for MTL file

Hi everybody,

My first steps on this forum …
I’m trying to integrate BabylonJs into the Node-RED open source IOT framework, and - although I’m only using BabylonJs for only a couple of weeks - I really like it!

All the 3D files are exposed by an endpoint on the server side, and they are available starting from a common path. I use a BaseUrl to make sure ALL files can be loaded from that endpoint:

BABYLON.Tools.BaseUrl = "ui_babylonjs/" + $scope.config.id + "/scene/";
BABYLON.SceneLoader.Load("", $scope.config.filename, $scope.engine,...

That works fine for a gltf file. Indeed both the gltf file and all other included files are nicely loaded from the server. For example the texture files (referenced from within the gltf file) are loaded from a subpath underneath the samen common base url. For example http://localhost:1880/ui/ui_babylonjs/<some id>/...

However when I try to load an obj file, I’m not able to load the corresponding mtl file. The mtl file is referenced inside the obj file:

# 
# Generated by Sweet Home 3D - ma feb 01 21:34:21 CET 2021
# http://www.sweethome3d.com/
# 
mtllib HouseWithDormers.mtl
g ground_1
usemtl ground_1

The obj file is loaded without problems, but the url of the mtl file contains the baseUrl twice:

I have not debugged BabylonJs yet, but by looking at the code I ‘think’ that it goes like this:

  1. The objFileLoader adds the baseUrl to the path:
    private _loadMTL(...) {
         //The complete path to the mtl file
         var pathOfFile = Tools.BaseUrl + rootUrl + url;
         Tools.LoadFile(...);
    }
    
  2. But the fileTools also add the baseUrl:
    public static RequestFile(...): IFileRequest {
        url = FileTools._CleanUrl(url);
        url = FileTools.PreprocessUrl(url);
    
        const loadUrl = FileTools.BaseUrl + url;
        ...
    }
    

But I might be completely mistaken, since I have not debugged this!!!
And perhaps I’m just using the baseUrl the wrong way …

Hopefully somebody can verify this.
If I need to supply a playground, I will figure out how to accomplish that…

Thanks !!!
Bart

You’re absolutely right, here’s the fix:

…and welcome aboard!

2 Likes

Hi @Evgeni_Popov,

Thanks a lot for fixing this so quickly!! What a support :wink:
Have you any idea in which version this will released? I’m not familiar yet with the BabylonJs release process …

It will normally be released in the next nightly built (available through the Playground or here for your project).

1 Like