我正在 swift 中尝试新的 RealityKit 框架,我想在 ARAnchor 上放置一个 2D 图像。我设法创建了一个网格平面,并尝试将图像作为纹理添加到该平面。我发现我可以为材料提供局部图像。我该如何使用 UIImage 代替?
let resource = try? TextureResource.load(named: "restart")
var material = UnlitMaterial()
material.baseColor = MaterialColorParameter.texture(resource!)
material.tintColor = UIColor.white.withAlphaComponent(0.99)
let imagePlane = ModelEntity(mesh: MeshResource.generatePlane(width: 0.25, height: 0.25), materials: [SimpleMaterial(color: color, isMetallic: true)])
Run Code Online (Sandbox Code Playgroud)