如何从 .usdz 创建 SCNNode? [英] How to create a SCNNode from a .usdz?
本文介绍了如何从 .usdz 创建 SCNNode?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经下载了 Apple 提供的 .usdz 模型:
为什么它没有纹理?
如您所见,我已将下载的 .usdz 文件放入我的项目目录中的文件夹中:
解决方案
添加 .USDZ 对象的正确方法实际上是使用文件的 URL 创建场景:
让场景 = 尝试!SCNScene(url: usdzURL, 选项: [.checkConsistency: true])
甚至通过引用节点创建:
let referenceNode = SCNReferenceNode(url: usdzURL)参考节点.load()
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:
解决方案
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()
这篇关于如何从 .usdz 创建 SCNNode?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文