【发布时间】:2018-04-30 20:42:40
【问题描述】:
我正在开展一个项目,通过扫描 qrCode 将模型加载到 ARKit 驱动的应用程序中。我将 qrCode 工作和 .scn 文件下载到 .tmp 文件中。然而,当我试图通过 SCNScene(url:) 捕捉场景时,所有返回的都是 nil。
我想知道是不是因为我太早复制了文件 --- 在它完成下载之前,因为应用程序在我扫描 qrCode 后立即冻结。
任何建议将不胜感激。 :D
2017-11-18 添加下载代码
模板:http://www.jianshu.com/p/6ca4864b3600
func sessionSimpleDownload( scnurl: URL){
let url = scnurl
let request = URLRequest(url: url)
let session = URLSession.shared
var ls: String!
let downloadTask = session.downloadTask(with: request,
completionHandler: { (location:URL?, response:URLResponse?, error:Error?)
-> Void in
print("location:\(String(describing: location))")
let locationPath = location!.path
let documents:String = NSHomeDirectory() + "/Documents/max.scn"
ls = NSHomeDirectory() + "/Documents"
let fileManager = FileManager.default
if (fileManager.fileExists(atPath: documents)){
try! fileManager.removeItem(atPath: documents)
}
try! fileManager.moveItem(atPath: locationPath, toPath: documents)
print("new location:\(documents)")
})
downloadTask.resume()
self.Modelscene = SCNScene(named: "max.scn", inDirectory: ls)
}
【问题讨论】:
标签: ios swift scenekit arkit scnscene