【问题标题】:How to detect if SCNBox was touched in scenekit?如何检测scenekit中是否触摸了SCNBox?
【发布时间】:2016-12-03 06:16:59
【问题描述】:

如何检测scenekit中是否触摸了SCNBox?我正在构建一个 VR 应用

【问题讨论】:

标签: ios scenekit scnnode scnvector3


【解决方案1】:

你可以用这个:

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)
    }
}

【讨论】:

    猜你喜欢
    • 2017-03-21
    • 1970-01-01
    • 2012-03-04
    • 2023-03-08
    • 1970-01-01
    • 1970-01-01
    • 2016-01-12
    • 1970-01-01
    • 2011-02-17
    相关资源
    最近更新 更多