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,
- 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 - 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.
Have you tried asset.loadTextures() since you already loaded the asset ?