FYI, for anyone else ending up in this thread.
I was running into this issue periodically when accessing the @Environment modelContext.insert from my view's onAppear method.
Seems to me that there is probably a race condition in how the .modelContainer is setup for the view...
I moved my insert into a button clickhandler instead of the onAppear and the issue went away entirely.
Post
Replies
Boosts
Views
Activity
so...
If you have a ModelEntity, you can get the .model which contains a mesh (https://developer.apple.com/documentation/realitykit/modelcomponent/mesh)
The mesh contains this contents struct (https://developer.apple.com/documentation/realitykit/meshresource/contents-swift.struct) , and eventually all the way down to the MeshResource.Part parts (https://developer.apple.com/documentation/realitykit/meshresource/part). Then you start to have index / triangle data.
By this point I feel pretty in-over-my-head....
What has worked is simply going into my scene in RealityComposer and creating a bunch of cubes with collision / physics, and placing them around the model / setting a transparent material. If you're willing to spend 3 hours lining your scene with cubes manually, this does work for simple concave-ish geometries.
There has to be a better solution...