How to use render 3D models inside a USDZ into a ModelEntity

I have a model called ChessPiecesModel and inside this model contains pawn, king, queen, etc. models.

I want to render each of these as ModelEntities but it does not render the chess pieces either

This is the current code I have where i am trying to render the ChessPieesModel into a RealityView:

        RealityView { content in
            if let chessPieces = try? await ModelEntity(named: "ChessPiecesModel") {
                chessPieces.transform.translation = .init(x: 0, y: 0, z: 0)
                chessPieces.scale = .init(x: 10, y: 20, z: 20)
                content.add(chessPieces)
            }
    }

I figured it out: I had to load it in using Entity.load


        if let chessPiecesEntity = try? Entity.load(named: "ChessPiecesModel") {
            self.chessPieces = chessPiecesEntity
        } else {
            self.chessPieces = ModelEntity(mesh: MeshResource.generateBox(width: self.width*0.02, height: self.height*1.1, depth: self.depth*0.02))

        }

Loading as an Entity instead of a ModelEntity will stop the model being collapsed into a single layer, but beware as Entity.load is blocking, and you'd be much better off using the Entity(named:in:) async throws initialiser, as it's asynchronous.

For example:

RealityView { content in
    do {
        let chessPiecesEntity = try await Entity(named: "ChessPiecesModel")
        guard let chessPiecesModelEntity = chessPiecesEntity as? ModelEntity else {
            throw Some.error
        }

        // Prepare the model entity if you need to set materials.

        content.add(chessPiecesEntity)
    }
    catch {
        print(error.localizedDescription)
    }
}
How to use render 3D models inside a USDZ into a ModelEntity
 
 
Q