-2

I want to add AR Quick Look to my app but placing the USDZ models into the app would take too much storage. That’s why I decided to store the models in Firebase Storage and download the model when needed. This is my code for quick looking a local USDZ model.

func numberOfPreviewItems(in controller: QLPreviewController) -> Int {
    return 1
}

func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem {
    let url = Bundle.main.url(forResource: models[thumbnailIndex], withExtension: "usdz")!
    return url as QLPreviewItem
}

func showModel() {
    let previewController = QLPreviewController()
    previewController.dataSource = self
    previewController.delegate = self
    present(previewController, animated: true)
}

How would I download the model from Firebase Storage and load it as such?

HeySaiK
  • 480
  • 1
  • 6
  • 17

1 Answers1

2

I will suggest to zip all the files relative to a scene: textures, environment images, the .scn prepared (avoid .usdz), etc

Then storage this zip in whatever server you are using. One zip per model.

From the app, just download the zip and unzip it. I recommend a framework called ZIP Foundation.

Then just populate your scene with the nodes (lights or whatever) from the downloaded .scn

Sergio
  • 1,610
  • 14
  • 28