Wil*_*ill 7 augmented-reality ios swift arkit
我已经开始尝试使用ARKit了,我遇到了一个问题.我找不到一个教程,展示如何将对象放在最近的表面上.
假设我正在使用.scn包含平面对象的文件.我知道如何把它放在相机的位置,但我怎样才能到达最近的表面.
很抱歉,如果这听起来像代码请求,但我不知道从哪里开始,任何指导将非常感谢
Gui*_*uig 14
您可以使用hitTest来返回包含距离和变换等信息的结果:https://developer.apple.com/documentation/arkit/arhittestresult
for result in sceneView.hitTest(CGPoint(x: 0.5, y: 0.5), types: [.existingPlaneUsingExtent, .featurePoint]) {
print(result.distance, result.worldTransform)
}
Run Code Online (Sandbox Code Playgroud)