小编Bar*_*bek的帖子

在 RealityKit 中将 UIImage 作为纹理添加到平面

我正在 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)

augmented-reality swift arkit realitykit

5
推荐指数
1
解决办法
885
查看次数

标签 统计

arkit ×1

augmented-reality ×1

realitykit ×1

swift ×1