表面/图像检测 ARKit 后,现实世界中场景节点抖动的原因是什么?

问题描述

我已经使用目标版本 OS 11 及更高版本实现了 ARKit 应用程序。

问题 1. 贴纸检测后物体没有停留在贴纸中间。如果我将设备垂直于贴纸移动,我可以看到物体远离贴纸移动。我正在使用 2cm * 2cm 宽度和高度的图像。会不会是这个问题的原因?

问题 2。 在表面检测之后,当我使用点击添加 3D 模型时,我可以看到对象在一段时间内或在模型动画中间移动。如何保持对象模型稳定在用户点击屏幕放置的准确位置。

这里是代码供参考。使用它进行表面检测

    let tapLocation = sender.location(in: sceneview)
       
        
        //2. Perform An ARNSCNHitTest To See If We Have Hit An ARPlaneAnchor
        let planeHitTest = sceneview.hitTest(tapLocation,types: .existingPlaneUsingExtent).first
        guard let planeAnchor = planeHitTest?.anchor as? ARPlaneAnchor else {
            return
        }
         
        
        //        print(planeAnchor)
        let position = SCNVector3Make(planeHitTest!.worldTransform.columns.3.x,planeHitTest!.worldTransform.columns.3.y,planeHitTest!.worldTransform.columns.3.z)

let animationParentNode = SCNNode()
        animationParentNode.transform = SCNMatrix4(planeAnchor.transform)
        animationParentNode.position = position
        animationParentNode.eulerAngles =  SCNVector3Make(0,0);
        
        self.sceneview.scene.rootNode.addChildNode(animationParentNode)
    

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)