Trying to traverse through a usdz file to copy materials from another usdz file to the traversed mesh

Hi All,

I am using RealityKit along with ARKit and Swift UI to develop an app where I am augmenting a usdz model of a complex geometry like that of a car.

I have some other usdz files with a simple plane geometry having the material properties embedded within them which also i am loading as model entities.

I want to traverse through my car usdz file such that i can pick the material from simple usdz file and apply it to the car as car paint. To do this i know the name of the mesh holding the car paint as well as the name of the material applied.

I have tried to traverse through the usdz files using both RealityKit and SceneKit but I am not successful to reach to the lowest mesh and copy the material properties to it.

With RealityKit, I have tried to get the instance data using modelEntity as follows :- "sourceModel?.model?.mesh.contents.instances". But this returns instance id, model name and transform only.

Any help will be highly appreciated.

Thank You

It sounds like you need a method to query an entity for a child entity with a given name. If that's correct then take a look at Entity.findEntity(named:) . In addition, the answer to Changing the texture of a RealityView has an example that demonstrates how to use this method. If that's not what you are looking for can you elaborate a bit more?

Trying to traverse through a usdz file to copy materials from another usdz file to the traversed mesh
 
 
Q