ios - 如何将 SCNPlane 颜色更改为清晰颜色
问题描述
我正在开发一个 ARKit 项目,该项目需要在水平平面上点击时产生波纹动画效果。为此,我采用了 UIView 对象并将其作为 SCNPlane 对象材料的内容传递。我已将波纹动画添加到 UIView 对象。一切正常。但我无法将 SCNPlane 颜色更改为清除颜色。我可以使用材质的透明度属性。但它也隐藏了波纹动画。所以,我需要的是,SCNPlane 对象的背景颜色应该是透明的,并且只有波纹动画应该出现在用户面前。有人可以帮我解决这个问题。
这是我的代码。
let location = tapGesture.location(in: self.sceneView)
let results = self.sceneView.hitTest(location, types: .existingPlane)
if !results.isEmpty{
guard let result = results.first else{ return }
let myUIView = UIView(frame: CGRect(origin: .zero, size: CGSize(width: 300, height: 300)))
myUIView.backgroundColor = .red
let plane = SCNPlane(width: 1.0, height: 1.0)
plane.firstMaterial?.diffuse.contents = myUIView
let planeViewNode = SCNNode(geometry: plane)
planeViewNode.eulerAngles.x = Float(-Double.pi / 2)
planeViewNode.position = SCNVector3(result.worldTransform.columns.3.x, result.worldTransform.columns.3.y, result.worldTransform.columns.3.z)
self.sceneView.scene.rootNode.addChildNode(planeViewNode)
//Ripple animation code goes here
}
我从 BBC 的 Civilizations AR 应用程序中截取了屏幕截图。请单击此链接参考屏幕截图。这正是我需要的。
解决方案
看看这个答案。设置UiView
isOpaque
为false
对我有用。
推荐阅读
- angular - 具有动态创建组件的组件 styleUrls
- github - 如何将 github 问题从我的仓库转移到我管理的组织?
- angular - 在可观察到的角度 http 中传递标头
- javascript - Promise 的返回值不稳定
- sql-server - 多行之间的 T-SQL 日期差异
- c# - 在基于 .Net 4.0 的应用程序中解码 JWT 令牌
- swift - 如何从 IOS 客户端连接到 Spring WebSocket 服务器?
- java - Java 网络指标
- css - 如何在带有嵌入阴影的倾斜框上显示背景图像
- python - 使 __init__ 在 python 中创建其他类