如何在ARKit应用中的运行时加载SCN或glTF模型? [英] How to load SCN or glTF model at runtime in ARKit app?

查看:292
本文介绍了如何在ARKit应用中的运行时加载SCN或glTF模型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行时从iOS内部的URL加载3d模型的最佳方法是什么.我已经试过这个.scn.gtlf模型导入器.

我正在使用此框架 https://github.com/prolificinteractive/SamMitiAR-iOS我像这样加载模型:

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

像上面一样,我正在从远程服务器加载不同的url,请指导我如何从远程服务器加载3d模型.我要采用哪种格式的url.请发送任何包含来自远程服务器的scn文件的链接 谢谢.

解决方案

似乎网址加载器功能在 SamMitiAR 框架中不起作用.在Placing and Removing Virtual Objects部分下显示正在进行中.

要了解如何将模型动态加载到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 under Placing 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆