'Can I load both obj and materials as an MDLAsset?

I have a directory containing an obj, mtl, and the textures. If I do

let asset = MDLAsset(url: url) then it loads the mesh, but no textures. Now, if I go rename the model.mtl file to model.abc and run the same code, I get the following on the console

020-10-08 19:24:36.277305-0700 ModelLoader2[1607:11820939] Unable to find mtl file /Users/myname/Documents/ModelLoader2/Models/model/model.mtl

What this tells me is that MDLAsset does find the mtl file, but it doesn't properly load the textures. Is there a way to get it to load the textures as well? I see some protocol called MDLAssetResolver with the following definition, but absolutely NO documentation on the internet and 0 useful hits on github

public protocol MDLAssetResolver : NSObjectProtocol {

    
    func canResolveAssetNamed(_ name: String) -> Bool

    func resolveAssetNamed(_ name: String) -> URL
}

My question are,

  1. what is the best way to load obj files? I had intended to use Model I/O so I could export to .usdz and other formats
  2. Is Model I/O not worth dealing with investing time into, or should I move on to other methods? It seems like there were a few WWDC talks hyping it up as a powerful framework, but so far it seems useless due to the lack of documentation.


Solution 1:[1]

Have you tried asset.loadTextures() since you already loaded the asset ?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kamal