我正在为我的应用程序使用ARKit,我尝试从我的web服务器(URL)动态加载.scn文件
这是我的代码的一部分
let urlString = "https://da5645f1.ngrok.io/mug.scn"
let url = URL.init(string: urlString)
let request = URLRequest(url: url!)
let session = URLSession.shared
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/mug.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)")
let node = SCNNode()
let scene = SCNScene(named:"mug.scn", inDirectory: ls)
let nodess …Run Code Online (Sandbox Code Playgroud) 我正在为我的应用程序使用ARKit,我尝试从web服务器动态加载.scn文件
这是我的代码的一部分
let url = URL(string: "http://192.168.0.31:1234/5a27e09cbad20a7a03ad5d80/box/box.scn")
if let objectScene = try? SCNScene(url: url!, options: [.overrideAssetURLs: true]) {
print("load success")
let node = SCNNode()
for childNode in objectScene.rootNode.childNodes {
node.addChildNode(childNode)
}
sceneView.scene.rootNode.addChildNode(node)
} else {
print("error loading")
}
Run Code Online (Sandbox Code Playgroud)
这里box.scn包含纹理.我收到了一个错误
加载失败:C3DImage 0x1c00f6f80 src:file:///var/containers/Bundle/Application/110F7AB6-00F8-4E5B-B843-46551A23CB7F/ar.app/maps/CMU_Split_Face_Running_200x400_bump.jpg [0.000000x0.000000]
为什么Scenekit会尝试从本地文件加载此纹理?我该如何解决?