我正在开发一个 ARKit 项目,该项目在水平平面上点击时需要波纹动画效果。为此,我采用了 UIView 对象并将其作为 SCNPlane 对象材料的内容传递。我已将 Ripple 动画添加到 UIView 对象。一切正常。但我无法将 SCNPlane 颜色更改为清晰颜色。我可以为材质使用透明度属性。但它也隐藏了 Ripple 动画。所以,我在这里需要的是,SCNPlane 对象的背景颜色应该是透明的,并且应该只向用户显示 Ripple 动画。有人可以帮我解决这个问题。
这是我的代码。
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) …Run Code Online (Sandbox Code Playgroud)