如何在 Swift 中将图像添加到 ARSCNScene? [英] How to add an image to an ARSCNScene in Swift?
本文介绍了如何在 Swift 中将图像添加到 ARSCNScene?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在开发我正在开发的 Swift 游乐场时偶然发现了一个障碍.我想将图像添加到我的 ARSCNScene (ARKit + SceneKit).不是作为背景,而是作为具有位置和所有内容的实际节点.有谁知道这是否可能?我在网上找不到任何东西.谢谢!
I stumbled upon a roadblock with the development of a Swift playground I'm developing. I want to add an image to my ARSCNScene (ARKit + SceneKit). Not as a background, but as an actual node with positions and all. Does anyone know whether this is possible? I couldn't find anything online. Thanks!
推荐答案
您可以轻松地将 UIImage 作为漫反射材质添加到您的 SCNPlane.示例:
You can easily add UIImage as diffuse material to your SCNPlane. Example:
let image = UIImage(named: "yourImageName")
let node = SCNNode(geometry: SCNPlane(width: 1, height: 1))
node.geometry?.firstMaterial?.diffuse.contents = image
此外,您可以根据需要修改您的节点.我希望它有帮助!
Further, you can modify your node as you like. I hope it helped!
这篇关于如何在 Swift 中将图像添加到 ARSCNScene?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文