仅使用摄像头检测 SCNNode
Detect SCNNode with camera only
假设我在屏幕中间画了一个圆圈,将其用作目标。如果我将这个圆圈指向一个节点,ARKit 怎么可能检测到它?
目前我使用的是点击方式
@IBAction func tapHandler(_ sender: UITapGestureRecognizer) {
let viewTouchLocation:CGPoint = sender.location(in: sceneView)
guard let result = sceneView.hitTest(viewTouchLocation, options: nil).first else {
return
}
// ...etc
}
效果非常好,但仅通过将相机对准节点来检测节点会好得多。
let screenRect = UIScreen.main.bounds
let screenWidth = screenRect.size.width
let screenHeight = screenRect.size.height
let location = CGPoint(x:screenWidth/2,y:screenHeight/2)
在命中测试中使用位置
假设我在屏幕中间画了一个圆圈,将其用作目标。如果我将这个圆圈指向一个节点,ARKit 怎么可能检测到它?
目前我使用的是点击方式
@IBAction func tapHandler(_ sender: UITapGestureRecognizer) {
let viewTouchLocation:CGPoint = sender.location(in: sceneView)
guard let result = sceneView.hitTest(viewTouchLocation, options: nil).first else {
return
}
// ...etc
}
效果非常好,但仅通过将相机对准节点来检测节点会好得多。
let screenRect = UIScreen.main.bounds
let screenWidth = screenRect.size.width
let screenHeight = screenRect.size.height
let location = CGPoint(x:screenWidth/2,y:screenHeight/2)
在命中测试中使用位置