相关疑难解决方法(0)

ARkit - 从SCNScene中的Web服务器URL加载.scn文件

我正在为我的应用程序使用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)

ios swift scnnode scnscene arkit

10
推荐指数
1
解决办法
2854
查看次数

使用纹理从URL导入.scn文件到场景

我正在为我的应用程序使用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会尝试从本地文件加载此纹理?我该如何解决?

ios scenekit swift arkit

5
推荐指数
1
解决办法
1649
查看次数

标签 统计

arkit ×2

ios ×2

swift ×2

scenekit ×1

scnnode ×1

scnscene ×1