Is there a way to load RealityKit Custom entities?

I've been watching a 2019 Developer Video "Building Apps with RealityKit" and working along with it. It shows how to create a custom entity. It shows how to load entities from .usd files. How do you either load a custom entity, convert an Entity to a custom entity, or maybe move model hierarchy from an Entity to a custom entity? I assume there's a way to do this.

Replies

I think I have it worked out. Instance the Custom Entity, load the model as a child of the Custom entity.

One option is to create a new instance of the CustomEntity, then copy desired components from a loaded ModelEntity.

Using the "Building Apps with RealityKit" video as an example, CardEntity would copy the model component from a loaded ModelEntity:

// modelEntity previously loaded from usdz file
let cardEntity = CardEntity()
cardEntity.model = modelEntity.model

Other components such as transform and collision can also be copied, if desired.