0

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?

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
heltisace
  • 13
  • 4
  • I am facing issue to store .zip file in documents directory i.e. from server and Unarchive that files . can you please help? – Divya Thakkar Nov 26 '18 at 07:26
  • @DivyaThakkar Hi. Sorry, but I if I remember correctly what I did, I didn't save zip files. I used a script that converts a model to the type that Xcode supports. And then everything worked smoothly. Unfortunately only can give only a direction on which to proceed, I'm not sure if I have any code left. – heltisace Nov 28 '18 at 12:37

1 Answers1

0

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

Sander
  • 1,325
  • 1
  • 11
  • 30
  • Worked for me! Thanks. But now I'm getting one of those: `[SceneKit] Error: COLLADA files are not supported on this platform.` using the `dae` file, and: `[SceneKit] Error: Failed loading : ` using `scn` file. As I understood I can do nothing with `dae`, because I'm downloading the model during the program work. Would be very grateful if you could help me at this too. – heltisace Oct 28 '17 at 22:41
  • Look here https://stackoverflow.com/questions/30097948/cant-display-3d-file-from-cache-directory It might be your problem – Sander Oct 28 '17 at 22:43
  • Yeah, but as I've said I'm downloading the model during the program work, and the scripts that are mentioned at those kind of articles allowing only to do it before the program starts with the script, or each time I'm downloading a new file with the special command. Do you know any solutions for `scn` models? – heltisace Oct 28 '17 at 22:49
  • I'm sorry, no. But why didn't you apply that script on your server side once so that you could download already required format of .dae files? – Sander Oct 28 '17 at 23:18
  • Sorry me for answering for so long, but it was already 2 AM in my country, so i went to bed. Yes, i've also thought about smth like this, but the problem is that i'm downloading the files from Firebase. But that's still the backup plan to just tell the customer either run the script himself, either hire a programmer for writting the server side, so thanks you for helping :) – heltisace Oct 29 '17 at 05:33