Download a USDZ file from web and load as entity at runtime in Reality Kit

I can't find a way to download a USDZ at runtime and load it into a Reality View with Reality kit.

As an example, imagine downloading one of the 3D models from this Apple Developer page: https://developer.apple.com/augmented-reality/quick-look/

I think the process should be:

  1. Download the file from the web and store in temporary storage with the FileManager API
  2. Load the entity from the temp file location using Entity.init (I believe Entity.load is being deprecated in Swift 6 - throws up compiler warning) - https://developer.apple.com/documentation/realitykit/loading-entities-from-a-file
  3. Add the entity to content in the Reality View.

I'm doing this at runtime on vision os in the simulator. I can get this to work with textures using slightly different APIs so I think the logic is sound but in that case I'm creating the entity with a mesh and material. Not sure if file size has an effect.

Is there any official guidance or a code sample for this use case?

Answered by DTS Engineer in 786740022

Hello, there is no sample code that demonstrates this use case, but yes your logic is sound:

  1. Download the asset with URLSession
  2. Follow the steps in Loading Entities from a File to load an Entity from the downloaded file.
Accepted Answer

Hello, there is no sample code that demonstrates this use case, but yes your logic is sound:

  1. Download the asset with URLSession
  2. Follow the steps in Loading Entities from a File to load an Entity from the downloaded file.
Download a USDZ file from web and load as entity at runtime in Reality Kit
 
 
Q