How to add materials to Entity

I have an Entity from findEntity and would like to clone that entity. But the problem is I also want to add a material to that entity. I can only add materials to ModelEntities from what I have seen. Here is my code:

        if let pieceEntity: Entity = self.chessPieces.findEntity(named: entityName){
            newEntity = pieceEntity.clone(recursive: true)
            pieceEntity.transform.translation = .init(repeating: 0)
            let newScale: SIMD3<Float> = .init(x: widthScale*universalScale, y: depthScale*universalScale, z: depthScale*universalScale)
            newEntity.scale = newScale
            let collisionComponent = CollisionComponent(shapes: [.generateBox(size: .init(x: width, y: height, z: depth))])
            newEntity.components.set(collisionComponent)
            newEntity.components.set(InputTargetComponent())
        }
        newEntity.model?.materials = [SimpleMaterial(color: chessPiece.color == .black ? .black : .white, isMetallic: false)]
        newEntity.name = chessPiece.toString()

Try passing your newEntity into a function like this instead of directly setting the material in that second to last line:

func changeMaterial(entity: Entity) -> Entity {
        
        // Make sure the entity has a ModelComponent.
        guard var modelComponent = entity?.components[ModelComponent.self]
        else {
            return Entity()
        }

      //set the materials
        modelComponent.materials = [SimpleMaterial(color: .purple, isMetallic: false)]
        entity?.components.set(modelComponent)
        
        return entity ?? Entity()
    }
How to add materials to Entity
 
 
Q