我正在进行一个 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
}