loadModel(named:in:)
Synchronously loads a model entity from a bundle.
Declaration
@MainActor @preconcurrency static func loadModel(named name: String, in bundle: Bundle? = nil) throws -> ModelEntityParameters
- name:
The base name of the file to load, omitting the filename extension.
- bundle:
The bundle containing the file. Use
nilto search the app’s main bundle.
Mentioned in
Return Value
The root entity in the loaded file, which Reality Kit casts as a ModelEntity.
Discussion
Loading an Entity with this method blocks the main actor because it’s synchronous, so only call it from a command-line application. The method can stall a regular app, which makes it visibly hitch, and the system terminates an app if its UI becomes unresponsive. See init(named:in:) for an example that demonstrates how to safely load content.