0

I'd like to be able to do the same as in this post :

let url = URL.init(string: "https://cloud.box.com/shared/static/ock9d81kakj91dz1x4ea.obj")
let asset = MDLAsset(url: url! as URL)
let object = asset.object(at: 0)
let node = SCNNode(mdlObject: object)

I don't want to have to load it from the user's phone like so :

guard let url = Bundle.main.url(forResource: "ock9d81kakj91dz1x4ea", withExtension: "obj") else { return nil }
let asset = MDLAsset(url: url)
let object = asset.object(at: 0)
let node = SCNNode(mdlObject: object)

Since I'd need many obj model in my app, it would be very inconvenient to have to download all the 3d obj models to the user's phone before showing them.. With time, it would take a lot of space on the user's phone.

So my question is, is there any way of showing a 3d obj model without it being on the user's phone like with an api? If there's another way of doing it besides obj file, I'm open to anything really.

Thanks!

David
  • 3
  • 1
  • 3
  • You should show us what you tried before asking for already done code. BTW take a look at URLSession to download data – Ptit Xav Sep 14 '21 at 15:25
  • The similar answer I posted for `usdz` model: https://stackoverflow.com/a/68237702/6576315 – RTXGamer Sep 14 '21 at 17:19
  • Maybe just show the site in a WebView or have thumbnails – lorem ipsum Sep 14 '21 at 19:00
  • @RTXGamer Sure, but you still have to download it to the user's phone in this case no? Unless I'm misunderstanding something from your code.. – David Sep 16 '21 at 19:55
  • @PtitXav URLSession isn't really the problem. It's more so the fact that I have to then save it to the user's phone to be able to access the 3d model that was downloaded instead of just using it from the cache and then releasing it afterwards.. – David Sep 16 '21 at 19:56
  • @David Yes, you have to download the model. MDLAsset won't allow loading remote URLs. It will throw an error - "Unable to issue extension for path". – RTXGamer Sep 16 '21 at 20:32
  • If you do your own model , you may consider using iCloud database to store information about the models like small rendered image and download url. So User can choose in a list inside appli and then you download it on the phone. Next time user want to use it it is already on the phone. You can use cache directory if you want the système to be able to do auto cleaning. – Ptit Xav Sep 17 '21 at 11:21

0 Answers0