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()