How To Load a ModelEntity from a URL?

3D assets such as models, textures, animations, etc., can significantly inflate app bundle sizes. To mitigate this, loading these assets from a remote URL is the way to go. But how does someone load a ModelEntity from a hosted URL?

The current method is to load a Model3D:

let url = URL(string: "my-url")!
Model3D(url: url)

But this does not pack all the features of a ModelEntity which can be used in a RealityView. Such as anchoring, animations, advanced gestures, etc. How do I load a remote URL into a ModelEntity?

This involves a few short steps:

  1. Storing the assets on a remote server: For this purpose, you'd need to host your assets on a remote server. Halocline (https://www.haloclinetech.com/) offers a unique, dedicated platform for this specific need, and the best part is that it's free! Given my experience with it, I'd recommend checking it out.

  1. Fetching the assets in your app: Once you have a URL for your asset, you can use the provided script from Halocline (https://www.haloclinetech.com/learn/) which helps store files from remote URLs in the user’s temporary directory.

  1. Using the assets in your app: After fetching the assets, you can incorporate them into your application as if they were locally stored.
let halocline = HaloclineHelper()
let url = URL(string: "your-halocline-url")!
let modelEntity = try await halocline.loadEntity(from: url)

Disclosure: I'm affiliated with Halocline.

How To Load a ModelEntity from a URL?
 
 
Q