Search code examples
iosswiftxcodeaugmented-realityarkit

Load a SCNScene object from the DAE model that is in the Sandbox


I need to create a SCNScene object with its path. For example something like this:

/private/var/mobile/Containers/Data/Application/.../tmp/MyUnzippedFiles/4823092205063.dae

I tried to use:

let virtualObjectScene = try SCNScene(url: url) 

but it returns:

NSURLConnection finished with error - code -1002.

How can I do it?


Solution

  • Probably you should do smth following. Replace path documentDirectory with yours in Sandbox

    let documentDirectory = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
    let pathToObject = documentDirectory + "/tmp/MyUnzippedFiles/4823092205063.dae"
    let fileUrl = URL(fileURLWithPath: pathToObject)
    let virtualObjectScene = try SCNScene(url: url)
    

    PS. I haven't check this code so there might be some typos