Reputation: 85542
Is there a way to pre-load ResolvedModel3D objects, so that they can be shown without a delay (instead of via Model3D)? Right now there's a delay while models are loaded; I'd like to front-load that time so that the eventual appearance is quicker.
Upvotes: 0
Views: 176
Reputation: 9277
Not that I could see with Model3D. Even loading the same model multiple times doesn't seem to cache it in any way.
However if you use RealityView
instead then it's possible. You can preload a model with Entity(named:)
then show that within a RealityView when ready by adding the model to the view's content.
struct PreloadView: View {
@State var showModel = false
@State var entity: Entity?
var body: some View {
VStack {
if (showModel) {
RealityView { content in
if let entity {
content.add(entity)
}
}
}
Button(showModel ? "hide" : "show") {
showModel.toggle()
}
}
.task {
entity = try? await Entity(named: "VintageGramophone")
}
}
}
Upvotes: 0