重置ARKit坐标 [英] Resetting ARKit coordinates

查看:119
本文介绍了重置ARKit坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的问题.如果我想开始游戏并将棋盘放在我面前:

I have a simple question. If I wanted to start a game and place the board right in front of me:

gameBoard!.position = SCNVector3(0, 0, -0.6)

这有效,直到我离开游戏并再次回来.我可以将游戏板显示在相机前面的完全相同位置还是0.6m在我前面的位置吗?我可能已经身体移动到另一个位置.

This works until I leave the game and come back again. Can I show the game board in exact same position in front of camera or 0.6m in front of me? I might have physically moved to another position.

推荐答案

如果要重置ARSession,则必须暂停,删除所有节点并通过重置跟踪和删除锚来重新运行会话.

If you want to reset you ARSession, you have to pause, remove all nodes and rerun your session by resetting tracking and removing anchors.

我做了一个重置​​按钮,只要我想重置它,便会执行此操作:

I made a reset button that does it whenever i want to reset:

@IBAction func reset(_ sender: Any) {

    sceneView.session.pause()
    sceneView.scene.rootNode.enumerateChildNodes { (node, stop) in
        node.removeFromParentNode()
    }
    sceneView.session.run(configuration, options: [.resetTracking, .removeExistingAnchors])
}

或者把它放在您的会话被中断的功能中!

Or put it in your session was interrupted function!

这篇关于重置ARKit坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆