如何在 ARKit 应用程序中在运行时加载 SCN 或 glTF 模型? [英] How to load SCN or glTF model at runtime in ARKit app?
问题描述
在运行时从 iOS 内部的 URL 加载 3d 模型的最佳方法是什么.我试过这个 .scn
和 .gtlf
模型导入器.
我正在使用这个框架 https://github.com/prolificinteractive/SamMitiAR-iOS 我像这样加载模型:
让 virtualObjectGLTFNode = SamMitiVirtualObject(gltfUrl: URL(string:https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Duck/glTF-Embedded/Duck.gltf")!, allowedAlignments:[.水平的])virtualObjectGLTFNode.name = "鸭子"virtualObjectGLTFNode.setAnimationForVirtualObjectRemoving {(节点,已完成)在SceneKitAnimator.animateWithDuration(持续时间:0.35/2,计时功能:.easeIn,动画:{让变换 = SCNMatrix4MakeScale(0.01, 0.01, 0.01)node.contentNode?.transform = 变换},完成:完成)}返回 virtualObjectGLTFNode
像上面一样,我正在从远程服务器加载不同的 url,请指导我如何从远程服务器加载 3d 模型.我想要哪种格式的 url.请发送任何链接,其中包含来自远程服务器的 scn 文件先谢谢了.
似乎是一个 url 加载器 功能在
SamMitiAR
框架中不起作用.它在Placing and Removing Virtual Objects
部分下显示 Work in Progress.
要了解如何将模型动态加载到 ARKit 应用程序中(当模型在编译时无法访问时),请阅读这篇文章(抱歉,有一个 Objective-C 代码):>
如果您想了解在使用 url
时如何使用不同的方法,请阅读以下 SO 帖子:
如需更多阅读,请使用 Apple 文档:
What is the best way to load a 3d model from a URL inside of iOS at runtime. I have tried this .scn
and .gtlf
models importer.
I am using this framework https://github.com/prolificinteractive/SamMitiAR-iOS I load the model like this:
let virtualObjectGLTFNode = SamMitiVirtualObject(gltfUrl: URL(string:
"https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-
Models/master/2.0/Duck/glTF-Embedded/Duck.gltf")!, allowedAlignments:
[.horizontal])
virtualObjectGLTFNode.name = "Duck"
virtualObjectGLTFNode.setAnimationForVirtualObjectRemoving { (node, completed) in
SceneKitAnimator.animateWithDuration(duration: 0.35 / 2,
timingFunction: .easeIn,
animations: {
let transform = SCNMatrix4MakeScale(0.01, 0.01, 0.01)
node.contentNode?.transform = transform
}, completion: completed)
}
return virtualObjectGLTFNode
like above i am loading different url from remote server please guide me How can i load 3d models from remote server.In which format i want take url.Please send any link have that scn files from remote server Thanks adavance.
Seems that a url loader feature doesn't work in
SamMitiAR
framework. It says Work in Progress underPlacing and Removing Virtual Objects
section.
To know how dynamically load a model into ARKit app (when a model isn't accessible at compile-time), read this article (sorry, there's an Objective-C code):
If you want to find out how to use different approaches when working with url
, please read the following SO posts:
For additional reading use Apple Documentation:
这篇关于如何在 ARKit 应用程序中在运行时加载 SCN 或 glTF 模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!