如何检测是否在scenekit中触摸了SCNBox?我正在构建一个VR应用程序
答案 0 :(得分:0)
您可以使用此:
let tapGR = UITapGestureRecognizer(target: self, action: #selector(tapGesture(sender:)))
sceneView.addGestureRecognizer(tapGR)
@objc func tapGesture(sender: UITapGestureRecognizer) {
let location: CGPoint = (sender.location(in: self.sceneView))
let hits = self.sceneView.hitTest(location, options: nil)
if let tappedNode : SCNNode = hits.first?.node {
tappedNode.position.y += 0.5
print(tappedNode)
}
}