Hi guys
How could I control the opacity of the ModelEntity or mesh in RealityKit?
Were you able to resolve your issue? I ran this code on a new RealityKit macOS project on macOS 12.0. The code should be similar on iOS, you should just need to change from NSColor to UIColor.
let entity = ModelEntity.init(mesh: MeshResource.generateBox(size: SIMD3<Float>(1.0, 1.0, 1.0)))
let anchor = AnchorEntity.init()
anchor.addChild(entity)
arView.scene.anchors.append(anchor)
var material = SimpleMaterial()
material.baseColor = MaterialColorParameter.color(
NSColor.init(displayP3Red: 1.0, green: 0.0, blue: 0.0, alpha: 0.5)
)
entity.model?.materials.append(material)
You can also take a look at our new PhysicallyBasedMaterial and CustomMaterial types in iOS 15 and macOS Monterey.