AssetsManager: Ignore .mtl file

Hey,

in my application i am loading some assets using the AssetsManager:

export function loadPlateMesh(assetLoader, callback, plateMaterial) {
  var plate = assetLoader.addMeshTask("", "", "/webshop/assets/", "plate.obj");
  plate.onSuccess = function() {
    var plateMesh = plate.loadedMeshes[0];
    plateMesh.scaling = new Vector3(0.7, 0.7, 0.7);
    plateMesh.setPositionWithLocalVector(new Vector3(-75, 0, 0));
    plateMesh.rotation.x = -Math.PI / 2;
    plateMesh.material = plateMaterial;

    callback(plateMesh);
  };
}

var assetLoader = new AssetsManager(this.babylon.scene);
loadPlateMesh(assetLoader, (mesh) => (this.scene.plateMesh = mesh), this.scene.plateMaterial);
await assetLoader.loadAsync();

Now this works perfectly fine. The AssetsManager tries to fetch an .mtl file tho, which doesn’t exist.
This results in a 404-error and a warning in the console. While its not a big deal, i would like to avoid it.

When using the OBJFileLoader, i saw it is possible, to ignore the .mtl file and just skip it.
Is this possible for the AssetsManager too?

Thanks alot!

Unfortunately this is not possible as of now because the AssetsManager is agnostic :frowning:

1 Like

The flag is static, so I think BABYLON.OBJFileLoader.SKIP_MATERIALS = true should work even when using the AssetManager, as in the end it will still use the OBJ file loader to load .obj files.

1 Like

Well actually:) It should work because the property is static
so calling OBJFileLoader.SKIP_MATERIALS = true before loading the assets should work :slight_smile:

2 Likes

Thanks alot, i missed that. Going to set the flag then and try it out :slight_smile:

#Edit: Works perfectly fine now.