问题
I have downloaded the .usdz models provided by Apple: https://developer.apple.com/arkit/gallery/
But now, I want to create a SCNNode with one of these models, so I am doing this to obtain the node:
guard let urlPath = Bundle.main.url(forResource: "retrotv", withExtension: "usdz") else {
return
}
let mdlAsset = MDLAsset(url: urlPath)
let modelRootNode = SCNScene(mdlAsset: mdlAsset).rootNode
Then I add it to the scene and the result is this:
Why does it have no textures?
I have the downloaded .usdz files into a folder in my project directory as you can see:
回答1:
The correct way to add the .USDZ object is actually creating the scene with the file's URL:
let scene = try! SCNScene(url: usdzURL, options: [.checkConsistency: true])
Or even creating via Reference Node:
let referenceNode = SCNReferenceNode(url: usdzURL)
referenceNode.load()
来源:https://stackoverflow.com/questions/53317392/how-to-create-a-scnnode-from-a-usdz