I am creating a ModelEntity with a programatic mesh.
var mat = PhysicallyBasedMaterial()
mat.baseColor = .init(tint: .lightGray)
mat.roughness = 0.0
mat.metallic = 1.0
let newEnt = ModelEntity(mesh: try! .generate(from: [hex.generateMeshDescriptor()]), materials: [mat])
stages.worldStage.addChild(newEnt)
where hex.generateMeshDescriptor()
generates the custom mesh. On the screen, everything looks great. The material looks exactly like I expect it to. However, a simple, print shows that my ModelEntity has a single material in its list and its a SimpleMaterial
, not a PhysicallyBasedMaterial
. This causes my program to crash as I am using PhysicallyBasedMaterial
's emissiveColor
and emissiveIntensity
later on to highlight the objects.
print(newEnt.components[ModelComponent.self]!.materials)
shows
[RealityKit.SimpleMaterial(__resource: RealityKit.__MaterialResource, ...
...]
I even try to force the material to be PhysicallyBasedMaterial
and it doesn't stick. It's always somehow converted to a SimpleMaterial
.
I figured I would ask on the forums before I submit a bug report in case there is something basic that I am not understanding.
Mac OS Monterey Beta 8. iMac Pro. Xcode 13 Beta 5.
Thanks in advance.
-Matt