作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在ARKit中,如果我有一个ARSCNView,如何获取当前场景的真实中心坐标?我使用 Swift 作为编程语言。
最佳答案
您可以通过使用这样的手势来获取触摸点
// 1.
@objc func tapped(recognizer :UIGestureRecognizer) {
// Get exact position where touch happened on screen of iPhone (2D coordinate)
let touchPosition = recognizer.location(in: sceneView)
// 2.
// Conduct a hit test based on a feature point that ARKit detected to find out what 3D point this 2D coordinate relates to
let hitTestResult = sceneView.hitTest(touchPosition, types: .featurePoint)
// 3.
if !hitTestResult.isEmpty {
guard let hitResult = hitTestResult.first else {
return
}
print(hitResult.worldTransform.columns.3)
}
}
你可以获得点位置
让positionOfObjectToAdd=SCNVector3(hitResult.worldTransform.columns.3.x,hitResult.wor
ldTransform.columns.3.y、hitResult.worldTransform.columns.3.z)
关于swift - 如何在 ARkit 中获取场景的真实中心坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54122614/
我是一名优秀的程序员,十分优秀!