Post not yet marked as solved
Post marked as unsolved with 1 replies, 585 views
import RealityKit
let newModel = ModelEntity(
mesh: .generatePlane(width: 1, height: 1)
)
var mat = SimpleMaterial(
color: UIColor.blue.withAlphaComponent(0.5),
isMetallic: true
)
newModel.model?.materials = [mat]
/* next line breaks transluency */
newModel.model?.mesh = .generatePlane(width: 1, height: 1)
/* next line fixes it */
newModel.model = ModelComponent( mesh: .generatePlane(width: 1, height: 1), materials: [mat])
In my code I was doing this every time a plane anchor updated:
self.model?.mesh = MeshResource.generatePlane(
width: planeAnchor.extent.x,
depth: planeAnchor.extent.z + 10
)
This resulted in a mesh updating its size, but the transparency completely breaking.
When switching to this, transparency worked correctly, but now I have to fully recreate the model whenever I want to update the size
var material = SimpleMaterial(color: MaterialColorParameter.texture(resource!), isMetallic: true)
material.tintColor = .init(white: 1, alpha: 0.5)
self.model = ModelComponent(
mesh: .generatePlane(
width: planeAnchor.extent.x,
depth: planeAnchor.extent.z
),
materials: [material]
)
Can we get some bug fixes in realitykit this year? So that we don't have to set isMetallic: true, and tintColor just to use a color with opacity? Or have to fully recreate the model just to update the mesh size? Thanks :)