【发布时间】:2018-10-26 08:11:39
【问题描述】:
我正在做一个 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
}
【问题讨论】:
-
你找到答案了吗?我现在遇到了这个问题
-
这个答案导致另一个答案有效,你为什么不接受它?当其他开发人员需要帮助时,这对社区更好,他们会看到并知道它有效。
标签: ios swift scenekit arkit scnnode